Simple pipeline

A simple pipeline expliciting with

  • reading some spectral data

  • plotting the data

  • plotting data with additional informative vertical band

  • fitting the data’s continuum

  • extracting a band from that data

  • running a simple fit on the extracted spectral band

import numpy as np
from specmodels.specmodels_base import SpecModel
import specmodels.specmodels_functions as sf
import os

print(os.getcwd())
print(os.path.dirname(os.path.realpath("./raponi_2020_67p_virtis_mir.txt")))
/workspace/cxlfeller/specmodels/pipelines/simple
/workspace/cxlfeller/specmodels/pipelines/simple
# Plot 67P data
data = SpecModel(
    data="./raponi_2020_67p_virtis_mir.txt",
    label="67P (Raponi+2020)",
    ylabel="RADF",
    interpolation_order=5,
)
# Regular plot
_ = data.base_plot()
../../_images/f5cf0e55a1abd2c4bad8e2de26754b58c9e1c0eb0e7066b55f22b3fbb7def351.png
# Define rectangle parameters
rect_params = [
    dict(
        xy=(2.80, 0.0),
        width=0.90,
        height=5.0,
        edgecolor="grey",
        facecolor="grey",
        alpha=0.7,
    ),
]

_ = data.base_plot_norm(wl_ref=1.2, rects=rect_params)
../../_images/c875f9efc03732a8fe89c04c99992ef66b382a206c9637f33b11c4553e0cebc4.png
# Define a set of spectral features to ignore in the fitting
# 1.05 -> 1.10
# 2.80 -> 3.70
mask = np.array([[1.05, 1.10], [2.8, 3.7]], dtype=np.float64)
# Reset the initial continuum fit with the added information
data.continuum_update_fits(order_max=4, mask=mask)
# Re-plot
_ = data.continuum_plt_fit(mask=mask)
../../_images/34d2b763cedc9b5d7d6e6a99ae6bf12acb854f71baa92d2e4c4c2af71187e2be.png ../../_images/ed9cdd11938b7c412541969dce81196db3c3d4307b3dbb8dd481c86957d6c36e.png ../../_images/8a4d2f61d9b0d1acad59b4921a2596143c66eacba6089af5a3f4721b24eb0511.png ../../_images/3b96d48d562a2eb526c55bacfffe732b634f4f2aa753c91fd051df09b5e7918e.png
band_3 = data.rectify_extract_band(
    wrange=np.array([2.75, 3.7]),
    dlt=np.array([[0.05, 0.05], [0.05, 0.05]]),
    label="band 3 µm",
)
../../_images/1312930198aa3c0fe9fe12ca698da43826931944ce7bc5c4c56ea4a356e245c1.png
_ = band_3.base_plot()
../../_images/9b93ca59edb9c6b36ca95a46bc4467dfd3a728b1461b131ed3b5dacc62f063ee.png
# Simple gaussian fit
rd, _, _ = band_3.simple_fit(sf.gaussian, area=True)
../../_images/3c3976bb5fb9f208b8dc981f58e95bf26fede314d2a70c0b3a752c0c63bda902.png

#EOF