Skip to content

Instantly share code, notes, and snippets.

@pllim
Created August 18, 2017 20:32
Show Gist options
  • Save pllim/babea1d1337da665740439887c5b6f5f to your computer and use it in GitHub Desktop.
Save pllim/babea1d1337da665740439887c5b6f5f to your computer and use it in GitHub Desktop.
How to get the same synphot results in Astropy v2

How to get the same synphot results in Astropy v2:

>>> import numpy as np >>> from astropy import constants as const >>> from astropy import units as u >>> from astropy.modeling import models as _models >>> from synphot import models >>> from synphot import units >>> t = 5500 * u.K >>> fac = const.sigma_sb * t ** 4 / np.pi >>> fac <Quantity 16516273.034342945 W / m2> >>> w = np.arange(3000, 3100, 10) * u.AA >>> bb_astro = _models.BlackBody1D(t, bolometric_flux=fac) >>> bb_astro(w) <Quantity [ 2.40339754e-09, 2.44947680e-09, 2.49604354e-09, 2.54309638e-09, 2.59063389e-09, 2.63865453e-09, 2.68715672e-09, 2.73613877e-09, 2.78559895e-09, 2.83553543e-09] W / (Hz m2)> >>> bb_astro(w).to(units.PHOTLAM, u.spectral_density(w)) <Quantity [ 1.20906134e+17, 1.22814830e+17, 1.24735247e+17, 1.26667200e+17, 1.28610503e+17, 1.30564970e+17, 1.32530412e+17, 1.34506639e+17, 1.36493462e+17, 1.38490689e+17] PHOTLAM> >>> bb_syn = models.BlackBody1D(t.value) >>> bb_syn(w) # PHOTLAM array([ 1.20906134e+17, 1.22814830e+17, 1.24735247e+17, 1.26667200e+17, 1.28610503e+17, 1.30564970e+17, 1.32530412e+17, 1.34506639e+17, 1.36493462e+17, 1.38490689e+17])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment