Parcels version
v4
Description
The current code in main/particleset.py for calculating the initial z of the ParticleSet does not work as expected:
|
if z is None: |
|
minz = 0 |
|
for field in self.fieldset.fields.values(): |
|
if field.grid.depth is not None: |
|
minz = min(minz, field.grid.depth[0]) |
|
z = np.ones(x.size) * minz |
This means that if the Grid.depth is e.g. [1, 5, 10] m, the particles will be initiated at z=0 m, which immediately throws an out of bound error.
Better to initialise zmin= np.inf; but then this still wouldn't work for depths that are negative (e.g. [-1, -5, -10] m). So a proper fix would be to make this code block aware of the direction of the grid.
An alternative (simpler) solution would be to force users to set the initial z explicitly; lik ewe already do for x and y. But this would be an API-change from v3, where depth would be inferred from he grid when users don't specify it.
Parcels version
v4
Description
The current code in main/particleset.py for calculating the initial
zof the ParticleSet does not work as expected:Parcels/src/parcels/_core/particleset.py
Lines 80 to 85 in df9a313
This means that if the
Grid.depthis e.g.[1, 5, 10]m, the particles will be initiated atz=0m, which immediately throws an out of bound error.Better to initialise
zmin= np.inf; but then this still wouldn't work for depths that are negative (e.g.[-1, -5, -10]m). So a proper fix would be to make this code block aware of the direction of the grid.An alternative (simpler) solution would be to force users to set the initial
zexplicitly; lik ewe already do forxandy. But this would be an API-change from v3, wheredepthwould be inferred from he grid when users don't specify it.