<jupyter_start><jupyter_text>`pysynphot2d` DemoThis notebook is a demonstration of the `pysynphot2d` wrapper which vectorizes the functionality of `pysynphot` so that it supports 2D spectra.<jupyter_code>%matplotlib inline
import numpy as np
import pysynphot as ps
import matplotlib.pyplot as plt
from pysynphot2d import psp2d<jupyter_output><empty_output><jupyter_text>`ArraySpectrum` to `ArraySpectra`Just pass a 1D wavelength array and 2D flux array to `psp2d.ArraySpectra` as you would pass a 1D flux array to `pysynphot.ArraySpectrum`.Here's a simple example with some toy data:<jupyter_code># Dummy data
wave = np.linspace(4000,8000,20)
flux = np.arange(100).reshape(5,20)
toy2D = psp2d.ArraySpectra(wave, flux)

# Take a look
for spec in toy2D.spectra:
    plt.plot(spec.wave, spec.flux)<jupyter_output><empty_output><jupyter_text>Now let's do some method calls as we would for a `pysynphot.ArraySpectrum` object.<jupyter_code># Sample each spectrum at the given wavelength
sampled_spectra = toy2D.sample(6789)
print('Samples:',sampled_spectra)
# Renormalize each spectrum to the given magnitude
V_band = ps.ObsBandpass('johnson,v')
renormed_spectra = toy2D.renorm(17, 'vegamag', V_band)

# Take a look
for spec in renormed_spectra:
    plt.plot(spec.wave, spec.flux)<jupyter_output><empty_output><jupyter_text>That's it! Try your favorite `pysynphot` methods on your new `psp2d.ArraySpectra` objects (and let me know if it breaks!).  `Observation` to `Observations`Just pass your `psp2d.ArraySpectra` object to `psp2d.Observations` along with a `pysynphot.ObsBandpass` as you would pass `pysynphot.ArraySpectrum` to `pysynphot.Observation`:<jupyter_code># Dummy observations
obs2d = psp2d.Observations(toy2D, V_band)

# Take a look
for spec in obs2d.spectra:
    plt.plot(spec.wave, spec.flux)<jupyter_output>(/grp/hst/cdbs/comp/nonhst/johnson_v_004_syn.fits) does not have a defined binset in the wavecat table. The waveset of the spectrum will be used instead.
(/grp/hst/cdbs/comp/nonhst/johnson_v_004_syn.fits) does not have a defined binset in the wavecat table. The waveset of the spectrum will be used instead.
(/grp/hst/cdbs/comp/nonhst/johnson_v_004_syn.fits) does not have a defined binset in the wavecat table. The waveset of the spectrum will be used instead.
(/grp/hst/cdbs/comp/nonhst/johnson_v_004_syn.fits) does not have a defined binset in the wavecat table. The waveset of the spectrum will be used instead.
(/grp/hst/cdbs/comp/nonhst/johnson_v_004_syn.fits) does not have a defined binset in the wavecat table. The waveset of the spectrum will be used instead.
{'fraction_non_alphanumeric': 0.08662026295436968, 'fraction_numerical': 0.02242846094354215, 'mean_word_length': 5.684754521963824, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '503666', 'license': 'MIT', 'n_tokens_mistral': 983, 'n_tokens_neox': 911, 'n_words': 282, 'path': 'psp2d_demo.ipynb', 'repo_name': 'hover2pi/pysynphot2d', 'size': '2586'}