-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from moeyensj/gauss
Initial Orbit Determination
- Loading branch information
Showing
37 changed files
with
1,728 additions
and
371 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import numpy as np | ||
from astropy import units as u | ||
from astropy.constants import codata2014 as c | ||
|
||
AU_TO_KM = 6.684587122268446e-09 | ||
|
||
class Constants: | ||
|
||
# Speed of light: AU per day (173.14463267424034) | ||
C = c.c.to(u.au / u.d).value | ||
|
||
# Gravitational constant: AU**3 / M_sun / d**2 (0.00029591220819207784) | ||
G = c.G.to(u.AU**3 / u.M_sun / u.d**2).value | ||
|
||
# Solar Mass: M_sun (1.0) | ||
M_SUN = 1.0 | ||
|
||
# Earth Mass: M_sun (3.0034893488507934e-06) | ||
M_EARTH = u.M_earth.to(u.M_sun) | ||
|
||
# Earth Equatorial Radius (6378.1363 km (DE431/DE430)) | ||
R_EARTH = (6378.1363 * u.km).to(u.AU) | ||
|
||
# Mean Obliquity at J2000: radians (0.40909280422232897) | ||
OBLIQUITY = (84381.448 * u.arcsecond).to(u.radian).value | ||
|
||
# Transformation matrix from Equatorial J2000 to Ecliptic J2000 | ||
TRANSFORM_EQ2EC = np.array([ | ||
[1, 0, 0], | ||
[0, np.cos(OBLIQUITY), np.sin(OBLIQUITY)], | ||
[0, -np.sin(OBLIQUITY), np.cos(OBLIQUITY) | ||
]]) | ||
|
||
# Transformation matrix from Ecliptic J2000 to Equatorial J2000 | ||
TRANSFORM_EC2EQ = TRANSFORM_EQ2EC.T |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .codes import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import os | ||
|
||
from ..utils import _downloadFile | ||
|
||
__all__ = [ | ||
"getMPCObsCodeFile", | ||
] | ||
|
||
def getMPCObsCodeFile(): | ||
""" | ||
Downloads the MPC Observatory Codes file. Checks if a newer version of the file exists online, if so, | ||
replaces the previously downloaded file if available. | ||
Parameters | ||
---------- | ||
None | ||
Returns | ||
------- | ||
None | ||
""" | ||
obscodes = os.path.join(os.path.dirname(__file__), "data/ObsCodes.html") | ||
url = 'https://www.minorplanetcenter.net/iau/lists/ObsCodes.html' | ||
_downloadFile(obscodes, url, update=True) | ||
return | ||
|
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import os | ||
import filecmp | ||
import shutil | ||
|
||
from ..codes import getMPCObsCodeFile | ||
|
||
def test_getMPCOBSCodeFile(): | ||
# Define some file paths, we expect only obscodes and obscodes_old to be affected | ||
# by any function call to getMPCObsCodeFile | ||
obscodes = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "data/ObsCodes.html")) | ||
obscodes_backup = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "data/ObsCodes_backup.html")) | ||
obscodes_test = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "data/.ObsCodes_test.html")) | ||
obscodes_old = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "data/ObsCodes.html_old")) | ||
|
||
getMPCObsCodeFile() | ||
|
||
# Lets check the file downloaded | ||
assert os.path.isfile(obscodes) | ||
|
||
# Modify the file by removing the last 10 lines | ||
codes = open(obscodes, "r") | ||
lines = codes.readlines() | ||
lines = lines[:-10] | ||
codes.close() | ||
|
||
# Write modified file to a new file | ||
testfile = open(obscodes_test, "w") | ||
testfile.writelines(lines) | ||
testfile.close() | ||
|
||
# Rename the modified file to the file name expected by getMPCObsCodeFile | ||
# See if the function recognizes the change and as a result downloads the correct file again. | ||
os.rename(obscodes, obscodes_backup) | ||
shutil.copy(obscodes_test, obscodes) | ||
|
||
getMPCObsCodeFile() | ||
|
||
# Check if newly downloaded file is the same as the unmodified one, check that that modified one has been saved as | ||
# ObsCodes_old.html | ||
# (this will only fail in the unlikely chance that between the tests the MPC updated the MPC Obs Codes file) | ||
assert filecmp.cmp(obscodes, obscodes_backup) | ||
assert filecmp.cmp(obscodes_test, obscodes_old) | ||
|
||
# Clean up files | ||
os.remove(obscodes_backup) | ||
os.remove(obscodes_old) | ||
os.remove(obscodes_test) | ||
os.remove(obscodes) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
from .pyoorb import * | ||
from .kepler import * | ||
from .propagate import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
from .gauss import * | ||
from .gibbs import * | ||
from .herrick_gibbs import * | ||
from .gauss import * | ||
from .iod import * |
Oops, something went wrong.