#!/usr/bin/env python import os import lsst.eotest.sensor as sensorTest import siteUtils sensor_id = siteUtils.getUnitId() fe55_files = siteUtils.datacatalog_glob('*_fe55_fe55_*.fits', testtype="FE55", imgtype="FE55", description='Fe55 files:') # Roll-off defects mask needs an input file to get the vendor # geometry and will be used for all analyses. rolloff_mask_file = '%s_rolloff_defects_mask.fits' % sensor_id sensorTest.rolloff_mask(fe55_files[0], rolloff_mask_file) task = sensorTest.Fe55Task() task.run(sensor_id, fe55_files, (rolloff_mask_file, ), accuracy_req=0.01)
def run_fe55_task(sensor_id): "Single sensor execution of the Fe55 analysis task." import os import glob import lsst.eotest.image_utils as imutils import lsst.eotest.sensor as sensorTest import siteUtils import eotestUtils file_prefix = '%s_%s' % (sensor_id, siteUtils.getRunNumber()) acq_jobname = siteUtils.getProcessName('fe55_raft_acq') fe55_files = siteUtils.dependency_glob('S*/%s_fe55_fe55_*.fits' % sensor_id, jobname=acq_jobname, description='Fe55 files:') # Reverse sort the fe55 files to avoid transient effects arising # from using frames taken right after cool down that could bias # the gain measurement. fe55_files = sorted(fe55_files, reverse=True) bias_files = siteUtils.dependency_glob('S*/%s_fe55_bias_*.fits' % sensor_id, jobname=acq_jobname, description='Bias files:') bias_frame = eotestUtils.make_median_bias_frame(bias_files, sensor_id, 'fe55_raft_acq', skip=0) # # Create a png zoom of the upper right corner of segment 1 for an Fe55 # exposure for inclusion in the test report. # print("processing fe55_zoom:", fe55_files[0]) siteUtils.make_png_file(sensorTest.fe55_zoom, '%(file_prefix)s_fe55_zoom.png' % locals(), fe55_files[0], size=250, amp=1, annotation='ADU/pixel') # # Perform analysis of 9-pixel statistics for Fe55 charge clusters. # try: pixel_stats = sensorTest.Fe55PixelStats(fe55_files, sensor_id=sensor_id) siteUtils.make_png_file(pixel_stats.pixel_hists, '%s_fe55_p3_p5_hists.png' % file_prefix, pix0='p3', pix1='p5') siteUtils.make_png_file(pixel_stats.pixel_diff_profile, '%s_fe55_p3_p5_profiles.png' % file_prefix, pixel_coord='x', pix0='p3', pix1='p5') siteUtils.make_png_file(pixel_stats.apflux_profile, '%s_fe55_apflux_serial.png' % file_prefix) siteUtils.make_png_file(pixel_stats.apflux_profile, '%s_fe55_apflux_parallel.png' % file_prefix, pixel_coord='y') except Exception as eobj: print("Exception raised while creating pixel statistics plots:") print(str(eobj)) print("Skipping these plots.") # Roll-off defects mask needs an input file to get the vendor # geometry, and will be used for all analyses. rolloff_mask_file = '%s_rolloff_defects_mask.fits' % sensor_id sensorTest.rolloff_mask(fe55_files[0], rolloff_mask_file) task = sensorTest.Fe55Task() task.config.temp_set_point = -100. hist_nsig = 10 dn_range = 1590. / 2., 1590. / 0.5 task.run(sensor_id, fe55_files, (rolloff_mask_file, ), bias_frame=bias_frame, accuracy_req=0.01, hist_nsig=hist_nsig, dn_range=dn_range) # Fe55 gain and psf analysis results plots for the test report. results_file = '%s_eotest_results.fits' % sensor_id plots = sensorTest.EOTestPlots(sensor_id, results_file=results_file) siteUtils.make_png_file(plots.gains, '%s_gains.png' % file_prefix) siteUtils.make_png_file(sensorTest.plot_flat, '%s_median_bias.png' % file_prefix, bias_frame, title='%s, median bias frame' % sensor_id, annotation='ADU/pixel, overscan-subtracted') fe55_file = glob.glob('%s_psf_results*.fits' % sensor_id)[0] siteUtils.make_png_file(plots.fe55_dists, '%s_fe55_dists.png' % file_prefix, fe55_file=fe55_file, xrange_scale=3, dn_range=dn_range) siteUtils.make_png_file(plots.psf_dists, '%s_psf_dists.png' % file_prefix, fe55_file=fe55_file)
def fe55_task(run, det_name, fe55_files, bias_frame=None): "Single sensor execution of the Fe55 analysis task." file_prefix = make_file_prefix(run, det_name) title = '{}, {}'.format(run, det_name) if bias_frame is None: bias_frame = bias_filename(run, det_name) png_files = [] try: pixel_stats = sensorTest.Fe55PixelStats(fe55_files, sensor_id=file_prefix) png_files.append('%s_fe55_p3_p5_hists.png' % file_prefix) siteUtils.make_png_file(pixel_stats.pixel_hists, png_files[-1], pix0='p3', pix1='p5') png_files.append('%s_fe55_p3_p5_profiles.png' % file_prefix) siteUtils.make_png_file(pixel_stats.pixel_diff_profile, png_files[-1], pixel_coord='x', pix0='p3', pix1='p5') except Exception: # Encountered error processing data or generating pngs so skip # these plots. pass rolloff_mask_file = '%s_edge_rolloff_mask.fits' % file_prefix sensorTest.rolloff_mask(fe55_files[0], rolloff_mask_file) hist_nsig = 20 task = sensorTest.Fe55Task() task.config.temp_set_point = -100. task.run(file_prefix, fe55_files, (rolloff_mask_file,), bias_frame=bias_frame, accuracy_req=0.01, hist_nsig=hist_nsig, linearity_correction=get_nlc_func(det_name)) # Fe55 gain and psf analysis results plots for the test report. results_file = '%s_eotest_results.fits' % file_prefix plots = sensorTest.EOTestPlots(file_prefix, results_file=results_file) png_files.append('%s_gains.png' % file_prefix) siteUtils.make_png_file(plots.gains, png_files[-1]) png_files.append('%s_fe55_median_bias.png' % file_prefix) siteUtils.make_png_file(sensorTest.plot_flat, png_files[-1], bias_frame, title='%s, median bias frame' % title, annotation='ADU/pixel, overscan-subtracted') fe55_file = glob.glob('%s_psf_results*.fits' % file_prefix)[0] png_files.append('%s_fe55_dists.png' % file_prefix) siteUtils.make_png_file(plots.fe55_dists, png_files[-1], fe55_file=fe55_file, xrange_scale=5, hist_nsig=hist_nsig) png_files.append('%s_psf_dists.png' % file_prefix) siteUtils.make_png_file(plots.psf_dists, png_files[-1], fe55_file=fe55_file) png_file_list = '{}_fe55_task_png_files.txt'.format(det_name) with open(png_file_list, 'w') as output: for item in png_files: if os.path.isfile(item): output.write('{}\n'.format(item))