miniufo / xgrads

Parse and read ctl and associated binary file commonly used by GrADS into xarray
https://xgrads.readthedocs.io/
MIT License
71 stars 27 forks source link

Error trying to convert from grads to netCDF #10

Closed jkreuz closed 4 years ago

jkreuz commented 4 years ago

Hi I'm having the following error when I try to convert from grads file to netCDF

grads2netcdf.py attm103.ctl

Traceback (most recent call last): File "grads2netcdf.py", line 3, in open_CtlDataset('[PATH]/output/exp_103/attm103.ctl').to_netcdf('[PATH]/output/exp_103/attm103.nc') File "/home/[USER]/.local/lib/python3.7/site-packages/xgrads/io.py", line 42, in open_CtlDataset ctl = CtlDescriptor(file=desfile) File "/home/[USER]/.local/lib/python3.7/site-packages/xgrads/core.py", line 133, in init self.parse(fileContent) File "/home/[USER]/.local/lib/python3.7/site-packages/xgrads/core.py", line 177, in parse self._processDSets(dpath_str) File "/home/[USER]/.local/lib/python3.7/site-packages/xgrads/core.py", line 204, in _processDSets part = (strTim + incre * l).item().strftime(fmt) TypeError: Cannot get a common metadata divisor for NumPy datetime metadata [s] and [M] because they have incompatible nonlinear base time units

miniufo commented 4 years ago

Hi @julianocruz, Thanks for bringing me this bug. This is related to a previous issue #3 that one month interval is generally not a constant in unit of days or seconds.

Please try with the latest version from github (I haven't updated that on pypi) and tell me if current version works fine.

miniufo commented 4 years ago

Oops I notice that there is a keyward sequential in the OPTIONS of your ctl file. I don't think this is currently supported properly. Would you please share part of your binary dataset for me so that I can dig this out? I've opened another issue #11 related to this.

jkreuz commented 4 years ago

I generated a simulation for 3 years and it split it in three files.

attm103_1996.grd.zip attm103_1997.grd.zip attm103_1998.grd.zip

miniufo commented 4 years ago

Thanks @julianocruz for your data. Would you please try with the latest version from github and tell me if current version works fine.

jkreuz commented 4 years ago

Thank you @miniufo ! Now it worked. I just didn't have time to check the netCDF file yet.