Skip to content

Commit

Permalink
adding flag for legs=1,2,3 of CAI observations in FUV per issue #207
Browse files Browse the repository at this point in the history
  • Loading branch information
cmillion committed Jun 21, 2016
1 parent 1399a87 commit 07f741a
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion gPhoton/curvetools.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,41 @@ def reduce_lcurve(bin_ix, region_ix, data, function, dtype='float64'):
return np.array(output, dtype=dtype)
# ------------------------------------------------------------------------------

# ------------------------------------------------------------------------------
def caiwarning(band,bin_ix,events,verbose=0):
"""
Test whether a bin contains data from the first 3 legs of an FUV
observation as part of the calibration (CAI) survey.
:param band: The band being used, either 'FUV' or 'NUV'.
:type band: str
:param bin_ix: Array indices designating which events are in the time bin
of interest.
:type bin_ix: numpy.ndarray
:param events: Set of photon events to check if they are near a masked
detector region.
:type events: dict
:param verbose: Verbosity level, a value of 0 is minimum verbosity.
:type verbose: int
"""

if band=='FUV':
for trange in dbt.distinct_tranges(np.array(events['photons']['t'])[bin_ix]):
t = np.median(trange)
obstype = gQuery.getArray(gQuery.obstype_from_t(t))
if ((str(gq.getArray(gq.obstype_from_t(t))[0][0]) is 'CAI')
and (gq.getArray(gq.obstype_from_t(t))[0][5]<=3)):
return True
return False
# ------------------------------------------------------------------------------

# ------------------------------------------------------------------------------
def maskwarning(band, bin_ix, events, verbose=0, mapkey='H', mode=None):
"""
Expand Down Expand Up @@ -696,7 +731,8 @@ def getflags(band, bin_ix, events, verbose=0):
if maskwarning(band, ix, events, mapkey='E',
mode='bg', verbose=verbose):
flags[i] += 128

if caiwarning(band, ix, events, verbose=verbose):
flags[i] += 256
except:
raise
else:
Expand Down

0 comments on commit 07f741a

Please sign in to comment.