Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/AstroAguirre/subtractAirglow

Subtract H I Lyman-alpha and O I airglow emission from HST-COS G130M spectra and reconstruct stellar emission profiles.
https://github.com/AstroAguirre/subtractAirglow

astronomy astrophysics hubble spectroscopy stars ultraviolet

Last synced: 3 months ago
JSON representation

Subtract H I Lyman-alpha and O I airglow emission from HST-COS G130M spectra and reconstruct stellar emission profiles.

Awesome Lists containing this project

README

        

# subtractAirglow
Subtract H I Lyman-alpha and O I airglow emission from HST-COS G130M spectra and reconstruct the underlying stellar H I and O I emission. This module was developed and optimized for main sequence F, G, K, and M dwarf stars, however the airglow subtraction feature can be used for other targers observed with COS G130M.

### Compatibility
- Anaconda 23.3.1 and above
- Python 3.10.9 and above
- Windows 10, 11
- Mac OS Monterey (Intel/M1 Chips), Ventura (M2 Chip)
- Linux (recent relases of Debian, Red Hat, and SUSE distribution families)

## Installation
**It is recommended to install this module in a virtual environment.** This can be done, for example, by running the following in the terminal:

```
conda create -n subAG python=3.10
```

Substituting `python=3.10` with `python=3.11` will also work. Activate the virtual environment with:

```
conda activate subAG
```

The `subtractAirglow` module can then be installed in the virtual environment by using `pip`:

```
pip install subtractAirglow
```

## Import the GUI
Once installed, the GUI can be accessed by importing the module:
```python
from subtractAirglow import GUI
GUI.run()
```

## Using the GUI
Below is the recommended order of operations when using the airglow subtraction and stellar reconstruction tool.

1. Load a COS G130M spectrum of a supported filetype
- `*_x1d.fits` files, such as those available from [MAST](https://mast.stsci.edu/portal/Mashup/Clients/Mast/Portal.html)
- `*.sav.txt` files, produced by [`COADD_X1D.pro`](https://casa.colorado.edu/~danforth/science/cos/coadd_x1d.pro)
- `*.dat` files, these files should only contain a wavelength array, a flux array, and a flux error array
2. If prompted, enter additional information. This allows for loading the appropriate model and airglow template
- Cenwave 1327?: Check this box if the data was taken using Cenwave 1327
- M Type?: Check this box if the target star is an M dwarf
- Side A Only?: Check this box if the data was taken only using Side A of the COS detector
3. (Optional) Load a STIS G140M or E140M spectrum of a supported filetype
- `*_x1d.fits` files, such such as those available from MAST
- `*.dat` files, in the same format as above
4. Select one of the four airglow contaminated emission lines, and if necessary, press the "Edit Ranges" button to adjust the fitting window
5. Input the initial guesses for the stellar radial velocity and ISM radial velocity. Press Enter in each input box after entering these values
6. Select a Fit Mode
- One Part: The GUI will simultaneously model stellar emission, self reversal, ISM attenuation, and airglow contamination
- Two Part: Simultaneously fits all components as in One Part fitting, then performs an internal airglow subtraction and performs a second fit of all non-airglow components on the airglow subtracted spectrum
7. Select an Airglow Mode
- Automatic: The airglow template is fit automatically using initial guesses for its spectral location and amplitude
- Manual: The airglow tempalte is manually placed with user input for its spectral location and amplitude

**Once a Fit Mode and Airglow Mode have been selected, a fit will be generated. The GUI may appear to freeze while generating a best fit to the data (particularly for H I Lyman-alpha). It is likely that the GUI is running in the background, and will unfreeze once a fit is generated.**

8. Use the sliders/input boxes surrounding the plot window to adjust the fit as needed (the matplotlib toolbar is available on the top of the GUI window)
9. (Optional) Use the "Normalized Residuals Menu" to remove data points which are negatively driving the best fit
10. (Optional) If STIS data was loaded, press the "Check STIS Comparison" button to compare the two airglow-free spectra
11. Once the fit has been finalized **for the selected emission line**, press "Remove Airglow". This will generate airglow removal plots in separate windows, and is required to save the recovered spectrum and fit components
12. (Optional) Press "Bootstrapping Menu" to generate 1 sigma confidence intervals for the best fit parameters via a residual resampling circular block bootstrap routine (this will replace the 1 sigma parameter errors generated by the standard fitting routine)
13. Select another emission line (if available) and repeat steps 8 - 12 to perform another airglow subtraction
14. Once all airglow subtractions have been complete and finalized, press "Save Recovered Spectrum" to save the data to a `.csv` file (an additional `.csv` file containing all user inputs is created automatically, for reproducibility)