pik-copan / pyunicorn

Unified Complex Network and Recurrence Analysis Toolbox
http://pik-potsdam.de/~donges/pyunicorn/
Other
195 stars 86 forks source link

data.py not working properly in Python3 #118

Closed pratiman-91 closed 5 years ago

pratiman-91 commented 5 years ago

Traceback (most recent call last): File "", line 1, in File "/python3.6/site-packages/pyunicorn/climate/climate_data.py", line 97, in str return 'ClimateData:\n' + Data.str(self) File "/python3.6/site-packages/pyunicorn/core/data.py", line 106, in str self.print_data_info() File "/python3.6/site-packages/pyunicorn/core/data.py", line 388, in print_data_info for name, obj in f.variables.iteritems(): AttributeError: 'collections.OrderedDict' object has no attribute 'iteritems'

pratiman-91 commented 5 years ago

/python3.6/site-packages/pyunicorn/core/data.py:281: VisibleDeprecationWarning: rank is deprecated; use the ndim attribute or function instead. To find the rank of a matrix see numpy.linalg.matrix_rank.

This warning can easily be removed.

jkroenke commented 5 years ago

Can you specify the problem? What code did you execute to get this traceback?

pratiman-91 commented 5 years ago

from pyunicorn import climate DATA_FILENAME = "test.nc" FILE_TYPE = "NetCDF" DATA_SOURCE = "TRMM 3B42 DAILY: V7" OBSERVABLE_NAME = "precip"

TIME_CYCLE = 122

data = climate.ClimateData.Load( file_name=DATA_FILENAME, observable_name=OBSERVABLE_NAME,time_cycle=TIME_CYCLE, file_type=FILE_TYPE)

print (data)

OUTPUT:

Reading NetCDF File and converting data to NumPy array... File format: NETCDF3_CLASSIC Global attributes: CDI: Climate Data Interface version 1.9.4 (http://mpimet.mpg.de/cdi) Conventions: CF-1.0 history: Sun Dec 9 12:02:58 2018: ncap2 -O -s where(precip <= 0.01) precip=0; trmm_index_1998_2013.nc test.nc Sun Dec 9 11:58:45 2018: ncap2 -S fl.nco trmm_1998_2013_JJAS_old.nc trmm_index_1998_2013.nc Fri Nov 23 11:29:36 2018: ncrcat trmm_0.25_1998.nc trmm_0.25_1999.nc trmm_0.25_2000.nc trmm_0.25_2001.nc trmm_0.25_2002.nc trmm_0.25_2003.nc trmm_0.25_2004.nc trmm_0.25_2005.nc trmm_0.25_2006.nc trmm_0.25_2007.nc trmm_0.25_2008.nc trmm_0.25_2009.nc trmm_0.25_2010.nc trmm_0.25_2011.nc trmm_0.25_2012.nc trmm_0.25_2013.nc trmm_1998_2013.nc Fri Nov 23 11:26:05 2018: cdo seltimestep,152/273 temp.nc trmm_0.25_1998.nc Fri Nov 23 11:26:02 2018: cdo sellonlatbox,60,95,6,35 3B42.1998.daily_V7.nc temp.nc creation_date: Mon Aug 11 10:07:55 MDT 2014 source_data: Download netCDF from NASA MIRADOR

title: TRMM: 3B42 DAILY: V7 CDO: Climate Data Operators version 1.9.4 (http://mpimet.mpg.de/cdo) NCO: "4.5.5" nco_openmp_thread_number: 1 Variables (size): Traceback (most recent call last):

File "", line 15, in print (data)

File "/python3.6/site-packages/pyunicorn/climate/climate_data.py", line 97, in str return 'ClimateData:\n' + Data.str(self)

File "/python3.6/site-packages/pyunicorn/core/data.py", line 106, in str self.print_data_info()

File "/python3.6/site-packages/pyunicorn/core/data.py", line 388, in print_data_info for name, obj in f.variables.iteritems():

AttributeError: 'collections.OrderedDict' object has no attribute 'iteritems'

jkroenke commented 5 years ago

The problem can be solved by simply replacing the 'iteritems()' in data.py with 'items()' which is the corresponding python 3 method.