py_eddy_tracker.dataset.grid.RegularGridDataset¶
-
class
py_eddy_tracker.dataset.grid.RegularGridDataset(*args, **kwargs)[source]¶ Bases:
py_eddy_tracker.dataset.grid.GridDatasetClass 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 which set indexs to use for non-coordinate dimensions
unset (bool) – Set to True to create an empty grid object without file
Methods
add_gridAdd a grid in handler
Compute a u and v grid
- param str grid_name
grid to filter, data will replace original one
c_to_boundsCentred coordinates to bounds coordinates
Function to remove all land pixel
Give a series of indexes which describe the path between to position
Apply stencil ponderation on field.
- param matplotlib.axes.Axes ax
matplotlib axes use to draw
- param str grid
grid name
copyDuplicate the variable from grid_in in grid_out
- param matplotlib.axes.Axes ax
matplotlib axes use to draw
eddy_identificationCompute eddy identification on the pecified grid
get_amplitudeGet indices of pixels in contour.
get_uavgCalculate geostrophic speed around successive contours Returns the average
gridGive the grid required
grid_tilesGive the grid tiles required, without buffer system
high_filterReturn the grid high-pass filtered, by substracting to the grid the low-pass filter (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
loadLoad variable (data).
load_general_featuresLoad attrs to be stored in object
low_filterReturn the grid low-pass filtered (default: order=1)
Interpolate another grid at the current grid position
Some nan can be computed over contour if we are near border, something to explore
unitsGet unit from variable
Geo matrix data must be ordered like this (X,Y) and masked with numpy.ma.array
writeWrite dataset output with same format as input
Attributes
EARTH_RADIUSGRAVITYNboundsGive bounds
centeredcontourscoordinatesdimensionsfilenameglobal_attrsindexsinterpolatorsis_centeredGive True if pixel is described with its center’s position or a corner
speed_coefvariablesvariables_descriptionvarsx_boundsx_cx_dimOnly for regular grid with no step variation
y_boundsy_cy_dimOnly for regular grid with no step variation
-
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 above no filtering apply
kwargs (dict) – look at
RegularGridDataset.convolve_filter_with_dynamic_kernel()
-
compute_pixel_path(x0, y0, x1, y1)[source]¶ Give a series of indexes which describe the path between to position
-
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 use to draw
name (str,array) – variable to display, could be an array
factor (float) – multiply grid by
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 use to draw
name (str,array) – variable to display, could be an array
factor (float) – multiply grid by
kwargs (dict) – look at
matplotlib.axes.Axes.pcolormesh()
-
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
-
speed_coef_mean(contour)[source]¶ Some nan can be computed over contour if we are near border, something to explore
-
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