Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding in ACS SBC, WFC3 and ACS narrow, and JWST filters and enhancing the filter plotting routine #799

Merged
merged 24 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
adding in ACS HRC filters and enhancing the filter plotting routine
  • Loading branch information
karllark committed May 14, 2024
commit 105bb6f328c192b3f5fd775e0f0140365e7c4c7a
32 changes: 22 additions & 10 deletions beast/plotting/plot_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def plot_filters(
filter_names,
filterLib=None,
save_name="beast_filters",
xlim=[1.4e3, 2e4],
xlim=[3e3, 1e3],
ylim=[1e-4, 2],
show_plot=True,
):
Expand Down Expand Up @@ -50,8 +50,11 @@ def plot_filters(
)

color_indices = np.log10(np.array(np.sort([f.norm for f in flist])))
color_indices -= color_indices.min()
color_indices /= color_indices.max()
if len(color_indices) > 1:
color_indices -= color_indices.min()
color_indices /= color_indices.max()
else:
color_indices = [0.0]

cmap = mpl.cm.plasma
# ax.set_prop_cycle(color=[cmap(i) for i in color_indices])
Expand All @@ -61,19 +64,25 @@ def plot_filters(
c = next(color)
ax.plot(f.wavelength, f.transmit, color=c, lw=2)
ax.fill_between(f.wavelength, f.transmit, alpha=0.2, color=c)
yval_text = max(f.transmit * 0.1)
ax.text(
np.nanmean(f.wavelength[f.transmit > 100.0 * ylim[0]]),
1.3 * np.nanmax(f.transmit[f.transmit > ylim[0]]),
np.nanmean(f.wavelength[f.transmit > yval_text]),
1.3 * np.nanmax(f.transmit[f.transmit > yval_text]),
f.name.split("_")[-1],
ha="center",
color=c,
)
gvals = (f.transmit > ylim[0]) & (f.transmit < ylim[1])
if min(f.wavelength[gvals]) < xlim[0]:
xlim[0] = min(f.wavelength[gvals])
if max(f.wavelength[gvals]) > xlim[1]:
xlim[1] = max(f.wavelength[gvals])

ax.set_xscale("log")
ax.set_yscale("log")
ax.set_xlim(xlim)
ax.set_ylim(ylim)
ax.set_xlabel(r"$\lambda$ [$\mu m$]")
ax.set_xlabel(r"$\lambda$ [$\AA$]")
ax.set_ylabel(r"$B_i(\lambda)$")

# ax.set_xticks([0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 2.0])
Expand All @@ -95,9 +104,7 @@ def plot_filters(
default="filters.appendVegaFilter",
help="Save figure to file",
)
args = parser.parse_args()

filter_names = [
def_filter_names = [
"HST_WFC3_F225W",
"HST_WFC3_F275W",
"HST_WFC3_F336W",
Expand All @@ -107,8 +114,13 @@ def plot_filters(
"HST_WFC3_F110W",
"HST_WFC3_F160W",
]
parser.add_argument("filter_names",
help="names of filters",
nargs='+',
default=def_filter_names)
args = parser.parse_args()

fig = plot_filters(filter_names, show_plot=False)
fig = plot_filters(args.filter_names, show_plot=False)

if args.tex:
plt.rc({"usetex": True})
Expand Down
50 changes: 49 additions & 1 deletion beast/tools/make_libfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,16 @@ def make_libfile():
"f775w",
"f814w",
]

acs_hrc = [
"f115lp",
"f125lp",
"f140lp",
"f150lp",
"f165lp",
"f122m",
]

# galex
galex = ["fuv", "nuv"]

Expand Down Expand Up @@ -228,7 +238,7 @@ def make_libfile():
pwaves.append(newfilt.lpivot.value)
comments.append("avg of 1, 2, 3, 4")

# Loop through ACS filters
# Loop through ACS WFC filters
for filt in acs_wfc:

# define wfc1, wfc2 modes
Expand Down Expand Up @@ -270,6 +280,44 @@ def make_libfile():
pwaves.append(newfilt.lpivot.value)
comments.append("avg of wfc1 and wfc2")

# Loop through ACS HRC filters
for filt in acs_hrc:

# define ir mode
mode = "acs, sbc, " + filt

# pull bandpasses from stsynphot for the two uvis modes
bp = stsyn.band(mode)

# extract the wavelength array
wave = bp.waveset

# define the filter name
filter_name = "HST_ACS_SBC_" + filt.upper()

# build array of wavelength and throughput
arr = np.array(
list(zip(wave.value.astype(np.float64), bp(wave).astype(np.float64))),
dtype=[("WAVELENGTH", "float64"), ("THROUGHPUT", "float64")],
)

# append dataset to the hdf5 filters group
f.create_dataset(filter_name, data=arr)

# generate filter instance to compute relevant info
newfilt = phot.Filter(wave, bp(wave), name=filt.upper())

# populate contents lists with relevant information
tablenames.append(filter_name)
observatories.append("HST")
instruments.append("ACS")
names.append(newfilt.name)
norms.append(newfilt.norm.value)
cwaves.append(newfilt.cl.value)
pwaves.append(newfilt.lpivot.value)
comments.append("")


# Loop through GALEX filters:
for filt in galex:
# define ir mode
Expand Down