Skip to content

Commit edaa3d1

Browse files
authored
Merge pull request #17 from moeyensj/gauss
Initial Orbit Determination
2 parents 119ad1a + 68d1f0b commit edaa3d1

37 files changed

+1728
-371
lines changed

requirements.txt

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
numpy
22
scipy
33
astropy
4+
astroquery
45
scikit-learn
56
matplotlib
67
seaborn
@@ -10,6 +11,8 @@ plotly
1011
pyyaml
1112
openorb
1213
ipykernel
14+
numba
15+
spiceypy
1316
pytest
1417
pytest-cov
1518
coveralls

requirements_travis.txt

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
numpy
22
scipy
33
astropy
4+
astroquery
45
scikit-learn
56
matplotlib
67
seaborn
@@ -9,6 +10,8 @@ fortranformat
910
plotly
1011
pyyaml
1112
openorb
13+
numba
14+
spiceypy
1215
pytest
1316
pytest-cov<2.6.0
1417
coveralls

thor/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from .config import *
2+
from .constants import *
23
from .data_processing import *
4+
from .utils import *
35
from .io import *
46
from .orbits import *
57
from .coordinates import *

thor/constants.py

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import numpy as np
2+
from astropy import units as u
3+
from astropy.constants import codata2014 as c
4+
5+
AU_TO_KM = 6.684587122268446e-09
6+
7+
class Constants:
8+
9+
# Speed of light: AU per day (173.14463267424034)
10+
C = c.c.to(u.au / u.d).value
11+
12+
# Gravitational constant: AU**3 / M_sun / d**2 (0.00029591220819207784)
13+
G = c.G.to(u.AU**3 / u.M_sun / u.d**2).value
14+
15+
# Solar Mass: M_sun (1.0)
16+
M_SUN = 1.0
17+
18+
# Earth Mass: M_sun (3.0034893488507934e-06)
19+
M_EARTH = u.M_earth.to(u.M_sun)
20+
21+
# Earth Equatorial Radius (6378.1363 km (DE431/DE430))
22+
R_EARTH = (6378.1363 * u.km).to(u.AU)
23+
24+
# Mean Obliquity at J2000: radians (0.40909280422232897)
25+
OBLIQUITY = (84381.448 * u.arcsecond).to(u.radian).value
26+
27+
# Transformation matrix from Equatorial J2000 to Ecliptic J2000
28+
TRANSFORM_EQ2EC = np.array([
29+
[1, 0, 0],
30+
[0, np.cos(OBLIQUITY), np.sin(OBLIQUITY)],
31+
[0, -np.sin(OBLIQUITY), np.cos(OBLIQUITY)
32+
]])
33+
34+
# Transformation matrix from Ecliptic J2000 to Equatorial J2000
35+
TRANSFORM_EC2EQ = TRANSFORM_EQ2EC.T

thor/coordinates/coordinate_transforms.py

+3-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
import numpy as np
22

3-
OBLIQUITY = np.radians(23.43928)
4-
TRANSFORM_EQ2EC = np.matrix([[1, 0, 0],
5-
[0, np.cos(OBLIQUITY), np.sin(OBLIQUITY)],
6-
[0, -np.sin(OBLIQUITY), np.cos(OBLIQUITY)]])
7-
TRANSFORM_EC2EQ = np.matrix([[1, 0, 0],
8-
[0, np.cos(OBLIQUITY), -np.sin(OBLIQUITY)],
9-
[0, np.sin(OBLIQUITY), np.cos(OBLIQUITY)]])
3+
from ..constants import Constants as c
104

5+
TRANSFORM_EQ2EC = c.TRANSFORM_EQ2EC
6+
TRANSFORM_EC2EQ = c.TRANSFORM_EC2EQ
117

128
__all__ = ["equatorialToEclipticCartesian",
139
"eclipticToEquatorialCartesian",

thor/main.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from .config import Config
1212
from .cell import Cell
1313
from .particle import TestParticle
14-
from .orbits import propagateOrbits
14+
from .orbits.propagate import propagateOrbits
1515
from .data_processing import findExposureTimes
1616
from .data_processing import grabLinkedDetections
1717
from .plotting import plotOrbitsFindable

thor/observatories/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from .codes import *

thor/observatories/codes.py

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import os
2+
3+
from ..utils import _downloadFile
4+
5+
__all__ = [
6+
"getMPCObsCodeFile",
7+
]
8+
9+
def getMPCObsCodeFile():
10+
"""
11+
Downloads the MPC Observatory Codes file. Checks if a newer version of the file exists online, if so,
12+
replaces the previously downloaded file if available.
13+
14+
Parameters
15+
----------
16+
None
17+
18+
Returns
19+
-------
20+
None
21+
"""
22+
obscodes = os.path.join(os.path.dirname(__file__), "data/ObsCodes.html")
23+
url = 'https://www.minorplanetcenter.net/iau/lists/ObsCodes.html'
24+
_downloadFile(obscodes, url, update=True)
25+
return
26+

thor/observatories/data/__init__.py

Whitespace-only changes.

thor/observatories/tests/__init__.py

Whitespace-only changes.
+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import os
2+
import filecmp
3+
import shutil
4+
5+
from ..codes import getMPCObsCodeFile
6+
7+
def test_getMPCOBSCodeFile():
8+
# Define some file paths, we expect only obscodes and obscodes_old to be affected
9+
# by any function call to getMPCObsCodeFile
10+
obscodes = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "data/ObsCodes.html"))
11+
obscodes_backup = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "data/ObsCodes_backup.html"))
12+
obscodes_test = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "data/.ObsCodes_test.html"))
13+
obscodes_old = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "data/ObsCodes.html_old"))
14+
15+
getMPCObsCodeFile()
16+
17+
# Lets check the file downloaded
18+
assert os.path.isfile(obscodes)
19+
20+
# Modify the file by removing the last 10 lines
21+
codes = open(obscodes, "r")
22+
lines = codes.readlines()
23+
lines = lines[:-10]
24+
codes.close()
25+
26+
# Write modified file to a new file
27+
testfile = open(obscodes_test, "w")
28+
testfile.writelines(lines)
29+
testfile.close()
30+
31+
# Rename the modified file to the file name expected by getMPCObsCodeFile
32+
# See if the function recognizes the change and as a result downloads the correct file again.
33+
os.rename(obscodes, obscodes_backup)
34+
shutil.copy(obscodes_test, obscodes)
35+
36+
getMPCObsCodeFile()
37+
38+
# Check if newly downloaded file is the same as the unmodified one, check that that modified one has been saved as
39+
# ObsCodes_old.html
40+
# (this will only fail in the unlikely chance that between the tests the MPC updated the MPC Obs Codes file)
41+
assert filecmp.cmp(obscodes, obscodes_backup)
42+
assert filecmp.cmp(obscodes_test, obscodes_old)
43+
44+
# Clean up files
45+
os.remove(obscodes_backup)
46+
os.remove(obscodes_old)
47+
os.remove(obscodes_test)
48+
os.remove(obscodes)

thor/orbits/__init__.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
from .pyoorb import *
1+
from .kepler import *
2+
from .propagate import *

thor/orbits/iod/__init__.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1+
from .gauss import *
2+
from .gibbs import *
13
from .herrick_gibbs import *
2-
from .gauss import *
4+
from .iod import *

0 commit comments

Comments
 (0)