AstraLambda is a Common Lisp System for loading and analyzing GAIA DRX catalog data. The Catalog data can be acquired by exporting it from “Aladin” by selecting the downloaded plane, then clicking File → Export Planes. This system works with the TSV and CSV formatting. Also you can download the data directly from within the system by using the TAP-URL: https://gea.esac.esa.int/tap-server/tap/
Load the astra-lambda module into your LISP implementation which gives you access to the following features:
Constant variables:
+AU+ ;; 1 astronomical unit in meters
+LY+ ;; 1 light year in meters
+PC+ ;; 1 parsec in meters
+c+ ;; the speed of light in meters per second
+G+ ;; gravitational constantEquation Functions:
(dist-pc-from-parallax-mas milliarcsec) ;; calculates the distance in parsecs based on the given parallax in milliarcseconds (radians)
(dist-pc-from-parallax-as arcsec) ;; calculates the distance in parsecs based on the given parallax in arcseconds (radians)
(emission-max-wavelength temperature) ;; calculates the wavelength of the emissive maximum of a black body in µm from temperature in Kelvin
(magnitude-from-flux magnitude-control flux-1 flux-2) ;; calculates the magnitude of a star from its relative flux to a control star with known magnitude
(color-index magnitude-blue magnitude-red) ;; calculates the color index of a star from blue and red channel instrument; higher means redConversion Functions:
(parsec-to-lightyears parsecs) ;; converts a distance from parsecs to light years
(degrees-to-radians degree) ;; converts degrees to radians
(radians-to-degrees radians) ;; converts radians to degrees
(kelvin-to-celsius temperature) ;; converts kelvin to celsius
(celsius-to-kelvin temperature) ;; converts celsius to kelvin
(right-ascension-to-decimal-degrees hours minutes seconds) ;; converts right ascension into decimal degrees. seconds may be used with decimal point
(declination-to-decimal-degrees degree minutes seconds) ;; converts declination into decimal degrees. seconds may be used with decimal point
(convert-list-data-to-numbers input-list) ;; converts a list of catalog data from strings to numeric valuesCatalog Management:
(download-catalog tap-url
catalog-release
rectacension
declination
radius
export-format
output-filename) ;; fetches catalog data from given parameters and saves it to a specified file
(load-catalog-from-file filename) ;; loads catalog data from an aladin export file with csv or tsv extension and returns a list of the catalog data
(get-catalog-architecture catalog) ;; returns number of columns and rows as well as data field titles
(get-catalog-data-from-field catalog
field-name
&optional
selection) ;; returns a list from the data field in the catalog as strings. optionally add a selection
(isolate-data x-values
y-values
&key
x-minimum
x-maximum
y-minimum
y-maximum) ;; isolates the area specified by the x/y minima and maxima and returns a list each for x and y values
(select-data x-values
y-values
&key
x-minimum
x-maximum
y-minimum
y-maximum) ;; creates a selection list of the specified area to be used with a catalogExample: Downloading Catalog
;; inputs for the function: download-catalog for the Messier 4 globular cluster
;; tap-url :: https://gea.esac.esa.int/tap-server/tap/
;; catalog-release :: gaiadr2
;; rectacension :: 245.9
;; declination :: -26.5
;; radius :: 0.15
;; format :: csv
(astra-lambda:download-catalog "https://gea.esac.esa.int/tap-server/tap/"
"gaiadr2"
245.9
-26.5
0.15
"csv"
"./m4.csv")This will download the catalog data from the Gaia mission (data release 2) of the M4 globular cluster in a 0.15’ (minutes) cone as a csv (you can also use tsv) file and save it as m4.csv utilizing the following SQL-Query:
SELECT *
FROM gaiadr2.gaia_source
WHERE 1 = CONTAINS(POINT('ICRS',ra,dec),CIRCLE('ICRS',245.89675,-26.52575,0.5))
AND phot_g_mean_mag < 22.0Orbital Mechanics Functions
(2d-vector-magnitude input-vector) ;; returns the magnitude of a vector represented by a list
(orbit-µ parent-body-mass) ;; returns the standard gravitational parameter from the parent body mass
(orbit-h position-vector ;; returns the specific angular momentum
velocity-vector)
(orbit-p specific-angular-momentum ;; returns the semi latus rectum
standard-gravitational-parameter)
(orbit-epsilon velocity-magnitude ;; returns the specific orbital energy
distance-to-planet
standard-gravitational-parameter)
(orbit-hyperbolic-a standard-gravitational-parameter ;; returns the semi major axis in a hyperbolic orbit
specific-orbital-energy)
(orbit-a apoapsis-distance ;; returns the semi major axis in a eliptical orbit
periapsis-distance)
(orbit-e-vector position-vector ;; returns a the eccentricity vector from position- and velocity vectors
standard-gravitational-parameter)
(orbit-e-from-vector eccentricity-vector) ;; returns the eccentricity from the eccentricity vector
(orbit-omega eccentricity-vector) ;; returns the argument of periapsis
(orbit-v-radial velocity-vector ;; returns the radial velocity from the velocity- and position vectors
position-vector)
(orbit-true-anomaly semi-latus-rectum ;; returns the true anomaly
position-vector
eccentricity
radial-velocity)
(orbit-hyperbolic-anomaly eccentricity ;; returns the hyperbolic anomaly
true-anomaly)
(orbit-hyperbolic-ttrp semi-major-axis ;; returns the time to periapsis in seconds
standard-gravitational-parameter
eccentricity
hyperbolic-anomaly)
(orbit-r-periapsis semi-latus-rectum ;; returns the height of the periapsis in m from the gravity source.
eccentricity)
(orbit-v-periapsis standard-gravitational-parameter ;; returns the velocity at periapsis in m/s
height-of-periapsis
semi-major-axis)
(orbit-v-ciruclar standard-gravitational-parameter ;; returns the velocity of a circular orbit in m/s with an eccentricity of 0.0
height-of-target-orbit)Clone this repository to your quicklisp installation folder and load it via (ql:quickload “astra-lambda”) Just to be on the save side, go into the src/libcatload folder and rebuild the library.
$ cd ~/.quicklisp/local-projects/ # change this one, if you set the quicklisp installation to a different path
$ git clone https://github.com/dw0xaa55/astra-lambda
$ cd astra-lambda/src/libcatload
$ make
$ sbcl
* (ql:quickload "astra-lambda")- [-] add functions for orbital mechanics
- [ ] make a list with coordinates of common astronomical objects
- [ ] get rid of the download-catalog-ffi and translate it to LISP completely
- C. Huffenbach
I am a hobbyist programmer who likes playing around with computer languages and astronomy, so do not expect either elegant nor efficient code. Also there may be bugs. The equations should be correct though. That being said, feel free to modify the code base to your liking and have fun using it :> ~Happy Hacking