EHTUtils
Documentation for EHTUtils.
EHTUtils.datetime2mjdEHTUtils.get_solidangleEHTUtils.get_unitEHTUtils.jd2mjdEHTUtils.mjd2datetimeEHTUtils.mjd2hourEHTUtils.mjd2jdEHTUtils.unique_idsEHTUtils.unitconvEHTUtils.@throwerror
EHTUtils.datetime2mjd — Methoddatetime2mjd(dt)Convert the input Datetime object into MJD
EHTUtils.get_solidangle — Functionget_solidangle(x, [y=0; angunit=u"rad", angunitout=nothing, satype="pixel"])compute the solid angle for a given set of the angular sizes at specified units of angular sizes in a specified type.
Arguments
Δx, Δy::Real: the size of the area in two orthogonal directions. ifΔy <= 0,Δy = Δx.angunit::Unitful.Units or Unitful.Quantity: the angular unit ofΔxandΔy. Default isradangunitout::Unitful.Units, Unitful.Quantity or nothing: the angular unit for the output solid angle. If nothing is specified, use the same unit specified inangunit.satype::SymbolThe type of the output solid angle::pixelfor the solid angle of the rectangular area, and:beamfor the beam solid angle. For:beam, Δx, Δy will be interperted as Gaussian FWHMs.
EHTUtils.get_unit — Methodget_unit(unitstring)Converting the given string for units to Unitful.Unit object.
Examples
julia> mas = get_unit("mas") # returns Unitful.Unit object EHTUtils.jd2mjd — Methodmjd2jd(jd)Convert JD to MJD.
EHTUtils.mjd2datetime — Methodmjd2datetime(mjd::Number)Convert the input Datetime object into MJD
EHTUtils.mjd2hour — Functionmjd2hour(mjd, refmjd=nothing)Convert a given array of mjd into utc hours.
mjd::AbstractArray: the input array of the modified Julian dates.refmjd::Number: the reference date. Default tofloor(minimum(mjd)).
EHTUtils.mjd2jd — Methodmjd2jd(mjd)Convert MJD to JD.
EHTUtils.unique_ids — Functionunique_ids(itr, sort::Bool=true; keywords...)This is a variant of unique function that returns not only a vector of unique elements in the input, but also a vector of the reverse index.
Arguments
itr: iterablessort::Bool: if the output vector is sorted. Default totrue.keywords...: keywords forpermsortfunction considered whensort == true.
Example
# the original vector
vec = [1,1,3,4,2,3,1,4]
# get unique elements and also the reverse index
uvec, idx = unique_ids(vec) # uvec should be [1,3,4,2]
# this will reconstruct the original vector
rec = uvec[idx]
println(rec == vec)EHTUtils.unitconv — Methodunitconv(unit1, unit2)Derive the conversion factor from unit1 to unit2. The value in unit1 can be converted to that in unit2 by mutiplying this conversion factor.
Examples
julia> # Converting 1K to mK
julia> val2 = 1 * unitconv(u"K", u"mK") # value 2 will be 1000 EHTUtils.@throwerror — Macro@throwerror exception messageLogging an error with the given message, and then throw the given exception (e) with the same message.
Examples
julia> @throwerror ArgumentError "Error Message"
┌ Error: Error Message
└ @ Main <PATH>/EHTUtils/src/logging.jl:8
ERROR: ArgumentError: Error Message
Stacktrace:
[1] top-level scope
@ logging.jl:8