py_eddy_tracker.observations.tracking.TrackEddiesObservations

class py_eddy_tracker.observations.tracking.TrackEddiesObservations(*args, **kwargs)[source]

Bases: GroupEddiesObservations

Class to practice Tracking on observations

Methods

add_distance

Add a field of distance (m) between two consecutive observations, 0 for the last observation of each track

add_fields

Add a new field.

add_rotation_type

align_on

Align the variable indices of two datasets.

append

Merge.

basic_formula_ellipse_major_axis

Give major axis in km with a given latitude

bins_stat

param str,array xname:

variable to compute stats on

box_display

Return values evenly spaced with few numbers

build_var_list

circle_contour

Set contours as circles from radius and center data.

close_tracks

Get close trajectories from another atlas.

coherence

Check coherence between two datasets.

compare_units

compute_index

If obs are not sorted by track, __first_index_of_track will be unusable

concatenate

contains

Return index of contour containing (x,y)

copy

copy_data_to_zarr

Copy with buffer for zarr.

cost_function

Return the cost function between two obs.

cost_function_common_area

How does it work on x bound ?

count_by_track

Count by track

create_particles

Create particles inside contour (Default : speed contour).

create_variable

create_variable_zarr

display

Plot the speed and effective (dashed) contour of the eddies

display_color

Plot colored contour of eddies

display_shape

This function draws the shape of each trajectory

distance

Use haversine distance for distance matrix between every self and other eddies.

distance_to_next

return:

array of distance in m, 0 when next obs is from another track

empty_dataset

extract_first_obs_in_box

extract_ids

extract_in_direction

extract_longer_eddies

Select the trajectories longer than nb_min

extract_toward_direction

Get trajectories going in the same direction

extract_with_area

Extract geographically with a bounding box.

extract_with_length

Return the observations within trajectories lasting between [b0:b1]

extract_with_mask

Extract a subset of observations

extract_with_period

Extract within a time period

field_table

Produce description table of the fields available in this object

fill_coherence

_summary_

filled

param matplotlib.axes.Axes ax:

matplotlib axe used to draw

filled_by_interpolation

Fill selected values by interpolation

first_obs

Get first obs of each trajectory.

fix_next_previous_obs

Function used after 'insert_virtual', to correct next_obs and previous obs.

fixed_ellipsoid_mask

follow_obs

Associate the observations to the segments

format_label

from_array

from_netcdf

from_zarr

get_azimuth

Return azimuth for each track.

get_color

Return colors as a cyclic list

get_filters_zarr

Get filters to store in zarr for known variable

get_infos

get_mask_from_id

get_missing_indices

Find indices where observations are missing.

get_next_obs

Forward association of observations to the segments

get_previous_obs

Backward association of observations to the segments

grid_box_stat

Get percentile of eddies in each bin

grid_count

Count the eddies in each bin (use all pixels in each contour)

grid_stat

Return the mean of the eddies' variable in each bin

hist

Build histograms.

index

Return obs from self at the index.

insert_observations

Insert other obs in self at the given index.

insert_virtual

Insert virtual observations on segments where observations are missing

inside

True for each point inside the effective contour of an eddy

intern

interp_grid

Interpolate a grid on a center or contour with mean, min or max method

is_convex

Get flag of the eddy's convexity

iter_on

Yield observation group for each bin.

iter_track

Yield track

keep_tracks_by_date

Find tracks that exist at date date and lasted at least nb_days after.

last_obs

Get Last obs of each trajectory.

load_file

Load the netcdf or the zarr file.

load_from_netcdf

Load data from netcdf.

load_from_zarr

Load data from zarr.

loess_filter

mask_from_polygons

Return mask for all observations in one of polygons list

mask_function

match

Return index and score computed on the effective contour.

median_filter

merge

Merge two datasets.

merge_filters

Compute an intersection between all filters after to evaluate each of them

merge_particle_result

Copy local result in merged result with global indexation

needed_variable

netcdf_create_dimensions

new_like

normalize_longitude

Normalize all longitudes

obs_dimension

parse_varname

particle_candidate_atlas

Select particles within eddies, advect them, return target observation and associated percentages

plot

This function will draw path of each trajectory

position_filter

post_process_link

propagate

Fill virtual obs (C).

re_reference_index

Shift index with ref

remove_fields

Copy with fields listed remove

reset

scatter

Scatter data.

set_global_attr_netcdf

Set global attributes

set_global_attr_zarr

set_tracks

Split one group (network) in segments

shape_polygon

Get the polygon enclosing each trajectory.

shifted_ellipsoid_degrees_mask

solve_conflict

solve_first

solve_function

solve_simultaneous

Deduce link from cost matrix.

split_network

Return each group (network) divided in segments

time_sub_sample

Time sub sampling

to_netcdf

to_zarr

track_slice

tracking

Track obs between self and other

write_file

Write a netcdf or zarr with eddy obs.

zarr_dimension

Attributes

COLORS

ELEMENTS

NB_COLORS

NOGROUP

age

Return age in % for each observation, will be [0:100]

array_variables

dtype

Return dtype to build numpy array.

elements

Return all the names of the variables.

fields

global_attr

index_from_track

lifetime

Return lifetime for each observation

nb_days

Return period in days covered by the dataset

nb_obs_by_track

nb_tracks

Count and return number of track

obs

Return observations.

observations

only_variables

period

Give the time coverage.

period_

raw_data

shape

sign_legend

sign_type

time_datetime64

track_array_variables

track_extra_variables

tracks

ELEMENTS = ['lon', 'lat', 'radius_s', 'radius_e', 'speed_area', 'effective_area', 'amplitude', 'speed_average', 'time', 'shape_error_e', 'shape_error_s', 'nb_contour_selected', 'num_point_e', 'num_point_s', 'height_max_speed_contour', 'height_external_contour', 'height_inner_contour', 'cost_association']
NOGROUP = 0
add_distance()[source]

Add a field of distance (m) between two consecutive observations, 0 for the last observation of each track

property age

Return age in % for each observation, will be [0:100]

close_tracks(other, nb_obs_min=10, **kwargs)[source]

Get close trajectories from another atlas.

Parameters:
  • other (self) – Atlas to compare

  • nb_obs_min (int) – Minimal number of overlap for one trajectory

  • kwargs (dict) – keyword arguments for match function

Returns:

return other atlas reduced to common trajectories with self

Warning

It could be a costly operation for huge dataset

compute_index()[source]

If obs are not sorted by track, __first_index_of_track will be unusable

classmethod concatenate(observations)[source]
count_by_track(mask)[source]

Count by track

Parameters:

mask (array[bool]) – Mask of boolean count +1 if true

Returns:

Return count by track

Return type:

array

display_shape(ax, ref=None, intern=False, **kwargs)[source]

This function draws the shape of each trajectory

Parameters:
  • ax (matplotlib.axes.Axes) – ax to draw

  • ref (float,int) – if defined, all coordinates are wrapped with ref as western boundary

  • intern (bool) – If True use speed contour instead of effective contour

  • kwargs (dict) – keyword arguments for Axes.plot

Returns:

matplotlib mappable

distance_to_next()[source]
Returns:

array of distance in m, 0 when next obs is from another track

Return type:

array

property elements

Return all the names of the variables.

extract_first_obs_in_box(res)[source]
extract_ids(tracks)[source]
extract_in_direction(direction, value=0)[source]
extract_longer_eddies(nb_min, nb_obs, compress_id=True)[source]

Select the trajectories longer than nb_min

extract_toward_direction(west=True, delta_lon=None)[source]

Get trajectories going in the same direction

Parameters:
  • west (bool) – Only eastward eddies if True return westward

  • delta_lon (None,float) – Only eddies with more than delta_lon span in longitude

Returns:

Only eastern eddy

Return type:

__class__

extract_with_length(bounds)[source]

Return the observations within trajectories lasting between [b0:b1]

Parameters:

bounds ((int,int)) – length min and max of the desired trajectories, if -1 this bound is not used

Returns:

Return all trajectories having length between bounds

Return type:

TrackEddiesObservations

Display fields

Display fields

Display Tracks

Display Tracks
extract_with_mask(mask, full_path=False, remove_incomplete=False, compress_id=False, reject_virtual=False)[source]

Extract a subset of observations

Parameters:
  • mask (array(bool)) – mask to select observations

  • full_path (bool) – extract the full trajectory if only one part is selected

  • remove_incomplete (bool) – delete trajectory if not fully selected

  • compress_id (bool) – resample trajectory number to use a smaller range

  • reject_virtual (bool) – if only virtuals are selected, the trajectory is removed

Returns:

same object with the selected observations

Return type:

self.__class__

extract_with_period(period, **kwargs)[source]

Extract within a time period

Parameters:
Returns:

Return all eddy tracks in period

Return type:

TrackEddiesObservations

fix_next_previous_obs()[source]

Function used after ‘insert_virtual’, to correct next_obs and previous obs.

classmethod follow_obs(i_next, track_id, used, ids, *args, **kwargs)[source]

Associate the observations to the segments

format_label(label)[source]
get_azimuth(equatorward=False)[source]

Return azimuth for each track.

Azimuth is computed with first and last observations

Parameters:

equatorward (bool) – If True, Poleward is positive and Equatorward negative

Return type:

array

get_mask_from_id(tracks)[source]
get_missing_indices(dt)[source]

Find indices where observations are missing.

Parameters:

dt (int,float) – theorical delta time between 2 observations

static get_next_obs(i_current, ids, x, y, time_s, time_e, time_ref, window, min_overlap=0.2, **kwargs)[source]

Forward association of observations to the segments

static get_previous_obs(i_current, ids, x, y, time_s, time_e, time_ref, window, min_overlap=0.2, **kwargs)[source]

Backward association of observations to the segments

property index_from_track
iter_track()[source]

Yield track

property lifetime

Return lifetime for each observation

loess_filter(half_window, xfield, yfield, inplace=True)[source]
median_filter(half_window, xfield, yfield, inplace=True)[source]
property nb_obs_by_track
property nb_tracks

Count and return number of track

normalize_longitude()[source]

Normalize all longitudes

Normalize longitude field and in the same range : - longitude_max - contour_lon_e (how to do if in raw) - contour_lon_s (how to do if in raw)

plot(ax, ref=None, **kwargs)[source]

This function will draw path of each trajectory

Parameters:
  • ax (matplotlib.axes.Axes) – ax to draw

  • ref (float,int) – if defined, all coordinates are wrapped with ref as western boundary

  • kwargs (dict) – keyword arguments for Axes.plot

Returns:

matplotlib mappable

position_filter(median_half_window, loess_half_window)[source]
set_global_attr_netcdf(h_nc)[source]

Set global attributes

set_tracks(x, y, ids, window, **kwargs)[source]

Split one group (network) in segments

Parameters:
  • x (array) – coordinates of group

  • y (array) – coordinates of group

  • ids (ndarray) – several fields like time, group, …

  • window (int) – number of days where observations could missed

shape_polygon(intern=False)[source]

Get the polygon enclosing each trajectory.

The polygon merges the non-overlapping bounds of the specified contours

Parameters:

intern (bool) – If True use speed contour instead of effective contour

Return type:

list(array, array)

split_network(intern=True, **kwargs)[source]

Return each group (network) divided in segments

track_slice(track)[source]