UnitfulAstro.jl Documentation

UnitfulAstro.jl is an extension of Unitful.jl to include units commonly encountered in astronomy.

Table of Units

The list of additional units is given below:

NameBindingValue
ErgUnitfulAstro.erg1//10000000 J
DyneUnitfulAstro.dyn1//100000 N
ArcminuteUnitfulAstro.arcminute0.016666666666666666 °
ArcsecondUnitfulAstro.arcsecond0.0002777777777777778 °
Julian yearUnitfulAstro.yr365.25 dy
Astronomical unitUnitfulAstro.AU1.495978707e13 cm
Light yearUnitfulAstro.ly9.4607304725808e17 cm
ParsecUnitfulAstro.pc3.0856775814913674e18 cm
JanskyUnitfulAstro.Jy1.0e-23 erg Hz^-1 cm^-2 s^-1
Solar radiusUnitfulAstro.Rsun6.957e10 cm
Solar irradianceUnitfulAstro.Ssun1.361e6 erg cm^-2 s^-1
Solar luminosityUnitfulAstro.Lsun3.828e33 erg s^-1
G × Solar massUnitfulAstro.GMsun1.3271244e20 m^3 s^-2
Solar massUnitfulAstro.Msun1.9884754153381438e33 g
Earth radius (equatorial)UnitfulAstro.Rearth_e6.3781e8 cm
Earth radius (polar)UnitfulAstro.Rearth_p6.3568e8 cm
Earth radiusUnitfulAstro.Rearth6.3781e8 cm
G × Earth massUnitfulAstro.GMearth3.986004e14 m^3 s^-2
Earth massUnitfulAstro.Mearth5.972364730419773e27 g
Jupiter radius (equatorial)UnitfulAstro.Rjup_e7.1492e9 cm
Jupiter radius (polar)UnitfulAstro.Rjup_p6.6854e9 cm
Jupiter radiusUnitfulAstro.Rjup7.1492e9 cm
G × Jupiter massUnitfulAstro.GMjup1.2668653e17 m^3 s^-2
Jupiter massUnitfulAstro.Mjup1.8981871658715508e30 g
Fifty-one ergsUnitfulAstro.foe1.0e51 erg
Solar flux unitUnitfulAstro.SFU10//1 kJy
Total electron content unitUnitfulAstro.TECU1.0e12 cm^-2

Examples

julia> using Unitful, UnitfulAstro

julia> uconvert(u"erg", 1 * Unitful.kg * Unitful.gn * Unitful.m)
9.80665e7 erg

julia> uconvert(u"Jy", 1.23e-20 * u"erg/s/cm^2/Hz")
1230.0000000000002 Jy

julia> uconvert(u"ly", 1 * u"pc")
3.2615637771674333 ly

Magnitudes

NameBindingZero Point
absolute bolometric MagnitudeUnitfulAstro.bol_Mag3.0128e28 W
apparent bolometric magnitudeUnitfulAstro.bol_mag2.518021002e-8 W m^-2
AB magnitudeUnitfulAstro.AB_mag3631 Jy
Johnson U magnitudeUnitfulAstro.U_mag1810 Jy
Johnson U magnitudeUnitfulAstro.B_mag4260 Jy
Johnson V magnitudeUnitfulAstro.V_mag3640 Jy
Johnson R magnitudeUnitfulAstro.R_mag3080 Jy
Johnson I magnitudeUnitfulAstro.I_mag2550 Jy
Johnson J magnitudeUnitfulAstro.J_mag1600 Jy
Johnson H magnitudeUnitfulAstro.H_mag1080 Jy
Johnson K magnitudeUnitfulAstro.K_mag670 Jy
Gunn g magnitudeUnitfulAstro.g_mag3730 Jy
Gunn r magnitudeUnitfulAstro.r_mag4490 Jy
Gunn i magnitudeUnitfulAstro.i_mag4760 Jy
Gunn z magnitudeUnitfulAstro.z_mag4810 Jy
Warn

Support for magnitudes is experimental. Please use care and report any issues you experience on the UnitfulAstro.jl GitHub issue tracker.

Currently only AB, bolometric, Johnson, and Gunn magnitudes are supported.

For example

julia> using Unitful, UnitfulAstro
    
julia> u = UnitfulAstro;

julia> 5*u.AB_mag + 5*u.AB_mag
4.247425010840047 AB mag

julia> 5*u.U_mag/100
10.0 Johnson U mag

julia> 5*u.g_mag + 10*u.Jy # magnitudes can be mixed with ordinary linear units
47.300000000000004 Jy

julia> uconvert(u.AB_mag, 1*u.μJy) # converting one μJy to AB magnitudes
23.90006562228223 AB mag

julia> uconvert(u.bol_mag, 1*u.Ssun) # apparent bolometric magnitude of the Sun
-26.83199694276591 bol mag

julia> uconvert(u.bol_Mag, 1*u.Lsun) # absolute bolometric magnitude of the Sun
4.7399959339194595 bol Mag

Color

Color index is also supported

julia> using UnitfulAstro

julia> u = UnitfulAstro;

julia> 1u.B_mag - 0.5u.V_mag
0.4999999999999999

Note: that the only operation that can happen between different bands is subtraction

julia> using UnitfulAstro

julia> u = UnitfulAstro;

julia> 1u.B_mag + 0.5u.V_mag
ERROR: MagnitudeError: an invalid operation was attempted with magnitudes: 0.9999999999999999 Johnson B mag, 0.5 Johnson V mag

and that + and - work on individual bands

julia> using UnitfulAstro

julia> u = UnitfulAstro;

julia> 1u.B_mag - 1.5u.B_mag
2.0823085833406205 Johnson B mag

julia> 1u.B_mag + 1.5u.B_mag
0.46889349301415084 Johnson B mag

IAU Resolutions

Copies of recent IAU resolutions which formalize the definitions of some units used in this package are linked below.