Skip to content

Commit

Permalink
updating for new STIS filenames and minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
karllark committed Feb 20, 2024
1 parent 8f5019f commit 8bed087
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
17 changes: 9 additions & 8 deletions measure_extinction/utils/merge_stis_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def read_stis_archive_format(filename):
)
stable = [stable]
else:
sfilename = f"{args.inpath}{args.starname}*_x1d.fits"
sfilename = f"{args.inpath}{args.starname}*.fits"

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

View check run for this annotation

Codecov / codecov/patch

measure_extinction/utils/merge_stis_spec.py#L87

Added line #L87 was not covered by tests
print(sfilename)
sfiles = glob.glob(sfilename)
print(sfiles)
Expand Down Expand Up @@ -117,13 +117,14 @@ def read_stis_archive_format(filename):
fig, ax = plt.subplots(nrows=1, ncols=1, figsize=(10, 5.5))

gvals = stable[0]["NPTS"] > 0
ax.plot(
stable[0]["WAVELENGTH"][gvals],
stable[0]["FLUX"][gvals],
"k-",
alpha=0.5,
label="orig",
)
for ctable in stable:
ax.plot(

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

View check run for this annotation

Codecov / codecov/patch

measure_extinction/utils/merge_stis_spec.py#L120-L121

Added lines #L120 - L121 were not covered by tests
ctable["WAVELENGTH"][gvals],
ctable["FLUX"][gvals],
"k-",
alpha=0.5,
label="orig",
)
gvals = rb_stis["NPTS"] > 0
ax.plot(
rb_stis["WAVELENGTH"][gvals],
Expand Down
18 changes: 12 additions & 6 deletions measure_extinction/utils/plot_mspec.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
#!/usr/bin/env python

from __future__ import absolute_import, division, print_function, unicode_literals

# import pkg_resources
import argparse
import matplotlib.pyplot as plt
import matplotlib as mpl

import numpy as np
import astropy.units as u

from measure_extinction.stardata import StarData
Expand Down Expand Up @@ -51,12 +47,20 @@ def plot_mspec_parser():
# setup the plot
fig, ax = plt.subplots(figsize=(13, 10))

# setup continuous colors
color_indices = np.array(range(len(starnames))) / len(starnames)

Check warning on line 51 in measure_extinction/utils/plot_mspec.py

View check run for this annotation

Codecov / codecov/patch

measure_extinction/utils/plot_mspec.py#L51

Added line #L51 was not covered by tests

cmap = mpl.cm.plasma
color = iter(cmap(np.linspace(0.1, 0.9, len(starnames))))

Check warning on line 54 in measure_extinction/utils/plot_mspec.py

View check run for this annotation

Codecov / codecov/patch

measure_extinction/utils/plot_mspec.py#L53-L54

Added lines #L53 - L54 were not covered by tests

# plot the bands and all spectra for this star
# plot all the spectra on the same plot
for k, cstarname in enumerate(starnames):
c = next(color)

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

View check run for this annotation

Codecov / codecov/patch

measure_extinction/utils/plot_mspec.py#L59

Added line #L59 was not covered by tests
fstarname, file_path = get_full_starfile(cstarname)
starobs = StarData(fstarname, path=file_path)
starobs.plot(ax, norm_wave_range=[0.2, 0.3] * u.micron, yoffset=2**k)
starobs.plot(ax, norm_wave_range=[0.3, 0.8] * u.micron, yoffset=2**k, pcolor=c,

Check warning on line 62 in measure_extinction/utils/plot_mspec.py

View check run for this annotation

Codecov / codecov/patch

measure_extinction/utils/plot_mspec.py#L62

Added line #L62 was not covered by tests
legend_key="BAND", legend_label=cstarname)

# finish configuring the plot
ax.set_yscale("log")
Expand All @@ -66,6 +70,8 @@ def plot_mspec_parser():
ax.tick_params("both", length=10, width=2, which="major")
ax.tick_params("both", length=5, width=1, which="minor")

ax.legend(ncol=2)

Check warning on line 73 in measure_extinction/utils/plot_mspec.py

View check run for this annotation

Codecov / codecov/patch

measure_extinction/utils/plot_mspec.py#L73

Added line #L73 was not covered by tests

# use the whitespace better
fig.tight_layout()

Expand Down

0 comments on commit 8bed087

Please sign in to comment.