Skip to content

Commit

Permalink
flake8 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
doutriaux1 committed Sep 15, 2016
1 parent 0e0936c commit 15dacdb
Show file tree
Hide file tree
Showing 8 changed files with 149 additions and 125 deletions.
6 changes: 4 additions & 2 deletions src/python/pcmdi/bias_xy.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import MV2
import cdutil


def compute(dm, do):
""" Computes bias"""
if dm is None and do is None: # just want the doc
Expand All @@ -10,5 +11,6 @@ def compute(dm, do):
"Contact": "[email protected]",
}
dif = MV2.subtract(dm, do)
return MV2.float(cdutil.averager(dif,axis='xy',weights='weighted'))
# return MV2.float(MV2.average(MV2.subtract(dm, do))) deprecated - does not use area weights
return MV2.float(cdutil.averager(dif, axis='xy', weights='weighted'))
# return MV2.float(MV2.average(MV2.subtract(dm, do))) deprecated - does
# not use area weights
6 changes: 4 additions & 2 deletions src/python/pcmdi/bias_xyt.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import MV2
import cdutil


def compute(dm, do):
""" Computes bias"""
if dm is None and do is None: # just want the doc
Expand All @@ -10,5 +11,6 @@ def compute(dm, do):
"Contact": "[email protected]",
}
dif = MV2.subtract(dm, do)
return MV2.float(cdutil.averager(dif,axis='xyt',weights='weighted'))
# return MV2.float(MV2.average(MV2.subtract(dm, do))) deprecated - does not use area weights
return MV2.float(cdutil.averager(dif, axis='xyt', weights='weighted'))
# return MV2.float(MV2.average(MV2.subtract(dm, do))) deprecated - does
# not use area weights
227 changes: 121 additions & 106 deletions src/python/pcmdi/io.py

Large diffs are not rendered by default.

19 changes: 10 additions & 9 deletions src/python/pcmdi/mean_climate_metrics_calculations.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ def compute_metrics(Var, dm, do):
None,
None)
metrics_defs["rms_xy"] = pcmdi_metrics.pcmdi.rms_xy.compute(None, None)
metrics_defs["bias_xy"] = pcmdi_metrics.pcmdi.bias_xy.compute(None, None)
metrics_defs["bias_xy"] = pcmdi_metrics.pcmdi.bias_xy.compute(
None, None)
metrics_defs["mae_xy"] = pcmdi_metrics.pcmdi.meanabs_xy.compute(
None,
None)
Expand Down Expand Up @@ -43,7 +44,7 @@ def compute_metrics(Var, dm, do):

# SET CONDITIONAL ON INPUT VARIABLE
if var == 'pr':
conv = 86400.
conv = 86400.
else:
conv = 1.

Expand All @@ -54,7 +55,7 @@ def compute_metrics(Var, dm, do):

# CALCULATE ANNUAL CYCLE SPACE-TIME RMS, CORRELATIONS and STD
rms_xyt = pcmdi_metrics.pcmdi.rms_xyt.compute(dm, do)
# cor_xyt = pcmdi_metrics.pcmdi.cor_xyt.compute(dm, do)
# cor_xyt = pcmdi_metrics.pcmdi.cor_xyt.compute(dm, do)
stdObs_xyt = pcmdi_metrics.pcmdi.std_xyt.compute(do)
std_xyt = pcmdi_metrics.pcmdi.std_xyt.compute(dm)

Expand All @@ -70,8 +71,8 @@ def compute_metrics(Var, dm, do):
# CALCULATE ANNUAL MEAN RMS
rms_xy = pcmdi_metrics.pcmdi.rms_xy.compute(dm_am, do_am)

# CALCULATE ANNUAL MEAN CORRELATION
cor_xy = pcmdi_metrics.pcmdi.cor_xy.compute(dm_am, do_am)
# CALCULATE ANNUAL MEAN CORRELATION
cor_xy = pcmdi_metrics.pcmdi.cor_xy.compute(dm_am, do_am)

# CALCULATE ANNUAL OBS and MOD STD
stdObs_xy = pcmdi_metrics.pcmdi.std_xy.compute(do_am)
Expand Down Expand Up @@ -201,27 +202,27 @@ def compute_metrics(Var, dm, do):
metrics_dictionary[
'bias_xy_' +
sea
] = format(
] = format(
bias_sea *
conv,
sig_digits)
metrics_dictionary[
'rms_xy_' +
sea
] = format(
] = format(
rms_sea *
conv,
sig_digits)
metrics_dictionary[
'cor_xy_' +
sea
] = format(
] = format(
cor_sea,
'.2f')
metrics_dictionary[
'mae_xy_' +
sea
] = format(
] = format(
mae_sea *
conv,
sig_digits)
Expand Down
6 changes: 4 additions & 2 deletions src/python/pcmdi/meanabs_xy.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import MV2
import cdutil


def compute(dm, do):
""" Computes Mean Absolute Error"""
if dm is None and do is None: # just want the doc
Expand All @@ -11,7 +12,8 @@ def compute(dm, do):
"Contact": "[email protected]",
}
absdif = MV2.absolute(MV2.subtract(dm, do))
mae = cdutil.averager(absdif,axis='xy',weights='weighted')
mae = cdutil.averager(absdif, axis='xy', weights='weighted')

# mae = MV.average(MV.absolute(MV.subtract(dm, do))) - depricated ... did not include area weights
# mae = MV.average(MV.absolute(MV.subtract(dm, do))) - depricated ... did
# not include area weights
return float(mae)
6 changes: 4 additions & 2 deletions src/python/pcmdi/meanabs_xyt.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import MV2
import cdutil


def compute(dm, do):
""" Computes Mean Absolute Error"""
if dm is None and do is None: # just want the doc
Expand All @@ -11,7 +12,8 @@ def compute(dm, do):
"Contact": "[email protected]",
}
absdif = MV2.absolute(MV2.subtract(dm, do))
mae = cdutil.averager(absdif,axis='xyt',weights='weighted')
mae = cdutil.averager(absdif, axis='xyt', weights='weighted')

# mae = MV.average(MV.absolute(MV.subtract(dm, do))) - depricated ... did not include area weights
# mae = MV.average(MV.absolute(MV.subtract(dm, do))) - depricated ... did
# not include area weights
return float(mae)
2 changes: 1 addition & 1 deletion src/python/pcmdi/scripts/build_obs_meta_dictionary.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
# FOR MONTHLY MEAN OBS
obs_dic_in = {'rlut': {'default': 'CERES'},
'rst': {'default': 'CERES'},
'rt':{'default':'CERES'},
'rt': {'default': 'CERES'},
'rsut': {'default': 'CERES'},
'rsds': {'default': 'CERES', },
'rlds': {'default': 'CERES', },
Expand Down
2 changes: 1 addition & 1 deletion src/python/pcmdi/scripts/pcmdi_metrics_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ def applyCustomKeys(O, custom_dict, var):
if level is not None:
metrics_dictionary["Variable"]["level"] = level

metrics_dictionary["json_version"]="2.0"
metrics_dictionary["json_version"] = "2.0"
metrics_dictionary["References"] = {}
metrics_dictionary["RegionalMasking"] = {}
for region in regions_dict[var]:
Expand Down

0 comments on commit 15dacdb

Please sign in to comment.