EHTUtils

Documentation for EHTUtils.

EHTUtils.get_solidangleFunction
get_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 Δx and Δy. Default is rad
  • angunitout::Unitful.Units, Unitful.Quantity or nothing: the angular unit for the output solid angle. If nothing is specified, use the same unit specified in angunit.
  • satype::Symbol The type of the output solid angle: :pixel for the solid angle of the rectangular area, and :beam for the beam solid angle. For :beam, Δx, Δy will be interperted as Gaussian FWHMs.
EHTUtils.get_unitMethod
get_unit(unitstring)

Converting the given string for units to Unitful.Unit object.

Examples

julia> mas = get_unit("mas") # returns Unitful.Unit object 
EHTUtils.mjd2hourFunction
mjd2hour(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 to floor(minimum(mjd)).
EHTUtils.unique_idsFunction
unique_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: iterables
  • sort::Bool: if the output vector is sorted. Default to true.
  • keywords...: keywords for permsort function considered when sort == 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.unitconvMethod
unitconv(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.@throwerrorMacro
@throwerror exception message

Logging 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