Skip to content

ParticleSet default initial z not set correctly (does not respect direction of depth axis) #2772

Description

@erikvansebille

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugneeds-triageIssue that has not been reviewed by a Parcels team member

    Type

    No type

    Projects

    Status
    Backlog

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions