From 8bed087b220650cd43da4b6d95929b63f2f26097 Mon Sep 17 00:00:00 2001 From: "Karl D. Gordon" Date: Tue, 20 Feb 2024 09:32:27 -0500 Subject: [PATCH] updating for new STIS filenames and minor improvements --- measure_extinction/utils/merge_stis_spec.py | 17 +++++++++-------- measure_extinction/utils/plot_mspec.py | 18 ++++++++++++------ 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/measure_extinction/utils/merge_stis_spec.py b/measure_extinction/utils/merge_stis_spec.py index 3b0e10a..0c541cb 100644 --- a/measure_extinction/utils/merge_stis_spec.py +++ b/measure_extinction/utils/merge_stis_spec.py @@ -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" print(sfilename) sfiles = glob.glob(sfilename) print(sfiles) @@ -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( + ctable["WAVELENGTH"][gvals], + ctable["FLUX"][gvals], + "k-", + alpha=0.5, + label="orig", + ) gvals = rb_stis["NPTS"] > 0 ax.plot( rb_stis["WAVELENGTH"][gvals], diff --git a/measure_extinction/utils/plot_mspec.py b/measure_extinction/utils/plot_mspec.py index 047c1e7..336d6ec 100755 --- a/measure_extinction/utils/plot_mspec.py +++ b/measure_extinction/utils/plot_mspec.py @@ -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 @@ -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) + + cmap = mpl.cm.plasma + color = iter(cmap(np.linspace(0.1, 0.9, len(starnames)))) + # 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) 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, + legend_key="BAND", legend_label=cstarname) # finish configuring the plot ax.set_yscale("log") @@ -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) + # use the whitespace better fig.tight_layout()