Skip to content

Commit

Permalink
Merge pull request #8 from radicamc/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
radicamc authored Jul 5, 2024
2 parents 83ba5ec + c77c9df commit d7c7163
Show file tree
Hide file tree
Showing 22 changed files with 4,028 additions and 1,621 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ ___

**exoTEDRF** (formerly supreme-SPOON) is an end-to-end pipeline for JWST exoplanet time series observations.

Currently supports: **NIRISS/SOSS**, **NIRSpec/BOTS** (coming soon), **MIRI/LRS** (in development).
Currently supports: **NIRISS/SOSS** and **NIRSpec/BOTS**. **MIRI/LRS** is in development.

## Documentation
An installation guide, code documentation, and tutorials are included in the [exoTEDRF documentation](https://exotedrf.readthedocs.io/en/latest/index.html).

## Citations
If you make use of this code in your work, please cite [Radica et al. (2023)](https://ui.adsabs.harvard.edu/abs/2023MNRAS.524..835R/abstract)
and [Feinstein et al. (2023)](https://ui.adsabs.harvard.edu/abs/2023Natur.614..670F/abstract).
If you make use of this code in your work, please cite [Radica (2024)](), as well as [Radica et al. (2023)](https://ui.adsabs.harvard.edu/abs/2023MNRAS.524..835R/abstract)
and [Feinstein et al. (2023)](https://ui.adsabs.harvard.edu/abs/2023Natur.614..670F/abstract) for its first uses.

A list of other works you should consider citing depending on which functionalities you are using can be found [here]().
A list of other works you should consider citing depending on which functionalities you are using can be found [here](https://exotedrf.readthedocs.io/en/latest/content/citations.html).

14 changes: 14 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
# Changelog
All notable changes to this project will be documented in this file.

### [2.0.0] -- 2024-07-05
#### Added
- Support for NIRSpec/BOTS observations.
- Functions to refine SOSS timestamps for limb asymmetry studies.
- Light curve fitting with exoUPRF.
- Updates to documentation.
- NIRSpec/G395H reduction tutorial.
- Misc. bug fixes.

#### Removed
- Light curve plotting routines
- juliet dependencies.
- Light curve fitting tutorial.

### [1.4.0] -- 2024-03-08
#### Added
- Package name changed to exoTEDRF.
Expand Down
11 changes: 6 additions & 5 deletions docs/content/citations.rst
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
Citations
==========

If you make use of this code in your work, please cite `Radica et al. (2023) <https://ui.adsabs.harvard.edu/abs/2023MNRAS.524..835R/abstract>`_ and `Feinstein et al. (2023) <https://ui.adsabs.harvard.edu/abs/2023Natur.614..670F/abstract>`_.
If you make use of this code in your work, please cite `Radica (2024) <xxx>`_, as well as `Radica et al. (2023) <https://ui.adsabs.harvard.edu/abs/2023MNRAS.524..835R/abstract>`_ and `Feinstein et al. (2023) <https://ui.adsabs.harvard.edu/abs/2023Natur.614..670F/abstract>`_ for its first uses.

For NIRSpec capabilities, please also cite `PLACEHOLDER <xxx>`_.

Additional Citations
--------------------
If you use the ATOCA extraction algorithm for NIRISS/SOSS, please also cite `Radica et al. (2022) <https://ui.adsabs.harvard.edu/abs/2022PASP..134j4502R/abstract>`_
and `Darveau-Bernier et al. (2022) <https://ui.adsabs.harvard.edu/abs/2022PASP..134i4502D/abstract>`_.

If you make use of the light curve fitting routines, also include the following citations for
`juliet <https://ui.adsabs.harvard.edu/abs/2019MNRAS.490.2262E/abstract>`_,
`batman <https://ui.adsabs.harvard.edu/abs/2015PASP..127.1161K/abstract>`_,
`dynesty <https://ui.adsabs.harvard.edu/abs/2020MNRAS.493.3132S/abstract>`_, and
`Kipping et al. (2013) <https://ui.adsabs.harvard.edu/abs/2013MNRAS.435.2152K/abstract>`_ for the limb-darkening sampling.
`exoUPRF <https://zenodo.org/records/12628067>`_,
`batman <https://ui.adsabs.harvard.edu/abs/2015PASP..127.1161K/abstract>`_, and
`dynesty <https://ui.adsabs.harvard.edu/abs/2020MNRAS.493.3132S/abstract>`_.

If you use Gaussian Processes please cite `celerite <https://ui.adsabs.harvard.edu/abs/2017AJ....154..220F/abstract>`_,
and if you use ExoTiC-LD for limb darkening priors cite `Grant & Wakeford (2022) <https://doi.org/10.5281/zenodo.7437681>`_.
Expand Down
9 changes: 0 additions & 9 deletions docs/content/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,6 @@ The default pip installation only includes Stages 1 to 3. Stage 4 can be include
pip install exotedrf[stage4]
.. attention::
The `radvel <https://github.com/California-Planet-Search/radvel>`_ package may fail to build during the installation of Stage 4. If so, simply run:

.. code-block:: bash
pip install cython
and then proceed with the **exoTEDRF** installation as before.

Alternatively, the package can be grabbed from GitHub (inlcludes all pipeline stages as well as tutorial notebooks, etc.) via:

.. code-block:: bash
Expand Down
434 changes: 0 additions & 434 deletions docs/content/notebooks/tutorial_light-curve-fitting.ipynb

This file was deleted.

1,163 changes: 1,163 additions & 0 deletions docs/content/notebooks/tutorial_nirspec-g395h.ipynb

Large diffs are not rendered by default.

9 changes: 6 additions & 3 deletions docs/content/usage.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
exoTEDRF Usage Guide
====================

Currently supported instruments/modes: **NIRISS/SOSS**, **NIRSpec/BOTS** (coming soon), **MIRI/LRS** (in development).
Currently supported instruments/modes: **NIRISS/SOSS** and **NIRSpec/BOTS**. **MIRI/LRS** is in development.

The pipeline is divided into four stages, which closely mirror the STScI pipeline:
The pipeline is divided into four stages, which closely mirror the STScI JWST calibration pipeline:

* Stage 1: Detector-Level Processing
* Stage 2: Spectroscopic Processing
Expand All @@ -20,8 +20,11 @@ Below are several tutorials that will walk you through the basics of JWST data a
:maxdepth: 2

notebooks/tutorial_niriss-soss
notebooks/tutorial_light-curve-fitting
notebooks/tutorial_nirspec-g395h

exoTEDRF also has the capabilities for basic transit and eclipse light curve fitting in Stage4 through the exoUPRF library.
If you are looking for some guidance on basic light curve fitting for JWST data, you can check out the exoUPRF tutorial notebooks
`here <https://exouprf.readthedocs.io/en/latest/content/usage.html#tutorial-notebooks>`_.

Scripting
---------
Expand Down
Binary file modified docs/figures/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ exoTEDRF: the EXOplanet Transit and Eclipse Data Reduction Framework!

**exoTEDRF** (formerly supreme-SPOON) is an end-to-end pipeline for JWST exoplanet time series observations.

Currently supported instruments/modes are: **NIRISS/SOSS**, **NIRSpec/BOTS** (coming soon), **MIRI/LRS** (in development).
Currently supported instruments/modes are: **NIRISS/SOSS** and **NIRSpec/BOTS**. **MIRI/LRS** is in development.

.. toctree::
:maxdepth: 2
Expand Down
4 changes: 1 addition & 3 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,5 @@ pastasoss
pyyaml
dynesty==1.2.2
exotic_ld
exouprf
h5py

#TODO: docs for Stage 4 will not build as they require juliet, which in turn requires radvel. radvel is not installing
#TODO: on readthedocs for some reason. It's installing fine (either as part of juliet or on its own) in a fresh conda env.
101 changes: 101 additions & 0 deletions exotedrf/extra_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,3 +183,104 @@ def make_smoothed_2d_lightcurve(spec, baseline_ints, nint, dimx, filename,
# Save file.
suffix = 'lcestimate_2d_o{}.npy'.format(order)
np.save(filename + suffix, ref_file)


def refine_soss_timestamps(mid_int_times, centroids, subarray='SUBSTRIP256',
outfile=None):
"""SOSS read times are long compared to other instruments meaning that
there are several seconds of time difference between when red and blue
wavelengths are read. For limb asymmetry studies, this can be important.
This function refines the default mid integration times to yield a
seperate timestamp for each wavelength, which can then be outputs as 2D
maps, or appended to an existing spectrum file.
Note, when binning these time stamps it is important to also consider the
relative contributions of each wavelength to the bin via the brightness of
the stellar spectrum.
Parameters
----------
mid_int_times : array-like(float)
Default mid-integration timestamps.
centroids : dict
Centroids dictionary.
subarray : str
SOSS subarray identifier, either "SUBSTRIP256" or "SUBSTRIP96".
outfile : str, None
Spectrum file to which to append output.
Returns
-------
int_times_o1 : ndarray(float)
Integration times for each wavelength in order 1.
int_times_o2 : ndarray(float), None
Integration times for each wavelength in order 2.
"""

tpix = 1e-5 # Read time for individual pixel
tgap = 1.2e-4 # Gap time between columns
# Note using these times results in a frame time which is ~5ms shorter
# than the actual frame time of 5.494s. Not sure why, since these are
# apparently the correct pixel and gap times. The frame time formula
# (Equ. 3 in Albert+ 2023) gives the 5.494s (for SUBSTRIP256).

# Get readout pattern and subarray dimensions.
if subarray == 'SUBSTRIP256':
dimx, dimy = 2048, 256
elif subarray == 'SUBSTRIP96':
dimx, dimy = 2048, 96
else:
raise ValueError('Unknown subarray: {}'.format(subarray))

# Create map of readout times of individual pixels.
time = 0
time_map = np.zeros((dimy, dimx))
for x in range(dimx - 1, -1, -1):
if x != dimx - 1:
time += tgap
for y in range(dimy - 1, -1, -1):
time += tpix
time_map[y, x] = time
# Assume default mid-integration time is the time at the frame center.
time_map -= time_map[dimy // 2, dimx // 2]

# Get time shift for each wavelength.
t_o1 = []
for x in range(dimx):
ypos1 = round(centroids['ypos o1'][x], 0).astype(int)
t_o1.append(time_map[ypos1, x])
t_o1 = np.array(t_o1)

int_times_o1 = np.repeat(mid_int_times[:, np.newaxis], dimx, axis=1)
int_times_o1 = int_times_o1 - t_o1 / 3600 / 24

# Only do order 2 for SUBSTRIP256.
if subarray != 'SUBSTRIP96':
t_o2 = []
for x in range(dimx):
ypos2 = round(centroids['ypos o2'][x], 0).astype(int)
if 0 <= ypos2 < dimy:
t_o2.append(time_map[ypos2, x])
else:
t_o2.append(np.nan)
t_o2 = np.array(t_o2)

int_times_o2 = np.repeat(mid_int_times[:, np.newaxis], dimx, axis=1)
int_times_o2 = int_times_o2 - t_o2 / 3600 / 24
else:
int_times_o2 = None

# If a spectrum file is passed, tack on the new timestamps.
if outfile is not None:
file = fits.open(outfile)
hdr = fits.Header()
hdr['EXTNAME'] = "Time O1"
hdr['UNITS'] = "MJD"
file.append(fits.ImageHDU(int_times_o1, header=hdr))
if subarray != 'SUBSRIP96':
hdr = fits.Header()
hdr['EXTNAME'] = "Time O2"
hdr['UNITS'] = "MJD"
file.append(fits.ImageHDU(int_times_o2, header=hdr))
file.writeto(outfile, overwrite=True)

return int_times_o1, int_times_o2
Loading

0 comments on commit d7c7163

Please sign in to comment.