Skip to main content

SMART (Spectral Modeling Analysis and RV Tool)

The SMART is a Markov Chain Monte Carlo (MCMC) forward-modeling framework for spectroscopic data, currently working for the Keck/NIRSPEC, SDSS/APOGEE, and IGRINS high-resolution near-infrared spectrometers. A slightly modified version that can model the Keck/OSIRIS medium-resolution near-infrared spectrometer is available here.

For NIRSPEC users, required adjustments need to be made before reducing private data using NIRSPEC-Data-Reduction-Pipeline(NSDRP), to perform telluric wavelength calibrations, and to forward model spectral data. The code is currently being developed.

Authors:

  • Dino Chih-Chun Hsu (Northwestern, UCSD)
  • Adam Burgasser, PI (UCSD)
  • Chris Theissen (UCSD, BU)
  • Jessica Birky (UW, UCSD)
  • Lingfeng Wei (UCSD)

Code Setup:

Dependencies. The SMART has been tested under the following environments:

  • Python 3.6.10/3.7.3
  • astropy 3.0.4/3.0.5
  • numpy 1.12.1/1.13.3/1.18.1
  • scipy 0.19.0/1.4.1
  • matplotlib 2.2.3/3.1.3
  • pandas 0.20.1/0.23.4/1.0.1
  • emcee 3.0.2/3.0.3.dev4+gc14b212
  • corner 2.0.1
  • openpyxl 3.0.10
  • wavelets (for defringeflat)

Download the SMART and the forked and modified version of the NSDRP to your computer.

There are two ways of setting up the code:


(i) In the terminal under the SMART folder,

pip install -e .


(ii) Set up the environment variables in the .bashrc or .bash_profile

export PYTHONPATH="/path/to/smart:${PYTHONPATH}"

To model the SDSS/APOGEE spectra, you will also need to put the associated APOGEE LSF and wavelength fits files under forward_model/apogee/:

apLSF-a-05440020.fits
apLSF-b-05440020.fits
apLSF-c-05440020.fits
apWave-a-02420038.fits
apWave-b-02420038.fits
apWave-c-02420038.fits

The codes under the apogee folder are from Jo Bovy's apogee package.

Defringe Flats:

The algorithm follows Rojo & Harrington (2006) to remove fringe patterns from flat files. The example and sample outputs are under the example folder.

>>> import smart
>>> smart.defringeflatAll(data_folder_path, diagnostic=False)

Reducing the data using NSDRP:

To reduce the data for the whole folder, use the forked NSDRP on the terminal:

$ python ~/path/to/NIRSPEC-Data-Reduction-Pipeline/nsdrp.py rawData/ reducedData/ -oh_filename ~/path/to/NIRSPEC-Data-Reduction-Pipeline/ir_ohlines.dat -spatial_jump_override -verbose -debug

, where the directory rawData/ is the path to the raw data is, and reducedData/ is the path where you want to store the reduced data.

To reduce the data of two nodding positions with a single flat file, you can run the following command:

$ python ~/path/to/NIRSPEC-Data-Reduction-Pipeline/nsdrp.py flat_file.fits nod_A_file.fits -b nod_B_file.fits -oh_filename ~/path/to/NIRSPEC-Data-Reduction-Pipeline/ir_ohlines.dat -spatial_jump_override -verbose -debug

Wavelength Calibration using Telluric Standard Spectra:

To calibrate the most precise wavelength solutions with a given data, we rely on the telluric spectrum using the algorithm that follows Blake at el. (2010) and Burgasser et al. (2016) to cross-correlate the ESO atmospheric model and an observed telluric spectrum, fit the residual, and iterate the process until the standard deviation of the residual reaches a mininum.

>>> import smart
>>> smart.run_wave_cal(data_name, data_path, order_list, save_to_path, test=False, save=True, applymask=True, pwv='0.5')

The parameters data_name, data_path, save_to_path have the type str, while order_list has the type list. The optional parameter applymask provides a simple sigma-clipping mask to remove cosmic rays in the telluric spectrum. The optional parameter pwv is the precipitable water vapor parameter for users to adjust. Typically, 0.5 mm to 3.0 mm can fit most cases under different weather conditions.

Forward Modeling Science and Telluric Spectra:

To fit the science data, SMART provides various self-consistent synthetic modeling grids to forward-model the data that are available to download here. Users will need to place the downloaded files in smart/libraries.

We perform the MCMC forward-modeling fitting to the high-resolution near-infrared spectroscopic data for both the telluric and science files.

The telluric spectrum after being calibrated with its wavelength solution is modeled with the equation:

D[p] = C[p] \times \Bigg[ \bigg(M \Big[p^* \big(\lambda \big[ 1 + \frac{RV^*}{c}\big] \big) , T_{\text{eff}}, \log{g} \Big] \otimes \kappa_R (v\sin{i}) \bigg) \times T \big[ p^*(\lambda) \big] \Bigg] \otimes \kappa_G (\Delta \nu_{inst}) + C_{flux}

, where $D[p]$ is the forward-model telluric spectrum, $C[p(\lambda)]$ is the continuum, $T \big[ p^*(\lambda) \big]$ is the earth atmosphere absorption model as a function of airmass and precipitable water vapor (pwv), $\Delta \nu_{inst}(p)$ is the instrumental line-spread function, and $C_{flux}$ is the nuisance parameter accounting for small flux offsets.

You can run the following command on the terminal:

>>> python /SMART_BASE/smart/smart/forward_model/run_mcmc_telluric_airmass_pwv.py order date_obs tell_data_name tell_path save_to_path -nwalkers 50 -step 600 -burn 300 -pixel_start 50 -pixel_end -80

The required parameters are nirspec order sorting filter order (e.g. 33), data of observation (e.g. 20100101) date_obs, telluric data name (e.g. nspec200101_1001) tell_data_name, telluric file path tell_path (e.g. BASE/data_obs), saving path save_to_path, and optional paramters MCMC number of chains/walkers -nwalkers, number of steps -step, burn-in -burn, starting/ending pixels -pixel_start and -pixel_end.

The most important parameter used as the input in the science modeling is the NIRSPEC instrumental line-spread function lsf.

The science spectrum is modeled with the equation:

D[p] = C[p] \times \Bigg[ \bigg(M \Big[p^* \big(\lambda \big[ 1 + \frac{RV^*}{c}\big] \big) , T_{\text{eff}}, \log{g} \Big] \otimes \kappa_R (v\sin{i}) \bigg) \times T \big[ p^*(\lambda) \big] \Bigg] \otimes \kappa_G (\Delta \nu_{inst}) + C_{flux}

, where $D[p]$ is the forward-model science spectrum, $C[p(\lambda)]$ is the continuum, $M \big[ p^*(\lambda) \big]$ is the self-consistent synthetic stellar/substellar modeling grids as a function of effective temperature $T_{\text{eff}}$ and surface gravity $\log{g}$, corrected with radial velocity $RV$ and projected rotational velocity $v\sin{i}$, $[ T \big[ p^*(\lambda) \big]$ is the earth atmosphere absorption model, $\Delta \nu_{inst}(p)$ is the instrumental line-spread function, $C_{flux}$ is the nuisance parameter accounting for small flux offsets. There are also two nudge factors for small wavelength offsets and noise scaling factors in the routine.

You can run the following command on the terminal:

>>> python /SMART_BASE/smart/smart/forward_model/run_mcmc_science.py order date_obs sci_data_name tell_data_name data_path tell_path save_to_path lsf -outlier_rejection 3.0 -nwalkers 50 -step 1000 -burn 800 -moves 2.0 -pixel_start 10 -pixel_end -80 -applymask False -modelset btsettl08

The required parameters order sorting filter order, data of observation date_obs, science data name sci_data_name, telluric data name tell_data_name, science file path data_path, telluric file path tell_path, saving path save_to_path, optional paramters MCMC number of chains/walkers -nwalkers, number of steps -step, burn-in -burn, starting/ending pixels -pixel_start and -pixel_end are defined the same as the telluric data modeling routine. The NIRSPEC line-spread function lsf is obtained from the telluric data modeling (typically 4.8 km/s). The outlier rejection -outlier_rejection is to perform a sigma-clipping outlier rejection (in this case sigma=3.0) to remove bad pixels by comparing the residual of the best-fit model and observed data. Finally, the model set to use -modelset in this case is the BT-Settl models. Other model sets are available and described in detail here.

Citation:

If you use this code in your research, please cite Hsu et al. 2021; ApJS, 257, 45 and the frozen version is on Hsu et al. 2021 Zenodo

Depending on which model sets you choose, please also cite the corresponding references listed under here.

Please also cite Carvalho & Johns-Krull (2023) if you enable slow (but accurate) rotational broadening in the forward-modeling routine.

Metadata

Release files for smart-astro 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for smart-astro 1.0.0
File Size Uploaded
smart_astro-1.0.0.tar.gz 158.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for smart-astro 1.0.0
File Interpreter ABI Platform
smart_astro-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 357.6 kB

Release files / smart_astro-1.0.0.tar.gz

Download URL smart_astro-1.0.0.tar.gz
Size 158.1 kB
Tags Source
SHA-256 checksum
How to use checksums
3844bb8aadd1a2fa1979521e8764940ce6b48cf6963b9cedd6ad8c5c2e86bb72
BLAKE2b-256 checksum
How to use checksums
b8d345af65ae163a5c254af5e7df739ccb3387a50644f67149f0ed93b65b3917
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.8

Release files / smart_astro-1.0.0-py3-none-any.whl

Download URL smart_astro-1.0.0-py3-none-any.whl
Size 199.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b70539c3cd8fb96ebcc4a02d46cceaf987c7ac7472c777215cb620109d1b6240
BLAKE2b-256 checksum
How to use checksums
04893d1a8fb670eb9418ea5b7b5438e9b7eabc853003eee1dc4d3b9930c3f65f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.8

Release history Release notifications | RSS feed

1.0.1

2 release files

This release

1.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page