Skip to content

Fieldset.from_netcdf with manual timestamps#540

Merged
erikvansebille merged 10 commits intoParcels-code:masterfrom
christensen5:fromNetcdf_noTimeDim
Feb 25, 2019
Merged

Fieldset.from_netcdf with manual timestamps#540
erikvansebille merged 10 commits intoParcels-code:masterfrom
christensen5:fromNetcdf_noTimeDim

Conversation

@christensen5
Copy link
Copy Markdown

This PR creates an option to provide time data as a separate 1D numpy array (called 'timestamps') when creating a fieldset from a netcdf file - this is useful when time is not explicitly included within the 'dimensions' dictionary of the numpy array, but only in the 'variables' dictionary. Note the following comments on the current implementation:

  • All the variables (u, v, w, temp, etc...) must be contained in the same files, and each file must correspond to exactly one timestep. I check if the number of files is equal to the length of timestamps and throw an exception if not.

  • Filenames must be provided as a list or as a dict; I throw an error if its a dict of dicts.

  • Works with deferred loading.

@erikvansebille
Copy link
Copy Markdown
Member

Thanks for this Pull, @christensen5; a nice feature for some users who have netcdf files without time dimension

I just tried to create a unit test that tests this new feature, but as you see it currently breaks. Can you have a look at it (see d5e7504)? Perhaps you can find why it breaks?

Alexander Kier Christensen added 3 commits February 22, 2019 14:22
Merge branch 'fromNetcdf_noTimeDim' of github.com:christensen5/parcels into fromNetcdf_noTimeDim
@christensen5
Copy link
Copy Markdown
Author

Unittest should now pass. The issue was that when working with the user-provided array of timestamps, netcdfFileBuffer.time() was returning the entire array, rather than the current time for a given file.

Copy link
Copy Markdown
Member

@erikvansebille erikvansebille left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice code; nothing to further comment. Well done for implementing this feature, @christensen5!

@erikvansebille erikvansebille merged commit 15433b1 into Parcels-code:master Feb 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants