Skip to content

Commit

Permalink
Merge pull request #155 from E3SM-Project/py3
Browse files Browse the repository at this point in the history
Py3
  • Loading branch information
zshaheen authored Apr 24, 2018
2 parents 152e818 + 21661ab commit d9c8c31
Show file tree
Hide file tree
Showing 16 changed files with 184 additions and 46 deletions.
6 changes: 3 additions & 3 deletions acme_diags/acme_diags_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ def provenance(results_dir):
output, err = p.communicate()
fnm = os.path.join(results_dir, 'env_prov.txt')

with file(fnm, 'w') as f:
f.write(output)
f.write(err)
with open(fnm, 'w') as f:
f.write(output.decode('utf-8'))
f.write(err.decode('utf-8'))
print('Saving provenance data in: {}'.format(fnm))


Expand Down
19 changes: 8 additions & 11 deletions acme_diags/acme_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def _add_pages_and_top_row(viewer, parameters):
set_to_seasons[set_num] = []
set_to_seasons[set_num].append(ssn)

for set_num, seasons in set_to_seasons.iteritems():
for set_num, seasons in list(set_to_seasons.items()):
ROW_INFO[set_num] = collections.OrderedDict()
col_labels = ['Description']
for s in ['ANN', 'DJF', 'MAM', 'JJA', 'SON']:
Expand Down Expand Up @@ -202,7 +202,7 @@ def _create_csv_from_dict(output_dir, season, test_name, run_type):
with open(table_path, 'w') as table_csv:
writer=csv.writer(table_csv, delimiter=',', lineterminator='\n', quoting=csv.QUOTE_NONE)
writer.writerow(col_names)
for key, metrics_dic in LAT_LON_TABLE_INFO[season].items():
for key, metrics_dic in list(LAT_LON_TABLE_INFO[season].items()):
metrics = metrics_dic['metrics']
if run_type == 'model_vs_model':
key = key.split()[0] + ' ' +key.split()[1]
Expand All @@ -223,7 +223,7 @@ def _create_csv_from_dict_taylor_diag(output_dir, season, test_name, run_type, r
writer=csv.writer(table_csv, delimiter=',', lineterminator='\n', quoting=csv.QUOTE_NONE)
writer.writerow(col_names)

for key, metrics_dic in LAT_LON_TABLE_INFO[season].items():
for key, metrics_dic in list(LAT_LON_TABLE_INFO[season].items()):
# only include variables in a a certain list for taylor diagram
if run_type == 'model_vs_obs':
if key.split()[0] in ['PRECT', 'PSL', 'SWCF', 'LWCF', 'TREFHT'] and '_'.join((key.split()[0], key.split()[2].split('_')[0])) in ['PRECT_GPCP','PSL_ERA-Interim','SWCF_ceres','LWCF_ceres', 'TREFHT_CRU']:
Expand Down Expand Up @@ -266,23 +266,20 @@ def _create_csv_from_dict_taylor_diag(output_dir, season, test_name, run_type, r
# Add samples to taylor diagram
for irow in range(1,row_count):
std_norm, correlation = float(data[irow][1])/float(data[irow][2]), float(data[irow][3])
print std_norm, correlation
taylordiag.add_sample(std_norm, correlation, marker = marker[irow], c = color[0],ms = 10, label = data[irow][0], markerfacecolor = 'None', markeredgecolor = color[0], linestyle = 'None')
# Add a figure legend

# Add a figure legend
fig.legend(taylordiag.samplePoints,
[ p.get_label() for p in taylordiag.samplePoints],
numpoints=1, loc='center right', bbox_to_anchor=(1.0, .5), prop={'size':10})
[p.get_label() for p in taylordiag.samplePoints],
numpoints=1, loc='center right', bbox_to_anchor=(1.0, .5), prop={'size':10})


# Add samples for baseline simulation:
if run_type == 'model_vs_obs':
for irow in range(1,row_count):
if data[irow][0] in keys_control_runs:
control_irow = keys_control_runs.index(data[irow][0])
#print control_irow
std_norm, correlation = float(control_runs_data[control_irow][1])/float(control_runs_data[control_irow][2]), float(control_runs_data[control_irow][3])
#print std_norm, correlation
taylordiag.add_sample(std_norm, correlation, marker = marker[irow], c = color[1],ms = 10, label = data[irow][0]+'E3sm_v0 B1850', markerfacecolor = 'None', markeredgecolor = color[1], linestyle = 'None')

baseline_text = 'E3SMv0_B1850'
Expand Down Expand Up @@ -493,7 +490,7 @@ def create_metadata(parameter):
parser = ACMEParser()

args = parser.view_args()
supported_cmd_args = args.__dict__.keys()
supported_cmd_args = list(args.__dict__.keys())

if 'other_parameters' in supported_cmd_args:
supported_cmd_args.remove('other_parameters')
Expand Down Expand Up @@ -577,7 +574,7 @@ def create_viewer(root_dir, parameters, ext):
if os.path.exists(metrics_path + '.json'):
_add_to_lat_lon_metrics_table(metrics_path, season, row_name)
else:
print('JSON does not exist: {}'.format(metrics_path + '.json'))
print(('JSON does not exist: {}'.format(metrics_path + '.json')))
continue
for row_name, fnm in row_name_and_fnm:
if parameter.case_id not in ROW_INFO[set_num]:
Expand Down
4 changes: 2 additions & 2 deletions acme_diags/derivations/acme.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def process_derived_var(var_key, derived_vars_dict, nc_file, parameter):

def _add_user_derived_vars(derived_vars_dict, parameter):
"""Append parameter.derived_variables to the correct part of derived_vars_dict"""
for key, user_derived_vars in parameter.derived_variables.iteritems():
for key, user_derived_vars in list(parameter.derived_variables.items()):
# append the user-defined vars to the already defined ones
# add to an existing entry, otherwise create a new one
if key in derived_vars_dict:
Expand All @@ -44,7 +44,7 @@ def _compute_derived_var(var_key, derived_vars_dict, nc_file):
derived_var_inputs = []

# get the first function and inputs from the derived_vars_dict dict
for inputs, func in derived_vars.iteritems():
for inputs, func in list(derived_vars.items()):
derived_var_inputs.append(inputs)
# tuples with a single string [ex: ('pr')] become just a string ['pr']
# are all of the variables (inputs) in the nc_file?
Expand Down
2 changes: 1 addition & 1 deletion acme_diags/driver/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
('13', 'cosp_histogram'): 'cosp_histogram',
}

SET_NAMES = SET_NAME_MAPPING.values()
SET_NAMES = list(SET_NAME_MAPPING.values())

def get_set_name(set_name):
"""Get the correct set name from the argument.
Expand Down
4 changes: 0 additions & 4 deletions acme_diags/driver/zonal_mean_2d_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,6 @@ def run_diag(parameter):
ref_name = parameter.ref_name
regions = parameter.regions

if getattr(parameter, 'multiprocessing', False):
# only force mpl when running with multiprocessing
parameter.backend = 'mpl'

for season in seasons:
try:
filename1 = utils.get_test_filename(parameter, season)
Expand Down
12 changes: 6 additions & 6 deletions acme_diags/metrics/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import corr
import rmse
import max_cdms
import mean
import min_cdms
import std
from . import corr
from . import rmse
from . import max_cdms
from . import mean
from . import min_cdms
from . import std

corr = corr.CORR()
rmse = rmse.RMSE()
Expand Down
2 changes: 1 addition & 1 deletion acme_diags/plot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def get_colormap(colormap, parameters):
cmap = LinearSegmentedColormap.from_list(name=colormap, colors=rgb_arr, N=n_levels)
vcs_cmap = matplotlib2vcs(cmap, vcs_name=colormap)

return vcs_cmap, range(n_levels)
return vcs_cmap, list(range(n_levels))

else:
raise RuntimeError('Invalid backend: {}'.format(parameters.backend))
2 changes: 1 addition & 1 deletion acme_diags/plot/cartopy/taylor_diagram.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def __init__(self, refstd, fig=None, rect=111, label='_'):
gl2_ticks = [(x, str(x)) for x in gl2_num]
gl2_ticks[-1] = [gl2_num[-1], '']
gl2_ticks[0] = [gl2_num[0], '0']
tf1 = GF.DictFormatter(dict(zip(tlocs, map(str,rlocs))))
tf1 = GF.DictFormatter(dict(list(zip(tlocs, list(map(str,rlocs))))))
tf2 = GF.DictFormatter(dict(gl2_ticks))

# Standard deviation axis extent
Expand Down
6 changes: 3 additions & 3 deletions acme_diags/plot/colormaps/rewrite_from_colorcet.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
try:
import colorcet
except BaseException:
print "Cannot convert from colorcet w/o colorcet"
print("Cannot convert from colorcet w/o colorcet")
import sys
sys.exit()

Expand All @@ -21,8 +21,8 @@ def dump_cmap(name, mpl_cmap):
a = float(i) / float(mpl_cmap.N - 1)
r, g, b, a = [int(x * 255) for x in mpl_cmap(a)]
f.write(" %3s %3s %3s\n" % (r, g, b))
print "Wrote %s" % nm
print("Wrote %s" % nm)


for cmap in all_cms.keys():
for cmap in list(all_cms.keys()):
dump_cmap(cmap, all_cms[cmap])
4 changes: 2 additions & 2 deletions acme_diags/plot/vcs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ def get_color_range(gm):
'white_to_magenta',
'white_to_red',
'white_to_yellow']:
return range(16, 240)
return list(range(16, 240))
else:
return range(256)
return list(range(256))


def set_colormap_of_graphics_method(
Expand Down
6 changes: 3 additions & 3 deletions conda/acme_diags_env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,12 @@ dependencies:
- yaml=0.1.7
- zict=0.1.3
- zlib=1.2.11
- cdp=1.3.2
- cdp=1.3.3
- dv3d=8.0
- output_viewer=1.2.3
- output_viewer=1.2.5
- vcs=8.0
- vcsaddons=8.0
- vtk-cdat=8.0.1.8.0
- vtk-cdat=8.0.1.8.0=py27_mesalib_1
- cdat_info=8.0
- cdms2=3.0
- cdtime=3.0
Expand Down
6 changes: 3 additions & 3 deletions conda/acme_diags_env_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,12 @@ dependencies:
- yaml=0.1.7
- zict=0.1.3
- zlib=1.2.11
- cdp=1.3.2
- cdp=1.3.3
- dv3d=8.0
- output_viewer=1.2.3
- output_viewer=1.2.5
- vcs=8.0
- vcsaddons=8.0
- vtk-cdat=8.0.1.8.0
- vtk-cdat=8.0.1.8.0=py27_mesalib_1
- cdat_info=8.0
- cdms2=3.0
- cdtime=3.0
Expand Down
142 changes: 142 additions & 0 deletions conda/acme_diags_env_dev_py3.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
name: acme_diags_env_dev_py3
channels:
- conda-forge
- cdat
- anaconda
- defaults
dependencies:
- asn1crypto=0.24.0=py36_0
- beautifulsoup4=4.6.0=py36h49b8c8c_1
- bokeh=0.12.15=py36_0
- bzip2=1.0.6=h9a117a8_4
- ca-certificates=2018.03.07=0
- certifi=2018.4.16=py36_0
- cffi=1.11.5=py36h9745a5d_0
- chardet=3.0.4=py36h0f667ec_1
- click=6.7=py36h5253387_0
- cloudpickle=0.5.2=py36_1
- cryptography=2.2.2=py36h14c3975_0
- curl=7.59.0=h84994c4_0
- cycler=0.10.0=py36h93f1223_0
- cytoolz=0.9.0.1=py36h14c3975_0
- dask=0.17.2=py36_0
- dask-core=0.17.2=py36_0
- dbus=1.13.2=h714fa37_1
- distributed=1.21.6=py36_0
- expat=2.2.5=he0dffb1_0
- ffmpeg=3.4=h7264315_0
- fontconfig=2.12.6=h49f89f6_0
- freetype=2.8=hab7d2ae_1
- future=0.16.0=py36_1
- g2clib=1.6.0=h838ce51_4
- glib=2.56.1=h000015b_0
- gst-plugins-base=1.14.0=hbbd80ab_1
- gstreamer=1.14.0=hb453b48_1
- hdf4=4.2.13=h3ca952b_2
- hdf5=1.10.1=h9caa474_1
- heapdict=1.0.0=py36_2
- icu=58.2=h9c2bf20_1
- idna=2.6=py36h82fb2a8_1
- intel-openmp=2018.0.0=8
- jasper=1.900.1=hd497a04_4
- jinja2=2.10=py36ha16c418_0
- jpeg=9b=h024ee3a_2
- kiwisolver=1.0.1=py36h764f252_0
- libcurl=7.59.0=h1ad7b7a_0
- libedit=3.1=heed3624_0
- libffi=3.2.1=hd88cf55_4
- libgcc=7.2.0=h69d50b8_2
- libgcc-ng=7.2.0=hdf63c60_3
- libgfortran=3.0.0=1
- libgfortran-ng=7.2.0=hdf63c60_3
- libnetcdf=4.4.1.1=h816af47_8
- libopus=1.2.1=hb9ed12e_0
- libpng=1.6.34=hb9fc6fc_0
- libssh2=1.8.0=h9cfc8f7_4
- libstdcxx-ng=7.2.0=hdf63c60_3
- libtiff=4.0.9=h28f6b97_0
- libvpx=1.6.1=h888fd40_0
- libxcb=1.13=h1bed415_1
- libxml2=2.9.8=hf84eae3_0
- libxslt=1.1.32=h1312cb7_0
- locket=0.2.0=py36h787c0ad_1
- lxml=4.2.1=py36h23eabaa_0
- markupsafe=1.0=py36hd9260cd_1
- matplotlib=2.2.2=py36h0e671d2_1
- mkl=2018.0.2=1
- mkl_fft=1.0.1=py36h3010b51_0
- mkl_random=1.0.1=py36h629b387_0
- msgpack-python=0.5.6=py36h6bb024c_0
- ncurses=6.0=h9df7e31_2
- numpy=1.14.2=py36hdbf6ddf_1
- openssl=1.0.2o=h20670df_0
- packaging=17.1=py36_0
- pandas=0.22.0=py36hf484d3e_0
- partd=0.3.8=py36h36fd896_0
- pcre=8.42=h439df22_0
- pip=9.0.3=py36_0
- proj4=4.9.3=hc8507d1_7
- psutil=5.4.5=py36h14c3975_0
- pthread-stubs=0.3=h0ce48e5_1
- pycparser=2.18=py36hf9f622e_1
- pyopenssl=17.5.0=py36h20ba746_0
- pyparsing=2.2.0=py36hee85983_1
- pyqt=5.9.2=py36h751905a_0
- pysocks=1.6.8=py36_0
- python=3.6.5=hc3d631a_0
- python-dateutil=2.7.2=py36_0
- pytz=2018.4=py36_0
- pyyaml=3.12=py36hafb9ca4_1
- qt=5.9.5=h7e424d6_0
- readline=7.0=ha6073c6_4
- requests=2.18.4=py36he2e5f8d_1
- setuptools=39.0.1=py36_0
- sip=4.19.8=py36hf484d3e_0
- six=1.11.0=py36h372c433_1
- sortedcontainers=1.5.10=py36_0
- sqlite=3.23.1=he433501_0
- system=5.8=2
- tblib=1.3.2=py36h34cf8b6_0
- tk=8.6.7=hc745277_3
- toolz=0.9.0=py36_0
- tornado=5.0.2=py36_0
- udunits2=2.2.25=hd30922c_1
- urllib3=1.22=py36hbe7ace6_0
- wheel=0.31.0=py36_0
- xz=5.2.3=h55aa19d_2
- yaml=0.1.7=had09818_2
- zict=0.1.3=py36h3a3bf81_0
- zlib=1.2.11=ha838bed_2
- cdp=1.3.3=py36_0
- dv3d=8.0=py36_0
- output_viewer=1.2.5
- vcs=8.0=py36_0
- vcsaddons=8.0=py36_0
- vtk-cdat=8.0.1.8.0=py36_mesalib_1
- cdat_info=8.0=py36_0
- cdms2=3.0=py36_6
- cdtime=3.0=py36_0
- cdutil=8.0=py36_1
- clapack=3.2.1=0
- distarray=2.12.2=py36_0
- esmf=7.1.0r=0
- esmpy=7.1.0r=py36_1
- genutil=8.0=py36_1
- lapack=3.6.1=1
- libcdms=3.0.1=0
- libcf=1.0.1=py36_1
- libdrs=3.0=0
- libdrs_f=3.0=0
- llvm-meta=6.0.0=0
- llvmdev=6.0.0=default_0
- mesalib=17.2.0=0
- mpi=1.0=mpich
- mpich=3.2.1=0
- netcdf-fortran=4.4.4=6
- ossuuid=1.6.2=0
- x264=20131217=3
- pip:
- mv2==3.0.0
- regrid2==3.0.0
prefix: /export/shaheen2/anaconda2/envs/acme_diags_env_dev_py3

3 changes: 3 additions & 0 deletions conda/conda_build_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
python:
- 2.7
- 3.6
6 changes: 3 additions & 3 deletions conda/meta-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ build:

requirements:
build:
- python 2
- python {{ python }}
- setuptools

run:
- python 2
- cdp 1.3.2
- python {{ python }}
- cdp 1.3.3
- vcs 8.0
- vtk-cdat 8.0.1.8.0
- vcsaddons 8.0
Expand Down
6 changes: 3 additions & 3 deletions conda/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ build:

requirements:
build:
- python 2
- python {{ python }}
- setuptools

run:
- python 2
- cdp 1.3.2
- python {{ python }}
- cdp 1.3.3
- vcs 8.0
- vtk-cdat 8.0.1.8.0
- vcsaddons 8.0
Expand Down

0 comments on commit d9c8c31

Please sign in to comment.