Skip to content

Commit

Permalink
adding in ABmag support
Browse files Browse the repository at this point in the history
  • Loading branch information
karllark committed Sep 9, 2024
1 parent 2528ec4 commit ff1c2d2
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 5 deletions.
43 changes: 38 additions & 5 deletions measure_extinction/stardata.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ def __init__(self, type):
def read_bands(self, lines, only_bands=None):
"""
Read the photometric band data from a DAT file
and upate class variables.
and update class variables.
Bands are filled in wavelength order to make life
easier in subsequent calcuations (interpolations!)
easier in subsequent calculations (interpolations!)
Parameters
----------
Expand All @@ -105,12 +105,21 @@ def read_bands(self, lines, only_bands=None):

if (eqpos >= 0) & (pmpos >= 0) & (line[0] != "#"):
# check for reference or unit
colpos = max((line.find(";"), line.find("#"), line.find("mJy")))
colpos = max(
(
line.find(";"),
line.find("#"),
line.find("mJy"),
line.find("ABmag"),
)
)
if colpos == -1:
colpos = len(line)
# if there is both a reference and a unit
elif line.find(";") != -1 and line.find("mJy") != -1:
colpos = min(line.find(";"), line.find("mJy"))
elif line.find(";") != -1 and (
line.find("mJy") != -1 or line.find("ABmag") != -1
):
colpos = min(line.find(";"), line.find("mJy"), line.find("ABmag"))

Check warning on line 122 in measure_extinction/stardata.py

View check run for this annotation

Codecov / codecov/patch

measure_extinction/stardata.py#L122

Added line #L122 was not covered by tests
band_name = line[0:eqpos].strip()

save_band = False
Expand All @@ -127,6 +136,8 @@ def read_bands(self, lines, only_bands=None):
# units
if line.find("mJy") >= 0:
self.band_units[band_name] = "mJy"
elif line.find("ABmag") >= 0:
self.band_units[band_name] = "ABmag"

Check warning on line 140 in measure_extinction/stardata.py

View check run for this annotation

Codecov / codecov/patch

measure_extinction/stardata.py#L140

Added line #L140 was not covered by tests
else:
self.band_units[band_name] = "mag"

Expand Down Expand Up @@ -479,6 +490,28 @@ def get_band_fluxes(self):
0.5 * (_flux2 - _flux1),
)
self.band_waves[pband_name] = poss_bands[pband_name][1]
elif _mag_vals[2] == "ABmag":
_flux1_nu = np.power(

Check warning on line 494 in measure_extinction/stardata.py

View check run for this annotation

Codecov / codecov/patch

measure_extinction/stardata.py#L493-L494

Added lines #L493 - L494 were not covered by tests
10.0, (-0.4 * (_mag_vals[0] + _mag_vals[1] + 48.60))
)
_flux1_nu *= u.erg / (u.cm * u.cm * u.s * u.Hz)
_flux1 = _flux1_nu.to(

Check warning on line 498 in measure_extinction/stardata.py

View check run for this annotation

Codecov / codecov/patch

measure_extinction/stardata.py#L497-L498

Added lines #L497 - L498 were not covered by tests
fluxunit,
equivalencies=u.spectral_density(poss_bands[pband_name][1] * u.micron),
)
_flux2_nu = np.power(

Check warning on line 502 in measure_extinction/stardata.py

View check run for this annotation

Codecov / codecov/patch

measure_extinction/stardata.py#L502

Added line #L502 was not covered by tests
10.0, (-0.4 * (_mag_vals[0] - _mag_vals[1] + 48.60))
)
_flux2_nu *= u.erg / (u.cm * u.cm * u.s * u.Hz)
_flux2 = _flux2_nu.to(

Check warning on line 506 in measure_extinction/stardata.py

View check run for this annotation

Codecov / codecov/patch

measure_extinction/stardata.py#L505-L506

Added lines #L505 - L506 were not covered by tests
fluxunit,
equivalencies=u.spectral_density(poss_bands[pband_name][1] * u.micron),
)
self.band_fluxes[pband_name] = (

Check warning on line 510 in measure_extinction/stardata.py

View check run for this annotation

Codecov / codecov/patch

measure_extinction/stardata.py#L510

Added line #L510 was not covered by tests
0.5 * (_flux1.value + _flux2.value),
0.5 * (_flux2.value - _flux1.value),
)
self.band_waves[pband_name] = poss_bands[pband_name][1]

Check warning on line 514 in measure_extinction/stardata.py

View check run for this annotation

Codecov / codecov/patch

measure_extinction/stardata.py#L514

Added line #L514 was not covered by tests
elif _mag_vals[2] == "mJy":
self.band_waves[pband_name] = poss_bands[pband_name][1]
mfac = (
Expand Down
2 changes: 2 additions & 0 deletions measure_extinction/utils/merge_stis_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ def read_stis_archive_format(filename):

if args.ralph:
sfilename = "%s/%s/%s.mrg" % (args.inpath, args.waveregion, args.starname)
sfilename = f"{args.inpath}{args.starname}.mrg"

Check warning on line 59 in measure_extinction/utils/merge_stis_spec.py

View check run for this annotation

Codecov / codecov/patch

measure_extinction/utils/merge_stis_spec.py#L59

Added line #L59 was not covered by tests


# determine the line for the 1st data (can vary between files)
f = open(sfilename, "r")
Expand Down

0 comments on commit ff1c2d2

Please sign in to comment.