Units and Time API
These are the full docstrings for the units and time functionality of Sargassum.jl.
Index
Sargassum.EARTH_RADIUSSargassum.EQRSargassum.T_REFSargassum.UNITSSargassum.EquirectangularReferenceSargassum.datetime2timeSargassum.months2timeSargassum.sph2xySargassum.time2datetimeSargassum.time2monthsSargassum.time2ymwSargassum.xy2sphSargassum.ymw2timeSargassum.ymwplusweekSargassum.ymwspan2weekspanSargassum.γ_sphereSargassum.τ_sphere
Sargassum.UNITS Constant
const UNITSA dictionary mapping dimension names to the Unitful.Unitlike that measures it.
Sargassum.T_REF Constant
T_REFThe time to which all times are referred, default January 1, 2000.
This is a Ref, access or modify the actual value with T_REF.x.
Sargassum.datetime2time Method
datetime2time(dt)Convert dt::DateTime to the amount of time since T_REF expressed in the units of UNITS["time"].
This inverts time2datetime.
Sargassum.months2time Method
months2time(months::Integer)Calculate the date in (year, month) format after months months have elapsed since T_REF.
Example
months2time(219)
(2018, 4)Sargassum.time2datetime Method
time2datetime(time)Convert the amount of time since T_REF expressed in the units of UNITS["time"] to a DateTime.
By convention, time is rounded down to the nearest second.
This inverts datetime2time.
Sargassum.time2months Method
time2months(yr::Integer, mnth::Integer)Calculate the number of months since T_REF of the date with year yr and month mnth.
time2months(yearmonth::Tuple{Integer, Integer})Compute time2months(yearmonth[1], yearmonth[2]).
time2months(time::DateTime)Compute time2months(year(time), month(time)).
Example
time2months(2018, 4)
219Sargassum.time2ymw Method
time2ymw(time)Convert the time measured in days since T_REF to the corresponding to the year y, month m and week w.
The days of the four weeks per month are defined as the 7th, 14th, 21nd and 28th.
This is the inverse of ymw2time.
Sargassum.ymw2time Method
ymw2time(y, m, w)Convert the time corresponding to the year y, month m and week w indicated into a single time measured in days since T_REF.
The days of the four weeks per month are defined as the 7th, 14th, 21nd and 28th.
Can be applied as ymw2time((y, m , w)).
This is the inverse of time2ymw.
Sargassum.ymwplusweek Method
ymwplusweek(ymw, n_week)Calculate the (year, month, week) after n_week weeks have passed since ymw.
Example
ymwplusweek((2018, 10, 2), 12) == (2019, 1, 2)
Sargassum.ymwspan2weekspan Method
ymwspan2weekspan(ymw1, ymw2)Return a vector list of all (year, month, week) tuples between ym1 = (year1, month1, week1) and ym2 = (year2, month2, week2) inclusive.
Sargassum.EQR Constant
const EQRThe EquirectangularReference used during all conversions. This is a Ref, use EQR.x to acess the actual EquirectangularReference.
Defaults
lon0: -75.0 degreeslat0: 10.0 degreesR: 6731 km
Sargassum.EquirectangularReference Type
EquirectangularReference{U}A container for the reference longitude and latitude of an equirectangular projection.
Fields
lon0: The standard longitude degrees (East/West).lat0: The standard latitude degrees (North/South).R: The radius of the Earth. The units of this quantity are the units of the equirectangular coordinates.
Constructor
EquirectangularReference(; lon0 = -75.0, lat0 = 10.0, units = UNITS["distance"])Example
To measure distances in meters,
eqr = EquirectangularReference(units = u"m")Sargassum.sph2xy Method
sph2xy(lon, lat; eqr = EQR.x)Compute planar coordinates [x, y] from spherical coordinates (lon, lat) [deg E/W, deg N/S] using EquirectangularReference, eqr, default EQR.
The units of x and y the same as eqr.R.
Further Methods
sph2xy(lon_range, lat_range; eqr = EQR)where lon_range and lat_range are AbstractRange. Returns (x_range, y_range).
sph2xy(lon_lat; eqr = EQR)where lon_lat is a 2 x N `Matrix. Returns a result in the same shape as the input.
Sargassum.xy2sph Method
xy2sph(x, y, eqr = EQR.x)Compute spherical coordinates [lon, lat] [deg] from rectilinear coordinates (x, y) using EquirectangularReference eqr, default EQR.
The units of x and y should be the same as eqr.R.
Further Methods
xy2sph(x_range, y_range)where x_range and y_range are AbstractRange. Returns (lon_range, lat_range).
xy2sph(xy)where xy is a 2 x N Matrix.
Sargassum.γ_sphere Method
γ_sphere(y; eqr = EQR.x, geometry = true)Calculate the geometric correction factor sec(lat_0) * cos(lat), converting y to lat automatically using EquirectangularReference eqr, default EQR.
If geometry == false, γ_sphere is always equal to 1.0.
Sargassum.τ_sphere Method
τ_sphere(y; eqr = EQR.x, geometry = true)Calculate the geometric correction factor τ = tan(lat)/R converting y to lat automatically using EquirectangularReference eqr, default EQR.
If geometry == false, τ_sphere is always equal to 0.0.