API#

Ocean#

Ocean module containin algorithms specifically built to work with ocean data

class dmelon.ocean.DispersionRelation[source]#

Bases: object

Dispersion Relation

Methods

low_freq(m)

Compute the scaled wavenumber and frequency for the mode m

static low_freq(m)[source]#

Compute the scaled wavenumber and frequency for the mode m

ARGO#

ARGO module made for some specific usage in downloading data from the GDAC center using rsync and screen

dmelon.ocean.argo.build_dl(argo_df: DataFrame, ARGO_localFTP: Optional[str] = None)[source]#

Build the download command using rsync and screen

dmelon.ocean.argo.launch_shell(cmd_list)[source]#

Launch the built command from a subshell

BM95#

Python implementation of the Boulanger & Menkes 1995 paper

class dmelon.ocean.bm95.Projection(sea_level, nmodes)[source]#

Bases: object

Projection object that computes the projection vector, wave coefficient vector and decomposed sea level as calculated by J.-P.Boulanger & C.Menkes (1995).

It constructs the meridional structures when instantiated.

Attributes:
decomposed_sea_level

Decompose the sea level

meridional_structures

Return the meridional structures used for the decomposition

projection_vector

Return the computed projection vector b

wave_coefficient_vector

Return the computed wave coefficient vector r.

property decomposed_sea_level#

Decompose the sea level

property meridional_structures#

Return the meridional structures used for the decomposition

property projection_vector#

Return the computed projection vector b

property wave_coefficient_vector#

Return the computed wave coefficient vector r. This variable represents the weights of the corresponding meridional structure present in the original sea level signal

dmelon.ocean.bm95.hermite_function(n, x)[source]#

Evaluates the hermite function of order n at a point x

dmelon.ocean.bm95.meridional_structures(n, lats)[source]#

Compute the meridional structures using the formulas in BM95

Parameters:
  • n (array_like) – Meridional modes. This is passed down as the order of the underlying Hermite Functions

  • lats (array_like) – Array of latitudes

dmelon.ocean.bm95.scale_lats(lats, c=2.5, return_scales=False)[source]#

Nondimensionalize latitutes using the following scales:

\[L = (c/eta)^{(1/2)} \ T = 1/(eta c)^{(1/2)}\]

Spectral#

Module containing spectral methods

Filters#

Lanczos filter port from MATLAB

dmelon.spectral.filters.lanczos_filter_coef(Cf, M)[source]#

Compute the filter coefficients

dmelon.spectral.filters.lanczosfilter(X, Cf, dT=1, M=100, kind='low', *args)[source]#

Core function that filters the signal in either low or high pass

dmelon.spectral.filters.lowpass_cosine_filter_coef(Cf, M)[source]#

Compute the lowpass coeficients using the cut frequency Cf

dmelon.spectral.filters.spectral_filtering(x, window)[source]#

Spectral filtering of series x with the specified windows

dmelon.spectral.filters.spectral_window(coef, N)[source]#

Get the spectral window from a series of coefficients

Power#

Module that contains algorithms mostly using the power spectra

dmelon.spectral.power.compute_power(xdata, Nx, Nt, xres, tres, window, noverlap, psmooth=True)[source]#

Filter the power spectra in the wavenumber-frequency space

dmelon.spectral.power.get_dispersion(data, Nx, Nt, xres, tres, window=None, nfft=None, **stft_kwargs)[source]#

Get the dispersion graph of series of maps

Wavelet#

Submodule containing wavelet methods

dmelon.spectral.wavelet.wavelet(Y: array, dt: float, pad: bool = False, dj: float = 0.25, s0: Optional[float] = None, J1: Optional[float] = None, mother: str = 'MORLET', param=-1, freq=None)[source]#

Wavelet transform of a time series

dmelon.spectral.wavelet.wt(x: DataArray, dt=1, pad=True, dj=0.08333333333333333, s0=None, mother='MORLET', AR1='auto', plot=True)[source]#

Wavelet transform of a time series

Statistics#

Statistics module

dmelon.statistics.edof(N, window, overlap)[source]#

Function to compute the effective degrees of freedom

Plotting#

Plotting module that contains most boilerplate code I use for my plots

dmelon.plotting.format_latlon(ax, proj, latlon_bnds=(-180, 180, -90, 90), lon_step=20, lat_step=10, nformat='g')[source]#

Format geoaxes nicely

Utils#

Helper functions that fit into a more general category

dmelon.utils.check_folder(base_path: str, name: Optional[str] = None) None[source]#

Create a folder if it does not exists

dmelon.utils.findPointsInPolys(pandas_df: DataFrame, shape_df: GeoDataFrame, crs: str = 'EPSG:4326') GeoDataFrame[source]#

Filter DataFrame by their spatial location within a GeoDataFrame

dmelon.utils.load_json(path: str) dict[source]#

Load the contents of a json file into a python dictionary

dmelon.utils.replace_x_y_nominal_lat_lon(ds)[source]#

Approximate the dimensional values of x and y with mean lat and lon at the equator