Skip to content

Commit fdea266

Browse files
authored
Merge pull request #250 from UV-CDAT/fixSST
Fix sst. All tests pass on my desktop. There's a problem with Travis' site.
2 parents 4242f03 + b89154b commit fdea266

File tree

6 files changed

+21
-19
lines changed

6 files changed

+21
-19
lines changed

src/python/computation/units.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# Each value is a synonymous unit which is supported by udunits.
1414
# NOTES: 'gpm' appears in JRA25_ANN_climo.nc, probably stands for "geopotential meters".
1515
unit_synonyms = {
16-
'mb':'millibar', 'pa':'pascal', 'gpm':'meters'
16+
'mb':'millibar', 'pa':'pascal', 'gpm':'meters', 'C':'Celsius'
1717
}
1818

1919
# Each key of the following dictionary is a unit not supported by udunits in a manner appropriate

src/python/frontend/diags.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -680,16 +680,13 @@ def makeplots(res, vcanvas, vcanvas2, varid, frname, plot, package, displayunits
680680
logger.warning("multiple displayunits not supported at this time, using: %s" % displayunits[0])
681681
displayunits=displayunits[0]
682682
try:
683-
scale = udunits(1.0, var.units)
684-
scale = scale.to(displayunits).value
683+
var = convert_units(var,displayunits)
685684
except:
686685
try:
687686
scale = float(displayunits)
688687
except:
689688
logger.critical('Invalid display units: '+ displayunits)
690689
sys.exit()
691-
var = var*scale
692-
var.units = displayunits
693690
var.id = '' #this was clearer earlier; var=anything makes an id
694691

695692
if hasattr(plot, 'customizeTemplates'):

src/python/graphics/default_levels.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@
6262
'OBS': {'difference': [-6, -5, -4, -3, -2, -1, -0.5, 0, 0.5, 1, 2, 3, 4, 5, 6], 'contours': [0, 0.5, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]}},
6363
'PSL': {'MODEL': {'difference': [-15, -10, -8, -6, -4, -2, -1, 0, 1, 2, 4, 6, 8, 10, 15], 'contours': [984, 988, 992, 996, 1000, 1004, 1008, 1012, 1016, 1020, 1024, 1028, 1032, 1036, 1040]},
6464
'OBS': {'difference': [-15, -10, -8, -6, -4, -2, -1, 0, 1, 2, 4, 6, 8, 10, 15], 'contours': [984, 988, 992, 996, 1000, 1004, 1008, 1012, 1016, 1020, 1024, 1028, 1032, 1036, 1040]}},
65-
'SST': {'MODEL': {'difference': [-5, -4, -3, -2, -1, -0.5, -0.2, 0, 0.2, 0.5, 1, 2, 3, 4, 5], 'contours': [-1, 0, 1, 3, 6, 9, 12, 15, 18, 20, 22, 24, 26, 28, 29]},
65+
'SST': {'displayunits':'celsius',
66+
'MODEL': {'difference': [-5, -4, -3, -2, -1, -0.5, -0.2, 0, 0.2, 0.5, 1, 2, 3, 4, 5], 'contours': [-1, 0, 1, 3, 6, 9, 12, 15, 18, 20, 22, 24, 26, 28, 29]},
6667
'OBS': {'difference': [-5, -4, -3, -2, -1, -0.5, -0.2, 0, 0.2, 0.5, 1, 2, 3, 4, 5], 'contours': [-1, 0, 1, 3, 6, 9, 12, 15, 18, 20, 22, 24, 26, 28, 29]}},
6768
'FLNS': {'MODEL': {'difference': [-70, -50, -40, -30, -20, -10, -5, 0, 5, 10, 20, 30, 40, 50, 70], 'contours': [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]},
6869
'OBS': {'difference': [-70, -50, -40, -30, -20, -10, -5, 0, 5, 10, 20, 30, 40, 50, 70], 'contours': [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]}},
@@ -137,4 +138,4 @@
137138
'SIWC_226': {'MODEL': {'difference': [-7.0, -6.0, -5.0, -4.0, -3.0, -2.0, -1.0, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0], 'contours': [0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0]}},
138139
'TCLDAREA': {'MODEL': {'difference': [-50, -40, -30, -20, -15, -10, -5, 0, 5, 10, 15, 20, 30, 40, 50], 'contours': [5, 10, 15, 20, 25, 30, 40, 50, 60, 70, 75, 80, 85, 90, 95]},
139140
'OBS': {'difference': [-50, -40, -30, -20, -15, -10, -5, 0, 5, 10, 15, 20, 30, 40, 50], 'contours': [5, 10, 15, 20, 25, 30, 40, 50, 60, 70, 75, 80, 85, 90, 95]}},
140-
'CLW_COSP': {'MODEL': {'difference': [-50, -40, -30, -20, -15, -10, -5, 0, 5, 10, 15, 20, 30, 40, 50], 'contours': [5, 10, 15, 20, 25, 30, 40, 50, 60, 70, 75, 80, 85, 90, 95]}} }
141+
'CLW_COSP': {'MODEL': {'difference': [-50, -40, -30, -20, -15, -10, -5, 0, 5, 10, 15, 20, 30, 40, 50], 'contours': [5, 10, 15, 20, 25, 30, 40, 50, 60, 70, 75, 80, 85, 90, 95]}} }

src/python/packages/amwg/amwg.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,10 @@ def commvar2var( cls, varnom, filetable, season, reduction_function, recurse=Tru
149149
#print "dbg in commvar2var to compute varnom=",varnom,"from filetable=",filetable
150150
for svd in cls.common_derived_variables[varnom]: # loop over ways to compute varnom
151151
invarnoms = svd.inputs()
152-
#print "dbg first round, invarnoms=",invarnoms
153-
#print "dbg filetable variables=",filetable.list_variables()
154-
if len( set(invarnoms) - set(filetable.list_variables_incl_axes()) )<=0:
152+
#print "dbg first round, invarnoms=",invarnoms
153+
#print "dbg filetable variables=",filetable.list_variables()
154+
if len( (set(invarnoms) - set(filetable.list_variables_incl_axes()))
155+
- set(builtin_variables) )<=0:
155156
func = svd._func
156157
computable = True
157158
break
@@ -172,7 +173,8 @@ def commvar2var( cls, varnom, filetable, season, reduction_function, recurse=Tru
172173

173174
available = rvs + dvs
174175
availdict = { v.id()[1]:v for v in available }
175-
inputs = [ availdict[v].id() for v in svd._inputs if v in availdict] + builtin_variables
176+
inputs = [ availdict[v].id() for v in svd._inputs if v in availdict ] +\
177+
[ v for v in svd._inputs if v in builtin_variables ]
176178
#print "dbg1 rvs ids=",[rv.id() for rv in rvs]
177179
if not computable and recurse==True:
178180
# Maybe the input variables are themselves computed. We'll only do this one
@@ -198,10 +200,12 @@ def commvar2var( cls, varnom, filetable, season, reduction_function, recurse=Tru
198200
func = svd._func
199201
available = rvs + dvs
200202
availdict = { v.id()[1]:v for v in available }
201-
inputs = [ availdict[v].id() for v in svd._inputs if v in availdict] + builtin_variables
202-
computable = True
203-
#print "dbg in second round, found",varnom,"computable by",func,"from",inputs
204-
break
203+
inputs = [ availdict[v].id() for v in svd._inputs if v in availdict ] +\
204+
[ v for v in svd._inputs if v in builtin_variables ]
205+
if len( (set(invarnoms) - set( availdict.keys()) -set(builtin_variables) ))<=0:
206+
computable = True
207+
#print "dbg in second round, found",varnom,"computable by",func,"from",inputs
208+
break
205209
if len(rvs)<=0:
206210
logger.warning("no inputs found for %s in filetable %s",varnom, filetable.id())
207211
logger.warning("filetable source files= %s",filetable._filelist[0:10])

src/python/packages/amwg/amwg1.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ def rmse( self ):
303303
""" This function computes the rmse and correlation between the model and observations.
304304
It also scales the data to the units in devel_levels before these computations."""
305305
from metrics.graphics.default_levels import default_levels
306-
from metrics.computation.units import scale_data
306+
from metrics.computation.units import convert_variable
307307
from metrics.computation.compute_rmse import compute_rmse
308308
#pdb.set_trace()
309309

@@ -314,8 +314,8 @@ def rmse( self ):
314314
#convert to the units specified in the default levels disctionay
315315
displayunits = default_levels[self.var].get('displayunits', None)
316316
if displayunits is not None and variable_values[key] is not None:
317-
logger.debug("%s, %s", displayunits, variable_values[key].units)
318-
variable_values[key] = scale_data( displayunits, variable_values[key])
317+
logger.debug("%s, %s", displayunits, getattr(variable_values[key],'units',''))
318+
variable_values[key] = convert_variable( variable_values[key], displayunits )
319319

320320
RMSE = self.undefined
321321
CORR = self.undefined

src/python/packages/amwg/atmos_derived_vars.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
func=aminusb )],
7373

7474
# miscellaneous:
75-
'PRECT':[derived_var(
75+
'PRECT':[derived_var(
7676
vid='PRECT', inputs=['pr'], outputs=['PRECT'],
7777
func=(lambda x:x)),
7878
derived_var(

0 commit comments

Comments
 (0)