Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
WWGolay committed Dec 3, 2024
1 parent 019a3b2 commit b04965b
Show file tree
Hide file tree
Showing 14 changed files with 615 additions and 103 deletions.
11 changes: 4 additions & 7 deletions pyscope/telrun/airmass_condition.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


class AirmassCondition(BoundaryCondition):
def __init__(self, airmass_limit=3, formula="Schoenberg1929", weight=1, **kwargs):
def __init__(self, airmass_limit=3, formula="Schoenberg1929", weight=1):
"""
A condition that penalizes targets for higher airmass values up to a limit.
Expand Down Expand Up @@ -56,9 +56,6 @@ def __init__(self, airmass_limit=3, formula="Schoenberg1929", weight=1, **kwargs
weight : `float`, default : 1
The weight of the condition in the final score. The default is 1.
**kwargs : `dict`, default : {}
Additional keyword arguments to pass to the `~pyscope.telrun.BoundaryCondition` constructor for storage in the `~pyscope.telrun.BoundaryCondition.kwargs` attribute.
References
----------
.. [1] `Schoenberg, E. 1929. Theoretische Photometrie, Über die Extinktion des Lichtes in der Erdatmosphäre. In Handbuch der Astrophysik. Band II, erste Hälfte. Berlin: Springer. <https://ia904707.us.archive.org/25/items/in.ernet.dli.2015.377128/2015.377128.Handbuch-Der.pdf>`_
Expand All @@ -77,7 +74,7 @@ def __init__(self, airmass_limit=3, formula="Schoenberg1929", weight=1, **kwargs
"""
logger.debug("AirmassCondition(airmass_limit=%s, formula=%s, weight=%s)")
super().__init__(func=self._func, lqs_func=self._lqs_func, **kwargs)
super().__init__(func=self._func, lqs_func=self._lqs_func)

@classmethod
def from_string(self, string, airmass_limit=None, formula=None, weight=None):
Expand Down Expand Up @@ -114,7 +111,7 @@ def __str__(self):
logger.debug("AirmassCondition().__str__()")

@staticmethod
def _func(target, time, location, formula="Schoenberg1929", **kwargs):
def _func(target, time, location, formula="Schoenberg1929"):
"""
Calculate the airmass value for the target.
Expand All @@ -132,7 +129,7 @@ def _func(target, time, location, formula="Schoenberg1929", **kwargs):
logger.debug("AirmassCondition._func(target=%s)" % target)

@staticmethod
def _lqs_func(self, value, airmass_limit=3, **kwargs):
def _lqs_func(self, value, airmass_limit=3):
"""
Calculate the linear quality score for the airmass value.
Expand Down
61 changes: 61 additions & 0 deletions pyscope/telrun/celestialbody_condition.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import logging

from astropy import units as u

from .boundary_condition import BoundaryCondition

logger = logging.getLogger(__name__)


class CelestialBodyCondition(BoundaryCondition):
def __init__(
self,
body_name,
min_sep=0 * u.deg,
max_sep=180 * u.deg,
min_alt=-90 * u.deg,
max_alt=90 * u.deg,
score_type="boolean",
inclusive=True,
):
""" """
pass

@classmethod
def from_string(cls, string):
pass

def __str__(self):
pass

@staticmethod
def _func(self, target, observer, time):
pass

@staticmethod
def _lsq_func(self, value):
pass

@property
def min_sep(self):
pass

@property
def max_sep(self):
pass

@property
def min_alt(self):
pass

@property
def max_alt(self):
pass

@property
def score_type(self):
pass

@property
def inclusive(self):
pass
182 changes: 160 additions & 22 deletions pyscope/telrun/coord_condition.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ def __init__(
min_val=None,
max_val=None,
score_type="boolean",
inclusive=True,
ref_coord=None,
**kwargs,
):
"""
A restriction on the coordinates of the target viewed from a specific location
Expand Down Expand Up @@ -48,14 +48,17 @@ def __init__(
that returns 1 if the condition is met and 0 if it is not, commonly used for
determining if the source is above or below the horizon. The default is "boolean".
inclusive : `bool`, default : `True`
If `True`, the condition is inclusive, meaning that the target must be within
the specified range. If `False`, the condition is exclusive, meaning that the
target must be outside the specified range. Useful for excluding certain parts
of the sky where a mount may be in jeopardy.
ref_coord : `~astropy.coordinates.SkyCoord`, default : `None`
If `coord_type` is "radec" or "galactic", a user can specify a center value
and `min_val` and `max_val` will be interpreted as a minimum and maximum angular
separation of the target from the reference coordinate.
**kwargs : `dict`, default : {}
Additional keyword arguments to pass to the `~pyscope.telrun.BoundaryCondition` constructor.
"""
logger.debug(
"""
Expand All @@ -65,10 +68,18 @@ def __init__(
min_val=%s,
max_val=%s,
score_type=%s,
inclusive=%s,
ref_coord=%s,
kwargs=%s
)"""
% (coord_type, coord_idx, min_val, max_val, score_type, ref_coord, kwargs)
% (
coord_type,
coord_idx,
min_val,
max_val,
score_type,
inclusive,
ref_coord,
)
)

@classmethod
Expand All @@ -80,11 +91,12 @@ def from_string(
min_val=None,
max_val=None,
score_type=None,
inclusive=None,
ref_coord=None,
**kwargs,
):
"""
Create a `~pyscope.telrun.CoordinateCondition` or a `list` of `~pyscope.telrun.CoordinateCondition` objects from a `str` representation of a `~pyscope.telrun.CoordinateCondition`.
Create a `~pyscope.telrun.CoordinateCondition` or a `list` of `~pyscope.telrun.CoordinateCondition` objects from a `str`
representation of a `~pyscope.telrun.CoordinateCondition`.
All optional parameters are used to override the parameters extracted from the `str` representation.
Parameters
Expand All @@ -101,14 +113,23 @@ def from_string(
score_type : `str`, default : `None`
ref_coord : `~astropy.coordinates.SkyCoord`, default : `None`
inclusive : `bool`, default : `None`
**kwargs : `dict`, default : {}
ref_coord : `~astropy.coordinates.SkyCoord`, default : `None`
"""
logger.debug(
"CoordinateCondition.from_string(string=%s, coord_type=%s, coord_idx=%s, min_val=%s, max_val=%s, score_type=%s, kwargs=%s)"
% (string, coord_type, coord_idx, min_val, max_val, score_type, kwargs)
"CoordinateCondition.from_string(string=%s, coord_type=%s, coord_idx=%s, min_val=%s, max_val=%s, score_type=%s, inclusive=%s, ref_coord=%s)"
% (
string,
coord_type,
coord_idx,
min_val,
max_val,
score_type,
inclusive,
ref_coord,
)
)

def __str__(self):
Expand All @@ -124,33 +145,150 @@ def __str__(self):
logger.debug("CoordinateCondition().__str__()")

@staticmethod
def _func():
pass
def _func(self, target, time, location):
"""
Determine if the target meets the coordinate condition.
Parameters
----------
target : `~astropy.coordinates.SkyCoord`, required
The target to check.
time : `~astropy.time.Time`, required
The time of the observation.
location : `~astropy.coordinates.EarthLocation`, required
The location of the observer.
Returns
-------
`float` or `bool`
The score value of the target. If `score_type` is "linear", the score is a `float`
value between 0 and 1. If `score_type` is "boolean", the score is a `bool` value of
`True` if the target meets the condition and `False` if it does not.
"""
logger.debug(
"CoordinateCondition()._func(target=%s, time=%s, location=%s)"
% (target, time, location)
)

@staticmethod
def _lqs_func():
pass
def _lqs_func(self, value):
"""
Calculate the linear quality score for the coordinate value.
Parameters
----------
value : `float` or `bool`, required
Returns
-------
`float`
The linear quality score for the coordinate value.
"""
logger.debug("CoordinateCondition._lqs_func(value=%s)" % value)

@property
def coord_type(self):
pass
"""
The type of coordinate system to use. Options are "altaz" for altitude and azimuth, "radec" for right ascension
and declination, and "galactic" for galactic latitude and longitude.
Returns
-------
`str`
The type of coordinate system to use.
"""
logger.debug("CoordinateCondition().coord_type == %s" % self._coord_type)
return self._coord_type

@property
def coord_idx(self):
pass
"""
The index of the coordinate to use. The default is 0 for the first coordinate, e.g. altitude or right ascension.
Returns
-------
`int`
The index of the coordinate to use.
"""
logger.debug("CoordinateCondition().coord_idx == %i" % self._coord_idx)
return self._coord_idx

@property
def min_val(self):
pass
"""
If `None`, there is no minimum value. Otherwise, the minimum value for the coordinate.
Returns
-------
`~astropy.units.Quantity`
The minimum value for the coordinate.
"""
logger.debug("CoordinateCondition().min_val == %s" % self._min_val)
return self._min_val

@property
def max_val(self):
pass
"""
If `None`, there is no maximum value. Otherwise, the maximum value for the coordinate.
Returns
-------
`~astropy.units.Quantity`
The maximum value for the coordinate.
"""
logger.debug("CoordinateCondition().max_val == %s" % self._max_val)
return self._max_val

@property
def score_type(self):
pass
"""
The type of scoring function to use. Options are "linear" for a linear function, commonly used for altitude,
and "boolean" for a binary function that returns 1 if the condition is met and 0 if it is not.
Returns
-------
`str`
The type of scoring function to use.
"""
logger.debug("CoordinateCondition().score_type == %s" % self._score_type)
return self._score_type

@property
def inclusive(self):
"""
If `True`, the condition is inclusive, meaning that the target must be within the specified range. If `False`,
the condition is exclusive, meaning that the target must be outside the specified range.
Essentially acts as a "not" operator.
Returns
-------
`bool`
If the condition is inclusive or exclusive.
"""
logger.debug("CoordinateCondition().inclusive == %s" % self._inclusive)
return self._inclusive

@property
def ref_coord(self):
pass
"""
If `coord_type` is "radec" or "galactic", a user can specify a center value and `min_val` and `max_val` will be interpreted
as a minimum and maximum radial angular separation of the target from the reference coordinate.
Returns
-------
`~astropy.coordinates.SkyCoord`
The reference coordinate.
"""
logger.debug("CoordinateCondition().ref_coord == %s" % self._ref_coord)
return self._ref_coord
Loading

0 comments on commit b04965b

Please sign in to comment.