当前位置: 首页>>代码示例>>Python>>正文


Python CCDData.read方法代码示例

本文整理汇总了Python中ccdproc.CCDData.read方法的典型用法代码示例。如果您正苦于以下问题:Python CCDData.read方法的具体用法?Python CCDData.read怎么用?Python CCDData.read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ccdproc.CCDData的用法示例。


在下文中一共展示了CCDData.read方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: makeMasterFlat

# 需要导入模块: from ccdproc import CCDData [as 别名]
# 或者: from ccdproc.CCDData import read [as 别名]
def makeMasterFlat(images, master_bias):
    """
    Flats are corrected for their bias level (if
    master_bias)

    TODO: Finish docstring
    """
    try:
        fitsfile = 'master_flat.fits'
        master_flat = CCDData.read(fitsfile, unit=u.adu)
        return master_flat
    except FileNotFoundError:
        # empty list for the flats
        flat_list = []
        # create the master flat field
        print('Reducing flats')
        for f in images.files_filtered(imagetyp=FLAT_KEYWORD):
            print(f)
            with fits.open(f) as fitsfile:
                data_exp = fitsfile[0].header[EXPTIME_KEYWORD]
            ccd = CCDData.read(f, unit=u.adu)
            if master_bias:
                ccd = subtract_bias(ccd, master_bias)
            else:
                print('No master bias, skipping correction...')
            flat_list.append(ccd)
        try:
            master_flat = combine(flat_list, method='median')
            master_flat.write('master_flat.fits', clobber=True)
            return master_flat
        except IndexError:
            print('There are no flats, skipping...')
            master_flat = None
开发者ID:jmccormac01,项目名称:Spectroscopy,代码行数:35,代码来源:Spector.py

示例2: load_image

# 需要导入模块: from ccdproc import CCDData [as 别名]
# 或者: from ccdproc.CCDData import read [as 别名]
def load_image(filename):
    try:
        data = CCDData.read(filename)
    except(ValueError):
        try:
            data = CCDData.read(filename, unit = u.dyn)
        except:
            raise
    return data
开发者ID:dunkenj,项目名称:lofar-tools,代码行数:11,代码来源:cutouts.py

示例3: reduce_image

# 需要导入模块: from ccdproc import CCDData [as 别名]
# 或者: from ccdproc.CCDData import read [as 别名]
def reduce_image(imagefile, dark=None, flat=None):
    im = CCDData.read(imagefile, unit='adu')
    if dark is not None:
        dark = CCDData.read(dark, unit='adu')
        im = im.subtract(dark)
    if flat is not None:
#         masterflat = CCDData.read(flat, unit='adu')
        hdul = fits.open(flat)
        masterflat = CCDData(data=hdul[0].data, uncertainty=None, meta=hdul[0].header, unit='adu')
        im = flat_correct(im, masterflat)
    return im
开发者ID:joshwalawender,项目名称:KeckUtilities,代码行数:13,代码来源:slitAlign.py

示例4: __call__

# 需要导入模块: from ccdproc import CCDData [as 别名]
# 或者: from ccdproc.CCDData import read [as 别名]
    def __call__(self, in_file, save=False):

        self.file = in_file
        self.fig, self.ax = plt.subplots()

        # read data and get its wavelength solution
        ccd = CCDData.read(self.file, unit=u.adu)
        wcs_reader = ReadWavelengthSolution(header=ccd.header,
                                            data=ccd.data)
        wavelength, intensity = wcs_reader()


        manager = plt.get_current_fig_manager()
        manager.window.showMaximized()
        plt.title('{:s}\n{:s}'.format(self.file, ccd.header['OBJECT']))

        self.ax.plot(wavelength, intensity, color='k', label='Data')
        self.ax.axvline(6562.8, color='r')
        self.ax.set_xlim((wavelength[0], wavelength[-1]))
        self.ax.set_ylabel('Intensity (ADU)')
        self.ax.set_xlabel('Wavelength (Angstrom)')

        plt.legend(loc='best')
        plt.subplots_adjust(left=0.05,
                            right=0.99,
                            top=0.96,
                            bottom=0.04,
                            hspace=0.17,
                            wspace=0.11)
        # plt.tight_layout()

        if not save:
            self.fig.canvas.mpl_connect('key_press_event', self.key_pressed)
            plt.show()
开发者ID:simontorres,项目名称:goodman,代码行数:36,代码来源:plot-fits-file.py

示例5: main

# 需要导入模块: from ccdproc import CCDData [as 别名]
# 或者: from ccdproc.CCDData import read [as 别名]
def main():
    parser = argparse.ArgumentParser(description='Perform LACosmic cleaning of images')
    parser.add_argument('filenames',nargs='+',help='List of files to clean.')
    parser.add_argument('-odir',metavar='outdir',required=True,type=str,help='Output directory for files.')
    #parser.add_argument('-mode',choices=['lacosmic','median'],default='lacosmic',help='Specify mode of operation (default=lacosmic)')
    parser.add_argument('-sclip',metavar='sigclip',type=float,default=5,help='Laplacian-to-noise limit for cosmic ray detection. Lower values will flag more pixels as cosmic rays (default=5).')
    parser.add_argument('-sfrac',metavar='sigfrac',type=float,default=0.3,help='Fractional detection limit for neighboring pixels. For cosmic ray neighbor pixels, a Laplacian-to-noise detection limit of sigfrac * sigclip will be used. (default=0.3).')
    parser.add_argument('-objlim',type=float,default=5,help='Minimum contrast between Laplacian image and the fine structure image. Increase this value if cores of bright stars are flagged as cosmic rays (default=5).')
    parser.add_argument('-satlevel',type=float,default=65535,help='Saturation level of the image (electrons). This value is used to detect saturated stars and pixels at or above this level are added to the mask (default=65535)')
    parser.add_argument('-niter',type=int,default=5,help='umber of iterations of the LA Cosmic algorithm to perform (default=5).')
    #parser.add_argument('-thresh',metavar='threshold',type=float,default=5,help='Threshold for detecting cosmic rays [median] (default=5).')
    #parser.add_argument('-mbox',type=float,default=11,help='Median box for detecting cosmic rays [mbox] (default=11).')
    parser.add_argument('-njobs',type=int,default=1,help='Process images in parallel. "-1" is all CPUs (default=1).')
    parser.add_argument('--c',action='store_true',help='Clobber (overwrite) on output')

    args = parser.parse_args()

    ccds = (CCDData.read(fname,unit='adu') for fname in args.filenames)
    
    with Parallel(args.njobs,verbose=11) as parallel:
        cleaned = parallel(delayed(cosmicray_lacosmic)(ccd,sigclip=args.sclip,sigfrac=args.sfrac,niter=args.niter,objlim=args.objlim,satlevel=args.satlevel) for ccd in ccds)

    outfiles = (os.path.join(args.odir,os.path.basename(fname)) for fname in args.filenames)
    for hdu,outfile in zip(cleaned,outfiles):
        if isinstance(hdu,CCDData):
            hdu = hdu.to_hdu(hdu_mask=None,hdu_uncertainty=None)
        header = hdu[0].header
        header.add_history('clean.py - %s' % Time(Time.now(),format='fits'))
        header['CLEANED'] = (True,'Cleaned with LACosmics')
        header['CLNMTHD'] = (CLNMTHD,'Method used to clean')
        try:
            hdu.writeto(outfile,overwrite=args.c)
        except OSError as e:
            raise OSError("File '%s' already exists.  Re-run with --c flag to overwrite existing files." % outfile) from e
开发者ID:msgordon,项目名称:optipol-reduc,代码行数:36,代码来源:clean.py

示例6: test_fit_linear

# 需要导入模块: from ccdproc import CCDData [as 别名]
# 或者: from ccdproc.CCDData import read [as 别名]
 def test_fit_linear(self):
     test_file = os.path.join(self.data_path,
                              'goodman_comp_400M1_HgArNe.fits')
     ccd = CCDData.read(test_file, unit='adu')
     pixel, angstrom = self._recover_lines(ccd=ccd)
     model = self.wcs.fit(physical=pixel,
                          wavelength=angstrom,
                          model_name='linear')
     self.assertIsInstance(model, Model)
开发者ID:simontorres,项目名称:goodman,代码行数:11,代码来源:test_functional.py

示例7: test_read__non_linear_legendre

# 需要导入模块: from ccdproc import CCDData [as 别名]
# 或者: from ccdproc.CCDData import read [as 别名]
    def test_read__non_linear_legendre(self):
        test_file = os.path.join(self.data_path,
                                 'non-linear_fits_solution_legendre.fits')
        self.assertTrue(os.path.isfile(test_file))

        ccd = CCDData.read(test_file, unit='adu')

        result = self.wcs.read(ccd=ccd)
        self.assertIsInstance(self.wcs.model, Model)
        self.assertEqual(self.wcs.model.__class__.__name__, 'Legendre1D')
开发者ID:simontorres,项目名称:goodman,代码行数:12,代码来源:test_functional.py

示例8: test_read__non_linear_cspline

# 需要导入模块: from ccdproc import CCDData [as 别名]
# 或者: from ccdproc.CCDData import read [as 别名]
    def test_read__non_linear_cspline(self):
        test_file = os.path.join(self.data_path,
                                 'non-linear_fits_solution_cubic-spline.fits')
        self.assertTrue(os.path.isfile(test_file))

        ccd = CCDData.read(test_file, unit='adu')
        self.assertRaises(NotImplementedError, self.wcs.read, ccd)
        self.assertRaisesRegex(NotImplementedError,
                               'Cubic spline is not implemented',
                               self.wcs.read, ccd)
开发者ID:simontorres,项目名称:goodman,代码行数:12,代码来源:test_functional.py

示例9: test_read_gsp_wcs

# 需要导入模块: from ccdproc import CCDData [as 别名]
# 或者: from ccdproc.CCDData import read [as 别名]
    def test_read_gsp_wcs(self):
        test_file = os.path.join(self.data_path,
                                 'goodman_comp_400M1_HgArNe.fits')

        self.assertTrue(os.path.isfile(test_file))
        ccd = CCDData.read(test_file, unit='adu')
        result = self.wcs.read_gsp_wcs(ccd=ccd)

        self.assertIsInstance(result, list)
        self.assertEqual(len(result), 2)
        self.assertIsInstance(self.wcs.get_model(), Model)
开发者ID:simontorres,项目名称:goodman,代码行数:13,代码来源:test_functional.py

示例10: test_read__linear

# 需要导入模块: from ccdproc import CCDData [as 别名]
# 或者: from ccdproc.CCDData import read [as 别名]
    def test_read__linear(self):
        test_file = os.path.join(self.data_path,
                                 'linear_fits_solution.fits')
        self.assertTrue(os.path.isfile(test_file))

        ccd = CCDData.read(test_file, unit='adu')

        result = self.wcs.read(ccd=ccd)

        self.assertIsInstance(result, list)
        self.assertEqual(len(result), 2)
        self.assertIsInstance(self.wcs.get_model(), Model)
开发者ID:simontorres,项目名称:goodman,代码行数:14,代码来源:test_functional.py

示例11: test_read__invalid

# 需要导入模块: from ccdproc import CCDData [as 别名]
# 或者: from ccdproc.CCDData import read [as 别名]
    def test_read__invalid(self):
        test_file = os.path.join(self.data_path,
                                 'linear_fits_solution.fits')
        self.assertTrue(os.path.isfile(test_file))

        ccd = CCDData.read(test_file, unit='adu')
        ccd.wcs.wcs.ctype[0] = 'INVALID'

        self.assertRaisesRegex(NotImplementedError,
                               'CTYPE INVALID is not recognized',
                               self.wcs.read,
                               ccd)
        self.assertRaises(NotImplementedError, self.wcs.read, ccd)
开发者ID:simontorres,项目名称:goodman,代码行数:15,代码来源:test_functional.py

示例12: makeMasterBias

# 需要导入模块: from ccdproc import CCDData [as 别名]
# 或者: from ccdproc.CCDData import read [as 别名]
def makeMasterBias(images):
    """
    Make a master bias using all biases found in
    images object

    TODO: Finish docstring
    """
    try:
        master_bias = CCDData.read('master_bias.fits', unit=u.adu)
        return master_bias
    except FileNotFoundError:
        bias_list = []
        for f in images.files_filtered(imagetyp=BIAS_KEYWORD):
            print(f)
            ccd = CCDData.read(f, unit=u.adu)
            bias_list.append(ccd)
        try:
            master_bias = combine(bias_list, method='median')
            master_bias.write('master_bias.fits', clobber=True)
            return master_bias
        except IndexError:
            return None
开发者ID:jmccormac01,项目名称:Spectroscopy,代码行数:24,代码来源:Spector.py

示例13: test_fit_chebyshev

# 需要导入模块: from ccdproc import CCDData [as 别名]
# 或者: from ccdproc.CCDData import read [as 别名]
    def test_fit_chebyshev(self):
        test_file = os.path.join(self.data_path,
                                 'goodman_comp_400M1_HgArNe.fits')
        ccd = CCDData.read(test_file, unit='adu')
        pixel, angstrom = self._recover_lines(ccd=ccd)
        model = self.wcs.fit(physical=pixel, wavelength=angstrom)
        self.assertIsInstance(model, Model)

        self.assertEqual(model.__class__.__name__, ccd.header['GSP_FUNC'])
        self.assertEqual(model.degree, ccd.header['GSP_ORDR'])
        for i in range(model.degree + 1):
            self.assertAlmostEqual(model.__getattr__('c{:d}'.format(i)).value,
                             ccd.header['GSP_C{:03d}'.format(i)])
开发者ID:simontorres,项目名称:goodman,代码行数:15,代码来源:test_functional.py

示例14: create_master_flat

# 需要导入模块: from ccdproc import CCDData [as 别名]
# 或者: from ccdproc.CCDData import read [as 别名]
def create_master_flat(filepath='../../../KeckData/MOSFIRE_FCS/',
                       flatfiles = ['m180130_0320.fits',
                                    'm180130_0321.fits',
                                    'm180130_0322.fits',
                                    'm180130_0323.fits',
                                    'm180130_0324.fits',],
                       darkfile = 'm180130_0001.fits',
                      ):
    dark = CCDData.read(os.path.join(filepath, darkfile), unit='adu')
    flats = []
    for i,file in enumerate(flatfiles):
        flat = CCDData.read(os.path.join(filepath, file), unit='adu')
        flat = flat.subtract(dark)
        flats.append(flat)

    flat_combiner = Combiner(flats)
    flat_combiner.sigma_clipping()
    scaling_func = lambda arr: 1/np.ma.average(arr)
    flat_combiner.scaling = scaling_func
    masterflat = flat_combiner.median_combine()

    masterflat.write('masterflat.fits', overwrite=True)
开发者ID:joshwalawender,项目名称:KeckUtilities,代码行数:24,代码来源:slitAlign.py

示例15: __call__

# 需要导入模块: from ccdproc import CCDData [as 别名]
# 或者: from ccdproc.CCDData import read [as 别名]
 def __call__(self):
     """Run the tool for all the images matching `search_pattern`"""
     for fits_file in self.file_list:
         print(fits_file)
         self.ccd = CCDData.read(fits_file, unit=u.adu)
         if not self.threads:
             # plot_thread = Thread(target=self._create_plot)
             # plot_thread.start()
             id_thread = Thread(target=self.identify_matching_line)
             id_thread.start()
             # self.identify_matching_line()
             # self.threads.
             self._create_plot()
             id_thread.join()
         self.ccd.write(fits_file, overwrite=True)
开发者ID:simontorres,项目名称:goodman,代码行数:17,代码来源:line_matcher_original.py


注:本文中的ccdproc.CCDData.read方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。