Skip to content

Commit

Permalink
Fix codestyle errors and add else
Browse files Browse the repository at this point in the history
  • Loading branch information
Chamani Gunasekera committed Sep 12, 2024
1 parent 3940885 commit ed897cf
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
22 changes: 15 additions & 7 deletions measure_extinction/modeldata.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,9 @@ def dust_extinguished_sed(self, params, sed, fit_range="all", velocity=0.0):
sed : dict
fluxes for each spectral piece
fit_range : string, optional
keyword to toggle SED fitting to be done with G23 only or to also include curve_F99_method
velocity : float, optional
velocity of dust
Expand All @@ -234,13 +237,13 @@ def dust_extinguished_sed(self, params, sed, fit_range="all", velocity=0.0):

# create the extinguished sed
ext_sed = {}
if fit_range == "g23":
if fit_range.lower() == "g23":
for cspec in self.fluxes.keys():
shifted_waves = (1.0 - velocity / 2.998e5) * self.waves[cspec]
axav = g23mod(shifted_waves)
ext_sed[cspec] = sed[cspec] * (10 ** (-0.4 * axav * params[0]))

elif fit_range == "all":
elif fit_range.lower() == "all":
optnir_axav_x = np.flip(1.0 / (np.arange(0.35, 30.0, 0.1) * u.micron))
optnir_axav_y = g23mod(optnir_axav_x)

Expand All @@ -255,11 +258,11 @@ def dust_extinguished_sed(self, params, sed, fit_range="all", velocity=0.0):
shifted_waves,
Rv,
C1,
params[2], #C2
params[3], #C3
params[4], #C4
xo=params[5], #xo
gamma=params[6], #gamma
params[2], # C2
params[3], # C3
params[4], # C4
xo=params[5], # xo
gamma=params[6], # gamma
optnir_axav_x=optnir_axav_x.value,
optnir_axav_y=optnir_axav_y,
valid_x_range=[0.033, 11.0],
Expand All @@ -277,6 +280,11 @@ def dust_extinguished_sed(self, params, sed, fit_range="all", velocity=0.0):
# axav = g23mod(shifted_waves)
# ext_sed[cspec] = sed[cspec] * (10 ** (-0.4 * axav * params[0]))

else:
raise ValueError(
"Incorrect input for fit_range argument in dust_extinguished_sed(). Available options are: g23, all"
)

return ext_sed

def dust_extinguished_sed_FM04(self, params, sed, velocity=0.0):
Expand Down
7 changes: 4 additions & 3 deletions measure_extinction/utils/fit_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ def lnlike(self, params, obsdata, modeldata, fit_range="all"):

# dust_extinguished sed
ext_modsed = modeldata.dust_extinguished_sed(
params[3:10], modsed, fit_range=fit_range,
velocity=self.velocities[0]
params[3:10], modsed, fit_range=fit_range, velocity=self.velocities[0]
)

# hi_abs sed
Expand All @@ -101,7 +100,9 @@ def lnlike(self, params, obsdata, modeldata, fit_range="all"):
try:
gvals = (self.weights[cspec] > 0) & (np.isfinite(hi_ext_modsed[cspec]))
except ValueError:
raise ValueError("Oops! The model data and reddened star data did not match.\n Hint: Make sure that the BAND name in the .dat files match.")
raise ValueError(
"Oops! The model data and reddened star data did not match.\n Hint: Make sure that the BAND name in the .dat files match."
)
chiarr = np.square(
(
obsdata.data[cspec].fluxes[gvals].value
Expand Down

0 comments on commit ed897cf

Please sign in to comment.