mod_interp module

class mod_interp.TimeSeries(ds)

Bases: object

Manage a time series composed of a grid stack.

Parameters:

ds (xarray.Dataset) – Input dataset containing the time series data.

ds

Input dataset containing the time series data.

Type:

xarray.Dataset

series

Time series data loaded from the dataset.

Type:

pandas.Series

dt

Time step duration between consecutive data points in the series.

Type:

datetime.timedelta

_is_sorted(array)

Check if an array is sorted.

_load_ts()

Load the time series data into memory.

_load_dataset(self, varname, start, end)

Loading the time series into memory for the defined period.

mod_interp.interp2d(ds, name_vars, lon_out, lat_out)

Interpolate 2D data on a new grid defined by lon_out and lat_out.

Parameters:
  • ds (xarray.Dataset) – Dataset containing the data to be interpolated.

  • name_vars (dict) – A dictionary specifying the variable names and dimension names. Example: {‘lon’: ‘longitude’, ‘lat’: ‘latitude’, ‘var’: ‘data_variable’}

  • lon_out (numpy.ndarray) – 2D array of longitudes for the output grid.

  • lat_out (numpy.ndarray) – 2D array of latitudes for the output grid.

Returns:

var_out – 2D array of the interpolated data on the new grid.

Return type:

numpy.ndarray

mod_interp.interpolate(df, time_series, start, end, var='sla')

Interpolate the time series over the defined period.

Parameters:
  • df (pandas.DataFrame) – Input DataFrame containing time series data.

  • time_series (TimeSeries) – Time series data and properties.

  • start (pandas.Timestamp) – Start timestamp of the interpolation period.

  • end (pandas.Timestamp) – End timestamp of the interpolation period.

mod_interp.interpolate_current(df, time_series, start, end)

Interpolate the current time series over the defined period.

Parameters:
  • df (pandas.DataFrame) – Input DataFrame containing time series data.

  • time_series (TimeSeries) – Time series data and properties.

  • start (pandas.Timestamp) – Start timestamp of the interpolation period.

  • end (pandas.Timestamp) – End timestamp of the interpolation period.

mod_interp.periods(df, time_series, var_name='sla_unfiltered', frequency='W')

Return the list of periods covering the time series loaded in memory.

Parameters:
  • df (pandas.DataFrame) – Input DataFrame containing time series data.

  • time_series (TimeSeries) – Time series data and properties.

  • var_name (str, optional) – Name of the variable to consider, by default “sla_unfiltered”.

  • frequency (str, optional) – Frequency for period grouping, by default ‘W’ (weekly).

Yields:

tuple – A tuple containing the start and end timestamps of each period.

mod_interp.reformat_drifter_dataset(ds)

Reformat a drifter dataset, extracting relevant variables.

Parameters:

ds (xarray.Dataset) – Input drifter dataset.

Returns:

Reformatted drifter dataset.

Return type:

xarray.Dataset

mod_interp.run_interpolation(ds_maps, ds_alongtrack, frequency='M', var='sla')

Interpolate time series data over specified periods.

Parameters:
  • ds_maps (xarray.Dataset) – Input dataset containing maps data.

  • ds_alongtrack (xarray.Dataset) – Input dataset containing along-track data.

  • frequency (str, optional) – Frequency for period grouping, by default ‘M’ (monthly).

Returns:

Interpolated dataset.

Return type:

xarray.Dataset

mod_interp.run_interpolation_drifters(ds_maps, ds_drifter, time_min, time_max, frequency='M')

Interpolate drifters data over specified periods.

Parameters:
  • ds_maps (xarray.Dataset) – Input dataset containing maps data.

  • ds_drifter (xarray.Dataset) – Input dataset containing drifter data.

  • time_min (numpy.datetime64) – Minimum time for interpolation.

  • time_max (numpy.datetime64) – Maximum time for interpolation.

  • frequency (str, optional) – Frequency for period grouping, by default ‘M’ (monthly).

Returns:

Interpolated drifter dataset.

Return type:

xarray.Dataset