Skip to content

Commit

Permalink
MIRI merging units fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
karllark committed Feb 22, 2024
1 parent ce4040a commit 9a9e6f5
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 15 deletions.
7 changes: 4 additions & 3 deletions measure_extinction/merge_obsspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def merge_gen_obsspec(obstables, wave_range, output_resolution=100):
Parameters
----------
obstables : list of astropy Table objects
list of tables containing the observed IRS spectra
list of tables containing the observed spectra
usually the result of reading tables
wave_range : 2 element float
Expand Down Expand Up @@ -367,7 +367,7 @@ def merge_irs_obsspec(obstables, output_resolution=150):
"""
wave_range = [5.0, 40.0] * u.micron
otable = merge_gen_obsspec(
obstables, wave_range, output_resolution=output_resolution
obstables, wave_range, output_resolution=output_resolution,
)
return otable

Expand Down Expand Up @@ -421,6 +421,7 @@ def merge_miri_ifu_obsspec(obstables, output_resolution=3000):
"""
wave_range = [4.8, 29.0] * u.micron
otable = merge_gen_obsspec(
obstables, wave_range, output_resolution=output_resolution
obstables, wave_range, output_resolution=output_resolution,
)

return otable
6 changes: 3 additions & 3 deletions measure_extinction/modeldata.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def stellar_sed(self, params, velocity=None):

return sed

def dust_extinguished_sed_FM90_G23(self, params, sed, velocity=0.0):
def dust_extinguished_sed(self, params, sed, velocity=0.0):
"""
Dust extinguished sed given the extinction parameters
Expand Down Expand Up @@ -254,7 +254,7 @@ def dust_extinguished_sed_FM90_G23(self, params, sed, velocity=0.0):
params[6],
optnir_axav_x.value,
optnir_axav_y,
[0.2, 11.0],
[0.033, 11.0],
"FM90_G23_measure_extinction",
)
ext_sed[cspec] = sed[cspec] * (10 ** (-0.4 * axav * params[0]))
Expand All @@ -270,7 +270,7 @@ def dust_extinguished_sed_FM90_G23(self, params, sed, velocity=0.0):

return ext_sed

def dust_extinguished_sed(self, params, sed, velocity=0.0):
def dust_extinguished_sed_FM04(self, params, sed, velocity=0.0):
"""
Dust extinguished sed given the extinction parameters
Expand Down
3 changes: 0 additions & 3 deletions measure_extinction/stardata.py
Original file line number Diff line number Diff line change
Expand Up @@ -844,9 +844,6 @@ def read_miri_ifu(self, line, path="./"):
"""
self.read_spectra(line, path)

# add units
self.fluxes = self.fluxes.value * u.Jy
self.uncs = self.uncs.value * u.Jy
self.fluxes = self.fluxes.to(
fluxunit, equivalencies=u.spectral_density(self.waves)
)
Expand Down
20 changes: 14 additions & 6 deletions measure_extinction/utils/merge_miri_ifu_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from measure_extinction.merge_obsspec import merge_miri_ifu_obsspec


fluxunit = u.erg / (u.s * u.cm * u.cm * u.angstrom)
fluxunit = u.erg / (u.cm * u.cm * u.s * u.angstrom)


if __name__ == "__main__":
Expand Down Expand Up @@ -61,7 +61,6 @@
mrs_file = f"{outname}_miri_ifu.fits"
rb_mrs.write(f"{args.outpath}/{mrs_file}", overwrite=True)


# plot the original and merged Spectra
fontsize = 14
font = {"size": fontsize}
Expand All @@ -75,19 +74,28 @@

for ctable in stable:
gvals = ctable["NPTS"] > 0
cfluxes = (

Check warning on line 77 in measure_extinction/utils/merge_miri_ifu_spec.py

View check run for this annotation

Codecov / codecov/patch

measure_extinction/utils/merge_miri_ifu_spec.py#L75-L77

Added lines #L75 - L77 were not covered by tests
ctable["FLUX"]
.to(fluxunit, equivalencies=u.spectral_density(ctable["WAVELENGTH"]))
.value
)
ax.plot(

Check warning on line 82 in measure_extinction/utils/merge_miri_ifu_spec.py

View check run for this annotation

Codecov / codecov/patch

measure_extinction/utils/merge_miri_ifu_spec.py#L82

Added line #L82 was not covered by tests
ctable["WAVELENGTH"][gvals],
ctable["FLUX"][gvals],
cfluxes[gvals],
"k-",
alpha=0.5,
label="orig",
)
gvals = rb_mrs["NPTS"] > 0
cfluxes = rb_mrs["FLUX"][gvals].data * fluxunit
# cfluxes = (rb_mrs["FLUX"][gvals].data * fluxunit).to(u.Jy, equivalencies=u.spectral_density(rb_mrs["WAVELENGTH"].data)).value
cfluxes = (

Check warning on line 90 in measure_extinction/utils/merge_miri_ifu_spec.py

View check run for this annotation

Codecov / codecov/patch

measure_extinction/utils/merge_miri_ifu_spec.py#L89-L90

Added lines #L89 - L90 were not covered by tests
rb_mrs["FLUX"]
.to(fluxunit, equivalencies=u.spectral_density(ctable["WAVELENGTH"]))
.value
)

ax.plot(

Check warning on line 96 in measure_extinction/utils/merge_miri_ifu_spec.py

View check run for this annotation

Codecov / codecov/patch

measure_extinction/utils/merge_miri_ifu_spec.py#L96

Added line #L96 was not covered by tests
rb_mrs["WAVELENGTH"][gvals].to(u.micron),
cfluxes,
rb_mrs["FLUX"][gvals],
"b-",
alpha=0.5,
label="merged",
Expand Down

0 comments on commit 9a9e6f5

Please sign in to comment.