-
Notifications
You must be signed in to change notification settings - Fork 168
Remove deferred loading of FieldSets #1908
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
Conversation
parcels/field.py
Outdated
| # if len(buffer_data.shape) == 2: | ||
| # data_list.append(buffer_data.reshape(sum(((len(tslice), 1), buffer_data.shape), ()))) | ||
| # elif len(buffer_data.shape) == 3: | ||
| # if len(filebuffer.indices["depth"]) > 1: | ||
| # data_list.append(buffer_data.reshape(sum(((1,), buffer_data.shape), ()))) | ||
| # else: | ||
| # data_list.append(buffer_data.reshape(sum(((len(tslice), 1), buffer_data.shape[1:]), ()))) | ||
| # else: | ||
| # data_list.append(buffer_data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note to self: Still need to work through this commented code so there's no unintended side-effects
|
Working off of @pytest.mark.parametrize("dt", [-300, 300])
@pytest.mark.parametrize("with_starttime", [True, False])
def test_globcurrent_startparticles_between_time_arrays(dt, with_starttime):
fieldset = set_globcurrent_fieldset()
data_folder = parcels.download_example_dataset("GlobCurrent_example_data")
fnamesFeb = sorted(glob(f"{data_folder}/200202*.nc"))
fieldset.add_field(
parcels.Field.from_netcdf(
fnamesFeb,
("P", "eastward_eulerian_current_velocity"),
{"lat": "lat", "lon": "lon", "time": "time"},
+ deferred_load=False,
)
)
MyParticle = parcels.Particle.add_variable("sample_var", initial=0.0)
def SampleP(particle, fieldset, time): # pragma: no cover
particle.sample_var += fieldset.P[
time, particle.depth, particle.lat, particle.lon
]
if with_starttime:
time = fieldset.U.grid.time[0] if dt > 0 else fieldset.U.grid.time[-1]
pset = parcels.ParticleSet(
fieldset, pclass=MyParticle, lon=[25], lat=[-35], time=time
)
else:
pset = parcels.ParticleSet(fieldset, pclass=MyParticle, lon=[25], lat=[-35])
if with_starttime:
with pytest.raises(parcels.TimeExtrapolationError):
pset.execute(
pset.Kernel(parcels.AdvectionRK4) + SampleP,
runtime=timedelta(days=1),
dt=dt,
)
else:
pset.execute(
pset.Kernel(parcels.AdvectionRK4) + SampleP,
runtime=timedelta(days=1),
dt=dt,
)
|
|
This is strange. Th test case is expected to throw a TimeExtrapolationError, right? See the |
This is half the story. |
|
Going ahead and disabling debugging info
By adding print statements to the VectorField.getitem method we get: I think the 2nd element of the tuple is the depth in question. |
609a88a to
990e1ac
Compare
test_kernel_warnings and test_globcurrent_startparticles_between_time_arrays
990e1ac to
20a0caa
Compare
Deferred loading will be handled natively by xarray
Changes/commits:
mainfor v3 changes,v4-devfor v4 changes)I'm still having difficulty with a couple failing tests, so this is still WIP.