Skip to content
This repository has been archived by the owner on Oct 21, 2024. It is now read-only.

Commit

Permalink
Move is_night to Orbit class
Browse files Browse the repository at this point in the history
  • Loading branch information
lpsinger committed Apr 29, 2021
1 parent 2c8992d commit 8b9b094
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
18 changes: 0 additions & 18 deletions dorado/scheduling/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
from astropy_healpix import HEALPix
import numpy as np

from .constraints import OrbitNightConstraint


class SurveyModel():
def __init__(self,
Expand Down Expand Up @@ -49,22 +47,6 @@ def __init__(self,
(self.number_of_orbits * self.mission.orbit.period /
self.time_step_duration).to_value(u.dimensionless_unscaled))

def is_night(self, time):
"""Determine if the spacecraft is in orbit night.
Parameters
----------
time : :class:`astropy.time.Time`
The time of the observation.
Returns
-------
bool, :class:`np.ndarray`
True when the spacecraft is in orbit night, False otherwise.
"""
return OrbitNightConstraint().compute_constraint(
time, Observer(self.mission.orbit(time).earth_location))

def _observable(self, time, location):
return is_event_observable(
self.mission.constraints,
Expand Down
19 changes: 19 additions & 0 deletions dorado/scheduling/orbit.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@
# SPDX-License-Identifier: NASA-1.3
#
"""Spacecraft orbit."""
from astroplan import Observer
from astropy.coordinates import SkyCoord, TEME
from astropy import units as u
from astropy.utils.data import get_readable_fileobj
import numpy as np
from sgp4.api import Satrec, SGP4_ERRORS

from .constraints import OrbitNightConstraint

__all__ = ('Orbit',)


Expand Down Expand Up @@ -110,3 +113,19 @@ def __call__(self, time):
else:
coord = coord[0]
return coord

def is_night(self, time):
"""Determine if the spacecraft is in orbit night.
Parameters
----------
time : :class:`astropy.time.Time`
The time of the observation.
Returns
-------
bool, :class:`np.ndarray`
True when the spacecraft is in orbit night, False otherwise.
"""
return OrbitNightConstraint().compute_constraint(
time, Observer(self(time).earth_location))

0 comments on commit 8b9b094

Please sign in to comment.