-
Notifications
You must be signed in to change notification settings - Fork 0
/
calcSeasonVisibilityGapsMetric.py
87 lines (72 loc) · 3.41 KB
/
calcSeasonVisibilityGapsMetric.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
################################################################################################
# Metric to evaluate the calcSeasonVisibilityGapsMetric
#
# Author - Rachel Street: [email protected]
################################################################################################
import numpy as np
import rubin_sim.maf as maf
import healpy as hp
import calcVisitIntervalMetric
class calcSeasonVisibilityGapsMetric(maf.BaseMetric):
"""Metric to evaluate the gap between sequential seasonal gaps in
observations in a lightcurve relative to the scientifically desired
sampling interval.
Parameters
----------
fieldRA : float, RA in degrees of a given pointing
observationStartMJD : float, MJD timestamp of the start of a given observation
"""
def __init__(self, cols=['fieldRA','observationStartMJD',],
metricName='calcSeasonVisibilityGapsMetric',
**kwargs):
"""tau_obs is an array of minimum-required observation intervals for four categories
of time variability"""
self.tau_obs = np.array([2.0, 20.0, 73.0, 365.0])
self.ra_col = 'fieldRA'
self.mjdCol = 'observationStartMJD'
super().__init__(col=cols, metricName=metricName, metricDtype='object')
def calcSeasonGaps(self, dataSlice):
"""Given the RA of a field pointing, and time of observation, calculate the length of
the gaps between observing seasons.
Parameters
----------
ra : float
The RA (in degrees) of the point on the sky
time : np.ndarray
The times of the observations, in MJD
Returns
-------
np.ndarray
Time gaps in days between sequential observing seasons
"""
seasons = maf.seasonMetrics.calcSeason(dataSlice[self.ra_col], dataSlice[self.mjdCol])
firstOfSeason, lastOfSeason = maf.seasonMetrics.findSeasonEdges(seasons)
ngaps = len(firstOfSeason)-1
season_gaps = dataSlice[self.mjdCol][lastOfSeason[0:ngaps-1]] - dataSlice[self.mjdCol][firstOfSeason[1:ngaps]]
return season_gaps
def run(self, dataSlice, slicePoint=None):
season_gaps = self.calcSeasonGaps(dataSlice)
# To avoid the intensive calculation of the exact visibility of every pointing
# for 365d a year, we adopt the pre-calculated values for an example field in
# the Galactic Bulge, which receives good, but not circumpolar, annual visibility.
total_time_visible_days = 1975.1256 / 24.0
expected_gap = 365.24 - total_time_visible_days
metric_data = TauObsMetricData()
interval_metric = calcVisitIntervalMetric()
for i,tau in enumerate(self.tau_obs):
if tau >= expected_gap:
metric_data.metric_values[i] = 0.0
for t in season_gaps:
metric_data.metric_values[i] += interval_metric.calc_interval_metric(np.array([t]), tau)
metric_data.metric_values[i] /= 10.0
else:
metric_data.metric_values[i] = 1.0
return metric_data
def reduceTau0(self, metric_data):
return metric_data.metric_values[0]
def reduceTau1(self, metric_data):
return metric_data.metric_values[1]
def reduceTau2(self, metric_data):
return metric_data.metric_values[2]
def reduceTau3(self, metric_data):
return metric_data.metric_values[3]