Skip to content

Commit

Permalink
Merge pull request #22 from lsst-camera-dh/u/jchiang/make_one_tearing…
Browse files Browse the repository at this point in the history
…_plot_per_sensor

make one tearing plot per sensor by default
  • Loading branch information
jchiang87 authored Feb 19, 2019
2 parents 0d09742 + 93970e7 commit 9d40dce
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import eotestUtils
import lsst.eotest.sensor as sensorTest
from camera_components import camera_info
from tearing_detection import persist_tearing_png_files
from bot_eo_analyses import make_file_prefix

def report_missing_data(validator, missing_data, components='detectors',
Expand Down Expand Up @@ -517,6 +518,9 @@ def validate_tearing(results, det_names):
list(values) + [slot, raft]))
results.append(lcatr.schema.valid(schema, **stats))

png_files = sorted(glob.glob('*_tearing.png'))
results.extend(persist_tearing_png_files(png_files))

report_missing_data("validate_tearing", missing_det_names)

return results
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
"""
Validator script for raft-level flat pairs analysis.
"""
import glob
import pickle
import lcatr.schema
import siteUtils
import camera_components
from tearing_detection import persist_tearing_png_files

raft_id = siteUtils.getUnitId()
raft = camera_components.Raft.create_from_etrav(raft_id)
Expand All @@ -22,6 +24,9 @@
list(values) + [slot]))
results.append(lcatr.schema.valid(schema, **stats))

png_files = sorted(glob.glob('*_tearing.png'))
results.extend(persist_tearing_png_files(png_files))

results.extend(siteUtils.jobInfo())
lcatr.schema.write_file(results)
lcatr.schema.validate_file()
5 changes: 3 additions & 2 deletions python/correlated_noise.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def get_overscans(infile, oscan_indices=None):
y0, y1, x0, x1 = oscan_indices
overscans = dict()
for amp in imutils.allAmps():
oscan_data = afw_image.ImageF(infile, amp).array
oscan_data = afw_image.ImageF(infile, imutils.dm_hdu(amp)).getArray()
overscans[amp] = copy.deepcopy(oscan_data[y0:y1, x0:x1])
return overscans

Expand All @@ -46,7 +46,8 @@ def get_mean_overscans(infiles, oscan_indices=None):
mean_overscans = defaultdict(list)
for infile in infiles:
for amp in imutils.allAmps():
oscan_data = afw_image.ImageF(infile, amp).array
oscan_data \
= afw_image.ImageF(infile, imutils.dm_hdu(amp)).getArray()
mean_overscans[amp].append(copy.deepcopy(oscan_data[y0:y1, x0:x1]))
for amp, images in mean_overscans.items():
mean_overscans[amp] = sum(images)/float(len(images))
Expand Down
10 changes: 5 additions & 5 deletions python/tearing_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

__all__ = ['tearing_detection', 'persist_tearing_png_files']

def tearing_detection(fitsfiles, make_png_files=False, bias_frame=None):
def tearing_detection(fitsfiles, num_png_files=1, bias_frame=None):
"""
Run the tearing detection code over a collection of single
sensor flats.
Expand All @@ -19,10 +19,10 @@ def tearing_detection(fitsfiles, make_png_files=False, bias_frame=None):
List of single sensor flats. This should generally be for a
given sensor since any png files of the tearing profiles would
be later persisted by slot number.
make_png_files: bool [False]
Flag to make png files of the tearing profiles.
num_png_files: int [1]
Number of the tearing profiles to output as a png file.
bias_frame: str [None]
Name of bias frame file. If None, then overscan region will be used.
Name of bias frame file. If None, then the overscan region will be used.
Returns
-------
Expand All @@ -36,7 +36,7 @@ def tearing_detection(fitsfiles, make_png_files=False, bias_frame=None):
ts = sensorTest.TearingStats(filename, bias_frame=bias_frame)
if ts.has_tearing():
files_with_tearing.append(filename)
if make_png_files:
if len(png_files) < num_png_files:
ts.plot_profiles()
outfile = (os.path.basename(filename).split('.')[0] +
'_tearing.png')
Expand Down

0 comments on commit 9d40dce

Please sign in to comment.