API#

Top-level API#

read_csv(f, **kwargs)

Construct a CF-compliant trajectory dataset from a CSV file.

from_dataframe(df[, lon, lat, time, name, ...])

Construct a CF-compliant trajectory dataset from a pd.DataFrame of positions.

trajectory_dict_to_dataset(trajectory_dict)

Create a CF-compatible trajectory file from dictionary of drifter positions

Dataset#

Attributes#

Dataset.traj.plot

See trajan.plot.Plot.

Dataset.traj.animate

See trajan.animation.Animation.

Dataset.traj.tx

Trajectory x coordinates (usually longitude).

Dataset.traj.ty

Trajectory y coordinates (usually latitude).

Dataset.traj.tlon

Retrieve the trajectories in geographic coordinates (longitudes).

Dataset.traj.tlat

Retrieve the trajectories in geographic coordinates (latitudes).

Dataset.traj.crs

Retrieve the pyproj.crs.CRS object from the CF-defined grid-mapping in the dataset.

Methods#

Dataset.traj.transform(to_crs)

Transform this datasets to to_crs coordinate system.

Dataset.traj.transformer(from_crs)

Create a transformer useful for transforming other coordinates to the CRS of this dataset.

Dataset.traj.set_crs(crs)

Returns a new dataset with the CF-supported grid-mapping / projection set to crs.

Dataset.traj.assign_cf_attrs([creator_name, ...])

Return a new dataset with CF-standard and common attributes set.

Dataset.traj.index_of_last()

Find index of last valid position along each trajectory.

Dataset.traj.speed()

Returns the speed [m/s] along trajectories.

Dataset.traj.time_to_next()

Returns the timedelta between time steps.

Dataset.traj.distance_to(other)

Distance between trajectories or a single point.

Dataset.traj.distance_to_next()

Returns distance in meters from one position to the next along trajectories.

Dataset.traj.azimuth_to_next()

Returns azimution travel direction in degrees from one position to the next.

Dataset.traj.length()

Returns distance in meters of each trajectory.

Dataset.traj.skill(other[, method])

Compare the skill score between this trajectory and other.

Dataset.traj.velocity_components()

Returns velocity components [m/s] from one position to the next.

Dataset.traj.velocity_spectrum()

Dataset.traj.convex_hull()

Return the scipy convex hull for all particles, in geographical coordinates.

Dataset.traj.convex_hull_contains_point(lon, lat)

Return True if given point is within the scipy convex hull for all particles.

Dataset.traj.get_area_convex_hull()

Return the area [m2] of the convex hull spanned by all positions.

Dataset.traj.gridtime(times[, time_varname])

Interpolate dataset to a regular time interval or a different grid.

Dataset.traj.sel(*args, **kwargs)

Select on each trajectory.

Dataset.traj.seltime([t0, t1])

Select observations in time window between t0 and t1 (inclusive).

Dataset.traj.iseltime(i)

Select observations by index (of non-nan, time, observation) across trajectories.

Dataset.traj.crop([lonmin, lonmax, latmin, ...])

Remove parts of trajectories outside of given geographical bounds.

Dataset.traj.contained_in([lonmin, lonmax, ...])

Return only trajectories fully within given geographical bounds.

Dataset.traj.is_1d()

Returns True if dataset is 1D, i.e. time is a 1D coordinate variable.

Dataset.traj.is_2d()

Returns True if dataset is 2D, i.e. time is a 2D variable and not a coordinate variable.

Dataset.traj.to_1d()

Convert dataset into a 1D dataset from.

Dataset.traj.to_2d([obs_dim])

Convert dataset into a 2D dataset from.

Dataset.traj.condense_obs()

Move all observations to the first index, so that the observation dimension is reduced to a minimum.

Plotting#