Skip to content

Conversation

@erikvansebille
Copy link
Member

@erikvansebille erikvansebille commented May 17, 2024

In developing plasticparcels, we realised that for many teams it could be useful to have a way to directly and effortlessly create a FieldSet instance from all the files in a particular directory. This is particularly useful if many use the same data on a shared storage.

This PR implements a simple method, Fieldset.from_modulefile(filename), that returns a FieldSet instance based on a python module file at filename. That file should include a create_fieldset() function, which returns a FieldSet object.

An example of how this can be used is in the unit tests:

The data manager places a function to create the fieldset somewhere (e.g. in the same directory as where the data is)
https://github.com/OceanParcels/parcels/blob/7d3cf6ed10e7b89fa0f840a8079cfaed972f0dfe/tests/test_data/fieldset_nemo.py#L5-L16

Then, a user only has to issue
https://github.com/OceanParcels/parcels/blob/548d62df1eabe31793cde92227f10a770bdc2913/tests/test_fieldset.py#L203-L205

The advantage is that users don't need to think anymore which fieldset creation method to use (from_nemo, from_netcdf, etc) and that all settings are immediately correct

@erikvansebille erikvansebille changed the title Creating a new Fieldset.from_directory() method Creating a new Fieldset.from_modulefile() method May 21, 2024
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.

2 participants