py_eddy_tracker.observations.network.NetworkObservations

class py_eddy_tracker.observations.network.NetworkObservations(*args, **kwargs)[source]

Bases: py_eddy_tracker.observations.groups.GroupEddiesObservations

Methods

add_fields

Add a new field.

add_rotation_type

align_on

Align the time indexes of two datasets.

append

Merge.

astype

basic_formula_ellips_major_axis

Give major axis in km with a given latitude

bins_stat

param str,array xname

variable to compute stats on

birth_event

box_display

Return value evenly spaced with few numbers

build_var_list

circle_contour

Set contours as a circles from radius and center data.

close_network

Get close network from another atlas.

coherence

Check coherence between two datasets.

compare_units

concatenate

connexions

create dictionnary for each segments, gives the segments which interact with

contains

Return index of contour which contain (x,y)

copy

copy_data_to_zarr

Copy with buffer for zarr.

correct_close_events

transform event where segment A split to B, then A merge into B

cost_function

Return the cost function between two obs.

cost_function_common_area

How does it work on x bound ?

create_variable

create_variable_zarr

death_event

display

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

display_timeline

Plot a timeline of a network.

dissociate_network

Dissociate network with no known interaction (spliting/merging)

distance

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

event_map

Add the merging and splitting events

event_timeline

mark events in plot

extract_event

extract_segment

extract_with_area

Extract geographically with a bounding box.

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

filled

param matplotlib.axes.Axes ax

matplotlib axe used to draw

filled_by_interpolation

Filled selected values by interpolation

find_link

find all observations where obs i_observation could be in future or past.

find_segments_relative

find all relative segments within an event from an order.

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

format_label

from_netcdf

from_split_network

Build a NetworkObservations object with Group dataset and indexes

from_zarr

fully_connected

get_color

Return colors like a cyclic list

get_infos

get_missing_indices

find indices where observations is missing.

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.

infos

insert_observations

Insert other obs in self at the index.

insert_virtual

insert virtual observation on segments where observations were not found

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.

keep_tracks_by_date

Find tracks which 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

longer_than

Select network on time duration

map_network

transform data y with method method for each track.

map_segment

mask_from_polygons

Return mask for all observation in one of polygons list

mask_function

match

Return index and score computed on the effective contour.

mean_by_segment

median_filter

merge

Merge two datasets.

merge_filters

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

merging_event

Return observation after a merging event.

needed_variable

netcdf_create_dimensions

network

network_slice

Return slice for one network

networks

new_like

normalize_longitude

Normalize all longitude

numbering_network

New numbering of network

numbering_segment

New numbering of segment

obs_dimension

obs_relative_order

only_one_network

Raise a warning or error? if there are more than one network

parse_varname

plot

This function will draw path of each trajectory

position_filter

post_process_link

propagate

Filled virtual obs (C).

re_reference_index

Shift index with ref

relative

Extract the segments at a certain order from one observation.

relatives

Extract the segments at a certain order from multiple observations.

remove_dead_end

Remove short segment which didn’t connect several segment

remove_fields

Copy with fields listed remove

remove_trash

reset

scatter

This function will scatter the path of each network, with the merging and splitting events

scatter_timeline

Must be call on only one network

segment_relative_order

Compute the relative order of each segment to the chosen segment

set_global_attr_netcdf

set_global_attr_zarr

shifted_ellipsoid_degrees_mask

solve_conflict

solve_first

solve_function

solve_simultaneous

Write something (TODO)

sort

sort observations

spliting_event

Return observation before a splitting event.

tag_segment

time_sub_sample

Time sub sampling

to_netcdf

to_zarr

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

array_variables

dtype

Return dtype to build numpy array.

elements

Return all the names of the variables.

global_attr

index_network

nb_days

Return period days cover by dataset

obs

Return observations.

observations

only_variables

period

Give the time coverage.

period_

raw_data

segment_track_array

Return a unique segment id when multiple networks are considered

shape

sign_legend

sign_type

track_array_variables

track_extra_variables

tracks

NOGROUP = 0
astype(cls)[source]
birth_event()[source]
close_network(other, nb_obs_min=10, **kwargs)[source]

Get close network 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 reduce to common track with self

Warning

It could be a costly operation for huge dataset

connexions(multi_network=False)[source]

create dictionnary for each segments, gives the segments which interact with

correct_close_events(nb_days_max=20)[source]

transform event where segment A split to B, then A merge into B

to

segment A split to B, then B merge to A

these events are filtered with nb_days_max, which the event have to take place in less than nb_days_max

Parameters

nb_days_max (float) – maximum time to search for splitting-merging event

death_event()[source]
display_timeline(ax, event=True, field=None, method=None, factor=1, colors_mode='roll', **kwargs)[source]

Plot a timeline of a network. Must be called on only one network.

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

  • event (bool) – if True, draw the splitting and merging events

  • field (str,array) – yaxis values, if None, segments are used

  • method (str) – if None, mean values are used

  • factor (float) – to multiply field

  • colors_mode (str) – color of lines. “roll” means looping through colors, “y” means color adapt the y values (for matching color plots)

Returns

plot mappable

dissociate_network()[source]

Dissociate network with no known interaction (spliting/merging)

property elements

Return all the names of the variables.

event_map(ax, **kwargs)[source]

Add the merging and splitting events

event_timeline(ax, field=None, method=None, factor=1, colors_mode='roll')[source]

mark events in plot

extract_event(indices)[source]
extract_segment(segments, absolute=False)[source]
extract_with_mask(mask)[source]

Extract a subset of observations.

Parameters

mask (array(bool)) – mask to select observations

Returns

same object with selected observations

Return type

self

extract_with_period(period)[source]

Extract within a time period

Parameters

period ((int,int)) – two dates to define the period, must be specify from 1/1/1950

Returns

Return all eddy tracks which are in bounds

Return type

NetworkObservations

find all observations where obs i_observation could be in future or past.

if forward=True, search all observation where water from obs “i_observation” could go

if backward=True, search all observation where water from obs i_observation could come from

Parameters
  • i_observation (int,iterable(int)) – indices of observation. Can be int, or iterable of int.

  • forward, backward (bool) – if forward, search observations after obs. else mode==backward search before obs

find_segments_relative(obs, stopped=None, order=1)[source]

find all relative segments within an event from an order.

Parameters
  • obs (int) – indice of event after the event

  • stopped (int) – indice of event before the event

  • order (int) – order of relatives accepted

Returns

all segments relatives

Return type

EddiesObservations

fix_next_previous_obs()[source]

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

classmethod from_split_network(group_dataset, indexs, **kwargs)[source]

Build a NetworkObservations object with Group dataset and indexes

Parameters

return NetworkObservations

fully_connected()[source]
get_missing_indices(dt)[source]

find indices where observations is missing.

As network have all untrack observation in tracknumber self.NOGROUP,

we don’t compute them

Parameters

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

property index_network
infos(label='')[source]
loess_filter(half_window, xfield, yfield, inplace=True)[source]
longer_than(nb_day_min=- 1, nb_day_max=- 1)[source]

Select network on time duration

Parameters
  • nb_day_min (int) – Minimal number of day covered by one network, if negative -> not used

  • nb_day_max (int) – Maximal number of day covered by one network, if negative -> not used

map_network(method, y, same=True, return_dict=False, **kw)[source]

transform data y with method method for each track.

Parameters
  • method (Callable) – method to apply on each tracks

  • y (np.array) – data where to apply method

  • same (bool) – if True, return array same size from y. else, return list with track edited

  • return_dict (bool) – if None, mean values are used

  • kw (float) – to multiply field

Returns

array or dict of result from method for each network

map_segment(method, y, same=True, **kw)[source]
mean_by_segment(y, **kw)[source]
median_filter(half_window, xfield, yfield, inplace=True)[source]
merging_event(triplet=False, only_index=False)[source]

Return observation after a merging event.

If triplet=True return the eddy after a merging event, the eddy before the merging event, and the eddy stopped due to merging.

network(id_network)[source]
network_slice(id_network)[source]

Return slice for one network

Parameters

id_network (int) – id to identify network

networks(id_networks)[source]
normalize_longitude()[source]

Normalize all longitude

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)

numbering_network(start=1)[source]

New numbering of network

numbering_segment(start=0)[source]

New numbering of segment

obs_relative_order(i_obs)[source]
only_one_network()[source]

Raise a warning or error? if there are more than one network

plot(ax, ref=None, color_cycle=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 will be wrapped with ref like west boundary

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

Returns

a list of matplotlib mappables

position_filter(median_half_window, loess_half_window)[source]
relative(i_obs, order=2, direct=True, only_past=False, only_future=False)[source]

Extract the segments at a certain order from one observation.

Parameters
  • obs (list) – indice of observation for relative computation

  • order (int) – order of relatives wanted. 0 means only observations in obs, 1 means direct relatives, …

Returns

all segments relatives

Return type

EddiesObservations

relatives(obs, order=2, direct=True, only_past=False, only_future=False)[source]

Extract the segments at a certain order from multiple observations.

Parameters
  • obs (list) – indices of observation for relatives computation

  • order (int) – order of relatives wanted. 0 means only observations in obs, 1 means direct relatives, …

Returns

all segments relatives

Return type

EddiesObservations

remove_dead_end(nobs=3, ndays=0, recursive=0, mask=None)[source]

Remove short segment which didn’t connect several segment

Parameters
  • nobs (int) – Minimal number of observation to keep segment

  • ndays (int) – Minimal number of days to keep segment

  • recursive (int) – Run method N times more

  • mask (int) – if one or more observation of segment are select by mask, the segment is keep

Warning

It will remove short segment which splits than merges with same segment

remove_trash()[source]
scatter(ax, name='time', factor=1, ref=None, edgecolor_cycle=None, **kwargs)[source]

This function will scatter the path of each network, with the merging and splitting events

Parameters
Returns

a dict of scattered mappables

scatter_timeline(ax, name, factor=1, event=True, yfield=None, yfactor=1, method=None, **kwargs)[source]

Must be call on only one network

segment_relative_order(seg_origine)[source]

Compute the relative order of each segment to the chosen segment

property segment_track_array

Return a unique segment id when multiple networks are considered

sort(order=('track', 'segment', 'time'))[source]

sort observations

Parameters

order (tuple) – order or sorting. Passed to np.argsort

spliting_event(triplet=False, only_index=False)[source]

Return observation before a splitting event.

If triplet=True return the eddy before a splitting event, the eddy after the splitting event, and the eddy starting due to splitting.

tag_segment(multi_network=False)[source]