Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

netCDF4-python renamed/moved time packages #485

Closed
bekozi opened this issue May 23, 2018 · 9 comments
Closed

netCDF4-python renamed/moved time packages #485

bekozi opened this issue May 23, 2018 · 9 comments
Labels
Milestone

Comments

@bekozi
Copy link
Contributor

bekozi commented May 23, 2018

netcdftime is lost in the ether somewhere around the v1.4.0 release. It is apparently a separate package now that itself may be renamed to cftime.

Until a patch release, a version requirement will be needed for the conda installations.

@bekozi bekozi added the bug label May 23, 2018
@jhamman
Copy link

jhamman commented May 23, 2018

If you were previously importing netcdftime, you should just be able to work around this with:

try:
    import cftime as netcdftime
except ImportError:
    import netcdftime
    warnings.warn('netcdftime has been ported to cftime, now would be a good time to update...')

@bekozi
Copy link
Contributor Author

bekozi commented May 23, 2018

Thanks @jhamman. We had to pin the nc4 version limitation to our conda packages to keep things working...

@bekozi
Copy link
Contributor Author

bekozi commented Jul 26, 2018

Update to cftime went smoothly. Biggest issue was a test that hit an edge case in leap day calendars that is now handled correctly by the new time library.

The auto masking behavior in netcdf4-python was also updated (probably a good thing). This affects many situations where mask used to be None and is now allocated with False. Mask creation might have to work more closely with the driver...

Also noticed CF unit libraries do not work with v1.4.0 of netcdf4-python yet.

@aaschwanden
Copy link

Hi,

after a fresh install of ocgis, I am unable to import ocgis anymore:

    import ocgis
  File "/Users/andy/Library/Python/3.6/lib/python/site-packages/ocgis-2.1.0-py3.6.egg/ocgis/__init__.py", line 7, in <module>
    from .vmachine.core import vm, OcgVM
  File "/Users/andy/Library/Python/3.6/lib/python/site-packages/ocgis-2.1.0-py3.6.egg/ocgis/vmachine/core.py", line 5, in <module>
    from ocgis.base import AbstractOcgisObject
  File "/Users/andy/Library/Python/3.6/lib/python/site-packages/ocgis-2.1.0-py3.6.egg/ocgis/base.py", line 10, in <module>
    from ocgis.util.helpers import get_iter
  File "/Users/andy/Library/Python/3.6/lib/python/site-packages/ocgis-2.1.0-py3.6.egg/ocgis/util/helpers.py", line 15, in <module>
    from netCDF4 import netcdftime

I have netCDF4, netcdftime, and cftime installed. So far the only solution I found was to patch the ocgis source code by hand before installing the module, replacing all calls

from netCDF4 import netcdftime

with

import netcdftime

Would it be possible to insert "try...except..." statements in the code wherever ocgis imports netcdftime?

@bekozi
Copy link
Contributor Author

bekozi commented Nov 1, 2018

Hi @aaschwanden. I have a branch that fixes this, and I'll try to push soon. The netCDF4 1.4.0 version made some changes that were backwards incompatible then backed out. Version 1.4.2 seems to be fixed and stable.

I know it's not convenient, but netCDF4 version 1.3.1 works in the meantime (should work with a fresh install using conda-forge). Sorry for the trouble!

@bekozi
Copy link
Contributor Author

bekozi commented Nov 2, 2018

@aaschwanden I pushed a branch (https://github.com/NCPP/ocgis/tree/i485-cftime) that supports netcdf4-python 1.4.2 with cftime. Can you test with your installation? Thanks!

@aaschwanden
Copy link

@bekozi : I updated netcdf4python to version 1.4.2 and installed ocgis using the i485-cftime branch. I can confirm that it now works. Thank you very much for your efforts and keep up the good work!

@bekozi
Copy link
Contributor Author

bekozi commented Nov 2, 2018

Thanks @aaschwanden! There's a bit of clean-up with this branch before merging to master. I'll close this issue once it's merged. Have a good weekend.

bekozi added a commit that referenced this issue Jan 14, 2019
- Added support for netcdftime and netCDF4 v1.4
- Support for netCDF4 < v1.4 maintained
- Fixed a number of warnings
@bekozi bekozi added this to the v2.2.0 milestone Jan 14, 2019
@bekozi
Copy link
Contributor Author

bekozi commented Jan 14, 2019

Merged to master.

@bekozi bekozi closed this as completed Jan 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants