slim4.interpolator

class slim4.interpolator.TimeSeries2D(mesh_file, path, variables=None)

Bases: object

interpolate(x, y, t, variables=None, lonlat_proj=True)
Return type:

Dict[str, ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]]

load_variable(name, t)
Return type:

ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]

class slim4.interpolator.TimeSeries3D(mesh_file, path_2d, path_3d, variables=None, path_z=None, use_eta=False, verbose=True)

Bases: object

Initialize a 3D time series object

Parameters:
  • file (mesh_file -- path to mesh)

  • files (path_3d -- path to the 3D output)

  • files

Optional parameters:

variables – list of variables to extract (default: all found variables) path_z – path to the z data file (default = None) use_eta – if True, the sea surface elevation is used for vertical interpolation (default = False) verbose – if True, display progress bar (default = True)

eta_dg(t)
Return type:

ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]

find_points_vert(z_mesh, eids, uv, z_points)

Find indices and weights for vertical interpolation

Parameters:
  • prisms (z_mesh -- z coordinates of the mesh)

  • mesh (eids -- ids of the triangles in the 2D)

  • points (z_points -- z coordinates of the)

  • points

Return type:

Tuple[ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]], ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]]

Returns:

prism_ids – index of the prisms in which points are found zeta – parametric z-coordinate in the elements

get_horizontal_transect(t, z, variables=None, lonlat_proj=True, water_line=False, above_bottom=False)

Extract given variables along a horizontal transect at z level (negative downwards) and timestep t

Parameters:
  • 00 (t -- Requested time (seconds since 1970-01-01) – 00:00)

  • If (z -- Level of requested transect.) –

    • ‘surface’ -> extract surface layer

    • ’bottom’ -> extract bottom layer

    • a number -> extract transect at requested depth

Optional parameters:

variables – list of requested varibles (default: all) lonlat_proj – if True, coordinates of transect returned as lon-lat coordinates (default: True) water_line – if True, z is modified to follow sea surface elevation (default: False) above_bottom – if True, z is interpreted as the distance above the bottom (default: False)

Return type:

Dict[str, ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]]

Returns:

data – dictionary of interpolated data (DG format, can be exported using append_to_xdmf)

get_stratification(x, y, times, variables=None, lonlat_proj=True)

Extract vertical profile at given point and times

Parameters:
  • coordinate (y -- y)

  • coordinate

  • data (t -- time at which to extract the)

Optional parameters:

variables – list of variables to extract (default = all) lonlat_proj – if True, x and y must be given in latlong (default = True):

Return type:

Tuple[Dict[str, ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]], ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]]

Returns:

data – dictionary of interpolated data zs – depths of interpolation

get_stratification_on_route(x, y, t, variables=None, lonlat_proj=True)

Extract vertical profiles along a route defined by the points (x,y) and times t

Parameters:
  • route (y -- y coordinates of the)

  • route

  • data (t -- timeseries at which to extract the)

Optional parameters:

variables – list of variables to extract (default = all) lonlat_proj – if True, x and y must be given in latlong (default = True)

Return type:

Tuple[Dict[str, ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]], ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]]

Returns:

data – dictionary of interpolated data z – depths of interpolation

get_vertical_transect(xy1, xy2, t, variables=None, between=False, n_points=200, lonlat_proj=True)

Extract given variables along a vertical transect

Parameters:
  • coordinates (xy2 --)

  • coordinates

  • data (t -- time at which to extract the)

Optional parameters:

variables – list of variables to extract (default = all) between – if True, the transect is limited to the segment between xy1 and xy2 (default = False) npoints – number of interpolation points (default = 200) lonlat_proj – if True, xy1 and xy2 must be given in latlong (default = True)

Return type:

Tuple[Dict[str, ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]], ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]], ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]], ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]]

Returns:

data – dictionary of interpolated data z_lyr – z coordinates along transect query_points – xy coordinates of the transect dist – distance along the transect

interpolate(x, y, z, t, variables=None, lonlat_proj=True, water_line=False)

Extract given variables at given point (x,y,z) and timeseries t

Parameters:
  • coordinate (z -- z)

  • coordinate

  • coordinate – if “surface” -> extract timseries at the top of the surface layer if “bottom” -> extract timseries at the bottom of the bottom layer

  • data (t -- timeseries at which to extract the)

Optional parameters:

variables – list of variables to extract (default = all) lonlat_proj – if True, x and y must be given in latlong (default = True) water_line – if True, z is modified to follow the sea surface elevation (default = False)

Return type:

Dict[str, ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]]

Returns:

data – dictionary of interpolated data

interpolate_on_route(x, y, z, t, variables=None, lonlat_proj=True, water_line=False)

Extract given variables following a given route with coordinates (x,y,z) and timeseries t x, y, z and t must have the same length

Parameters:
  • route (z -- z coordinates of the)

  • route

  • route – if “surface” -> extract timseries at the top of the surface layer if “bottom” -> extract timseries at the bottom of the bottom layer

  • data (t -- times at which to extract the)

Optional parameters:

variables – list of variables to extract (default = all) lonlat_proj – if True, x and y must be given in latlong (default = True) water_line – if True, z is modified to follow the sea surface elevation (default = False)

Return type:

Dict[str, ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]]

Returns:

data – dictionary of interpolated data

load_variable(name, t)
Return type:

ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]

class slim4.interpolator.Zlevel(*values)

Bases: float, Enum

BOTTOM = -1e+20
SURFACE = 1e+20
slim4.interpolator.extract_variables_from_xdmf(file_name)
Return type:

List[str]

slim4.interpolator.find_transect_extremities(mesh2d, xy1, xy2)

Get extremities of a transect defined by two points xy1 and xy2 in mesh2d.

Return type:

ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]

slim4.interpolator.myinterp1d(t, x, tq)

Interpolate x defined at times t to times tq. Works even if t has only one value, UNLIKE scipy.interpolate.interp1d (shame)

slim4.interpolator.weights_3d(u, v, zeta)