brahe

package module
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 8, 2024 License: MIT Imports: 9 Imported by: 0

README

brahe

Brahe is a collection of utilities in Go for working with the Augmented Tycho - HYG star catalog (https://github.com/astronexus/ATHYG-Database).

Specifics

  • athyg.go: defines tools for reading and parsing the AT-HYG catalog (versions 2.2 - current)
  • brahe.go: base file for the library. It defines a Star data type for the data found in AT-HYG and a few other types useful for data processing.
  • consts.go: constants used within the brahe module
  • constellations.go: defines standard names, abbreviations, and genitive forms for the 88 Western constellations, plus locations suitable for adding their names when drawn on a chart
  • lists.go: defines several types of lists of Star objects useful for reporting and charts
  • utils.go: defines various astronomical conversion utilities, for both generic data and Star object data

See ./USAGE.md for some specific examples of tasks brahe can perform.

Dependencies

brahe uses the Gonum floating point library for vector math.

License

Brahe is licensed under the following license:

Copyright 2024, David Nash

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Documentation

Overview

Package brahe defines core variable types and basic utility functions for astronomy programs using the AT-HYG (Augmented Tycho-HYG) catalog. The base file (brahe.go) defines the most widely used types in these utility functions.

See TYPE_DETAILS.md for a more detailed description of each type.

Index

Constants

View Source
const (
	ATHYG_ID       = 0  // AT-HYG sequential catalog ID column in AT-HYG
	ATHYG_TYC      = 1  // Tycho-2 ID column in AT-HYG
	ATHYG_GAIA     = 2  // Gaia DR3 ID column in AT-HYG
	ATHYG_HIP      = 4  // HIPPARCOS ID column in AT-HYG
	ATHYG_HD       = 5  // Henry Draper ID column in AT-HYG
	ATHYG_HR       = 6  // HR/YBSC ID column in AT-HYG
	ATHYG_GLIESE   = 7  // Gliese/GJ catalog ID column in AT-HYG
	ATHYG_BAYER    = 8  // Bayer Greek letter (+ optional subscript) column in AT-HYG
	ATHYG_FLAM     = 9  // Flamsteed number column in AT-HYG
	ATHYG_CON      = 10 // 3-letter constellation abbreviation column in AT-HYG
	ATHYG_PROPER   = 11 // Proper name (e.g. Rigel, Polaris) column in AT-HYG
	ATHYG_RA       = 12 // Right ascension, equinox J2000.0 column in AT-HYG
	ATHYG_DEC      = 13 // Declination, equinox J2000.0 column in AT-HYG
	ATHYG_X        = 16 // Cartesian x position column in AT-HYG
	ATHYG_Y        = 17 // Cartesian y position column in AT-HYG
	ATHYG_Z        = 18 // Cartesian z position column in AT-HYG
	ATHYG_DIST_SRC = 19 // Distance source field column in AT-HYG -- IDs ultimate source catalog for distance (e.g. G_R3 for Gaia DR3, HIP for HIPPARCOS)
	ATHYG_MAG      = 20 // Visual apparent magnitude column in AT-HYG
	ATHYG_ABSMAG   = 21 // Visual absolute magnitude column in AT-HYG
	ATHYG_VX       = 29 // Cartesian x velocity column in AT-HYG
	ATHYG_VY       = 30 // Cartesian y velocity column in AT-HYG
	ATHYG_VZ       = 31 // Cartesian z velocity column in AT-HYG
	ATHYG_SPECTRUM = 32 // MK spectral type column in AT-HYG
)

AT-HYG catalog field IDs. This is for AT-HYG v2.2 or later. For CSV format catalogs, these are 0-indexed column IDs.

View Source
const (
	LABEL_PROPER_ID    = iota // Default proper name label priority
	LABEL_BAYER_ID            // Default Bayer Greek letter designation priority
	LABEL_FLAMSTEED_ID        // Default Flamsteed number priority
	LABEL_HR_ID               // Default HR number priority
	LABEL_GLIESE_ID           // Default Gliese/GJ catalog priority
	LABEL_HIP_ID              // Default HIPPARCOS priority
	LABEL_TYCHO_ID            // Default Tycho-2 ID priority
	LABEL_GAIA_ID             // Default Gaia catalog ID priority
)

AT-HYG ID label priorities. Labels use the first nonempty one in the list, then the second. This list sets the normal order; changing the order, either here or in a list of priorities passed to a request for a label, changes the labels chosen.

View Source
const ATHYG_RECORD_LENGTH = 34 // 0-index record length of a standard AT-HYG record
View Source
const ATHYG_SUN_ID = 1

ATHYG_SUN_ID is the specific ID for the Sun in Augmented Tycho (it's defined as such in all AT-HYG > v1.0)

View Source
const INVALID_OBJECT_ID = -1e6

INVALID_OBJECT_ID is a placeholder ID for a Star object that could not be found, or otherwise invalid. By convention, negative IDs are used for special cases (all valid catalog IDs are > 0) and the value chosen here is intended not to clash with possible use cases.

View Source
const MAX_BINARY_STEPS = 32

MAX_BINARY_STEPS is the maximum allowed number of steps in binary search before the search is terminated. A value of 32 is good for up to ~4E9 items, which is well beyond any practical use case.

View Source
const MIN_APPARENT_LUMINOSITY = 0.001

MIN_APPARENT_LUMINOSITY is the minimum scaled luminosity (current brightness of the star compared to the Sun at a standard distance) for a star to be included in a list. This value is faster to calculate for a star than the apparent magnitude, so long as the Luminosity property is known. The default value of 0.001 corresponds roughly to an apparent magnitude of +7.4; about 20000 stars will meet this criterion in general, making it a more restrictive criterion than an angle cutoff (unless the cutoff is very small) in longer lists of stars.

View Source
const NO_TRANSLATE_LIMIT = 0.01

NO_TRANSLATE_LIMIT is the distance, in parsecs, from the Sun under which it is safe to neglect explicit calculations of new positions+velocities for stars in a list.

View Source
const PCYR_TO_KMSEC = 977812.0 // conversion from parsecs/year to km/second

Values for basic astronomical computation:

View Source
const PC_TO_LY = 3.262 // conversion from parsesc to light years
View Source
const PLACEHOLDER_APP_DIST = 1.0e-4 // distance below which the apparent magnitude is set to the placeholder value
View Source
const PLACEHOLDER_APP_MAG = -25.0 // an arbitrary apparent magnitude for extremely nearby stars. Same order of magnitude as Sun as seen from Earth.
View Source
const PLACEHOLDER_CATALOG_DISTANCE = 1000000.0 // To use when the XYZ coordinates of the star are unknown. Use to create a very distant placeholder.
View Source
const PLACEHOLDER_CATALOG_MAGNITUDE = +10.0 // To use when a magnitude value is invalid
View Source
const SOL_ABSMAG = 4.85 // absolute Johnson V magnitude of the Sun (apparent magnitude @ 10.0 parsec)

Variables

View Source
var CONSTELLATION_DATA = Constellations{
	"And": ConstellationDetails{"Andromeda", "And", "Andromedae", LabelLocations{EquatorialPosition{0.5, 40}}},
	"Ant": ConstellationDetails{"Antlia", "Antliae", "Ant", LabelLocations{EquatorialPosition{10.0, -35.0}}},
	"Aps": ConstellationDetails{"Apus", "Apodis", "Aps", LabelLocations{EquatorialPosition{16.0, -77.5}}},
	"Aqr": ConstellationDetails{"Aquarius", "Aquarii", "Aqr", LabelLocations{EquatorialPosition{22.0, -5.0}}},
	"Aql": ConstellationDetails{"Aquila", "Aquilae", "Aql", LabelLocations{EquatorialPosition{19.5, 0.0}}},
	"Ara": ConstellationDetails{"Ara", "Arae", "Ara", LabelLocations{EquatorialPosition{17.0, -55.0}}},
	"Ari": ConstellationDetails{"Aries", "Arietis", "Ari", LabelLocations{EquatorialPosition{2.5, 20.0}}},
	"Aur": ConstellationDetails{"Auriga", "Aurigae", "Aur", LabelLocations{EquatorialPosition{5.75, 40.0}}},
	"Boo": ConstellationDetails{"Bootes", "Bootis", "Boo", LabelLocations{EquatorialPosition{14.5, 30.0}}},
	"Cae": ConstellationDetails{"Caelum", "Caeli", "Cae", LabelLocations{EquatorialPosition{4.5, -40.0}}},
	"Cam": ConstellationDetails{"Camelopardalis", "Camelopardalis", "Cam", LabelLocations{EquatorialPosition{6.0, 70.0}}},
	"Cnc": ConstellationDetails{"Cancer", "Cancri", "Cnc", LabelLocations{EquatorialPosition{8.5, 20.0}}},
	"CVn": ConstellationDetails{"Canes Venatici", "Canum Venaticorum", "CVn", LabelLocations{EquatorialPosition{13.0, 40.0}}},
	"CMa": ConstellationDetails{"Canis Major", "Canis Majoris", "CMa", LabelLocations{EquatorialPosition{6.75, -20.0}}},
	"CMi": ConstellationDetails{"Canis Minor", "Canis Minoris", "CMi", LabelLocations{EquatorialPosition{7.5, 10.0}}},
	"Cap": ConstellationDetails{"Capricornus", "Capricorni", "Cap", LabelLocations{EquatorialPosition{21.0, -20.0}}},
	"Car": ConstellationDetails{"Carina", "Carinae", "Car", LabelLocations{EquatorialPosition{8.0, -55.0}}},
	"Cas": ConstellationDetails{"Cassiopeia", "Cassiopeiae", "Cas", LabelLocations{EquatorialPosition{1.0, 65.0}}},
	"Cen": ConstellationDetails{"Centaurus", "Centauri", "Cen", LabelLocations{EquatorialPosition{13.0, -45.0}}},
	"Cep": ConstellationDetails{"Cepheus", "Cephei", "Cep", LabelLocations{EquatorialPosition{22.0, 65.0}}},
	"Cet": ConstellationDetails{"Cetus", "Ceti", "Cet", LabelLocations{EquatorialPosition{2.0, -5.0}}},
	"Cha": ConstellationDetails{"Chamaeleon", "Chamaeleontis", "Cha", LabelLocations{EquatorialPosition{10.0, -80.0}}},
	"Cir": ConstellationDetails{"Circinus", "Circini", "Cir", LabelLocations{EquatorialPosition{15.0, -60.0}}},
	"Col": ConstellationDetails{"Columba", "Columbae", "Col", LabelLocations{EquatorialPosition{5.5, -40.0}}},
	"Com": ConstellationDetails{"Coma Berenices", "Comae Berenices", "Com", LabelLocations{EquatorialPosition{12.75, 20.0}}},
	"CrA": ConstellationDetails{"Corona Australis", "Coronae Australis", "CrA", LabelLocations{EquatorialPosition{18.75, -40}}},
	"CrB": ConstellationDetails{"Corona Borealis", "Coronae Borealis", "CrB", LabelLocations{EquatorialPosition{16.00, 30.0}}},
	"Crv": ConstellationDetails{"Corvus", "Corvi", "Crv", LabelLocations{EquatorialPosition{12.5, -20.0}}},
	"Crt": ConstellationDetails{"Crater", "Crateris", "Crt", LabelLocations{EquatorialPosition{11.25, -15}}},
	"Cru": ConstellationDetails{"Crux", "Crucis", "Cru", LabelLocations{EquatorialPosition{12.75, -62.5}}},
	"Cyg": ConstellationDetails{"Cygnus", "Cygni", "Cyg", LabelLocations{EquatorialPosition{20.5, 35.0}}},
	"Del": ConstellationDetails{"Delphinus", "Delphini", "Del", LabelLocations{EquatorialPosition{20.5, 15.0}}},
	"Dor": ConstellationDetails{"Dorado", "Doradus", "Dor", LabelLocations{EquatorialPosition{5.0, -65.0}}},
	"Dra": ConstellationDetails{"Draco", "Draconis", "Dra", LabelLocations{EquatorialPosition{17.0, 60.0}}},
	"Equ": ConstellationDetails{"Equuleus", "Equulei", "Equ", LabelLocations{EquatorialPosition{21.1, 10.0}}},
	"Eri": ConstellationDetails{"Eridanus", "Eridani", "Eri", LabelLocations{EquatorialPosition{4.0, -30.0}}},
	"For": ConstellationDetails{"Fornax", "Fornacis", "For", LabelLocations{EquatorialPosition{3.0, -30.0}}},
	"Gem": ConstellationDetails{"Gemini", "Geminorum", "Gem", LabelLocations{EquatorialPosition{7.0, 25.0}}},
	"Gru": ConstellationDetails{"Grus", "Gruis", "Gru", LabelLocations{EquatorialPosition{22.5, -45.0}}},
	"Her": ConstellationDetails{"Hercules", "Herculis", "Her", LabelLocations{EquatorialPosition{17.5, 30.0}}},
	"Hor": ConstellationDetails{"Horologium", "Horologii", "Hor", LabelLocations{EquatorialPosition{3.5, -50.0}}},
	"Hya": ConstellationDetails{"Hydra", "Hydrae", "Hya", LabelLocations{EquatorialPosition{9.5, -15.0}, EquatorialPosition{13.5, -25.0}}},
	"Hyi": ConstellationDetails{"Hydrus", "Hydri", "Hyi", LabelLocations{EquatorialPosition{2.0, -70.0}}},
	"Ind": ConstellationDetails{"Indus", "Indi", "Ind", LabelLocations{EquatorialPosition{21.0, -55.0}}},
	"Lac": ConstellationDetails{"Lacerta", "Lacertae", "Lac", LabelLocations{EquatorialPosition{22.5, 45.0}}},
	"Leo": ConstellationDetails{"Leo", "Leonis", "Leo", LabelLocations{EquatorialPosition{11.0, 15.0}}},
	"LMi": ConstellationDetails{"Leo Minor", "Leonis Minoris", "LMi", LabelLocations{EquatorialPosition{10.0, 35.0}}},
	"Lep": ConstellationDetails{"Lepus", "Leporis", "Lep", LabelLocations{EquatorialPosition{5.5, -20.0}}},
	"Lib": ConstellationDetails{"Libra", "Librae", "Lib", LabelLocations{EquatorialPosition{15.25, -17.5}}},
	"Lup": ConstellationDetails{"Lupus", "Lupi", "Lup", LabelLocations{EquatorialPosition{15.0, -45.0}}},
	"Lyn": ConstellationDetails{"Lynx", "Lyncis", "Lyn", LabelLocations{EquatorialPosition{8.0, 45.0}}},
	"Lyr": ConstellationDetails{"Lyra", "Lyrae", "Lyr", LabelLocations{EquatorialPosition{19.0, 35.0}}},
	"Men": ConstellationDetails{"Mensa", "Mensae", "Men", LabelLocations{EquatorialPosition{5.5, -75.0}}},
	"Mic": ConstellationDetails{"Microscopium", "Microscopii", "Mic", LabelLocations{EquatorialPosition{20.75, -35.0}}},
	"Mon": ConstellationDetails{"Monoceros", "Monocerotis", "Mon", LabelLocations{EquatorialPosition{7.0, 0.0}}},
	"Mus": ConstellationDetails{"Musca", "Muscae", "Mus", LabelLocations{EquatorialPosition{12.0, -70.0}}},
	"Nor": ConstellationDetails{"Norma", "Normae", "Nor", LabelLocations{EquatorialPosition{16.0, -50.0}}},
	"Oct": ConstellationDetails{"Octans", "Octantis", "Oct", LabelLocations{EquatorialPosition{21.0, -80.0}}},
	"Oph": ConstellationDetails{"Ophiuchus", "Ophiuchi", "Oph", LabelLocations{EquatorialPosition{17.0, -5.0}}},
	"Ori": ConstellationDetails{"Orion", "Orionis", "Ori", LabelLocations{EquatorialPosition{5.5, 2.5}}},
	"Pav": ConstellationDetails{"Pavo", "Pavonis", "Pav", LabelLocations{EquatorialPosition{19.5, -65.0}}},
	"Peg": ConstellationDetails{"Pegasus", "Pegasi", "Peg", LabelLocations{EquatorialPosition{22.5, 20.0}}},
	"Per": ConstellationDetails{"Perseus", "Persei", "Per", LabelLocations{EquatorialPosition{3.5, 45.0}}},
	"Phe": ConstellationDetails{"Phoenix", "Phoenicis", "Phe", LabelLocations{EquatorialPosition{1.0, -50.0}}},
	"Pic": ConstellationDetails{"Pictor", "Pictoris", "Pic", LabelLocations{EquatorialPosition{5.5, -52.0}}},
	"Psc": ConstellationDetails{"Pisces", "Piscium", "Psc", LabelLocations{EquatorialPosition{0.5, 10.0}}},
	"PsA": ConstellationDetails{"Piscis Austrinus", "Piscis Austrini", "PsA", LabelLocations{EquatorialPosition{22.5, -30.0}}},
	"Pup": ConstellationDetails{"Puppis", "Puppis", "Pup", LabelLocations{EquatorialPosition{7.5, -35.0}}},
	"Pyx": ConstellationDetails{"Pyxis", "Pyxidis", "Pyx", LabelLocations{EquatorialPosition{9.0, -30.0}}},
	"Ret": ConstellationDetails{"Reticulum", "Reticuli", "Ret", LabelLocations{EquatorialPosition{4.0, -60.0}}},
	"Sge": ConstellationDetails{"Sagitta", "Sagittae", "Sge", LabelLocations{EquatorialPosition{19.75, 18.5}}},
	"Sgr": ConstellationDetails{"Sagittarius", "Sagittarii", "Sgr", LabelLocations{EquatorialPosition{19.25, -25.0}}},
	"Sco": ConstellationDetails{"Scorpius", "Scorpii", "Sco", LabelLocations{EquatorialPosition{16.5, -30.0}}},
	"Scl": ConstellationDetails{"Sculptor", "Sculptoris", "Scl", LabelLocations{EquatorialPosition{0.5, -30.0}}},
	"Sct": ConstellationDetails{"Scutum", "Scuti", "Sct", LabelLocations{EquatorialPosition{18.5, -10.0}}},
	"Ser": ConstellationDetails{"Serpens", "Serpentis", "Ser", LabelLocations{EquatorialPosition{15.5, 5.0}, EquatorialPosition{18.25, -2.0}}},
	"Sex": ConstellationDetails{"Sextans", "Sextantis", "Sex", LabelLocations{EquatorialPosition{10.5, -5.0}}},
	"Tau": ConstellationDetails{"Taurus", "Tauri", "Tau", LabelLocations{EquatorialPosition{4.5, 20.0}}},
	"Tel": ConstellationDetails{"Telescopium", "Telescopii", "Tel", LabelLocations{EquatorialPosition{19.0, -50.0}}},
	"Tri": ConstellationDetails{"Triangulum", "Trianguli", "Tri", LabelLocations{EquatorialPosition{2.0, 30.0}}},
	"TrA": ConstellationDetails{"Triangulum Australe", "Trianguli Australis", "TrA", LabelLocations{EquatorialPosition{16.75, -67.5}}},
	"Tuc": ConstellationDetails{"Tucana", "Tucanae", "Tuc", LabelLocations{EquatorialPosition{23.0, -60.0}}},
	"UMa": ConstellationDetails{"Ursa Major", "Ursae Majoris", "UMa", LabelLocations{EquatorialPosition{10.5, 55.0}}},
	"UMi": ConstellationDetails{"Ursa Minor", "Ursae Minoris", "UMi", LabelLocations{EquatorialPosition{16.0, 80.0}}},
	"Vel": ConstellationDetails{"Vela", "Velorum", "Vel", LabelLocations{EquatorialPosition{9.5, -45.0}}},
	"Vir": ConstellationDetails{"Virgo", "Virginis", "Vir", LabelLocations{EquatorialPosition{13.5, 0.0}}},
	"Vol": ConstellationDetails{"Volans", "Volantis", "Vol", LabelLocations{EquatorialPosition{8.0, -70.0}}},
	"Vul": ConstellationDetails{"Vulpecula", "Vulpeculae", "Vul", LabelLocations{EquatorialPosition{20.0, 25.0}}},
}

Functions

func AbsMagToLuminosity

func AbsMagToLuminosity(absmag float64) float64

AbsMagToLuminosity calculates the luminosity (in terms of the Sun and visual magnitude) from the given star's absolute magnitude [absmag].

func ApparentMagnitude

func ApparentMagnitude(star Star) float64

ApparentMagnitude returns the specifed star's apparent magnitude from its current position and absolute magnitude. This assumes the position is in parsecs.

Don't use this for sorting long lists. The Log10() is expensive in a comparison function. Use ScaledLuminosity(star) instead.

func AthygIDTypeLookup

func AthygIDTypeLookup(id string) string

AthygIDTypeLookup takes an ID [id] and attempts to get the most likely catalog ID type in an index created by GeneratAthygIndex. Note that this makes some assumptions: - Any integer < 2^17 (128K): A HIPPARCOS catalog (HIP) ID. - Any integer in the range 2^17 to 2^64: A Gaia (DR2/DR3) ID. - Any string with exactly two dashes ("-"): A Tycho ID. Items that fail this quick parse (e.g., a proper name) can still be looked up; it just requires an additional step.

func AthygTargetIDLookup

func AthygTargetIDLookup(atIndex map[string]int, id string) int

AthygTargetIDLookup(attempts to find the specified ID in an index [atIndex] prepared by CreateAthygIndex. It returns the AT-HYG DB ID for the star if the lookup is successful, or 0 if it is not.

func CreateAthygIndex

func CreateAthygIndex(athygStars []Star) map[string]int

CreateAthygIndex takes a list of standard Star objects [athygStars] and creates a map of common names + IDs to AT-HYG record IDs. A common use case for this is looking up stars by name or ID without having to resort to SIMBAD or other sources for lookups.

func DirectionCosine

func DirectionCosine(v1 CartesianVector, v2 CartesianVector) float64

DirectionCosine gets the cosine of the angle between vectors [v1] and [v2].

func Distance

func Distance(star Star) float64

Distance returns the specifed star's current distance, in the same units as the Cartesian velocity components.

func GetAthygGaiaLabel

func GetAthygGaiaLabel(gaia int64) string

GetAthygGaiaLabel gets a standardized Gaia release label for the Gaia label [gaia] used in AT-HYG v2.x / v3.x.

func GetAthygStarLabels

func GetAthygStarLabels(star *Star, labelPriorities []int) (string, string)

GetAtHygStarLabels gets two labels for the specified Star object [star], based on an ordered list of label IDs in order of priority [labelPriorities].

func GetGenitiveForConstellation

func GetGenitiveForConstellation(abbreviation string) string

GetGenitiveForConstellation gets the Latin genetive form (e.g. "Centauri" for "Centaurus") for the supplied constellation abbreviation [abbreviation].

func GetHRLabel

func GetHRLabel(hr int) string

GetHRLabel gets a standardized Harvard Revised / Yale Bright Star catalog label for the catalog ID number [hr].

func GetHipLabel

func GetHipLabel(hip int) string

GetHipLabel gets a standardized HIPPARCOS catalog label for the catalog ID number [hip].

func GetNameForConstellation

func GetNameForConstellation(abbreviation string) string

GetNameForConstellation gets the full, official constellation name for the supplied constellation abbreviation [abbreviation].

func GetTychoLabel

func GetTychoLabel(tyc string) string

GetTychoLabel gets a standardized Tycho-2 catalog label for the catalog ID [tyc].

func KmPerSecToParsecPerYear

func KmPerSecToParsecPerYear(kms float64) float64

KmPerSecToParsecPerYear converts km/sec to parsecs/year

func LightYearsToParsecs

func LightYearsToParsecs(ly float64) float64

LightYearsToParsecs takes a float64 representing light years and returns the equivalent number of parsecs.

func MapGreekLetterName

func MapGreekLetterName(name string) string

MapGreekLetterName takes a Latin version of a Greek letter and returns the appropriate Unicode character for the Greek letter. Note: The 3-letter format for one set of Latin versions is from the digital version of the Yale Bright Star Catalog. It is present in HYG and AT-HYG for space reasons.

func ParsecPerYearToKmPerSec

func ParsecPerYearToKmPerSec(pcyr float64) float64

ParsecPerYearToKmPerSec converts parsecs/year to km/sec

func ParsecsToLightYears

func ParsecsToLightYears(pc float64) float64

ParsecsToLightYears takes a float64 representing parsecs and returns the equivalent number of light years.

func ScaledLuminosity

func ScaledLuminosity(star Star) float64

ScaledLuminosity calculates a quantity that is rigorously proportional to the apparent brightness (based on apparent visual magnitude), but much more quickly. This is primarily useful as a comparison function for sorts. Luminosity / distance^2 is proportional to apparent brightness, but much faster to calculate from the data stored in a Star object, because there are no logs or square roots to calculate.

func StarPassesFilter

func StarPassesFilter(star Star, sightline []float64, dircos float64, minScaledLuminosity float64) bool

StarPassesFilter compares the position of the star [star] to a given center / target vector [sightline] and to the minimum allowed brightness [minScaledLuminosity] for the data set. Angle comparison is via the minimum allowed cosine between the vectors [dircs].

func ToDegrees

func ToDegrees(rad float64) float64

ToDegrees takes a float64, understood to be radians, and returns its equivalent in decimal degrees.

func ToRadians

func ToRadians(deg float64) float64

ToRadians takes a float64, understood to be decimal degrees, and returns its equivalent in radians.

func TranslateStarList

func TranslateStarList(list []Star, origin CartesianVector)

TranslateStarList translates a list of Star objects [list] by the specified vector [origin].

Types

type CartesianVector

type CartesianVector []float64

CartesianVector represents coordinates in [x,y,z] components. It is of arbitrary length to work with gonum's "floats" library.

func DistanceDelta

func DistanceDelta(star Star, time float64) CartesianVector

DistanceDelta calculates the distance change for a given star object [star] over the specified time in years time. It returns a Cartesian vector with the relevant distance deltas in each component.

func EquatorialToGalactic

func EquatorialToGalactic(v1 CartesianVector) CartesianVector

EquatorialToGalactic takes a CartesianVector in equatorial coordinate components and turns it into the corresponding vector in galactic coordinate components.

Matrix coordinates taken from https://casper.astro.berkeley.edu/astrobaki/index.php/Coordinates. They are appropriate for equinox 2000, the equinox of HYG and AT-HYG data sets.

func PolarToCartesian

func PolarToCartesian(v1 SphericalVector) CartesianVector

PolarToCartesian converts a vector of polar coordinates [v1] into a vector of Cartesian coordinates. The conventions are the same as in CartesianToEquatorial.

type ConstellationDetails

type ConstellationDetails struct {
	Name          string         // The official name of the constellation, e.g. "Centaurus"
	Genitive      string         // The Latin genitive form used in star and object designations, e.g. "Alpha Centauri"
	Abbreviation  string         // The official 3-letter abbreviation of the constellation, e.g. "Cen"
	LabelLocation LabelLocations // This is a list because some constellations are large, and one (Serpens) is disjoint, so it's useful to be able to label multiple locations.
}

ConstellationDetails is a collection of useful information about a constellation.

type Constellations

type Constellations map[string]ConstellationDetails

Constellations is a map of constellation IDs (generally their abbreviations) to a ConstellationDetails object.

type EquatorialPosition

type EquatorialPosition [2]float64

EquatorialPosition represents the right ascension and declination of a location; this is usually best for 2D operations. For 3D, use a SphericalVector.

func GetLabelLocationsForConstellation

func GetLabelLocationsForConstellation(abbreviation string) []EquatorialPosition

GetLabelLocationsForConstellation gets a list of one or more locations suggested for labeling the supplied constellation abbreviation [abbreviation].

type LabelLocations

type LabelLocations []EquatorialPosition

LabelLocations is a list of right ascension/declination pairs (in decimal hours + decimal degrees) representing the constellation's general location(s) in the sky.

type SphericalVector

type SphericalVector []float64

SphericalVector represents coordinates in terms of [r, theta, phi].

func CartesianToEquatorial

func CartesianToEquatorial(v1 CartesianVector) SphericalVector

CartesianToEquatorial converts a 3-vector [v1] of Cartesian coordinates to a form similar to Earth-based equatorial coordinates in degrees. (right ascension and declination both in degrees, radial distance in the same units as the original Cartesian coordinates) If you need hours of the RA-like coordinate, divide v2[0] by 15.

func CartesianToPolar

func CartesianToPolar(v1 CartesianVector) SphericalVector

CartesianToPolar turns a 3-vector of Cartesian coordinates [v1] into polar coordinates in radians. Convention: theta-phi-r, where:

1) theta is the angle in the xy plane, range 0 to 2*pi, theta == 0 when x > 0 and y = 0

2) phi is the angle above or below the xy plane, range +/- pi/2

3) r is the total vector length

type Star

type Star struct {
	ID            int              `json:"id"`            // ID is the primary key from a source DB, such as AT-HYG.
	Position      CartesianVector  `json:"position"`      // 3-vector of Cartesian coordinates in parsecs. Can be freely translated to any origin to calculate distance, apparent magnitude, etc. from that location.
	Velocity      CartesianVector  `json:"velocity"`      // 3-vector of Cartesian velocities (same coordinate system as Position) in parsecs/year.
	Designations  StarDesignations `json:"designations"`  // All the known designations available for this star among the options in a StarDesignations type.
	Name          string           `json:"name"`          // A "canonicalized" version of the star's name, typically consisting of 2 widely-used IDs. Usually in order proper name, Bayer, Flamsteed, smaller catalog IDs (e.g. HR, HIP), larger catalog IDs (e.g. TYC, Gaia)
	AbsoluteMag   float64          `json:"absoluteMag"`   // Absolute visual magnitude (expected to be Johnson V or something very close to it, e.g. VT for Tycho-2 catalog entries)
	Spectrum      string           `json:"spectrum"`      // MK spectral type, when known
	Constellation string           `json:"constellation"` // Standard 3-letter constellation abbreviation (e.g. "Ori", "UMa")
	Luminosity    float64          `json:"luminosity"`    // Absolute brightness as multiple of Sun's. Optional, for convenience, if desired; absolute magnitude + distance carry equivalent information.
}

Star defines a star in sufficient detail for plotting and reporting, including position, velocity, brightness, and various catalog names and IDs.

func CloneStar

func CloneStar(originalStar Star) Star

CloneStar returns a deep (no retained references) copy of the specified star data object [originalStar].

func CreateStarFromAthygRecord

func CreateStarFromAthygRecord(record []string) (*Star, error)

CreateStarFromAthygRecord() creates a standard Star object from data in a standard AT-HYG database record [record]. Note: this assumes AT-HYG v2.2 or later, which has the velocities + spectrum data.

func GetAthygStarByName

func GetAthygStarByName(athygStars []Star, athygIndex map[string]int, name string) *Star

GetAthygStarByName looks up the name or designation [name] in an index of star IDs to names [athygIndex] and finds the matching star in [athygStars]. If a match is found, the full Star object is returned. Otherwise, an empty record with a placeholder ID is returned.

func GetStarByID

func GetStarByID(stars []Star, lookupID int) *Star

GetStarByID looks in a *sorted* list of Star objects [stars] and does a binary search to find the one matching the supplied ID [lookupID]. The sort has to be an ascending sort on the "ID" field/property.

It returns a reference to the Star object found, or a placeholder Star object with no physically relevant data and an invalid ID if not found.

func GetViewToTargetStar

func GetViewToTargetStar(list []Star, listConfig StarListConfig, concurrency int, subset int) []Star

GetViewToTargetStar requests a list of Star objects meeting specific criteria as defined in listConfig, such as location in space, direction or object looking towards, and the minimum allowed brightness (as seen from the location specified).

Under the hood, it invokes TranslateStarVectorListSubset. GetViewToTargetStar is *generally* the function you wish to use in an application using this module.

[concurrency] and [subset] enable concurrent computations. [concurrency] is the number of concurrent routines, and [subset] is the ID of the subset being processed (from 0 to [concurrency]-1). Use 1 and 0 respectively for non-concurrent (single process) operation.

func ReadAthygData

func ReadAthygData(title string) ([]Star, error)

ReadAthygData loads the AT-HYG data from the file name+path given by [title] into the usual data structure of Star objects.

func SelfTranslateStar

func SelfTranslateStar(star Star, time float64) Star

SelfTranslateStar creates a copy of [star1] in the position it has time years before or after the chart epoch.

This is functionally equivalent to TranslateStar(star1, star2, time) when star2 represents the Sun, but simpler.

func TranslateStar

func TranslateStar(star1 Star, star2 Star, time float64) Star

TranslateStar creates a copy of [star1] with position and velocity values as seen from [star2], at a time time years before or after the epoch.

func TranslateStarVectorListSubset

func TranslateStarVectorListSubset(list []Star, viewpoint Star, sightline CartesianVector, angle float64, magnitude float64, time float64, concurrency int, subset int) []Star

TranslateStarVectorListSubset takes a list of Star objects [list], and computes a subset of star objects that pass certain criteria. The core criteria are: (1) positions are calculated with the star [viewpoint] at the center at a time time years before (negative) or after (positive) the application epoch; (2) all valid positions are within [angle] radians from the target vector [sightline], and (3) the calculated stars have an apparent magnitude brighter than [magnitude].

Computational concurrency level [concurrency] and concurrent subset ID [subset] can be specified to enable concurrent calculations. For non-concurrent ones, use concurrency=1, subset=0.

type StarDesignations

type StarDesignations struct {
	Gaia       int64  `json:"gaia"`       // Always Gaia DR3 ID in AT-HYG v2.x and v3.x.
	Tycho      string `json:"tycho"`      // Always Tycho-2 ID in AT-HYG.
	HIP        int    `json:"hip"`        // The HIPPARCOS ID number from HYG or AT-HYG.
	HD         int    `json:"hd"`         // The Henry Draper ID number from HYG or AT-HYG.
	HR         int    `json:"hr"`         // The Harvard Revised number from HYG, same as the ID number for Yale Bright Star Catalog objects.
	Gliese     string `json:"gliese"`     // The Gliese (Gl) or Gliese-Jahreiss (GJ) catalog ID from HYG. Unlike HIP, HD, and HR, normally expected to contain a prefix ("Gl" or "GJ") to the actual ID.
	Bayer      string `json:"bayer"`      // A Latinized representation of the Greek letter from the Bayer catalog designation from HYG. Can be subscripted, represented with a dash as, e.g., "Pi-1".
	Flamsteed  string `json:"flamsteed"`  // The Flamsteed number for the star.
	ProperName string `json:"properName"` // Proper name of the star, if known
}

StarDesignations is a collection of common historical and modern names and designations for a given star.

type StarListConfig

type StarListConfig struct {
	From      Star    // Star object that is the position origin for the dataset.
	To        Star    // Star object at the center of the charted area in a chart.
	Angle     float64 // The maximum angle allowed between the vector to the "To" coordinate and any stars in the list being generated.
	Magnitude float64 // The faintest (highest numerical value) *apparent* visual magnitude allowed for stars in the list being generated.
	Time      float64 // The time, in years, before (negative) or after (positive) the epoch used for star data. The AT-HYG epoch in current versions (v2.0 +) is J2000.0.

}

StarListConfig is a collection of data needed to get a selected list of Star objects as a dataset.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL