Documentation for EHTUtils.

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.


  • Δ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.

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


julia> mas = get_unit("mas") # returns Unitful.Unit object 
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)).
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.


  • itr: iterables
  • sort::Bool: if the output vector is sorted. Default to true.
  • keywords...: keywords for permsort function considered when sort == true.


# 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)
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.


julia> # Converting 1K to mK
julia> val2 = 1 * unitconv(u"K", u"mK") # value 2 will be 1000 
@throwerror exception message

Logging an error with the given message, and then throw the given exception (e) with the same message.


julia> @throwerror ArgumentError "Error Message"
┌ Error: Error Message
└ @ Main <PATH>/EHTUtils/src/logging.jl:8
ERROR: ArgumentError: Error Message
 [1] top-level scope
   @ logging.jl:8