py_eddy_tracker.dataset.grid.RegularGridDataset¶
- class py_eddy_tracker.dataset.grid.RegularGridDataset(*args, **kwargs)[source]¶
Bases:
GridDataset
Class only for regular 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 that sets indexes to use for non-coordinate dimensions
unset (bool) – Set to True to create an empty grid object without file
nan_masking (bool) – Set to True to replace data.mask with isnan method result
Methods
add_grid
Add a grid in handler
Compute a u and v grid
At each call it will update position in place with u & v field
- param str grid_name:
grid to filter, data will replace original one
c_to_bounds
Centered coordinates to bounds coordinates
clean
Function to remove all land pixel
Give a series of indexes describing the path between two positions
Apply stencil ponderation on field.
- param matplotlib.axes.Axes ax:
matplotlib axes used to draw
- param str grid:
grid name
copy
Duplicate the variable from grid_in in grid_out
- param matplotlib.axes.Axes ax:
matplotlib axes used to draw
eddy_identification
Compute eddy identification on the specified grid
Produce filament with concatenation of advection
get_amplitude
get_mask
Get indexes of pixels in contour.
get_uavg
Compute geostrophic speed around successive contours Returns the average
grid
Give the grid required
grid_tiles
Give the grid tiles required, without buffer system
high_filter
Return the high-pass filtered grid, by substracting to the initial grid the low-pass filtered grid (default: order=1)
Draft
Compute z over lons, lats
Check if the grid is circular
wave_length in km order must be int
Not really operational wave_length in km order must be int
load
Load variable (data).
load_general_features
Load attrs to be stored in object
low_filter
Return the low-pass filtered grid (default: order=1)
populate
Interpolate another grid at the current grid position
Some nan can be computed over contour if we are near borders, something to explore
units
Get unit from variable
Get U,V to be used in degrees with precomputed time step
Geo matrix data must be ordered like this (X,Y) and masked with numpy.ma.array
write
Write dataset output with same format as input
Attributes
EARTH_RADIUS
GRAVITY
N
bounds
Give bounds
centered
contours
coordinates
dimensions
filename
global_attrs
indexs
is_centered
Give True if pixel is described with its center's position or a corner
nan_mask
variables
variables_description
vars
x_bounds
x_c
x_dim
Only for regular grid with no step variation
y_bounds
y_c
y_dim
Only for regular grid with no step variation
- add_uv(grid_height, uname='u', vname='v', stencil_halfwidth=4)[source]¶
Compute a u and v grid
- Parameters:
\[ \begin{align}\begin{aligned}u = \frac{g}{f} \frac{dh}{dy}\\v = -\frac{g}{f} \frac{dh}{dx}\end{aligned}\end{align} \]where
\[ \begin{align}\begin{aligned}g = gravity\\f = 2 \Omega sin(\phi)\end{aligned}\end{align} \]Get mean of grid in each eddies
Get mean of grid in each eddiesEddy detection : MedEddy detection : Gulf streamEddy detection and filterEddy detection on SLA and ADTEddy detection : Antartic Circumpolar Current
Eddy detection : Antartic Circumpolar CurrentLAVD experimentGrid advectionCollocating external data
- advect(x, y, u_name, v_name, nb_step=10, rk4=True, **kw)[source]¶
At each call it will update position in place with u & v field
It’s a dummy advection using only one layer of current
- Parameters:
LAVD experimentGrid advectionLAVD detection and geometric detection
LAVD detection and geometric detection
- bessel_high_filter(grid_name, wave_length, order=1, lat_max=85, **kwargs)[source]¶
- Parameters:
grid_name (str) – grid to filter, data will replace original one
wave_length (float) – in km
order (int) – order to use, if > 1 negative values of the cardinal sinus are present in kernel
lat_max (float) – absolute latitude, no filtering above
kwargs (dict) – look at
RegularGridDataset.convolve_filter_with_dynamic_kernel()
Eddy detection : MedEddy detection : Gulf streamEddy detection and filterEddy detection on SLA and ADTEddy detection : Antartic Circumpolar Current
Eddy detection : Antartic Circumpolar CurrentGrid filtering in PETLAVD detection and geometric detection
LAVD detection and geometric detectionCollocating external data
- compute_pixel_path(x0, y0, x1, y1)[source]¶
Give a series of indexes describing the path between two positions
- compute_stencil(data, stencil_halfwidth=4, mode='reflect', vertical=False)[source]¶
Apply stencil ponderation on field.
- Parameters:
- Returns:
gradient array from stencil application
- Return type:
array
Short story, how to get stencil coefficient for stencil (3 points, 5 points and 7 points)
Taylor’s theorem:
\[f(x \pm h) = f(x) \pm f'(x)h + \frac{f''(x)h^2}{2!} \pm \frac{f^{(3)}(x)h^3}{3!} + \frac{f^{(4)}(x)h^4}{4!} \pm \frac{f^{(5)}(x)h^5}{5!} + O(h^6)\]If we stop at O(h^2), we get classic differenciation (stencil 3 points):
\[f(x+h) - f(x-h) = f(x) - f(x) + 2 f'(x)h + O(h^2)\]\[f'(x) = \frac{f(x+h) - f(x-h)}{2h} + O(h^2)\]If we stop at O(h^4), we will get stencil 5 points:
(1)¶\[f(x+h) - f(x-h) = 2 f'(x)h + 2 \frac{f^{(3)}(x)h^3}{3!} + O(h^4)\](2)¶\[f(x+2h) - f(x-2h) = 4 f'(x)h + 16 \frac{f^{(3)}(x)h^3}{3!} + O(h^4)\]If we multiply equation (1) by 8 and substract equation (2), we get:
\[8(f(x+h) - f(x-h)) - (f(x+2h) - f(x-2h)) = 16 f'(x)h - 4 f'(x)h + O(h^4)\]\[f'(x) = \frac{f(x-2h) - 8f(x-h) + 8f(x+h) - f(x+2h)}{12h} + O(h^4)\]If we stop at O(h^6), we will get stencil 7 points:
(3)¶\[f(x+h) - f(x-h) = 2 f'(x)h + 2 \frac{f^{(3)}(x)h^3}{3!} + 2 \frac{f^{(5)}(x)h^5}{5!} + O(h^6)\](4)¶\[f(x+2h) - f(x-2h) = 4 f'(x)h + 16 \frac{f^{(3)}(x)h^3}{3!} + 64 \frac{f^{(5)}(x)h^5}{5!} + O(h^6)\](5)¶\[f(x+3h) - f(x-3h) = 6 f'(x)h + 54 \frac{f^{(3)}(x)h^3}{3!} + 486 \frac{f^{(5)}(x)h^5}{5!} + O(h^6)\]If we multiply equation (3) by 45 and substract equation (4) multiply by 9 and add equation (5), we get:
\[45(f(x+h) - f(x-h)) - 9(f(x+2h) - f(x-2h)) + (f(x+3h) - f(x-3h)) = 90 f'(x)h - 36 f'(x)h + 6 f'(x)h + O(h^6)\]\[f'(x) = \frac{-f(x-3h) + 9f(x-2h) - 45f(x-h) + 45f(x+h) - 9f(x+2h) +f(x+3h)}{60h} + O(h^6)\]…
- contour(ax, name, factor=1, ref=None, **kwargs)[source]¶
- Parameters:
ax (matplotlib.axes.Axes) – matplotlib axes used to draw
name (str,array) – variable to display, could be an array
factor (float) – multiply grid by
ref (float,None) – if defined, all coordinates are wrapped with ref as western boundary
kwargs (dict) – look at
matplotlib.axes.Axes.contour()
- convolve_filter_with_dynamic_kernel(grid, kernel_func, lat_max=85, extend=False, **kwargs_func)[source]¶
- Parameters:
- Returns:
filtered value
- Return type:
array
- display(ax, name, factor=1, ref=None, **kwargs)[source]¶
- Parameters:
ax (matplotlib.axes.Axes) – matplotlib axes used to draw
name (str,array) – variable to display, could be an array
factor (float) – multiply grid by
ref (float,None) – if defined, all coordinates are wrapped with ref as western boundary
kwargs (dict) – look at
matplotlib.axes.Axes.pcolormesh()
Get mean of grid in each eddies
Get mean of grid in each eddiesStastics on identification files
Stastics on identification filesEddy detection : MedEddy detection : Gulf streamEddy detection and filterEddy detection on SLA and ADTEddy detection : Antartic Circumpolar Current
Eddy detection : Antartic Circumpolar CurrentSelect pixel in eddiesGrid filtering in PETLAVD experimentGet Okubo WeisFSLE experiment in medLAVD detection and geometric detection
LAVD detection and geometric detectionGeographical statisticsBirth and deathCount pixel usedCount centerCollocating external dataNetwork Analysis
- filament(x, y, u_name, v_name, nb_step=10, filament_size=6, rk4=True, **kw)[source]¶
Produce filament with concatenation of advection
It’s a dummy advection using only one layer of current
- Parameters:
- Returns:
x,y for a line
Grid advection
- kernel_lanczos(lat, wave_length, order=1)[source]¶
Not really operational wave_length in km order must be int
- regrid(other, grid_name, new_name=None)[source]¶
Interpolate another grid at the current grid position
- Parameters:
other (RegularGridDataset) –
grid_name (str) – variable name to interpolate
new_name (str) – name used to store, if None method will use current ont
Collocating external data
- speed_coef_mean(contour)[source]¶
Some nan can be computed over contour if we are near borders, something to explore
- uv_for_advection(u_name=None, v_name=None, time_step=600, h_name=None, backward=False, factor=1)[source]¶
Get U,V to be used in degrees with precomputed time step
- classmethod with_array(coordinates, datas, variables_description=None, **kwargs)[source]¶
Geo matrix data must be ordered like this (X,Y) and masked with numpy.ma.array
- x_size¶
- property xstep¶
Only for regular grid with no step variation
- property ystep¶
Only for regular grid with no step variation