本文整理汇总了Python中astropy.units.erg方法的典型用法代码示例。如果您正苦于以下问题:Python units.erg方法的具体用法?Python units.erg怎么用?Python units.erg使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类astropy.units
的用法示例。
在下文中一共展示了units.erg方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: trace_table
# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import erg [as 别名]
def trace_table(self):
"""
Table of trace parameters. Trace is unit-indexed.
"""
dtype = np.float32
tab = utils.GTable()
tab.meta['CONFFILE'] = os.path.basename(self.beam.conf.conf_file)
tab['wavelength'] = np.cast[dtype](self.beam.lam*u.Angstrom)
tab['trace'] = np.cast[dtype](self.beam.ytrace + self.beam.sh_beam[0]/2 - self.beam.ycenter)
sens_units = u.erg/u.second/u.cm**2/u.Angstrom/(u.electron/u.second)
tab['sensitivity'] = np.cast[dtype](self.beam.sensitivity*sens_units)
return tab
示例2: datacube
# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import erg [as 别名]
def datacube():
"""Produces a simple 3D array for datacube testing."""
flux = numpy.tile([numpy.arange(1, 1001, dtype=numpy.float32)],
(100, 1)).T.reshape(1000, 10, 10)
ivar = (1. / (flux / 100))**2
mask = numpy.zeros(flux.shape, dtype=numpy.int)
wave = numpy.arange(1, 1001)
redcorr = numpy.ones(1000) * 1.5
mask[50:100, 5, 5] = 2**10
mask[500:600, 3, 3] = 2**4
scale = 1e-3
datacube = DataCube(flux, wave, ivar=ivar, mask=mask, redcorr=redcorr, scale=scale,
unit=u.erg / u.s / (u.cm ** 2) / u.Angstrom / spaxel_unit,
pixmask_flag='MANGA_DRP3PIXMASK')
yield datacube
示例3: spectrum
# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import erg [as 别名]
def spectrum():
"""Produces a simple 1D array for datacube testing."""
flux = numpy.arange(1, 1001, dtype=numpy.float32)
ivar = (1. / (flux / 100))**2
mask = numpy.zeros(flux.shape, dtype=numpy.int)
wave = numpy.arange(1, 1001)
mask[50:100] = 2**10
mask[500:600] = 2**4
scale = 1e-3
datacube = Spectrum(flux, wave, ivar=ivar, mask=mask, scale=scale,
unit=u.erg / u.s / (u.cm ** 2) / u.Angstrom / spaxel_unit,
pixmask_flag='MANGA_DRP3PIXMASK')
yield datacube
示例4: test_JsonCustomEncoder
# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import erg [as 别名]
def test_JsonCustomEncoder():
from astropy import units as u
assert json.dumps(np.arange(3), cls=misc.JsonCustomEncoder) == '[0, 1, 2]'
assert json.dumps(1+2j, cls=misc.JsonCustomEncoder) == '[1.0, 2.0]'
assert json.dumps(set([1, 2, 1]), cls=misc.JsonCustomEncoder) == '[1, 2]'
assert json.dumps(b'hello world \xc3\x85',
cls=misc.JsonCustomEncoder) == '"hello world \\u00c5"'
assert json.dumps({1: 2},
cls=misc.JsonCustomEncoder) == '{"1": 2}' # default
assert json.dumps({1: u.m}, cls=misc.JsonCustomEncoder) == '{"1": "m"}'
# Quantities
tmp = json.dumps({'a': 5*u.cm}, cls=misc.JsonCustomEncoder)
newd = json.loads(tmp)
tmpd = {"a": {"unit": "cm", "value": 5.0}}
assert newd == tmpd
tmp2 = json.dumps({'a': np.arange(2)*u.cm}, cls=misc.JsonCustomEncoder)
newd = json.loads(tmp2)
tmpd = {"a": {"unit": "cm", "value": [0., 1.]}}
assert newd == tmpd
tmp3 = json.dumps({'a': np.arange(2)*u.erg/u.s}, cls=misc.JsonCustomEncoder)
newd = json.loads(tmp3)
tmpd = {"a": {"unit": "erg / s", "value": [0., 1.]}}
assert newd == tmpd
示例5: test_spectraldensity2
# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import erg [as 别名]
def test_spectraldensity2():
# flux density
flambda = u.erg / u.angstrom / u.cm ** 2 / u.s
fnu = u.erg / u.Hz / u.cm ** 2 / u.s
a = flambda.to(fnu, 1, u.spectral_density(u.Quantity(3500, u.AA)))
assert_allclose(a, 4.086160166177361e-12)
# luminosity density
llambda = u.erg / u.angstrom / u.s
lnu = u.erg / u.Hz / u.s
a = llambda.to(lnu, 1, u.spectral_density(u.Quantity(3500, u.AA)))
assert_allclose(a, 4.086160166177361e-12)
a = lnu.to(llambda, 1, u.spectral_density(u.Quantity(3500, u.AA)))
assert_allclose(a, 2.44728537142857e11)
示例6: test_equivalent_units2
# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import erg [as 别名]
def test_equivalent_units2():
units = set(u.Hz.find_equivalent_units(u.spectral()))
match = set(
[u.AU, u.Angstrom, u.Hz, u.J, u.Ry, u.cm, u.eV, u.erg, u.lyr,
u.m, u.micron, u.pc, u.solRad, u.Bq, u.Ci, u.k, u.earthRad,
u.jupiterRad])
assert units == match
from astropy.units import imperial
with u.add_enabled_units(imperial):
units = set(u.Hz.find_equivalent_units(u.spectral()))
match = set(
[u.AU, u.Angstrom, imperial.BTU, u.Hz, u.J, u.Ry,
imperial.cal, u.cm, u.eV, u.erg, imperial.ft, imperial.fur,
imperial.inch, imperial.kcal, u.lyr, u.m, imperial.mi,
imperial.mil, u.micron, u.pc, u.solRad, imperial.yd, u.Bq, u.Ci,
imperial.nmi, u.k, u.earthRad, u.jupiterRad])
assert units == match
units = set(u.Hz.find_equivalent_units(u.spectral()))
match = set(
[u.AU, u.Angstrom, u.Hz, u.J, u.Ry, u.cm, u.eV, u.erg, u.lyr,
u.m, u.micron, u.pc, u.solRad, u.Bq, u.Ci, u.k, u.earthRad,
u.jupiterRad])
assert units == match
示例7: get_flux_constant
# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import erg [as 别名]
def get_flux_constant(self):
return units.erg / units.angstrom
示例8: __init__
# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import erg [as 别名]
def __init__(self, flux_unit, energy_unit, flux_model, test_model):
"""
Handles differential flux conversion and model building
for point sources
:param test_model: model to test the flux on
:param flux_unit: an astropy unit string for differential flux
:param energy_unit: an astropy unit string for energy
:param flux_model: the base flux model to use
"""
self._flux_lookup = {
"photon_flux": 1.0 / (u.keV * u.cm ** 2 * u.s),
"energy_flux": old_div(u.erg, (u.keV * u.cm ** 2 * u.s)),
"nufnu_flux": old_div(u.erg ** 2, (u.keV * u.cm ** 2 * u.s)),
}
self._model_converter = {
"photon_flux": test_model,
"energy_flux": lambda x: x * test_model(x),
"nufnu_flux": lambda x: x * x * test_model(x),
}
self._model_builder = {
"photon_flux": flux_model,
"energy_flux": lambda x, **param_specification: x
* flux_model(x, **param_specification),
"nufnu_flux": lambda x, **param_specification: x
* x
* flux_model(x, **param_specification),
}
super(DifferentialFluxConversion, self).__init__(
flux_unit, energy_unit, flux_model
)
示例9: stellar_info
# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import erg [as 别名]
def stellar_info(chain, data):
"""
computes stellar masses and SFRs
"""
gal_do, irlum_dict, nh_dict, BBebv_dict, SFRdict = data.dictkey_arrays #call dictionary info
#relevanta parameters form the MCMC chain
tau_mcmc = chain[:,0]
age_mcmc = chain[:,1]
GA = chain[:,6] - 18. #1e18 is the common normalization factor used in parspace.ymodel in order to have comparable NORMfactors
z = data.z
distance = z2Dlum(z)
#constants
solarlum = const.L_sun.to(u.erg/u.second) #3.839e33
solarmass = const.M_sun
Mstar_list=[]
SFR_list=[]
for i in range (len (tau_mcmc)):
N = 10**GA[i]* 4* pi* distance**2 / (solarlum.value)/ (1+z)
gal_do.nearest_par2dict(tau_mcmc[i], 10**age_mcmc[i], 0.)
tau_dct, age_dct, ebvg_dct=gal_do.t, gal_do.a,gal_do.e
SFR_mcmc =SFRdict[tau_dct, age_dct]
# Calculate Mstar. BC03 templates are normalized to M* = 1 M_sun.
# Thanks to Kenneth Duncan, and his python version of BC03, smpy
Mstar = np.log10(N * 1)
#Calculate SFR. output is in [Msun/yr].
SFR = N * SFR_mcmc
SFR_list.append(SFR.value)
Mstar_list.append(Mstar)
return np.array(Mstar_list) , np.array(SFR_list)
示例10: test_unit
# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import erg [as 别名]
def test_unit():
w = wcs.WCS()
w.wcs.cunit[0] = u.erg
assert w.wcs.cunit[0] == u.erg
assert repr(w.wcs.cunit) == "['erg', '']"
示例11: blackbody_lambda
# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import erg [as 别名]
def blackbody_lambda(in_x, temperature):
"""Like :func:`blackbody_nu` but for :math:`B_{\\lambda}(T)`.
Parameters
----------
in_x : number, array_like, or `~astropy.units.Quantity`
Frequency, wavelength, or wave number.
If not a Quantity, it is assumed to be in Angstrom.
temperature : number, array_like, or `~astropy.units.Quantity`
Blackbody temperature.
If not a Quantity, it is assumed to be in Kelvin.
Returns
-------
flux : `~astropy.units.Quantity`
Blackbody monochromatic flux in
:math:`erg \\; cm^{-2} s^{-1} \\mathring{A}^{-1} sr^{-1}`.
"""
if getattr(in_x, 'unit', None) is None:
in_x = u.Quantity(in_x, u.AA)
bb_nu = blackbody_nu(in_x, temperature) * u.sr # Remove sr for conversion
flux = bb_nu.to(FLAM, u.spectral_density(in_x))
return flux / u.sr # Add per steradian to output flux unit
示例12: test_fit
# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import erg [as 别名]
def test_fit(self):
fitter = LevMarLSQFitter()
b = BlackBody1D(3000 * u.K)
wav = np.array([0.5, 5, 10]) * u.micron
fnu = np.array([1, 10, 5]) * u.Jy
b_fit = fitter(b, wav, fnu)
assert_quantity_allclose(b_fit.temperature, 2840.7438339457754 * u.K)
assert_quantity_allclose(b_fit.bolometric_flux, 6.821837075583734e-08 * u.erg / u.cm**2 / u.s)
示例13: test_blackbody_return_units
# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import erg [as 别名]
def test_blackbody_return_units():
# return of evaluate has no units when temperature has no units
b = BlackBody(1000.0 * u.K, scale=1.0)
assert not isinstance(b.evaluate(1.0 * u.micron, 1000.0, 1.0), u.Quantity)
# return has "standard" units when scale has no units
b = BlackBody(1000.0 * u.K, scale=1.0)
assert isinstance(b(1.0 * u.micron), u.Quantity)
assert b(1.0 * u.micron).unit == u.erg / (u.cm ** 2 * u.s * u.Hz * u.sr)
# return has scale units when scale has units
b = BlackBody(1000.0 * u.K, scale=1.0 * u.MJy / u.sr)
assert isinstance(b(1.0 * u.micron), u.Quantity)
assert b(1.0 * u.micron).unit == u.MJy / u.sr
示例14: bolometric_flux
# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import erg [as 别名]
def bolometric_flux(self):
"""Bolometric flux."""
# bolometric flux in the native units of the planck function
native_bolflux = (
self.scale.value * const.sigma_sb * self.temperature ** 4 / np.pi
)
# return in more "astro" units
return native_bolflux.to(u.erg / (u.cm ** 2 * u.s))
示例15: test_units_manipulation
# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import erg [as 别名]
def test_units_manipulation():
# Just do some manipulation and check it's happy
(u.kpc * u.yr) ** Fraction(1, 3) / u.Myr
(u.AA * u.erg) ** 9