Giter VIP home page Giter VIP logo

thor's Introduction

banner

THOR

Tracklet-less Heliocentric Orbit Recovery

Python 3.9+ License DOI
docker - Build, Lint, and Test conda - Build, Lint, and Test pip - Build, Lint, Test, and Coverage
pre-commit Coverage Status Docker Pulls
Anaconda-Server Badge Anaconda-Server Badge Anaconda-Server Badge

Warning: THOR is still in very active development.

The latest "stable" version is v1.2. The code on the main branch is currently being used to develop THOR v2.0 and is not guaranteed to be stable. We anticipate that v2.0 will be the one most useful to the community and we aim for it to be released by the end of 2023. THOR v2.0 is a complete re-write of the THOR code primarily designed to enable it for use as a service on the Asteroid, Discovery, Analysis and Mapping (ADAM) platform. The primary goal of v2.0 is to enable THOR to work at scale on many small cloud-hosted VMs. The secondary goal of v2.0 is to add changes that will work towards enabling the linking of NEOs (THOR is currently configured to work on the Main Belt and outwards).

Installation

The corresponding notebook repository can be found at: https://github.com/moeyensj/thor_notebooks

The following installation paths are available:
Anaconda
Docker
Source

Anaconda

thor can be downloaded directly from anaconda:
conda install -c moeyensj thor

Or, if preferred, installed into its own environment via:
conda create -n thor_py38 -c moeyensj thor python=3.8

Docker

A Docker container with the latest version of the code can be pulled using:

docker pull moeyensj/thor:latest

To run the container:

docker run -it moeyensj/thor:latest

The THOR code is installed the /projects directory, and is by default also installed in the container's Python installation. To access the code in Python:

(base) root@202110177eee:/# python
Python 3.6.9 |Anaconda, Inc.| (default, Jul 30 2019, 19:07:31)
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import thor
>>>

Source

Clone this repository using either ssh or https. Once cloned and downloaded, cd into the repository.

To install THOR in its own conda enviroment please do the following:

conda create -n thor_py38 -c defaults -c conda-forge -c astropy -c moeyensj --file requirements.txt python=3.8

Or, to install THOR in a pre-existing conda environment called env:

conda activate env
conda install -c defaults -c conda-forge -c astropy -c moeyensj --file requirements.txt

Once pre-requisites have been installed using either one of the options above, then:

python setup.py install

Or, if you are actively planning to develop or contribute to THOR, then:

python setup.py develop --no-deps

You should now be able to start Python and import THOR.

┌─(thor_py38)[moeyensj][±][main ✓][~/projects/thor]
└─▪ python
Python 3.8.8 (default, Apr 13 2021, 19:58:26)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import thor
>>>

If you would like to run Jupyter Notebook or Juptyter Lab with THOR please see the installation instructions in the THOR notebooks repository.

thor's People

Contributors

akoumjian avatar mjuric avatar moeyensj avatar spenczar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

thor's Issues

Add testing and packaging for macOS and Windows

Add/update GitHub workflows:

  • Update conda package workflow to build and test on macOS
  • Update conda package workflow to build and test on Windows
  • Update conda publishing workflow to build and publish package on macOS
  • Update conda publishing workflow to build and publish package on Windows

worth adding clarification in README.md

Worth mentioning that docker run -it moeyensj/thor:latest opens a virtual machine, it doesn't run the thor code yet (for newbies in docker like me step-by-step is pretty useful :)

Add astropy.time support for all main user-facing functions

Agreeing on time scales is a persistent issue for astronomers: requiring all times to be passed as astropy Time objects should prevent most major issues.

Internally, all orbits should be propagated with the TDB scale, all ephemeris could be returned in UTC.

IOD observation combinations bottleneck

The default IOD process will iterate through all combinations of three observations until a combination of three meets the reduced chi^2 threshold, this process ignores the number of outliers set by the contamination percentage parameter. As a consequence, for erroneous clusters with many observations, IOD can spend an inordinate amount of time iterating through combinations even though it already tried more combinations than the number of outliers should have allowed.

Add attribution and precovery

Given a newer catalogue of orbits and a set of observations, THOR should have the ability to update associations between observations and orbits.

Add pip build workflows

A recent attempt at installing THOR with pip failed due to missing requirements in the setup.cfg (see: B612-Asteroid-Institute/thorctl#34). This calls for a GH workflow to test pip installs. We can pull openorb from conda and then install the rest of the packages with pip.

Find observers heliocentric position at user-given epoch or epochs

Not all observations will come with the observer's heliocentric location, we need code that can get these position vectors.

Naively, we could use spicepy but to avoid pulling in more dependencies we can also use oorb and generate an ephemeris for a sample asteroid and from there pull the observer's position vector.

Make internal notation consistent

We need to re-standardize internal notation before the code gets to a stage where it will be harder to do so.

Propositon (following Milani et al. 2008):
r : heliocentric position vector in AU
q : heliocentric position vector of the observer in AU
rho : target to observer distance vector in AU
t : time in units of MJD

A suffix of _mag appended to a vector indicates the magnitude. A suffix of _hat indicates a unit vector.

Write runIOD function

Once we have the IOD functions working, we need an integration function that drives running IOD on clusters and can handle some of the IO corner cases, particularly, how to deal with partial clusters.

This issue is blocked by #6.

Support upgrades to DEXXX planetary ephemerides

JPL's transition to DE44X has lead to the current iteration of unit tests failing since they rely on data products tied to the DE43X series of planetary ephemerides. Unit tests currently rely heavily on JPL's Horizons service (exposed through astroquery) and so are not static since the underlying JPL data products can change. In terms of reproducibility, unit tests should be upgraded to rely on a static snapshot of the data products provided through the astroquery interface. A second set of tests could be added to test the code as JPL data products are updated to the latest and greatest.

To accomplish this I think we will need to:

  • Upgrade the constants class to have versions tied to the DEXXX ephemerides
  • Upgrade the spice.py utilties to use the DEXXX class defined by the current constants class

We could also extract constants directly from the ephemeris files via spiceypy.

Add observations-to-orbits integration test

Pull state vectors from Horizons for a sample population of asteroids, simulated their observations, and use one test orbit per asteroid to recover the orbits. This should be a straightforward and simple test of the major pipeline components.

Velocity calculation

Gauss' method gives you an estimate of the topocentric distance (distance from minor planet to topocenter) at the time of the second observation. To get the initial orbit we need the velocity at that location. There are a variety of methods, but to begin with lets add the Gibbs and Herrick+Gibbs methods.

Add constants.py

We should add a constants class that stores all relevant constants as opposed to relying on those provided by astropy.

Command-line Interface

THOR needs a command-line interface that exposes more of its key functions.
Something like python runTHOR.py --task=link --inputs_dir={directory} as suggested by @spenczar .

Where task should probably be some of the following:

  • link (run the full pipeline)
  • propagate (propagate orbits to a desired time)
  • ephemeris (generate ephemerides for an observer)
  • iod
  • od
  • attribution
  • test_orbits (find/create test orbits)

Add probabilistic residuals

Residuals on the sky-plane should be calculated probabilistically. In the absence of a covariance matrix, a covariance matrix can be created using the RA and Dec sigmas. Once a covariance matrix is calculated, we can then proceed to calculate the Mahalanobis distance and the subsequent probability that two coordinates belong to the same distribution (or same object..).

Add initial orbit determination

An implementation of Gauss' method with Herrick+Gibbs or Gibbs to determine the velocity needs to be added so we can validate clusters on the fly.

This also requires quality of fit calculations using ephemeris generation (residuals, chi2, etc..).

Improve ray usage throughout pipeline

ray usage throughout THOR is not heavily tested and likely sub-optimal. With THOR's deployment on GCP we need to identify bottlenecks and areas of improvement so we can fully utilize the cores that are available to us.

Small logger issue

Hey @moeyensj 🙂 It looks like there's maybe a small issue with the logger when generating ephemerides times out?

For reference I am currently using v1.1 of Thor. Here's the most relevant part of the traceback and I'll copy the whole thing below.

File "/astro/users/tomwagg/.conda/envs/neocp/lib/python3.9/site-packages/thor/backend/backend.py", line 61, in ephemeris_worker
    logger.CRITICAL("Ephemeris generation timed out on orbit IDs (showing first 5): {}".format(orbits.ids[:5]))
AttributeError: 'Logger' object has no attribute 'CRITICAL'

Let me know if you need more info. Whole trackback below

---------------------------------------------------------------------------
RemoteTraceback                           Traceback (most recent call last)
RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/astro/users/tomwagg/.conda/envs/neocp/lib/python3.9/site-packages/thor/backend/backend.py", line 59, in ephemeris_worker
    ephemeris = backend._generateEphemeris(orbits, observers)
  File "/astro/users/tomwagg/.conda/envs/neocp/lib/python3.9/site-packages/thor/backend/pyoorb.py", line 463, in _generateEphemeris
    ephemeris, err = oo.pyoorb.oorb_ephemeris_full(
  File "/astro/users/tomwagg/.conda/envs/neocp/lib/python3.9/site-packages/thor/backend/backend.py", line 32, in handle_timeout
    raise TimeoutError(self.error_message)
TimeoutError: Timeout

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/astro/users/tomwagg/.conda/envs/neocp/lib/python3.9/multiprocessing/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
  File "/astro/users/tomwagg/.conda/envs/neocp/lib/python3.9/multiprocessing/pool.py", line 51, in starmapstar
    return list(itertools.starmap(args[0], args[1]))
  File "/astro/users/tomwagg/.conda/envs/neocp/lib/python3.9/site-packages/thor/backend/backend.py", line 61, in ephemeris_worker
    logger.CRITICAL("Ephemeris generation timed out on orbit IDs (showing first 5): {}".format(orbits.ids[:5]))
AttributeError: 'Logger' object has no attribute 'CRITICAL'
"""

Improve configuration handling

The runTHOR function takes configuration dictionaries for the different pipeline components and then saves those dictionaries into a config.yaml. The config class should ideally be improved to support a toYaml and fromYaml class method, and also support checking for configuration equality.

Add a .dockerignore

Hi!

Congrats for thor! Learned about it from HackerNews, and was surprised by the quality of the code! 👏

I think a .dockerignore file could be helpful, to avoid including unnecessary files in the build context.

Refs:

I tried to quickly run thor using the Docker image, but stopped it when the last layer started downloading 1.3 GB 😅 Will leave it for when I'm connected to $work's network to save my bandwidth.

Cheers
Bruno

Add observations to ADES utility

Once potential linkages or potential attributions have been found they need to be submittable to the MPC. This involves writing an ADES converter and curl submission utility.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.