Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

seaduck.lagrangian

Particle

class Particle(uname='UVELMASS', vname='VVELMASS', wname='WVELMASS', free_surface='noflux', save_raw=False, transport=False, callback=None, max_iteration=200, **kwarg)

Lagrangian particle object.

The Lagrangian particle object. Simply a eulerian Position object that know how to move itself.

Parameters

Particle.analytical_step (method)

analytical_step(self, tf)

Integrate the particle with velocity.

The core method. A set of particles trying to integrate for time tf (could be negative). at the end of the call, every particle are either:

  1. ended up somewhere within the cell after time tf.

  2. ended up on a cell wall before (if tf is negative, then “after”) tf.

Parameters

Particle.cross_cell_wall (method)

cross_cell_wall(self, tend)

Update properties after particles cross wall.

This function is called when particle reached the wall. The nearest grid points change as well as the way the package describe the location of particles. This method handles the handover of particles between grid points.

Parameters

Particle.deepcopy (method)

deepcopy(self)

Return a clone of the object.

Particle.empty_lists (method)

empty_lists(self)

Empty/Create the lists.

Some times the raw-data list get too long, It would be necessary to dump the data, and empty the lists containing the raw data. This method does the latter.

Particle.fatten (method)

fatten(self, knw, four_d=False, required='all', ind_moves_kwarg={})

Fatten in all the required dimensions.

Finding the neighboring center grid points in all 4 dimensions.

Parameters

Particle.fillna (method)

fillna(self)

Fill the np.nan values to nan.

This is just to let those in rock stay in rock.

Particle.from_bool_array (method)

from_bool_array(self, t=None, data=None, bool_array=None, num=None, random_seed=None)

Update/Generate new object with random points in given grid boxes.

Use the methods from the ocedata to transform from lat-lon-dep-time coords to rel-coords store the output in the Position object.

Parameters

Particle.from_latlon (method)

from_latlon(self, x=None, y=None, z=None, t=None, data=None)

Fill in the coord info using lat-lon-dep-time dims.

Use the methods from the ocedata to transform from lat-lon-dep-time coords to rel-coords store the output in the Position object.

Parameters

Particle.get_f_node_weight (method)

get_f_node_weight(self)

Find weight for the corner points interpolation.

Particle.get_px_py (method)

get_px_py(self)

Get the nearest 4 corner points of the given point.

Used for oceanparcel style horizontal interpolation.

Returns

Particle.get_u_du (method)

get_u_du(self)

Read the velocity at particle position.

Read the velocity and velocity derivatives in all three dimensions using the interpolate method with the default kernel. Read eulerian.Position.interpolate for more detail.

Particle.get_vol (method)

get_vol(self)

Read in the volume of the cell.

For particles that has transport = True, volume of the cell is needed for the integration. This method read the volume that is calculated at init.

Particle.interpolate (method)

interpolate(self, var_name, knw, vec_transform=True, prefetched=None, prefetch_prefix=None)

Do interpolation.

This is the method that does the actual interpolation/derivative. It is a combination of the following methods: _register_interpolation_input, _fatten_required_index_and_register, _transform_vector_and_register, _read_data_and_register, _mask_value_and_register, _compute_weight_and_registe,.

Parameters

Returns

Particle.note_taking (method)

note_taking(self, subset_index=None, stamp=-1)

Record raw data into list of lists.

This method is only called in save_raw = True particles. This method will note done the raw info of the particle trajectories. With those info, one could reconstruct the analytical trajectories to arbitrary position.

Parameters

Particle.subset (method)

subset(self, which)

Create a subset of the Position object.

Parameters

Returns

Particle.to_list_of_time (method)

to_list_of_time(self, normal_stops, update_stops='default', return_in_between=True, dump_filename=False, store_kwarg={})

Integrate the particles to a list of time.

Parameters

Returns

Particle.to_next_stop (method)

to_next_stop(self, t_stop)

Integrate all particles towards time tl.

This is done by repeatedly calling analytical step. Or at least try to do so before maximum_iteration is reached. If the maximum time is reached, we also force all particle’s internal clock to be tl.

Parameters

Particle.trim (method)

trim(self, tol=0.0)

Move the particles from outside the cell into the cell.

At the same time change the velocity accordingly. In the mean time, creating some negiligible error in time.

Parameters

Particle.update_from_subset (method)

update_from_subset(self, sub, which)

Update from the original one from a subset of the Position object.

Parameters

Particle.update_uvw_array (method)

update_uvw_array(self)

Update the prefetched velocity arrays.

The way to do it is slightly different for dataset with time dimensions and those without.