Skip to content

Commit b2d4056

Browse files
committed
Bug fix and more flexibility
-TransformCoords bug fix: basis=1e3 -> basis=[1e3] for compatibility with Cart2Log -New input parameter to LoadData: replaceNaN. This was not an input, and set to False. Now it’s an input and set to True by default
1 parent 8465fea commit b2d4056

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

basic.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def GridAspectRatio(ratios, src=GetActiveSource()):
9494
return calc
9595

9696
# transform coordinates: logarithmic, aspect ratio
97-
def TransformCoords(src=GetActiveSource(), aspectRatios=[1,1,1], logCoords=[2], basis=1e3):
97+
def TransformCoords(src=GetActiveSource(), aspectRatios=[1,1,1], logCoords=[2], basis=[1e3]):
9898
"""Transform the coordinates depending on whether or not there are logarithmic coordinates"""
9999
if len(logCoords)>0 :
100100
transCoor = Cart2Log(src=src,ratios=aspectRatios,logCoords=logCoords,basis=basis)
@@ -111,7 +111,7 @@ def MakeSelectable(src=GetActiveSource()):
111111

112112
######### read in data, redefine pressure coordinates and change aspect ratio ###############
113113

114-
def LoadData( fileName, ncDims=['lon','lat','pfull'], aspectRatios=[1,1,1], logCoords=[2], basis=[1e3] ):
114+
def LoadData( fileName, ncDims=['lon','lat','pfull'], aspectRatios=[1,1,1], logCoords=[2], basis=[1e3], replaceNaN=True ):
115115
"""Load netCDF file, convert coordinates into useful aspect ratio.
116116
117117
Adds file output_nc, and Calculator LogP or Calculator AspRat to the pipeline
@@ -122,6 +122,7 @@ def LoadData( fileName, ncDims=['lon','lat','pfull'], aspectRatios=[1,1,1], logC
122122
aspectRatios -- how to scale coordinates [xscale,yscale,zscale]. Z coordinate is scaled after applying log10 for logarithmic axes
123123
logCoords -- index/indices of dimension(s) to be logarithmic
124124
basis -- basis to normalize argument to logarithm (ie defines origin). List of same length as logCoords
125+
replaceNaN -- whether or not to replace the FillValue with NaNs
125126
OUTPUTS:
126127
output_nc -- netCDF reader object with the file data as read
127128
transCoor -- Calculator filter corresponding to the transformed coordinates
@@ -139,7 +140,7 @@ def LoadData( fileName, ncDims=['lon','lat','pfull'], aspectRatios=[1,1,1], logC
139140

140141
output_nc.SphericalCoordinates = 0
141142
output_nc.OutputType = 'Unstructured'
142-
output_nc.ReplaceFillValueWithNan = 0
143+
output_nc.ReplaceFillValueWithNan = replaceNaN
143144
MakeSelectable()
144145
RenameSource(fileName,output_nc)
145146

0 commit comments

Comments
 (0)