-
Notifications
You must be signed in to change notification settings - Fork 5
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 #21 from desihub/refactorI
Re-added avoidobject, with the option to use the JPL dependent versio…
- Loading branch information
Showing
8 changed files
with
223 additions
and
100 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
__version__ = '0.1.1' | ||
__version__ = '0.2.0' | ||
|
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,98 @@ | ||
import ephem | ||
from datetime import datetime | ||
import numpy as np | ||
from surveysim.kpno import mayall | ||
|
||
MIN_VENUS_SEP = np.radians(2.0) | ||
MIN_MARS_SEP = np.radians(2.0) | ||
MIN_JUPITER_SEP = np.radians(2.0) | ||
MIN_SATURN_SEP = np.radians(2.0) | ||
MIN_NEPTUNE_SEP = np.radians(2.0) | ||
MIN_URANUS_SEP = np.radians(2.0) | ||
MIN_CERES_SEP = np.radians(2.0) | ||
|
||
def avoidObject(datetime, ra0, dec0): | ||
""" | ||
Checks whether all the objects on the list are far enough away from | ||
the input coordinates. | ||
The current list has: Venus, Mars, Jupiter, Saturn, Neptune, Uranus; | ||
the Moon is treated separately. | ||
Args: | ||
datetime: datetime object; should have timezone info | ||
ra0: float (apparent or observed, degrees) | ||
dec0: float (apparent or observed, degrees) | ||
Returns: | ||
bool, True if all objects on the list are far enough away | ||
""" | ||
|
||
ra = np.radians(ra0) | ||
dec = np.radians(dec0) | ||
|
||
dt = ephem.Date(datetime.datetime) | ||
gatech = ephem.Observer() | ||
gatech.lon, gatech.lat = np.radians(mayall.west_lon_deg), np.radians(mayall.lat_deg) | ||
gatech.date = dt | ||
gatech.epoch = dt | ||
|
||
venus = ephem.Venus() | ||
venus.compute(gatech) | ||
if ephem.separation(venus, (ra, dec)) < MIN_VENUS_SEP: | ||
return False | ||
mars = ephem.Mars() | ||
mars.compute(gatech) | ||
if ephem.separation(mars, (ra, dec)) < MIN_MARS_SEP: | ||
return False | ||
#ceres = ephem.Ceres() | ||
#ceres.compute(gatech) | ||
#if ephem.separation(ceres, (ra, dec)) < MIN_CERES_SEP: | ||
# return False | ||
jupiter = ephem.Jupiter() | ||
jupiter.compute(gatech) | ||
if ephem.separation(jupiter, (ra, dec)) < MIN_JUPITER_SEP: | ||
return False | ||
saturn = ephem.Saturn() | ||
saturn.compute(gatech) | ||
if ephem.separation(saturn, (ra, dec)) < MIN_SATURN_SEP: | ||
return False | ||
neptune = ephem.Neptune() | ||
neptune.compute(gatech) | ||
if ephem.separation(neptune, (ra, dec)) < MIN_NEPTUNE_SEP: | ||
return False | ||
uranus = ephem.Uranus() | ||
uranus.compute(gatech) | ||
if ephem.separation(uranus, (ra, dec)) < MIN_URANUS_SEP: | ||
return False | ||
|
||
# If still here, return True | ||
return True | ||
|
||
def moonLoc (datetime, ra0, dec0): | ||
""" | ||
Returns the distance to the Moon if RA and DEC as well as alt, az. | ||
Args: | ||
datetime: datetime object; should have timezone info | ||
ra0: float (apparent or observed, degrees) | ||
dec0: float (apparent or observed, degrees) | ||
Returns: | ||
float, distance from the Moon (degrees) | ||
float, Moon altitude (degrees) | ||
float, Moon azimuth (degrees) | ||
""" | ||
|
||
dt = ephem.Date(datetime.datetime) | ||
gatech = ephem.Observer() | ||
gatech.lon, gatech.lat = np.radians(mayall.west_lon_deg), np.radians(mayall.lat_deg) | ||
gatech.date = dt | ||
gatech.epoch = dt | ||
|
||
moon = ephem.Moon() | ||
moon.compute(gatech) | ||
ra = np.radians(ra0) | ||
dec = np.radians(dec0) | ||
moondist = ephem.separation(moon, (ra, dec)) | ||
|
||
return np.degrees(moondist), np.degrees((moon.alt)), np.degrees((moon.az)) |
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
Oops, something went wrong.