Package: astro-aleph
AlephAleph is a fast ephemeris producer joiningastropyandreboundwith orbital parameters fromMPC'sMPCORB.DATor Lowell'sastorb.dat. It allows you to get multi-epoch ephemeris of any asteroid in the catalogue or single-epoch ephemeris ofallasteroids in a given field of view.You can choose if ephemeris are calculated using the simple 2-Body equations (fast but not very accurate) or integrating the N-Body problem including the Sun and the planets with their masses and each asteroid as massless particles (much more accurate but more time expensive). To speed up the ephemeris calculation of so many bodies, almost all functions allows parallel integrations.InstalationYou can clone (or download) this repository and install it from there:git clone https://github.com/josepenaz/ephs.git
cd ephs
python3 setup.py installYou can also install it usingpipfrom the cloned repository:git clone https://github.com/josepenaz/ephs.git
cd ephs
python3 -m pip install --upgrade pip
python3 -m pip install --upgrade build
python3 -m build
python3 -m pip install dists aleph-X.X.tar.gzGetting started - DataBase classThe most basic class in Aleph isDataBase.OrbParamswhich reads and saves an orbital parameter catalogue. By default, it will try to readMPCORB.DAT. The first time you start anOrbParamsobject, it will raise an error since the catalogue hasn't been downloaded. To avoid this, you can setupdate=Trueand it will download the catalogue and save it in the Aleph's directory:from aleph import DataBase
orbs = DataBase.OrbParams(update=True)Useupdate=Trueonly when you want to download the catalogue. Once it is download and saved, it will automatically read it each time you initialize anOrbParamsobject. Do not useupdate=Trueunless you want to download it again.
If you want to use another version of MPCORB.DAT, you can give give the path to the file you want to open:orbs = DataBase.OrbParams(filename='path/MPCORB.DAT')OrbParamscan also read Lowell'sastorb.datby settingservice='Lowell'. Since FTP access to astorb.dat is not allowed, you must download it manually and specify the path to the file:orbs = DataBase.OrbParams(service='Lowell', filename='path/astorb.dat')Once you have loaded the catalogue withOrbParamsyou can access to all asteroid's orbital parameters with theastsattribute, which is a list of dictionaries. Each dictionary saves the orbital parameters of each asteroid. For example, you can access to Ceres (the first body of the catalogue):ceres = orbs.asts[0]You also can access to the epochs of the asteroids' mean anomaly with the attributedicc_epochs_M. That atribute is important because it tells you how much the orbits need to be integrated to get the ephemeris (the integration starts at that epoch and ends at the epoch you want the ephemeris to be).Getting EphemerisTo look for all the asteroids that are visible in a given field of view you first have to create aQueryinstance:from aleph.Query import Query
q = Query()By default, it will load the MPCORB.DAT database. If you want to load the astorb.dat catalogue, you need to setservice='Lowell'and provide the catalogue itself withfilename='path/astorb.dat':from aleph.Query import Query
q = Query(service='Lowell', filename='path/astorb.dat')Virtual Observatory: Using the cataloguesWith theQueryinstance initialized you canqueryfor the ephemeris you want. In the next example, you ask for the asteroids in a field of 0.5 degrees of radius centered in the equatorial coordinates (0.5, 0.5) degrees, observed in July 25th, 2020 at Palomar Observatory. And to speed up things, we tellQueryto compute the ephemeris in 5 parallel process:from astropy.coordinates import SkyCoord, EarthLocation
from astropy.time import Time
from astropy import units as u
 
palomar = EarthLocation.of_site('Palomar')
field_center = SkyCoord(0.5*u.deg, 0.5*u.deg)
field_radius = 0.5*u.deg
epoch = Time('2020-07-25')

ephs = q.query_mixed_cat(field_center, field_radius, epoch=epoch, observer=palomar, njobs=5)The functionquery_mixed_catstarts integrating using the equations of the 2-Body problem, it takes all bodies fallen in a similar but wider area than the field of view and integrates them along with the 8 planets of our Solar System (this integration is performed with theIAS15integrator ofrebound).You can use the 2-Body or the N-Body integrations just by using thequery_2b_catandquery_nb_catfunctions respectively.Creating your own Data Base of integrated orbitsLets say you need many ephemeris far from the mean anomaly epoch of your database. This means that for every time you run aq.query_mixed_cator aq.query_nb_catall asteroids will be integrated again and again the same period of time till the ephemeris epoch each time you call those methods. So the idea is you integrate all asteroids only once to an epoch close to the epoch you need to query, so every time you make a query the integrations will be much shorter. This can only be done using the astorb.dat catalogue. In the next example you will create the database (which is done just by saving the orbital parameters of the catalogue) and then you will integrate all bodies and save theirstates(positions and velocities) at a far epoch. Finally, you can compute and save the orbital parameters that corresponds to the states you just compute.from astropy.time import Time
from aleph import DataBase

aleph = DataBase.OrbParams(service='Lowell', filename='path/astorb.dat')
aleph.create_states_database() # You can provide 'sqlfile' with
                               # the name of the file where you
                               # want to save the database.

# Lets say you want to integrate till two epochs:
integ_epochs = Time(['2022-01-02','2022-06-02']).jd # You need to provide the Julian Day
aleph.adding_states_into_db(integ_epochs, njobs=5)  # Remember to provide 'sqlfile' if
                                                    # you use it before
aleph.adding_params_into_db()    # Again, remember 'sqlfile' if you use it beforeThat process can take a long time, but it will greatly increase the execution time of any ephemeride queried around the integrated epochs.Using your own Data Base of integrated orbitsOnce the database is created, you can query for ephemeris using thequery_2b_db,query_nb_dbandquery_mixed_dbfunctions (that work in the same manner than the functions above). Remember that those functions work only with astorb.dat:from astropy.coordinates import SkyCoord, EarthLocation
from astropy.time import Time
from astropy import units as u
from aleph.Query import Query

q = Query(service='Lowell', filename='path/astorb.dat')
 
palomar = EarthLocation.of_site('Palomar')
field_center = SkyCoord(0.5*u.deg, 0.5*u.deg)
field_radius = 0.5*u.deg
epochs = Time(['2022-01-01','2022-01-02','2022-01-03',
               '2022-06-01','2022-06-02','2022-06-03'])

all_ephs = []
for epoch in epochs:
    ephs = q.query_mixed_cat(field_center, field_radius, epoch=epoch, observer=palomar, njobs=5)
    all_ephs.append(ephs)Getting multi-epoch ephemeris of a single bodyYou can get ephemeris of a single body at as many epochs you want. This ephemeris are computed integrating the N-Body problem (Sun, planets and the body).from astropy.coordinates import SkyCoord, EarthLocation
from astropy.time import Time
from astropy import units as u
from aleph.Query import Query

q = Query(service='Lowell', filename='path/astorb.dat')
 
palomar = EarthLocation.of_site('Palomar')
epochs = Time(['2022-01-01','2022-01-02','2022-01-03',
               '2022-06-01','2022-06-02','2022-06-03'])

ephs = q.asteph(0, epochs=epochs, observer=palomar)To use this function, you need to create an Aleph database (see previous section), although you do not need to integrate all the asteroids to any epoch (runningaleph.create_states_database()is enough).