Skip to content

Instantly share code, notes, and snippets.

@emontgomery-usgs
Created October 15, 2018 14:07
Show Gist options
  • Save emontgomery-usgs/18741fdd410668beaece811f7340ee9d to your computer and use it in GitHub Desktop.
Save emontgomery-usgs/18741fdd410668beaece811f7340ee9d to your computer and use it in GitHub Desktop.
to_netcdf_issues
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@emontgomery-usgs
Copy link
Author

in cell 11, why doesn't the unlimited_dims argument work?

@mmartini-usgs
Copy link

So this sequence of steps does successfully create time and time2 but ncBrowse does not make use of time2 and there is no metadata for either variable.

@mmartini-usgs
Copy link

mmartini-usgs commented Oct 29, 2018

So I thought I could just get metadata and I hit a weird error in xarray - any ideas?

ValueError: invalid time units: True Julian Day

Gist is here:
https://gist.github.com/mmartini-usgs/ef997bb24792ead3a0469f436d3c677d

@dnowacki-usgs
Copy link

Hi Ellyn,

First, make sure you are using the latest stglib. You call a function that hasn't existed for 5 months (stglib.utils.create_epic_time was renamed to stglib.utils.create_epic_times with an "s" at the end).

In any case, the error still appears even with the newest stglib, xarray, etc. The error seems to be with some extra encoding values that crept in to many of the variables. What created the .nc file that you are working with? For example, here is the encoding dictionary for u_1205:

{'zlib': False,
 'shuffle': False,
 'complevel': 0,
 'fletcher32': False,
 'contiguous': True,
 'chunksizes': None,
 'source': '/Volumes/Backstaff/scratch/mvco/10811v/10811whVcurrents00repodropna-cal-trm-met.nc',
 'original_shape': (12517, 52, 1, 1),
 'dtype': dtype('float32'),
 '_FillValue': nan}

If I delete all of these but _FillValue and dtype, then the file will save with the unlimited_dims argument. Not sure why. Knowing where the file came from could help. Then we can implement some code to guard against the error.

@dnowacki-usgs
Copy link

So I thought I could just get metadata and I hit a weird error in xarray - any ideas?

ValueError: invalid time units: True Julian Day

Gist is here:
https://gist.github.com/mmartini-usgs/ef997bb24792ead3a0469f436d3c677d

Marinna can you create a new issue for this problem? Thanks.

@emontgomery-usgs
Copy link
Author

emontgomery-usgs commented Feb 6, 2019

@dnowacki-usgs (not sure if this syntax works in gists)

Hi Dan-
The file I am working with is one created by Marinna's new V processing code. I believe she instantiates variables largely with the xarray defaults, which is probably where the extraneous stuff comes from.

This gist was started because she had trouble writing EPIC times in her processing, so leaves time in these files as xarray/CF time. I am trying to generate the EPIC times to make something I can release on stellwagen using your create_epic_times module. (OK, I should have updated. thanks for pointing out the correct module!).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment