NEDAS.utils.conversion module

NEDAS.utils.conversion.units_convert(units_from, units_to, var)[source]

Convert units for a given variable.

Parameters:
  • units_from (str or numbers.Number) – Source units for the input variable

  • units_to (str or numbers.Number) – Target units to convert to

  • var (np.ndarray) – The input variable

Returns:

Variable with converted units

Return type:

np.ndarray

NEDAS.utils.conversion.proj2dict(proj: Proj) dict[source]

Convert map projection name in pyproj.Proj to a dictionary of human-readable parameters

Parameters:

proj (pyproj.Proj) – Map projection object.

Returns:

A dictionary of projection parameters, such as name, lat_0, lon_0, etc.

Return type:

dict

NEDAS.utils.conversion.t2h(t: datetime) float[source]

Convert datetime object to hours since 1900-1-1 00:00

NEDAS.utils.conversion.h2t(h: float) datetime[source]

Convert hours since 1900-1-1 00:00 to datetime object

NEDAS.utils.conversion.t2s(t: datetime) str[source]

Convert datetime object to a time string 'ccyymmddHHMM'

NEDAS.utils.conversion.s2t(s: str) datetime[source]

Convert a time string 'ccyymmddHHMM' to a datetime object

NEDAS.utils.conversion.seconds_to_timestr(seconds: int) str[source]

Convert from seconds to time duration string ‘HH:MM:SS’

NEDAS.utils.conversion.ensure_list(v) list[source]

If the input v is a list, return itself; if not, return [v].