本文整理汇总了Python中ccdproc.CCDData.copy方法的典型用法代码示例。如果您正苦于以下问题:Python CCDData.copy方法的具体用法?Python CCDData.copy怎么用?Python CCDData.copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ccdproc.CCDData
的用法示例。
在下文中一共展示了CCDData.copy方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: WavelengthCalibrationTests
# 需要导入模块: from ccdproc import CCDData [as 别名]
# 或者: from ccdproc.CCDData import copy [as 别名]
class WavelengthCalibrationTests(TestCase):
def setUp(self):
argument_list = ['--data-path', os.getcwd(),
'--proc-path', os.getcwd(),
'--search-pattern', 'cfzsto',
'--output-prefix', 'w',
'--extraction', 'fractional',
'--reference-files', 'data/ref_comp',
'--max-targets', '3',
]
arguments = get_args(argument_list)
self.wc = WavelengthCalibration(args=arguments)
self.ccd = CCDData(data=np.random.random_sample(200),
meta=fits.Header(),
unit='adu')
self.ccd = add_wcs_keys(ccd=self.ccd)
self.ccd.header.set('SLIT',
value='1.0" long slit',
comment="slit [arcsec]")
def test_add_wavelength_solution(self):
self.wc.rms_error = 0.1
self.wc.n_points = 100
self.wc.n_rejections = 2
self.wc.calibration_lamp = 'non-existent.fits'
crval1 = 3977.948
npix = 4060
cdelt = 0.9910068
x_axis = np.linspace(crval1,
crval1 + cdelt * npix,
npix)
self.ccd = self.wc.add_wavelength_solution(ccd=self.ccd,
x_axis=x_axis)
self.assertEqual(self.ccd.header['CTYPE1'], 'LINEAR')
self.assertEqual(self.ccd.header['CRVAL1'], crval1)
self.assertEqual(self.ccd.header['CRPIX1'], 1)
self.assertAlmostEqual(self.ccd.header['CDELT1'], cdelt, places=3)
self.assertEqual(self.ccd.header['DCLOG1'],
'REFSPEC1 = {:s}'.format(self.wc.calibration_lamp))
self.assertEqual(self.ccd.header['GSP_WRMS'], self.wc.rms_error)
self.assertEqual(self.ccd.header['GSP_WPOI'], self.wc.n_points)
self.assertEqual(self.ccd.header['GSP_WREJ'], self.wc.n_rejections)
@skip
def test_automatic_wavelength_solution(self):
pass
def test__bin_reference_data(self):
wavelength = np.linspace(3000, 7000, 4000)
intensity = np.random.random_sample(4000)
for i in range(1, 4):
self.wc.serial_binning = i
new_wavelength, new_intensity = self.wc._bin_reference_data(
wavelength=wavelength,
intensity=intensity)
self.assertEqual(len(wavelength), len(intensity))
self.assertEqual(len(new_wavelength), len(new_intensity))
self.assertEqual(len(new_wavelength), np.floor(len(wavelength) / i))
@skip
def test__cross_correlation(self):
self.wc.lamp = self.ccd.copy()
self.wc.serial_binning = 1
x_axis = np.arange(0, 4060, 1)
reference = np.zeros(4060)
gaussian = models.Gaussian1D(stddev=2)
for i in sorted(np.random.choice(x_axis, 30)):
gaussian.mean.value = i
reference += gaussian(x_axis)
offset = np.random.choice(range(1, 15), 1)[0]
for slit in [1, 2, 3, 4, 5]:
new_array = np.append(reference[offset:], np.zeros(offset))
if slit > 3:
box_kernel = Box1DKernel(width=slit / 0.15)
new_array = convolve(new_array, box_kernel)
self.assertEqual(len(reference), len(new_array))
self.wc.lamp.header['SLIT'] = '{:d}.0" long slit'.format(slit)
correlation_value = self.wc._cross_correlation(reference=reference,
new_array=new_array)
self.assertEqual(correlation_value, offset)
#.........这里部分代码省略.........