NCPP / ocgis

OpenClimateGIS is a set of geoprocessing and calculation tools for CF-compliant climate datasets.
Other
70 stars 21 forks source link

Temporal conversion #445

Closed huard closed 7 years ago

huard commented 7 years ago

Using date bounds of 31-12-yyyy with 360 days calendar triggers a fallback mechanism within get_numtime, but here arr is a list, not a numpy array.

/home/dhuard/.miniconda3/envs/OPG2/lib/python2.7/site-packages/ocgis-2.0.0.dev1-py2.7.egg/ocgis/variable/temporal.pyc in get_numtime(self, arr)
    266             else:
    267                 # Odd behavior in netcdftime objects? Try with datetime objects.
--> 268                 flat_arr = arr.flatten()
    269                 fill = np.zeros(flat_arr.shape, dtype=object)
    270                 for idx, element in enumerate(flat_arr):

AttributeError: 'list' object has no attribute 'flatten'
bekozi commented 7 years ago

I think this try/catch may be masking another data issue. In the meantime, I added code to make sure a NumPy array will be used in both blocks: https://github.com/NCPP/ocgis/blob/v-2.0.0.dev1/src/ocgis/variable/temporal.py#L260.

bekozi commented 7 years ago

Seems to be working.