dubfi.util

Collection of utility functions for dubfi.

Added in version 0.1.0: (initial release)

Functions

str2timedelta64(→ numpy.timedelta64)

Convert string (user input) to np.timedelta64.

config_overwrite(config, changes)

Overwrite config by given changes, recursively updating dictionaries.

sphere_dist_deg(→ float | numpy.ndarray)

Like sphere_dist_rad(), but input and output is in degrees.

earth_dist_deg(→ float | numpy.ndarray)

Distance on spherical earth input in degrees, output in meters.

sphere_dist_rad(→ float | numpy.ndarray)

Angle between two points on the unit sphere.

Module Contents

dubfi.util.str2timedelta64(s: str) numpy.timedelta64

Convert string (user input) to np.timedelta64.

dubfi.util.config_overwrite(config: dict, changes: dict)

Overwrite config by given changes, recursively updating dictionaries.

dubfi.util.sphere_dist_deg(lon1: float | numpy.ndarray, lat1: float | numpy.ndarray, lon2: float | numpy.ndarray, lat2: float | numpy.ndarray) float | numpy.ndarray

Like sphere_dist_rad(), but input and output is in degrees.

dubfi.util.earth_dist_deg(lon1: float | numpy.ndarray, lat1: float | numpy.ndarray, lon2: float | numpy.ndarray, lat2: float | numpy.ndarray) float | numpy.ndarray

Distance on spherical earth input in degrees, output in meters.

Parameters:
  • lon1 (array or float) – longitude of first position(s) (degrees east)

  • lat1 (array or float) – latitude of first position(s) (degrees north)

  • lon2 (array or float) – longitude of second position(s) (degrees east)

  • lat2 (array or float) – latitude of second position(s) (degrees north)

Return type:

distance on spherical earth (meters)

dubfi.util.sphere_dist_rad(lon1: float | numpy.ndarray, lat1: float | numpy.ndarray, lon2: float | numpy.ndarray, lat2: float | numpy.ndarray) float | numpy.ndarray

Angle between two points on the unit sphere.

Parameters:
  • lon1 (array or float) – longitude of first position(s) (radians)

  • lat1 (array or float) – latitude of first position(s) (radians)

  • lon2 (array or float) – longitude of second position(s) (radians)

  • lat2 (array or float) – latitude of second position(s) (radians)

Return type:

angle on unit sphere (radians)