nenupy.schedule.constraints


Observation constraints classes

In the following, an instance of ESTarget is initialized for the source Cygnus A and stored in the variable target. The method computePosition() is called to compute all astronomical properties at the location of NenuFAR for the time-range times.

>>> from astropy.time import Time, TimeDelta
>>> import numpy as np
>>> from nenupy.schedule import ESTarget

>>> dt = TimeDelta(3600, format='sec')
>>> times = Time('2021-01-01 00:00:00') + np.arange(24)*dt

>>> target = ESTarget.fromName('Cas A')
>>> target.computePosition(times)

See also

ESTarget or ESTarget objects are described in TARGETS in more details.

Single constraint

There are several constraints that could be defined (see Constraint classes). The simplest and probably most basic one is the ‘elevation constraint’ (embedded in the ElevationCnst class) since observing at \(e > 0^\circ\) is a necessary requirement for a ground-based observatory. Once the constraint has been evaluated on target, a normalized ‘score’ is returned and can be plotted using the plot() method.

>>> from nenupy.schedule import ElevationCnst

>>> c = ElevationCnst()
>>> score = c(target)
>>> c.plot()
_images/elevconstraint_casa0deg.png

If the required elevation to perform a good-quality observation needs to be greater than a given value, it could be specified to the elevationMin attribute.

>>> c = ElevationCnst(elevationMin=40)
>>> score = c(target)
>>> c.plot()
_images/elevconstraint_casa40deg.png

The ElevationCnst’s score is now at \(0\) whenever the target elevation is lower than elevationMin.

Multiple constraints

Several constraints are often needed to select an appropriate time window for a given observation. The Constraints class is by default initialized with ElevationCnst(elevationMin=0), but any other constraint may be passed as arguments:

>>> from nenupy.schedule import (
        ESTarget,
        Constraints,
        ElevationCnst,
        MeridianTransitCnst,
        LocalTimeCnst
    )
>>> from astropy.time import Time, TimeDelta
>>> from astropy.coordinates import SkyCoord, Angle

>>> dts = np.arange(24+1)*TimeDelta(3600, format='sec')
>>> times = Time('2021-01-01 00:00:00') + dts
>>> target = ESTarget.fromName('Cas A')
>>> target.computePosition(times)

>>> cnst = Constraints(
        ElevationCnst(elevationMin=20, weight=3),
        MeridianTransitCnst(),
        LocalTimeCnst(Angle(12, 'hour'), Angle(4, 'hour'))
    )

>>> cnst.evaluate(target, times)

>>> cnst.plot()
_images/sch_constraints.png

Constraint classes

Constraints(*constraints)

Added in version 1.2.0.

ElevationCnst([elevationMin, ...])

Elevation constraint

MeridianTransitCnst([weight])

Meridian Transit constraint

AzimuthCnst(azimuth[, weight])

Added in version 1.2.0.

LocalTimeCnst(hMin, hMax[, weight])

Added in version 1.2.0.

TimeRangeCnst(time_min, time_max[, weight])

Added in version 1.2.0.

LocalSiderealTimeCnst(lst[, ...])

NightTimeCnst([sun_elevation_max, ...])

Inheritance diagram of nenupy.schedule.constraints
class nenupy.schedule.constraints.AzimuthCnst(azimuth, weight=1)[source]

Bases: TargetConstraint

Added in version 1.2.0.

property azimuth
get_score(indices)[source]
class nenupy.schedule.constraints.Constraint(weight=1)[source]

Bases: ABC

Base class for all the constraint definitions.

Added in version 1.2.0.

plot(**kwargs)[source]

Plots the constraint’s score previously evaluated.

Parameters:
property weight
class nenupy.schedule.constraints.Constraints(*constraints)[source]

Bases: object

Added in version 1.2.0.

evaluate(target, time, nslots=1, sun_elevation=None)[source]
evaluate_various_nslots(target, time, test_indices, sun_elevation=None)[source]
plot(**kwargs)[source]
kwargs:

figsize figname

property size
property weights
class nenupy.schedule.constraints.ElevationCnst(elevationMin=0.0, scale_elevation=True, weight=1)[source]

Bases: TargetConstraint

Elevation constraint

Parameters:
  • elevationMin (int, float, or Angle) – Target’s elevation below which the constraint score is null. If provided as a dimensionless quantity, the value is interpreted as degrees.

  • weight (int or float) – Weight of the constraint. Allows to ponderate each constraint with respect to each other if ElevationCnst is included in Constraints for instance.

Added in version 1.2.0.

Example:
>>> from astropy.time import Time, TimeDelta
>>> from nenupy.schedule.targets import ESTarget
>>> from nenupy.schedule.constraints import ElevationCnst
>>> dt = TimeDelta(3600, format='sec')
>>> times = Time('2021-01-01 00:00:00') + np.arange(24)*dt
>>> cas_a = ESTarget.fromName('Cas A')
>>> cas_a.computePosition(times)
>>> elevation_constraint = ElevationCnst()
>>> score = elevation_constraint(target, None)
>>> c.plot()
property elevationMin

Minimal elevation required to perform an observation.

Type:

float or Angle

get_score(indices)[source]

Computes the ElevationCnst’s score for the given indices.

The score is computed as:

\[{\rm score} = \left\langle \frac{\mathbf{e}(t)}{{\rm max}(\mathbf{e})} \right\rangle_{\rm indices}\]

where \(\mathbf{e}(t)\) is the elevation of the target (set to \(0\) whenever it is lower than elevationMin).

Parameters:

indices (ndarray) – Indices of score on which the score will be evaluated.

Returns:

Constraint score.

Return type:

float

class nenupy.schedule.constraints.LocalSiderealTimeCnst(lst, strict_crossing=True, weight=1)[source]

Bases: TargetConstraint

get_score(indices)[source]
class nenupy.schedule.constraints.LocalTimeCnst(hMin, hMax, weight=1)[source]

Bases: ScheduleConstraint

Added in version 1.2.0.

get_score(indices)[source]
property hMax
property hMin
class nenupy.schedule.constraints.MeridianTransitCnst(weight=1)[source]

Bases: TargetConstraint

Meridian Transit constraint

Added in version 1.2.0.

get_score(indices)[source]

Computes the MeridianTransitCnst’s score for the given indices.

Returns 1 if the merdian transit is within the indices

The score is computed as:

\[\begin{split}{\rm score} = \begin{cases} 1, t_{\rm transit} \in \mathbf{t}({\rm indices})\\ 0, t_{\rm transit} \notin \mathbf{t}({\rm indices}) \end{cases}\end{split}\]

where \(t_{\rm transit}\) is the meridian transit time and \(\mathbf{t}\) is the time range on which the target positions are computed.

Parameters:

indices (ndarray) – Indices of score on which the score will be evaluated.

Returns:

Constraint score.

Return type:

float

class nenupy.schedule.constraints.NightTimeCnst(sun_elevation_max=0.0, scale_elevation=True, weight=1)[source]

Bases: Constraint

get_score(indices)[source]
class nenupy.schedule.constraints.ScheduleConstraint(weight)[source]

Bases: Constraint

Base class for constraints involving time range checks.

Warning

ScheduleConstraint should not be used on its own.

Added in version 1.2.0.

class nenupy.schedule.constraints.TargetConstraint(weight)[source]

Bases: Constraint

Base class for constraints involving target property checks.

Warning

TargetConstraint should not be used on its own.

Added in version 1.2.0.

class nenupy.schedule.constraints.TimeRangeCnst(time_min, time_max, weight=1)[source]

Bases: ScheduleConstraint

Added in version 1.2.0.

get_score(indices)[source]
property time_max
property time_min