Пример #1
0
    def make_avg_mosaic_at_pos(self, pos, outdir):
        """
        Creates a mosaic image from a given sensor illuminated by the CCOB at a given position, 
        by averaging all exposures made from this position.
        
        Parameters
        ----------
            pos : string
                Position of the CCOB in the format "xpos_ypos", matching the name of the directories 
                generated during acquisition
            outdir : string
                Directory where to save the temporary FITS file created when taking the mean.
        """

        dirlist = [d for d in self.dir_list if pos in d]
        flist = np.reshape(np.array([glob.glob(os.path.join(d, '*'+self.ccdid+'*')) for d in dirlist]),(len(dirlist)))
        print('Averaging the following files:\n')
        print(flist)
        
        tmp_file = os.path.join(outdir,'tmp.fits')
        imutils.fits_mean_file(flist, os.path.join(outdir,tmp_file))
        
        self.template_file = flist[0]
        
        mosaic, amp_coord = u.make_ccd_2d_array(tmp_file, gains=self.gains, biasfile=self.biasfile)
        self.data[pos] = {'mosaic':mosaic, 
                          'amp_coord':amp_coord}
Пример #2
0
def build_mean_bias_frame(config, slot, file_patterm='_mean_bias_image.fits'):
    """
    Builds and save mean bias frames. Only need to do it once for each slot.
    make_image will look into config['tmp_dir'] to find them.
    """
    bias_frames = glob.glob(os.path.join(config['path'], slot+'_Bias*'))
    outfile = slot + file_pattern
    imutils.fits_mean_file(bias_frames, os.path.join(config['tmp_dir'],outfile))
Пример #3
0
    def load_ccd(self, led_name='red'):
        """
        Load and generate mosaic image from a given sensor illuminated 
        by the CCOB. The path to the data is provided in the self.config_file_data file.
        
        Parameters
        ----------
            led_name: choice of the CCOB LED. Either one of ['nm960','nm850','nm750,'red','blue,'uv'] 
        """

        #config_file_data = '../ccob_config_RTM-006.yaml'
#        config_data = u.load_ccob_config(self.config_file_data)
#        config_beam = u.load_ccob_config(self.config_file_beam)

        self.config_data['led_name'] = led_name
        slot = self.beam.properties['ref_slot']
        file_list=sorted(u.find_files(self.config_data, slot=slot))

        mean_slot_file = slot+'_mean_ccob_image.fits'
        imutils.fits_mean_file(file_list, os.path.join(self.config_data['tmp_dir'],mean_slot_file))

        fits_file = os.path.join(self.config_data['tmp_dir'],mean_slot_file)
        gains_dict={}
        ccd_dict={}

        #bias_frames = glob.glob(os.path.join(config['path'], slot+'_bias*'))
        #mean_bias_file = slot+'_mean_bias_image_RTM-006_new.fits'
        #imutils.fits_mean_file(bias_frames, os.path.join(config['tmp_dir'],mean_bias_file))
        #ccd_dict = sensorTest.MaskedCCD(fits_file, bias_frame=os.path.join(self.config_data['tmp_dir'],mean_bias_file))
        
        superbias_frame = make_superbias_frame(self.config_data, slot=slot)
        ccd_dict = sensorTest.MaskedCCD(fits_file, bias_frame=os.path.join(self.config_data['tmp_dir'],superbias_frame))

        eotest_results_file = os.path.join(self.config_data['eo_data_path'],\
                                           '{}_eotest_results.fits'.format(ccd_dict.md('LSST_NUM')))

        gains_dict = u.gains(eotest_results_file)
        self.ccd = {}
        self.ccd['mosaic'], self.ccd['amp_coord'] = u.make_ccd_2d_array(fits_file, gains=gains_dict)
        self.ccd['xpos_ccob'] = self.config_data['xpos']
        self.ccd['ypos_ccob'] = self.config_data['ypos']
        
        return self.ccd
#sensor_id = []
#sensor_id.append(siteUtils.getUnitId())
sensor_id = siteUtils.getUnitId()
fe55_files = siteUtils.dependency_glob('*_fe55_fe55_*.fits',
                                       jobname=siteUtils.getProcessName('fe55_acq'),
                                       description='Fe55 files:')

#
# Create a mean bias file from the 25 bias files generated by fe55_acq
#
bias_files = siteUtils.dependency_glob('*_fe55_bias_*.fits',
                                       jobname=siteUtils.getProcessName('fe55_acq'),
                                       description='Bias files:')
nf = len(bias_files)
outfile = '%(sensor_id)s_mean_bias_%(nf)i.fits' % locals()
imutils.fits_mean_file(bias_files, outfile)

#
# Create a png zoom of the upper right corner of segment 1 for an Fe55
# exposure for inclusion in the test report
#
sensorTest.fe55_zoom(fe55_files[0], size=250, amp=1)
plt.savefig('%(sensor_id)s_fe55_zoom.png' % locals())

#
# Perform analysis of 9-pixel statistics for Fe55 charge clusters.
#
pixel_stats = sensorTest.Fe55PixelStats(fe55_files, sensor_id=sensor_id)
pixel_stats.pixel_hists(pix0='p3', pix1='p5')
plt.savefig('%(sensor_id)s_fe55_p3_p5_hists.png' % locals())