Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 30 additions & 27 deletions hipercam/reduction.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
This contains code used in common by the script reduce.py
"""

from collections import OrderedDict
import sys
import warnings
Expand Down Expand Up @@ -32,7 +33,6 @@
pgpt1,
)


NaN = float("NaN")


Expand Down Expand Up @@ -3067,13 +3067,15 @@ def add_point(self, results, tzero, tmax, fmin, fmax, skipbadt):
ft = targ["counts"]
fte = targ["countse"]
saturated = targ["flag"] & hcam.TARGET_SATURATED
nonlinear = targ["flag"] & hcam.TARGET_NONLINEAR

if fte == fte:
if self.comp != "!":
comp = reses[self.comp]
fc = comp["counts"]
fce = comp["countse"]
saturated |= comp["flag"] & hcam.TARGET_SATURATED
nonlinear |= comp["flag"] & hcam.TARGET_NONLINEAR

if fc == fc and fce == fce:
f = ft / fc
Expand Down Expand Up @@ -3108,6 +3110,9 @@ def add_point(self, results, tzero, tmax, fmin, fmax, skipbadt):
if saturated:
# mark saturated data with cross
self.symb.append(5)
elif nonlinear:
# mark nonlinear data with triangle
self.symb.append(7)
else:
# blob if OK
self.symb.append(17)
Expand Down Expand Up @@ -3201,6 +3206,9 @@ def add_point(self, results, tzero, tmax, xmin, xmax, skipbadt):
if targ["flag"] & hcam.TARGET_SATURATED:
# mark saturated data with cross
self.symb.append(5)
elif targ["flag"] & hcam.TARGET_NONLINEAR:
# mark nonlinear data with triangle
self.symb.append(7)
else:
# blob if OK
self.symb.append(17)
Expand Down Expand Up @@ -3293,6 +3301,9 @@ def add_point(self, results, tzero, tmax, ymin, ymax, skipbadt):
if targ["flag"] & hcam.TARGET_SATURATED:
# mark saturated data with cross
self.symb.append(5)
elif targ["flag"] & hcam.TARGET_NONLINEAR:
# mark nonlinear data with triangle
self.symb.append(7)
else:
# blob if OK
self.symb.append(17)
Expand Down Expand Up @@ -3363,6 +3374,9 @@ def add_point(self, results, tzero, tmax, skipbadt):
if targ["flag"] & hcam.TARGET_SATURATED:
# mark saturated data with cross
self.symb.append(5)
elif targ["flag"] & hcam.TARGET_NONLINEAR:
# mark nonlinear data with triangle
self.symb.append(7)
else:
# blob if OK
self.symb.append(17)
Expand Down Expand Up @@ -3441,6 +3455,9 @@ def add_point(self, results, tzero, tmax, fmax, skipbadt):
if targ["flag"] & hcam.TARGET_SATURATED:
# mark saturated data with cross
self.symb.append(5)
elif targ["flag"] & hcam.TARGET_NONLINEAR:
# mark nonlinear data with triangle
self.symb.append(7)
else:
# blob if OK
self.symb.append(17)
Expand Down Expand Up @@ -3650,8 +3667,7 @@ def float2str(value, form, sval=None):

def write_header(self):
# first, a general description
self.log.write(
"""#
self.log.write("""#
# This is a logfile produced by the HiPERCAM pipeline command 'reduce'. It consists
# of one line per reduced CCD per exposure. Each line contains all the information
# from all apertures defined for the CCD. The column names are defined just before
Expand All @@ -3662,23 +3678,18 @@ def write_header(self):
# of the HiPERCAM reduction software, and was generated using the following
# command-line inputs to 'reduce':
#
""".format(
hipercam_version=self.hipercam_version
)
)
""".format(hipercam_version=self.hipercam_version))

# second, list the command-line inputs to the logfile
for line in self.plist:
self.log.write("# {:s}".format(line))

# third, list the reduce file
self.log.write(
"""#
self.log.write("""#
# and here is a minimal version of the reduce file used ['rfile' above] with
# all between-line comments removed for compactness:
#
"""
)
""")

# skip these as they only affect the on the fly plots,
# not the final values
Expand All @@ -3699,13 +3710,11 @@ def write_header(self):
self.log.write("# {:s}".format(line))

# fourth, write the apertures
self.log.write(
"""#
self.log.write("""#
# Next here is the aperture file used in JSON-style format that (without
# the initial comment hashes) is readable by setaper and reduce:
#
"""
)
""")
# convert aperture file to JSON-style string, split line by line,
# pre-pend comment and indentation, write out to the logfile.
lines = [
Expand All @@ -3716,8 +3725,7 @@ def write_header(self):

# fifth the column names for each CCD which has any
# apertures
self.log.write(
"""#
self.log.write("""#
# Now follow column name definitions for each CCD. These include all apertures
# of the CCD. Since there are 15 items stored per aperture and each column name
# is built from the item name followed by an underscore and finally the aperture
Expand Down Expand Up @@ -3757,8 +3765,7 @@ def write_header(self):
#
# Start of column name definitions:
#
"""
)
""")
toffset = self.rfile["general"]["toffset"]
for cnam, ccdaper in self.rfile.aper.items():
if len(ccdaper) == 0:
Expand Down Expand Up @@ -3787,8 +3794,7 @@ def write_header(self):
self.log.write(cnames + "\n")

# now the datatypes for building into structured arrays
self.log.write(
"""#
self.log.write("""#
# End of column name definitions
#
# Now follow a similar series of datatypes which are designed to be used to
Expand All @@ -3797,8 +3803,7 @@ def write_header(self):
#
# Start of data type definitions:
#
"""
)
""")
atypes = "f4 f4 f4 f4 f4 f4 f4 f4 f4 f4 f4 f4 i4 i4 i4 u4 "
for cnam, ccdaper in self.rfile.aper.items():
if len(ccdaper) == 0:
Expand All @@ -3810,11 +3815,9 @@ def write_header(self):
"# {:s} = s i4 f8 ? f4 f4 f4 {:s}\n".format(cnam, len(ccdaper) * atypes)
)

self.log.write(
"""#
self.log.write("""#
# End of data type definitions
#
"""
)
""")

# that's it for the headers!
Loading