s2d2.unit_conversion

Module Contents

Functions

datetime2doy(dt)

Convert array of datetime64 to a day of year.

doy2dmy(doy, year)

given day of years, calculate the day and month

datetime2calender(dt)

Convert array of datetime64 to a calendar year, month, day.

datenum2datetime(t)

some write a date as a number "YYYYMMDD" conver this to numpy.datetime

datetime2datenum(dt)

convert numpy.datetime to a date as a number "YYYYMMDD"

deg2dms(ang)

convert decimal degrees to degree minutes seconds format

dms2deg(deg, min, sec)

convert degree minutes seconds format to decimal degrees

deg2compass(θ)

adjust angle to be in bounds of a positive argument angle,like a compass

deg2arg(θ)

adjust angle to be in bounds of an argument angle

s2d2.unit_conversion.datetime2doy(dt)[source]

Convert array of datetime64 to a day of year.

Parameters:

dt (np.datetime64) – times of interest

Returns:

  • year (integer, {x ∈ ℕ}) – calender year

  • doy (integer, {x ∈ ℕ}) – day of year

s2d2.unit_conversion.doy2dmy(doy, year)[source]

given day of years, calculate the day and month

Parameters:
  • year (integer, {x ∈ ℕ}) – calender year

  • doy (integer, {x ∈ ℕ}) – day of year

Return type:

day, month, year

s2d2.unit_conversion.datetime2calender(dt)[source]

Convert array of datetime64 to a calendar year, month, day.

Parameters:

dt (np.datetime64) – times of interest

Returns:

cal – calendar array with last axis representing year, month, day

Return type:

numpy array

s2d2.unit_conversion.datenum2datetime(t)[source]

some write a date as a number “YYYYMMDD” conver this to numpy.datetime

Parameters:

t ({int,numpy.array}) – time, in format YYYYMMD

Returns:

dt – times in numpy time format

Return type:

{numpy.datetime64, numpy.array}, type=numpy.datetime64[D]

See also

datetime2datenum

s2d2.unit_conversion.datetime2datenum(dt)[source]

convert numpy.datetime to a date as a number “YYYYMMDD”

Parameters:

dt ({numpy.datetime64, numpy.array}, type=numpy.datetime64[D]) – times in numpy time format

Returns:

t – time, in format YYYYMMD

Return type:

{int, numpy.array}

See also

datenum2datetime

s2d2.unit_conversion.deg2dms(ang)[source]

convert decimal degrees to degree minutes seconds format

Parameters:

ang ({float,np.array}, unit=decimal degrees) – angle(s) of interest

Returns:

  • deg ({integer,np.array}) – degrees

  • min ({integer,np.array}, range=0…60) – angular minutes

  • sec ({float,np.array}, range=0…60) – angular seconds

s2d2.unit_conversion.dms2deg(deg, min, sec)[source]

convert degree minutes seconds format to decimal degrees

Parameters:
  • deg ({integer,np.array}) – degrees

  • min ({integer,np.array}, range=0...60) – angular minutes

  • sec ({float,np.array}, range=0...60) – angular seconds

Returns:

ang – angle(s) of interest

Return type:

{float,np.array}, unit=decimal degrees

s2d2.unit_conversion.deg2compass(θ)[source]

adjust angle to be in bounds of a positive argument angle,like a compass

Parameters:

θ (unit=degrees) –

Returns:

θ

Return type:

unit=degrees, range=0…+360

See also

deg2arg

Notes

The angle is declared in the following coordinate frame:

     ^ North & y
     |
- <--|--> +
     |
     +----> East & x
s2d2.unit_conversion.deg2arg(θ)[source]

adjust angle to be in bounds of an argument angle

Parameters:

θ (unit=degrees) –

Returns:

θ

Return type:

unit=degrees, range=-180…+180

See also

deg2compass

Notes

The angle is declared in the following coordinate frame:

     ^ North & y
     |
- <--|--> +
     |
     +----> East & x