Skip to content

Commit 698a98e

Browse files
author
pv-atmos
committed
Adding comments
Adding more commenting in the entire file
1 parent 6fa975e commit 698a98e

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

examples/example_ocean.py

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
1+
#!/usr/bin/python
2+
# Filename: example_ocean.py
3+
#
4+
# Code by Martin Jucker, distributed under an MIT License
5+
# Any publication benefitting from this piece of code should cite
6+
# Jucker, M 2014. Scientific Visualisation of Atmospheric Data with ParaView.
7+
# Journal of Open Research Software 2(1):e4, DOI: http://dx.doi.org/10.5334/jors.al
8+
9+
# define a helper function for adjusting ocean bathymetry (topography) aspect ratio and color scheme
210
def transformTopo(src=GetActiveSource(),moveXFunction=''):
311
depth = Calculator(src)
412
depth.Function = 'iHat*(coordsX'+moveXFunction+') + jHat*coordsY - kHat*abs('+str(depthVar)+')'
@@ -23,6 +31,7 @@ def transformTopo(src=GetActiveSource(),moveXFunction=''):
2331

2432
#########
2533

34+
#import pv_atmos
2635
try:
2736
from atmos_basic import *
2837
from atmos_grids import *
@@ -32,12 +41,15 @@ def transformTopo(src=GetActiveSource(),moveXFunction=''):
3241
execfile(pvAtmosPath + 'atmos_grids.py')
3342

3443
## show me where the files are ##
44+
# path to ocean files
3545
oceanPath='./'
3646

47+
# file containing bathymetry
3748
topoFile = 'ocean_depth.nc'
3849
topoDims = ['rlon','rlat']
3950
depthVar = 'deptho'
4051

52+
# file containing oxygen data
4153
dataFile = 'ocean_o2.nc'
4254
dataDims = ['xt_ocean','yt_ocean','st_ocean']
4355
# the values we will be interested in
@@ -46,21 +58,21 @@ def transformTopo(src=GetActiveSource(),moveXFunction=''):
4658

4759
## how would you like the transformation to work ##
4860
logCoord = [] #no logarithmic coordinates
49-
aspRat = [1,1,0.01]
61+
aspRat = [1,1,0.01] # divide bathymetry by 100
5062

5163

5264
### get the data ###
5365

54-
# topography
66+
# bathymetry
5567
(depth_out,depth_coor)=LoadData(oceanPath+topoFile,ncDims=topoDims,logCoords=logCoord )
56-
# get the bounds of the topography
68+
# get the bounds of the topography. This is important if bathymetry and data files have different origins
5769
topoBds = depth_out.GetDataInformation().GetBounds()
5870

5971
# data
6072
(o2_out,o2_coor)=LoadData(oceanPath+dataFile,ncDims=dataDims,aspectRatios=aspRat,logCoords=logCoord )
6173
# we want to replace the fill values with NaNs here
6274
o2_out.ReplaceFillValueWithNan = 1
63-
# get the bounds of the data file
75+
# get the bounds of the data file. Again important if different from bathymetry files
6476
dataBds = o2_out.GetDataInformation().GetBounds()
6577
# instead of NaNs, there are -1e10 values in this file that we don't want
6678
o2_thresh = Threshold(o2_coor,ThresholdRange=[0,1])
@@ -70,7 +82,7 @@ def transformTopo(src=GetActiveSource(),moveXFunction=''):
7082
c2p=CellDatatoPointData(depth_coor)
7183
MakeSelectable()
7284

73-
### see if we have to move the topography file to align it with the data file
85+
### see if we have to move the bathymetry file to align it with the data file
7486
### this is not necessary with the provided files, but might be with other files
7587
swapTopo = False
7688
if topoBds[0] != dataBds[0] or topoBds[1] != dataBds[1]:
@@ -101,7 +113,7 @@ def transformTopo(src=GetActiveSource(),moveXFunction=''):
101113
swapTopo = True
102114

103115

104-
### work on the topography #####
116+
### work on the bathymetry #####
105117

106118
if swapTopo :
107119
transformTopo(moveClip,moveXFunction)

0 commit comments

Comments
 (0)