smart-astro 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- smart_astro-1.0.0/LICENSE +21 -0
- smart_astro-1.0.0/PKG-INFO +167 -0
- smart_astro-1.0.0/README.md +134 -0
- smart_astro-1.0.0/setup.cfg +4 -0
- smart_astro-1.0.0/setup.py +38 -0
- smart_astro-1.0.0/smart/__init__.py +36 -0
- smart_astro-1.0.0/smart/forward_model/InterpolateModel.py +485 -0
- smart_astro-1.0.0/smart/forward_model/InterpolateModel_txt.py +494 -0
- smart_astro-1.0.0/smart/forward_model/__init__.py +3 -0
- smart_astro-1.0.0/smart/forward_model/apogee/__init__.py +3 -0
- smart_astro-1.0.0/smart/forward_model/apogee/bitmask.py +249 -0
- smart_astro-1.0.0/smart/forward_model/apogee/lsf.py +563 -0
- smart_astro-1.0.0/smart/forward_model/apogee/lsf_function.py +212 -0
- smart_astro-1.0.0/smart/forward_model/apogee/lsf_gh.py +17 -0
- smart_astro-1.0.0/smart/forward_model/classForwardModel.py +47 -0
- smart_astro-1.0.0/smart/forward_model/classForwardModelInit.py +252 -0
- smart_astro-1.0.0/smart/forward_model/classModel.py +232 -0
- smart_astro-1.0.0/smart/forward_model/classSpectrum.py +888 -0
- smart_astro-1.0.0/smart/forward_model/continuum.py +431 -0
- smart_astro-1.0.0/smart/forward_model/fringe_model.py +245 -0
- smart_astro-1.0.0/smart/forward_model/integralResample.py +89 -0
- smart_astro-1.0.0/smart/forward_model/mask.py +184 -0
- smart_astro-1.0.0/smart/forward_model/mcmc.py +1658 -0
- smart_astro-1.0.0/smart/forward_model/mcmc_utils.py +113 -0
- smart_astro-1.0.0/smart/forward_model/model_fit.py +1144 -0
- smart_astro-1.0.0/smart/forward_model/rotation_broaden.py +188 -0
- smart_astro-1.0.0/smart/forward_model/run_mcmc_science.py +803 -0
- smart_astro-1.0.0/smart/forward_model/run_mcmc_science_binary.py +920 -0
- smart_astro-1.0.0/smart/forward_model/run_mcmc_science_binary_igrins.py +928 -0
- smart_astro-1.0.0/smart/forward_model/run_mcmc_science_igrins.py +756 -0
- smart_astro-1.0.0/smart/forward_model/run_mcmc_telluric.py +630 -0
- smart_astro-1.0.0/smart/forward_model/run_mcmc_telluric_airmass_pwv.py +563 -0
- smart_astro-1.0.0/smart/forward_model/run_mcmc_telluric_airmass_pwv_fringe.py +511 -0
- smart_astro-1.0.0/smart/forward_model/run_mcmc_telluric_airmass_pwv_igrins.py +546 -0
- smart_astro-1.0.0/smart/forward_model/run_mcmc_telluric_airmass_pwv_no_wave_offset.py +549 -0
- smart_astro-1.0.0/smart/forward_model/run_mcmc_telluric_airmass_pwv_noise.py +557 -0
- smart_astro-1.0.0/smart/forward_model/tellurics.py +366 -0
- smart_astro-1.0.0/smart/initialize.py +42 -0
- smart_astro-1.0.0/smart/utils/__init__.py +3 -0
- smart_astro-1.0.0/smart/utils/addKeyword.py +147 -0
- smart_astro-1.0.0/smart/utils/barycorr.py +136 -0
- smart_astro-1.0.0/smart/utils/compute_galactic_thin_thick_disk.py +62 -0
- smart_astro-1.0.0/smart/utils/compute_uvw_velocity.py +127 -0
- smart_astro-1.0.0/smart/utils/data_reduction_utils.py +85 -0
- smart_astro-1.0.0/smart/utils/defringeflat.py +491 -0
- smart_astro-1.0.0/smart/utils/defringetelluric.py +298 -0
- smart_astro-1.0.0/smart/utils/hires_tool.py +149 -0
- smart_astro-1.0.0/smart/utils/interpolations.py +436 -0
- smart_astro-1.0.0/smart/utils/listTarget.py +119 -0
- smart_astro-1.0.0/smart/utils/mask.py +167 -0
- smart_astro-1.0.0/smart/utils/run_nsdrp.py +134 -0
- smart_astro-1.0.0/smart/utils/stats.py +19 -0
- smart_astro-1.0.0/smart/utils/subtractDark.py +82 -0
- smart_astro-1.0.0/smart/wavelength_calibration/__init__.py +3 -0
- smart_astro-1.0.0/smart/wavelength_calibration/cal_param.py +48 -0
- smart_astro-1.0.0/smart/wavelength_calibration/residual.py +49 -0
- smart_astro-1.0.0/smart/wavelength_calibration/telluric_wavelength_fit.py +1662 -0
- smart_astro-1.0.0/smart/wavelength_calibration/telluric_wavelength_fit_igrins.py +1488 -0
- smart_astro-1.0.0/smart_astro.egg-info/PKG-INFO +167 -0
- smart_astro-1.0.0/smart_astro.egg-info/SOURCES.txt +62 -0
- smart_astro-1.0.0/smart_astro.egg-info/dependency_links.txt +1 -0
- smart_astro-1.0.0/smart_astro.egg-info/not-zip-safe +1 -0
- smart_astro-1.0.0/smart_astro.egg-info/requires.txt +7 -0
- smart_astro-1.0.0/smart_astro.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 Dino Chih-Chun Hsu
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: smart-astro
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: The Spectral Modeling Analysis and RV Tool
|
|
5
|
+
Home-page: https://github.com/chihchunhsu/smart
|
|
6
|
+
Author: Chih-Chun Hsu
|
|
7
|
+
Author-email: chsu@northwestern.edu
|
|
8
|
+
License: MIT
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Requires-Python: >=3.6
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
Requires-Dist: numpy
|
|
16
|
+
Requires-Dist: scipy
|
|
17
|
+
Requires-Dist: pandas
|
|
18
|
+
Requires-Dist: matplotlib
|
|
19
|
+
Requires-Dist: astropy
|
|
20
|
+
Requires-Dist: emcee
|
|
21
|
+
Requires-Dist: corner
|
|
22
|
+
Dynamic: author
|
|
23
|
+
Dynamic: author-email
|
|
24
|
+
Dynamic: classifier
|
|
25
|
+
Dynamic: description
|
|
26
|
+
Dynamic: description-content-type
|
|
27
|
+
Dynamic: home-page
|
|
28
|
+
Dynamic: license
|
|
29
|
+
Dynamic: license-file
|
|
30
|
+
Dynamic: requires-dist
|
|
31
|
+
Dynamic: requires-python
|
|
32
|
+
Dynamic: summary
|
|
33
|
+
|
|
34
|
+
# SMART (Spectral Modeling Analysis and RV Tool)
|
|
35
|
+
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](https://github.com/ctheissen/osiris_fmp).
|
|
36
|
+
|
|
37
|
+
For NIRSPEC users, required adjustments need to be made before reducing private data using [NIRSPEC-Data-Reduction-Pipeline(NSDRP)](https://github.com/Keck-DataReductionPipelines/NIRSPEC-Data-Reduction-Pipeline), to perform telluric wavelength calibrations, and to forward model spectral data. The code is currently being developed.
|
|
38
|
+
|
|
39
|
+
Authors:
|
|
40
|
+
* Dino Chih-Chun Hsu (Northwestern, UCSD)
|
|
41
|
+
* Adam Burgasser, PI (UCSD)
|
|
42
|
+
* Chris Theissen (UCSD, BU)
|
|
43
|
+
* Jessica Birky (UW, UCSD)
|
|
44
|
+
* Lingfeng Wei (UCSD)
|
|
45
|
+
|
|
46
|
+
## Code Setup:
|
|
47
|
+
Dependencies. The `SMART` has been tested under the following environments:
|
|
48
|
+
* Python 3.6.10/3.7.3
|
|
49
|
+
* astropy 3.0.4/3.0.5
|
|
50
|
+
* numpy 1.12.1/1.13.3/1.18.1
|
|
51
|
+
* scipy 0.19.0/1.4.1
|
|
52
|
+
* matplotlib 2.2.3/3.1.3
|
|
53
|
+
* pandas 0.20.1/0.23.4/1.0.1
|
|
54
|
+
* emcee 3.0.2/3.0.3.dev4+gc14b212
|
|
55
|
+
* corner 2.0.1
|
|
56
|
+
* openpyxl 3.0.10
|
|
57
|
+
* wavelets (for defringeflat)
|
|
58
|
+
|
|
59
|
+
Download the `SMART` and the forked and modified version of the NSDRP to your computer.
|
|
60
|
+
|
|
61
|
+
There are two ways of setting up the code:
|
|
62
|
+
|
|
63
|
+
<br/>(i) In the terminal under the `SMART` folder,
|
|
64
|
+
|
|
65
|
+
```
|
|
66
|
+
pip install -e .
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
<br/>(ii) Set up the environment variables in the `.bashrc` or `.bash_profile`
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
export PYTHONPATH="/path/to/smart:${PYTHONPATH}"
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
To model the SDSS/APOGEE spectra, you will also need to put the associated APOGEE LSF and wavelength fits files under `forward_model/apogee/`:
|
|
76
|
+
|
|
77
|
+
[apLSF-a-05440020.fits](https://dr13.sdss.org/sas/dr13/apogee/spectro/redux/r6/cal/lsf/apLSF-a-05440020.fits)<br/>
|
|
78
|
+
[apLSF-b-05440020.fits](https://dr13.sdss.org/sas/dr13/apogee/spectro/redux/r6/cal/lsf/apLSF-b-05440020.fits)<br/>
|
|
79
|
+
[apLSF-c-05440020.fits](https://dr13.sdss.org/sas/dr13/apogee/spectro/redux/r6/cal/lsf/apLSF-c-05440020.fits)<br/>
|
|
80
|
+
[apWave-a-02420038.fits](https://dr13.sdss.org/sas/dr13/apogee/spectro/redux/r6/cal/wave/apWave-a-02420038.fits)<br/>
|
|
81
|
+
[apWave-b-02420038.fits](https://dr13.sdss.org/sas/dr13/apogee/spectro/redux/r6/cal/wave/apWave-b-02420038.fits)<br/>
|
|
82
|
+
[apWave-c-02420038.fits](https://dr13.sdss.org/sas/dr13/apogee/spectro/redux/r6/cal/wave/apWave-c-02420038.fits)<br/>
|
|
83
|
+
|
|
84
|
+
The codes under the apogee folder are from Jo Bovy's [apogee](https://github.com/jobovy/apogee) package.
|
|
85
|
+
|
|
86
|
+
## Defringe Flats:
|
|
87
|
+
The algorithm follows Rojo & Harrington (2006) to remove fringe patterns from flat files. The example and sample outputs are under the example folder.
|
|
88
|
+
|
|
89
|
+
```
|
|
90
|
+
>>> import smart
|
|
91
|
+
>>> smart.defringeflatAll(data_folder_path, diagnostic=False)
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Reducing the data using NSDRP:
|
|
95
|
+
To reduce the data for the whole folder, use the forked [NSDRP](https://github.com/ctheissen/NIRSPEC-Data-Reduction-Pipeline) on the terminal:
|
|
96
|
+
|
|
97
|
+
```
|
|
98
|
+
$ 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
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
, 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.
|
|
102
|
+
|
|
103
|
+
To reduce the data of two nodding positions with a single flat file, you can run the following command:
|
|
104
|
+
|
|
105
|
+
```
|
|
106
|
+
$ 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
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Wavelength Calibration using Telluric Standard Spectra:
|
|
110
|
+
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)](https://ui.adsabs.harvard.edu/abs/2010ApJ...723..684B/abstract) and [Burgasser et al. (2016)](https://ui.adsabs.harvard.edu/abs/2016ApJ...827...25B/abstract) to cross-correlate the [ESO atmospheric model](https://ui.adsabs.harvard.edu/abs/2014A%26A...568A...9M/abstract) and an observed telluric spectrum, fit the residual, and iterate the process until the standard deviation of the residual reaches a mininum.
|
|
111
|
+
|
|
112
|
+
```
|
|
113
|
+
>>> import smart
|
|
114
|
+
>>> smart.run_wave_cal(data_name, data_path, order_list, save_to_path, test=False, save=True, applymask=True, pwv='0.5')
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
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.
|
|
118
|
+
|
|
119
|
+
## Forward Modeling Science and Telluric Spectra:
|
|
120
|
+
To fit the science data, `SMART` provides various self-consistent synthetic modeling grids to forward-model the data that are available to download [here](https://drive.google.com/drive/folders/1_23bl-BXqlFlrO7EIJX3FeFI4Rix-6kP?usp=sharing). Users will need to place the downloaded files in `smart/libraries`.
|
|
121
|
+
|
|
122
|
+
We perform the MCMC forward-modeling fitting to the high-resolution near-infrared spectroscopic data for both the telluric and science files.
|
|
123
|
+
|
|
124
|
+
The telluric spectrum after being calibrated with its wavelength solution is modeled with the equation:
|
|
125
|
+
|
|
126
|
+
```math
|
|
127
|
+
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}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
, 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.
|
|
131
|
+
|
|
132
|
+
You can run the following command on the terminal:
|
|
133
|
+
|
|
134
|
+
```
|
|
135
|
+
>>> 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
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
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`.
|
|
139
|
+
|
|
140
|
+
The most important parameter used as the input in the science modeling is the NIRSPEC instrumental line-spread function `lsf`.
|
|
141
|
+
|
|
142
|
+
The science spectrum is modeled with the equation:
|
|
143
|
+
|
|
144
|
+
```math
|
|
145
|
+
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}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
, 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.
|
|
149
|
+
|
|
150
|
+
You can run the following command on the terminal:
|
|
151
|
+
|
|
152
|
+
```
|
|
153
|
+
>>> 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
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
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](https://ui.adsabs.harvard.edu/abs/2012RSPTA.370.2765A/abstract) models. Other model sets are available and described in detail [here](https://github.com/chihchunhsu/smart/tree/master/smart/libraries).
|
|
157
|
+
|
|
158
|
+
## Citation:
|
|
159
|
+
|
|
160
|
+
If you use this code in your research, please cite [Hsu et al. 2021; ApJS, 257, 45](https://ui.adsabs.harvard.edu/abs/2021ApJS..257...45H/abstract) and the frozen version is on [Hsu et al. 2021 Zenodo](https://ui.adsabs.harvard.edu/abs/2021zndo...4765258H/abstract)
|
|
161
|
+
|
|
162
|
+
Depending on which model sets you choose, please also cite the corresponding references listed under [here](https://github.com/chihchunhsu/smart/tree/main/smart/libraries).
|
|
163
|
+
|
|
164
|
+
Please also cite [Carvalho & Johns-Krull (2023)](https://github.com/Adolfo1519/RotBroadInt) if you enable slow (but accurate) rotational broadening in the forward-modeling routine.
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
# SMART (Spectral Modeling Analysis and RV Tool)
|
|
2
|
+
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](https://github.com/ctheissen/osiris_fmp).
|
|
3
|
+
|
|
4
|
+
For NIRSPEC users, required adjustments need to be made before reducing private data using [NIRSPEC-Data-Reduction-Pipeline(NSDRP)](https://github.com/Keck-DataReductionPipelines/NIRSPEC-Data-Reduction-Pipeline), to perform telluric wavelength calibrations, and to forward model spectral data. The code is currently being developed.
|
|
5
|
+
|
|
6
|
+
Authors:
|
|
7
|
+
* Dino Chih-Chun Hsu (Northwestern, UCSD)
|
|
8
|
+
* Adam Burgasser, PI (UCSD)
|
|
9
|
+
* Chris Theissen (UCSD, BU)
|
|
10
|
+
* Jessica Birky (UW, UCSD)
|
|
11
|
+
* Lingfeng Wei (UCSD)
|
|
12
|
+
|
|
13
|
+
## Code Setup:
|
|
14
|
+
Dependencies. The `SMART` has been tested under the following environments:
|
|
15
|
+
* Python 3.6.10/3.7.3
|
|
16
|
+
* astropy 3.0.4/3.0.5
|
|
17
|
+
* numpy 1.12.1/1.13.3/1.18.1
|
|
18
|
+
* scipy 0.19.0/1.4.1
|
|
19
|
+
* matplotlib 2.2.3/3.1.3
|
|
20
|
+
* pandas 0.20.1/0.23.4/1.0.1
|
|
21
|
+
* emcee 3.0.2/3.0.3.dev4+gc14b212
|
|
22
|
+
* corner 2.0.1
|
|
23
|
+
* openpyxl 3.0.10
|
|
24
|
+
* wavelets (for defringeflat)
|
|
25
|
+
|
|
26
|
+
Download the `SMART` and the forked and modified version of the NSDRP to your computer.
|
|
27
|
+
|
|
28
|
+
There are two ways of setting up the code:
|
|
29
|
+
|
|
30
|
+
<br/>(i) In the terminal under the `SMART` folder,
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
pip install -e .
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
<br/>(ii) Set up the environment variables in the `.bashrc` or `.bash_profile`
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
export PYTHONPATH="/path/to/smart:${PYTHONPATH}"
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
To model the SDSS/APOGEE spectra, you will also need to put the associated APOGEE LSF and wavelength fits files under `forward_model/apogee/`:
|
|
43
|
+
|
|
44
|
+
[apLSF-a-05440020.fits](https://dr13.sdss.org/sas/dr13/apogee/spectro/redux/r6/cal/lsf/apLSF-a-05440020.fits)<br/>
|
|
45
|
+
[apLSF-b-05440020.fits](https://dr13.sdss.org/sas/dr13/apogee/spectro/redux/r6/cal/lsf/apLSF-b-05440020.fits)<br/>
|
|
46
|
+
[apLSF-c-05440020.fits](https://dr13.sdss.org/sas/dr13/apogee/spectro/redux/r6/cal/lsf/apLSF-c-05440020.fits)<br/>
|
|
47
|
+
[apWave-a-02420038.fits](https://dr13.sdss.org/sas/dr13/apogee/spectro/redux/r6/cal/wave/apWave-a-02420038.fits)<br/>
|
|
48
|
+
[apWave-b-02420038.fits](https://dr13.sdss.org/sas/dr13/apogee/spectro/redux/r6/cal/wave/apWave-b-02420038.fits)<br/>
|
|
49
|
+
[apWave-c-02420038.fits](https://dr13.sdss.org/sas/dr13/apogee/spectro/redux/r6/cal/wave/apWave-c-02420038.fits)<br/>
|
|
50
|
+
|
|
51
|
+
The codes under the apogee folder are from Jo Bovy's [apogee](https://github.com/jobovy/apogee) package.
|
|
52
|
+
|
|
53
|
+
## Defringe Flats:
|
|
54
|
+
The algorithm follows Rojo & Harrington (2006) to remove fringe patterns from flat files. The example and sample outputs are under the example folder.
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
>>> import smart
|
|
58
|
+
>>> smart.defringeflatAll(data_folder_path, diagnostic=False)
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Reducing the data using NSDRP:
|
|
62
|
+
To reduce the data for the whole folder, use the forked [NSDRP](https://github.com/ctheissen/NIRSPEC-Data-Reduction-Pipeline) on the terminal:
|
|
63
|
+
|
|
64
|
+
```
|
|
65
|
+
$ 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
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
, 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.
|
|
69
|
+
|
|
70
|
+
To reduce the data of two nodding positions with a single flat file, you can run the following command:
|
|
71
|
+
|
|
72
|
+
```
|
|
73
|
+
$ 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
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Wavelength Calibration using Telluric Standard Spectra:
|
|
77
|
+
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)](https://ui.adsabs.harvard.edu/abs/2010ApJ...723..684B/abstract) and [Burgasser et al. (2016)](https://ui.adsabs.harvard.edu/abs/2016ApJ...827...25B/abstract) to cross-correlate the [ESO atmospheric model](https://ui.adsabs.harvard.edu/abs/2014A%26A...568A...9M/abstract) and an observed telluric spectrum, fit the residual, and iterate the process until the standard deviation of the residual reaches a mininum.
|
|
78
|
+
|
|
79
|
+
```
|
|
80
|
+
>>> import smart
|
|
81
|
+
>>> smart.run_wave_cal(data_name, data_path, order_list, save_to_path, test=False, save=True, applymask=True, pwv='0.5')
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
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.
|
|
85
|
+
|
|
86
|
+
## Forward Modeling Science and Telluric Spectra:
|
|
87
|
+
To fit the science data, `SMART` provides various self-consistent synthetic modeling grids to forward-model the data that are available to download [here](https://drive.google.com/drive/folders/1_23bl-BXqlFlrO7EIJX3FeFI4Rix-6kP?usp=sharing). Users will need to place the downloaded files in `smart/libraries`.
|
|
88
|
+
|
|
89
|
+
We perform the MCMC forward-modeling fitting to the high-resolution near-infrared spectroscopic data for both the telluric and science files.
|
|
90
|
+
|
|
91
|
+
The telluric spectrum after being calibrated with its wavelength solution is modeled with the equation:
|
|
92
|
+
|
|
93
|
+
```math
|
|
94
|
+
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}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
, 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.
|
|
98
|
+
|
|
99
|
+
You can run the following command on the terminal:
|
|
100
|
+
|
|
101
|
+
```
|
|
102
|
+
>>> 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
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
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`.
|
|
106
|
+
|
|
107
|
+
The most important parameter used as the input in the science modeling is the NIRSPEC instrumental line-spread function `lsf`.
|
|
108
|
+
|
|
109
|
+
The science spectrum is modeled with the equation:
|
|
110
|
+
|
|
111
|
+
```math
|
|
112
|
+
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}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
, 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.
|
|
116
|
+
|
|
117
|
+
You can run the following command on the terminal:
|
|
118
|
+
|
|
119
|
+
```
|
|
120
|
+
>>> 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
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
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](https://ui.adsabs.harvard.edu/abs/2012RSPTA.370.2765A/abstract) models. Other model sets are available and described in detail [here](https://github.com/chihchunhsu/smart/tree/master/smart/libraries).
|
|
124
|
+
|
|
125
|
+
## Citation:
|
|
126
|
+
|
|
127
|
+
If you use this code in your research, please cite [Hsu et al. 2021; ApJS, 257, 45](https://ui.adsabs.harvard.edu/abs/2021ApJS..257...45H/abstract) and the frozen version is on [Hsu et al. 2021 Zenodo](https://ui.adsabs.harvard.edu/abs/2021zndo...4765258H/abstract)
|
|
128
|
+
|
|
129
|
+
Depending on which model sets you choose, please also cite the corresponding references listed under [here](https://github.com/chihchunhsu/smart/tree/main/smart/libraries).
|
|
130
|
+
|
|
131
|
+
Please also cite [Carvalho & Johns-Krull (2023)](https://github.com/Adolfo1519/RotBroadInt) if you enable slow (but accurate) rotational broadening in the forward-modeling routine.
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
#! /usr/bin/env python
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
|
|
4
|
+
import re
|
|
5
|
+
import setuptools
|
|
6
|
+
|
|
7
|
+
#import smart
|
|
8
|
+
#from smart.__init__ import __version__
|
|
9
|
+
|
|
10
|
+
# PyPI
|
|
11
|
+
with open("smart/__init__.py") as f:
|
|
12
|
+
__version__ = re.search(r'__version__\s*=\s*["\']([^"\']+)["\']', f.read()).group(1)
|
|
13
|
+
|
|
14
|
+
with open("README.md", "r") as fh:
|
|
15
|
+
long_description = fh.read()
|
|
16
|
+
|
|
17
|
+
setuptools.setup(
|
|
18
|
+
name="smart-astro",
|
|
19
|
+
version=__version__,
|
|
20
|
+
author="Chih-Chun Hsu",
|
|
21
|
+
author_email="chsu@northwestern.edu",
|
|
22
|
+
packages=setuptools.find_packages(),
|
|
23
|
+
url="https://github.com/chihchunhsu/smart",
|
|
24
|
+
license="MIT",
|
|
25
|
+
description=("The Spectral Modeling Analysis and RV Tool"),
|
|
26
|
+
long_description=open("README.md").read(),
|
|
27
|
+
long_description_content_type="text/markdown", # for PyPI
|
|
28
|
+
package_data={"": ["LICENSE", "AUTHORS.rst"]},
|
|
29
|
+
include_package_data=False,
|
|
30
|
+
install_requires=["numpy", "scipy", "pandas", "matplotlib", "astropy", "emcee", "corner"],
|
|
31
|
+
classifiers=[
|
|
32
|
+
"Programming Language :: Python :: 3",
|
|
33
|
+
"License :: OSI Approved :: MIT License",
|
|
34
|
+
"Operating System :: OS Independent",
|
|
35
|
+
],
|
|
36
|
+
python_requires='>=3.6',
|
|
37
|
+
zip_safe=False,
|
|
38
|
+
)
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
__version__ = "1.0.0"
|
|
2
|
+
|
|
3
|
+
from .initialize import *
|
|
4
|
+
from .utils.barycorr import barycorr
|
|
5
|
+
from .forward_model.classModel import Model
|
|
6
|
+
from .forward_model.classSpectrum import Spectrum
|
|
7
|
+
from .forward_model.classForwardModelInit import ForwardModelInit
|
|
8
|
+
from .forward_model.integralResample import integralResample
|
|
9
|
+
from .forward_model.InterpolateModel import InterpModel
|
|
10
|
+
from .forward_model.rotation_broaden import lsf_rotate, broaden
|
|
11
|
+
from .forward_model.continuum import *
|
|
12
|
+
from .forward_model.tellurics import InterpTelluricModel, convolveTelluric
|
|
13
|
+
from .forward_model.model_fit import *
|
|
14
|
+
from .forward_model.fringe_model import double_sine, doub_sine_wave_dependent, double_sine_fringe, double_sine_fringe_telluric
|
|
15
|
+
from .forward_model.mcmc import run_mcmc, telluric_mcmc, run_mcmc2, run_mcmc3
|
|
16
|
+
from .forward_model.apogee.lsf_function import computeAPLSF, convolveAPLSF
|
|
17
|
+
try:
|
|
18
|
+
from .forward_model.apogee.lsf import eval
|
|
19
|
+
except FileNotFoundError:
|
|
20
|
+
print("You need to put the APOGEE LSF and wavelength fits files under forward_model/apogee. See README.md for more details.")
|
|
21
|
+
pass
|
|
22
|
+
from .forward_model.apogee.bitmask import bits_set
|
|
23
|
+
from .wavelength_calibration.telluric_wavelength_fit import *
|
|
24
|
+
from .wavelength_calibration.residual import residual
|
|
25
|
+
from .utils.stats import chisquare
|
|
26
|
+
from .utils.addKeyword import add_nsdrp_keyword, add_wfits_keyword
|
|
27
|
+
from .utils.listTarget import makeTargetList
|
|
28
|
+
from .utils.compute_uvw_velocity import compute_uvw_velocity
|
|
29
|
+
from .utils.compute_galactic_thin_thick_disk import compute_galactic_pop_prob
|
|
30
|
+
from .utils.interpolations import bilinear_interpolation, trilinear_interpolation, quadlinear_interpolation
|
|
31
|
+
try:
|
|
32
|
+
from .utils.defringeflat import defringeflat, defringeflatAll
|
|
33
|
+
except ImportError:
|
|
34
|
+
print("You need to install the wavelets package (https://github.com/aaren/wavelets) to use defringeflat functions.")
|
|
35
|
+
pass
|
|
36
|
+
#from .utils.subtractDark import subtractDark
|