Grid

class py_eddy_tracker.dataset.grid.GridDataset(filename, x_name, y_name, centered=None, indexs=None, unset=False)[source]

Bases: object

Class to have basic tool on NetCDF Grid

Parameters:
  • filename (str) – Filename to load
  • x_name (str) – Name of longitude coordinates
  • y_name (str) – Name of latitude coordinates
  • centered (bool,None) – Allow to know how coordinates could be used with pixel
  • indexs (dict) – A dictionary which set indexs to use for non-coordinate dimensions
  • unset (bool) – Set to True to create an empty grid object without file
EARTH_RADIUS = 6370997.0
GRAVITY = 9.807
N = 1
bounds

Give bound

centered
contours
coordinates
copy(grid_in, grid_out)[source]

Duplicate a variable

Parameters:
  • grid_in
  • grid_out
dimensions
eddy_identification(grid_height, uname, vname, date, step=0.005, shape_error=55, sampling=50, pixel_limit=None, precision=None, force_height_unit=None, force_speed_unit=None)[source]

Compute eddy identification on specified grid

Parameters:
  • grid_height (str) – Grid name of height
  • uname (str) – Grid name of u speed component
  • vname (str) – Grid name of v speed component
  • date (datetime.datetime) – Date which will be store in object to date data
  • step (float,int) – Height between two layers in m
  • shape_error (float,int) – Maximal error allow for outter contour in %
  • sampling (int) – Sampling of contour and speed profile
  • pixel_limit ((int,int),None) – Min and max of pixel which must be inside inner and outer contour to be considered like an eddy
  • precision (float,None) – Truncate value at the defined precision in m
  • force_height_unit (str) – Unit to used for height unit
  • force_speed_unit (str) – Unit to used for speed unit
Returns:

Return a list of 2 elements: Anticyclone and Cyclone

Return type:

py_eddy_tracker.observations.observation.EddiesObservations

filename
static get_amplitude(contour, contour_height, data, anticyclonic_search=True, level=None, step=None)[source]
get_uavg(all_contours, centlon_e, centlat_e, original_contour, anticyclonic_search, level_start, pixel_min=3)[source]

Calculate geostrophic speed around successive contours Returns the average

global_attrs
grid(varname, indexs=None)[source]

give grid required

grid_tiles(varname, slice_x, slice_y)[source]

give grid tiles required, without buffer system

high_filter(grid_name, w_cut, **kwargs)[source]

create a high filter with a low one

indexs
interpolators
is_centered

Give information if pixel is describe with center position or a corner

is_circular()[source]

Check grid circularity

load()[source]

Load variable (data)

load_general_features()[source]

Load attrs

low_filter(grid_name, w_cut, **kwargs)[source]

low filtering

setup_coordinates()[source]
speed_coef
units(varname)[source]
variables_description
vars
write(filename)[source]

Write dataset output with same format like input

x_bounds
x_c
x_dim
xinterp
y_bounds
y_c
y_dim
yinterp
class py_eddy_tracker.dataset.grid.RegularGridDataset(*args, **kwargs)[source]

Bases: py_eddy_tracker.dataset.grid.GridDataset

Class only for regular grid

add_uv(grid_height, uname='u', vname='v', stencil_halfwidth=4)[source]

Compute a u and v grid

add_uv_lagerloef(grid_height, uname='u', vname='v', schema=15)[source]
bbox_indice(vertices)[source]
bessel_band_filter(grid_name, wave_length_inf, wave_length_sup, **kwargs)[source]
bessel_high_filter(grid_name, wave_length, order=1, lat_max=85, **kwargs)[source]
bessel_low_filter(grid_name, wave_length, order=1, lat_max=85, **kwargs)[source]
static check_order(order)[source]
clean_land()[source]

Function to remove all land pixel

compute_finite_difference(data, schema=1, mode='reflect', vertical=False)[source]
compute_pixel_path(x0, y0, x1, y1)[source]

Give a series of index which describe the path between to position

compute_stencil(data, stencil_halfwidth=4, mode='reflect', vertical=False)[source]
convolve_filter_with_dynamic_kernel(grid, kernel_func, lat_max=85, extend=False, **kwargs_func)[source]
display(ax, name, factor=1, **kwargs)[source]
estimate_kernel_shape(lat, wave_length, order)[source]
finalize_kernel(kernel, order, half_x_pt, half_y_pt)[source]
get_pixels_in(contour)[source]
get_step_in_km(lat, wave_length)[source]
init_pos_interpolator()[source]

Create function to have a quick index interpolator

init_speed_coef(uname='u', vname='v')[source]

Draft

interp(grid_name, lons, lats)[source]

Compute z over lons, lats

Parameters:
  • grid_name (str) – Grid which will be interp
  • lons – new x
  • lats – new y
Returns:

new z

is_circular()[source]

Check if grid is circular

kernel_bessel(lat, wave_length, order=1)[source]

wave_length in km order must be int

kernel_lanczos(lat, wave_length, order=1)[source]

Not really operational wave_length in km order must be int

lanczos_high_filter(grid_name, wave_length, order=1, lat_max=85, **kwargs)[source]
lanczos_low_filter(grid_name, wave_length, order=1, lat_max=85, **kwargs)[source]
nearest_grd_indice(x, y)[source]
normalize_x_indice(indices)[source]
setup_coordinates()[source]
spectrum_lonlat(grid_name, area=None, ref=None, **kwargs)[source]
speed_coef_mean(contour)[source]

some nan can be compute over contour if we are near border, something to explore

classmethod with_array(coordinates, datas, variables_description=None, **kwargs)[source]
x_size
xstep

Only for regular grid with no step variation

ystep

Only for regular grid with no step variation

class py_eddy_tracker.dataset.grid.UnRegularGridDataset(filename, x_name, y_name, centered=None, indexs=None, unset=False)[source]

Bases: py_eddy_tracker.dataset.grid.GridDataset

Class which manage unregular grid

Parameters:
  • filename (str) – Filename to load
  • x_name (str) – Name of longitude coordinates
  • y_name (str) – Name of latitude coordinates
  • centered (bool,None) – Allow to know how coordinates could be used with pixel
  • indexs (dict) – A dictionary which set indexs to use for non-coordinate dimensions
  • unset (bool) – Set to True to create an empty grid object without file
bbox_indice(vertices)[source]
bounds

Give bound

compute_pixel_path(x0, y0, x1, y1)[source]
get_pixels_in(contour)[source]
index_interp
init_pos_interpolator()[source]
init_speed_coef(uname='u', vname='v')[source]
load()[source]

Load variable (data)

nearest_grd_indice(x, y)[source]
normalize_x_indice(indices)[source]

Not do

speed_coef_mean(contour)[source]
py_eddy_tracker.dataset.grid.bbox_indice_regular[source]
py_eddy_tracker.dataset.grid.bbox_slice
py_eddy_tracker.dataset.grid.compute_pixel_path[source]

Give a series of index which describe the path between to position

py_eddy_tracker.dataset.grid.filter2D(src, ddepth, kernel[, dst[, anchor[, delta[, borderType]]]]) → dst

. @brief Convolves an image with the kernel. . . The function applies an arbitrary linear filter to an image. In-place operation is supported. When . the aperture is partially outside the image, the function interpolates outlier pixel values . according to the specified border mode. . . The function does actually compute correlation, not the convolution: . . f[texttt{dst} (x,y) = sum _{ substack{0leq x’ < texttt{kernel.cols}\{0leq y’ < texttt{kernel.rows}}}} texttt{kernel} (x’,y’)* texttt{src} (x+x’- texttt{anchor.x} ,y+y’- texttt{anchor.y} )f] . . That is, the kernel is not mirrored around the anchor point. If you need a real convolution, flip . the kernel using #flip and set the new anchor to (kernel.cols - anchor.x - 1, kernel.rows - . anchor.y - 1). . . The function uses the DFT-based algorithm in case of sufficiently large kernels (~`11 x 11` or . larger) and the direct algorithm for small kernels. . . @param src input image. . @param dst output image of the same size and the same number of channels as src. . @param ddepth desired depth of the destination image, see @ref filter_depths “combinations” . @param kernel convolution kernel (or rather a correlation kernel), a single-channel floating point . matrix; if you want to apply different kernels to different channels, split the image into . separate color planes using split and process them individually. . @param anchor anchor of the kernel that indicates the relative position of a filtered point within . the kernel; the anchor should lie within the kernel; default value (-1,-1) means that the anchor . is at the kernel center. . @param delta optional value added to the filtered pixels before storing them in dst. . @param borderType pixel extrapolation method, see #BorderTypes. #BORDER_WRAP is not supported. . @sa sepFilter2D, dft, matchTemplate

py_eddy_tracker.dataset.grid.fit_circle_path(self, method='fit')[source]
py_eddy_tracker.dataset.grid.has_masked_value[source]
py_eddy_tracker.dataset.grid.has_value[source]
py_eddy_tracker.dataset.grid.lat
py_eddy_tracker.dataset.grid.lon
py_eddy_tracker.dataset.grid.mean_coordinates
py_eddy_tracker.dataset.grid.mean_on_regular_contour[source]
py_eddy_tracker.dataset.grid.nb_pixel
py_eddy_tracker.dataset.grid.pixels_in(self, grid)[source]
py_eddy_tracker.dataset.grid.pixels_index
py_eddy_tracker.dataset.grid.raw_resample(datas, fixed_size)[source]
py_eddy_tracker.dataset.grid.uniform_resample_stack[source]
py_eddy_tracker.dataset.grid.value_on_regular_contour[source]