本文整理汇总了Python中lsst.sims.photUtils.Sed.fluxFromMag方法的典型用法代码示例。如果您正苦于以下问题:Python Sed.fluxFromMag方法的具体用法?Python Sed.fluxFromMag怎么用?Python Sed.fluxFromMag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lsst.sims.photUtils.Sed
的用法示例。
在下文中一共展示了Sed.fluxFromMag方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_mags_vs_flux
# 需要导入模块: from lsst.sims.photUtils import Sed [as 别名]
# 或者: from lsst.sims.photUtils.Sed import fluxFromMag [as 别名]
def test_mags_vs_flux(self):
"""
Verify that the relationship between Sed.calcMag() and Sed.calcFlux()
is as expected
"""
wavelen = np.arange(100.0, 1500.0, 1.0)
flambda = np.exp(-0.5*np.power((wavelen-500.0)/100.0,2))
sb = (wavelen-100.0)/1400.0
ss = Sed(wavelen=wavelen, flambda=flambda)
bp = Bandpass(wavelen=wavelen, sb=sb)
mag = ss.calcMag(bp)
flux = ss.calcFlux(bp)
self.assertAlmostEqual(ss.magFromFlux(flux)/mag, 1.0, 10)
self.assertAlmostEqual(ss.fluxFromMag(mag)/flux, 1.0, 10)
示例2: test_avro_alert_generation_diff_dmag
# 需要导入模块: from lsst.sims.photUtils import Sed [as 别名]
# 或者: from lsst.sims.photUtils.Sed import fluxFromMag [as 别名]
#.........这里部分代码省略.........
avro_gen = AvroAlertGenerator()
avro_gen.load_schema(os.path.join(getPackageDir('sims_catUtils'), 'tests', 'testData', 'avroSchema'))
sql_prefix_list = ['alert_test']
out_prefix = 'test_avro'
log_file_name = tempfile.mktemp(dir=self.avro_out_dir,
prefix='test_avro',
suffix='log.txt')
for obshistid in obshistid_list:
avro_gen.write_alerts(obshistid, self.alert_data_output_dir,
sql_prefix_list,
obshistid_to_htmid[obshistid],
self.avro_out_dir, out_prefix,
dmag_cutoff_avro, lock=None,
log_file_name=log_file_name)
list_of_avro_files = os.listdir(self.avro_out_dir)
self.assertGreater(len(list_of_avro_files), 2)
alert_ct = 0
dummy_sed = Sed()
bp_dict = BandpassDict.loadTotalBandpassesFromFiles()
photParams = PhotometricParameters()
diasourceId_set = set()
for avro_file_name in list_of_avro_files:
if avro_file_name.endswith('log.txt'):
continue
full_name = os.path.join(self.avro_out_dir, avro_file_name)
with DataFileReader(open(full_name, 'rb'), DatumReader()) as data_reader:
for alert in data_reader:
alert_ct += 1
obshistid = alert['alertId'] >> 20
obs = obs_dict[obshistid]
uniqueId = alert['diaObject']['diaObjectId']
true_alert_id = (uniqueId << obshistid_bits) + obshistid
self.assertIn(true_alert_id, true_alert_dict)
self.assertEqual(alert['l1dbId'], uniqueId)
true_alert = true_alert_dict[true_alert_id]
diaSource = alert['diaSource']
self.assertAlmostEqual(diaSource['ra'], true_alert['ra'], 10)
self.assertAlmostEqual(diaSource['decl'], true_alert['decl'], 10)
self.assertAlmostEqual(diaSource['x'], true_alert['xPix'], 3)
self.assertAlmostEqual(diaSource['y'], true_alert['yPix'], 3)
self.assertAlmostEqual(diaSource['midPointTai'], obs.mjd.TAI, 4)
true_tot_flux = dummy_sed.fluxFromMag(true_alert['mag'])
true_q_mag = true_alert['mag'] - true_alert['dmag']
true_q_flux = dummy_sed.fluxFromMag(true_q_mag)
true_dflux = true_tot_flux - true_q_flux
self.assertAlmostEqual(diaSource['psFlux']/true_dflux, 1.0, 6)
self.assertAlmostEqual(diaSource['totFlux']/true_tot_flux, 1.0, 6)
self.assertAlmostEqual(diaSource['diffFlux']/true_dflux, 1.0, 6)
true_tot_snr, gamma = calcSNR_m5(true_alert['mag'], bp_dict[obs.bandpass],
obs.m5[obs.bandpass], photParams)
true_q_snr, gamma = calcSNR_m5(true_q_mag, bp_dict[obs.bandpass],
self.obs_mag_cutoff[mag_name_to_int[obs.bandpass]],
photParams)
true_tot_err = true_tot_flux/true_tot_snr
true_q_err = true_q_flux/true_q_snr
true_diff_err = np.sqrt(true_tot_err**2 + true_q_err**2)
self.assertAlmostEqual(diaSource['snr']/np.abs(true_dflux/true_diff_err),
1.0, 6)
self.assertAlmostEqual(diaSource['totFluxErr']/true_tot_err, 1.0, 6)
self.assertAlmostEqual(diaSource['diffFluxErr']/true_diff_err, 1.0, 6)
chipnum = int(true_alert['chipName'].replace('R', '').replace('S', '').
replace(',', '').replace(':', '').replace(' ', ''))
true_ccdid = (chipnum*10**7)+obshistid
self.assertEqual(true_ccdid, diaSource['ccdVisitId'])
self.assertEqual(uniqueId, diaSource['diaObjectId'])
self.assertNotIn(diaSource['diaSourceId'], diasourceId_set)
diasourceId_set.add(diaSource['diaSourceId'])
diaObject = alert['diaObject']
obj_dex = (uniqueId//1024) - 1
self.assertAlmostEqual(0.001*diaObject['pmRa']/self.pmra_truth[obj_dex], 1.0, 5)
self.assertAlmostEqual(0.001*diaObject['pmDecl']/self.pmdec_truth[obj_dex], 1.0, 5)
self.assertAlmostEqual(0.001*diaObject['parallax']/self.px_truth[obj_dex], 1.0, 5)
(true_ra_base,
true_dec_base) = applyProperMotion(self.ra_truth[obj_dex],
self.dec_truth[obj_dex],
self.pmra_truth[obj_dex],
self.pmdec_truth[obj_dex],
self.px_truth[obj_dex],
self.vrad_truth[obj_dex],
mjd=ModifiedJulianDate(TAI=diaObject['radecTai']))
self.assertAlmostEqual(true_ra_base, diaObject['ra'], 7)
self.assertAlmostEqual(true_dec_base, diaObject['decl'], 7)
self.assertEqual(alert_ct, len(true_alert_dict))