Beispiel #1
0
def get_bot_amp_data(run, schema_name, field_name):
    """
    Get the amp values for the specified run, schema_name, and field_name
    for BOT data.
    """
    results = siteUtils.ETResults(run=run)
    return results.get_amp_data(schema_name, field_name)
 def _get_gains_from_run(self, et_results_file):
     if not os.path.isfile(et_results_file):
         self.et_results = siteUtils.ETResults(self.run)
         with open(et_results_file, 'wb') as fd:
             pickle.dump(self.et_results, fd)
     else:
         with open(et_results_file, 'rb') as fd:
             self.et_results = pickle.load(fd)
     if self.verbose:
         print("GetAmplifierGains: Using gains from run", self.run)
 def test_plot_focal_plane(self):
     """
     An operational test of generating a png image of the focal plane.
     """
     run = '6549D'
     results = siteUtils.ETResults(run)
     gains = results.get_amp_data('fe55_BOT_analysis', 'gain')
     fig = plt.figure(figsize=(12, 10))
     ax = fig.add_subplot(1, 1, 1)
     plot_focal_plane(ax, gains, camera=self.camera, z_range=(0.5, 1.2))
     plt.savefig(self.pngfile)
Beispiel #4
0
def get_ts8_amp_data(schema_name, field_name):
    """
    Get the amp values for the specified schema_name and field_name
    (e.g., 'fe55_raft_analysis' and 'gain') for the good TS8 runs.
    """
    raft_info = get_raft_slot_info()
    amp_data = defaultdict(dict)
    for raft_slot, (_, run) in raft_info.items():
        df = siteUtils.ETResults(run=run)[schema_name]
        for _, row in df.iterrows():
            det_name = f'{raft_slot}_{row.slot}'
            channel = 'C' + imutils.channelIds[row.amp]
            amp_data[det_name][channel] = row[field_name]
            if raft_slot in ts8_gain_scale_factors:
                amp_data[det_name][channel] *= ts8_gain_scale_factors[
                    raft_slot]
    return amp_data
Beispiel #5
0
def make_focal_plane_plots():
    #
    # Focal plane heat maps
    #
    fp_configs = {
        'fe55_BOT_analysis':
        (('gain', 'psf_sigma'), ('clipped_autoscale', (3, 5.5)),
         ('e-/ADU', 'micron'), (False, False), ('1', '1')),
        'read_noise_BOT':
        (('read_noise', ), ((0, 20), ), ('e-', ), (False, ), ('1', )),
        'bright_defects_BOT':
        (('bright_pixels', 'bright_columns'), (None, None), (None, None),
         (True, True), ('1', '1')),
        'dark_defects_BOT': (('dark_pixels', 'dark_columns'), (None, None),
                             (None, None), (True, True), ('1', '1')),
        'dark_current_BOT': (('dark_current_95CL', ), ((0, 0.3), ),
                             ('e-/pix/s', ), (False, ), ('1', )),
        'dark_current_fit_BOT':
        (('dark_current_slope', 'dark_current_intercept'), ((0, 0.1), (-1, 1)),
         ('e-/pix/s', 'e-/pix'), (False, False), ('1', '1')),
        'traps_BOT': (('num_traps', ), (None, ), (None, ), (False, ), ('1', )),
        'cte_BOT': (('cti_high_serial', 'cti_high_parallel', 'cti_low_serial',
                     'cti_low_parallel'), ((0, 1e-5), (0, 1e-5), (0, 1e-5),
                                           (0, 1e-5)),
                    (None, None, None, None), (False, False, False, False),
                    ('1e-6', '1e-6', '1e-6', '1e-6')),
        'flat_pairs_BOT':
        (('max_frac_dev', 'max_observed_signal', 'row_mean_var_slope',
          'linearity_turnoff'), ((0, 0.05), (5e4, 2.e5), (0, 2), (5e4, 2.e5)),
         (None, 'ADU', None, 'ADU'), (False, False, False, False), ('1', '1',
                                                                    '1', '1')),
        'ptc_BOT': (('ptc_gain', 'ptc_a00',
                     'ptc_turnoff'), ('clipped_autoscale', (0, 5e-6),
                                      (5e4, 2e5)), ('e-/ADU', None, 'ADU'),
                    (False, False, False), ('1', '1', '1')),
        'brighter_fatter_BOT': (('bf_xcorr', 'bf_ycorr'), ((-5, 5), (-5, 5)),
                                (None, None), (False, False), ('1', '1')),
        'tearing_stats_BOT': (('tearing_detections', ), (None, ), (None, ),
                              (False, ), ('1', )),
        'divisadero_tearing_BOT': (('divisadero_max_dev', ), ((0, 0.05), ),
                                   (None, ), (False, ), ('1', ))
    }

    camera = camera_info.camera_object

    run = siteUtils.getRunNumber()
    acq_run = os.environ.get('LCATR_ACQ_RUN', None)
    unit_id = siteUtils.getUnitId()
    et_results = siteUtils.ETResults(run)
    for schema_name, configs in fp_configs.items():
        for column, z_range, units, use_log10, scale_factor in zip(*configs):
            fig = plt.figure(figsize=(12, 10))
            ax = fig.add_subplot(1, 1, 1)
            try:
                amp_data = et_results.get_amp_data(schema_name, column)
            except KeyError:
                print("No focal plane results for {}: {} in eTraveler.".format(
                    schema_name, column))
            else:
                if units is not None:
                    title = 'Run {}, {} ({})'.format(run, column, units)
                else:
                    title = 'Run {}, {}'.format(run, column)
                if acq_run is not None:
                    title += f' (acq {acq_run})'

                plot_focal_plane(ax,
                                 amp_data,
                                 camera=camera,
                                 z_range=z_range,
                                 use_log10=use_log10,
                                 scale_factor=scale_factor)
                plt.title(title)
                outfile = '{}_{}_{}.png'.format(unit_id, run, column)
                plt.savefig(outfile)

                # Histogram the amp-level data.
                plt.figure()
                hist_range = None if z_range == 'clipped_autoscale' \
                             else z_range
                hist_amp_data(amp_data,
                              column,
                              hist_range=hist_range,
                              use_log10=use_log10,
                              scale_factor=scale_factor)
                plt.title(title)
                outfile = '{}_{}_{}_hist.png'.format(unit_id, run, column)
                plt.savefig(outfile)