Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Why time indices are ignored in FieldSet.from_netcdf? #1563

Closed
bbarcelollull opened this issue May 14, 2024 · 1 comment
Closed

Why time indices are ignored in FieldSet.from_netcdf? #1563

bbarcelollull opened this issue May 14, 2024 · 1 comment

Comments

@bbarcelollull
Copy link

I have a set of netcdf files with a date overlap: the last date of one file is the first date of the next file. I have one file per day and hourly outputs, and instead of having 24 indices per file, I have 25 indices. Because of this, I get an error when creating the fieldset with FieldSet.from_netcdf. To solve this, I need to read only the first 24 indices of each file. However, when doing an easy test like this for only one file:

indices = {'depth': np.arange(2).tolist(),
              'lat': np.arange(2).tolist(), 
              'lon': np.arange(2).tolist(), 
              'time': np.arange(2).tolist()} 

fieldset = FieldSet.from_netcdf(filenames, variables, dimensions, indices, deferred_load=False)

I get the following warning: "WARNING: time dimension in indices is not necessary anymore. It is then ignored."

And the shape of the U field (fieldset.U.data.shape) is (25, 2, 2, 2).

Hence, indices works for all dimensions except for time. Why this happens? Can I force the code to read the time indices?

@erikvansebille
Copy link
Member

Hi @bbarcelollull, thanks for posting this question. You are right that parcels doesn't support indexing for the time-dimensions. That would have take a lot of development effort, and in most use-cases so far there is one snapshot per file so users can easily subselect by changing the list of files they provide when creating a fieldset.

An alternative is to use FieldSet.from_xarray_dataset(), which is much more flexible because it allows you to pass xarray datasets directly

@OceanParcels OceanParcels locked and limited conversation to collaborators May 24, 2024
@erikvansebille erikvansebille converted this issue into discussion #1573 May 24, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants