Git Product home page Git Product logo

jwst-kpi's Introduction

JWST stage 3 pipeline for kernel phase imaging.

Authors: Jens Kammerer, Thomas Vandal, Katherine Thibault, Frantz Martinache

Supported instruments: NIRCam, NIRISS, MIRI

This package provides a pipeline to extract kernel phases from JWST data. The code aims to replicate the interface of the official JWST data reduction pipeline to provide a custom stage 3 kernel phase pipeline that outputs KPFITS files. The pipeline is based on the XARA1 package and uses stage 2 calibrated ("cal" or "calints") products from the official JWST data reduction pipeline.

Installation

Virtual environment

It is recommended to install the pipeline in a new virtual environment either with conda:

conda create -n <env-name> python
conda activate <env-name>

or venv:

python -m venv <env-name>
source <env-name>/bin/activate

Install jwst-kpi

To install the Kpi3Pipeline in the new virtual environment, you can either clone and install locally:

git clone https://github.com/kammerje/jwst-kpi
cd jwst-kpi/
python -m pip install .

or directly with pip from the GitHub repository:

python -m pip install git+https://github.com/kammerje/jwst-kpi

Usage

Examples of how to use the pipeline are available. There are examples for processing NIRCam, NIRISS, and MIRI cal and calints data.

Pupil model

A discrete representation of the pupil is required for the kernel phase extraction. Default pupil models for all supported instruments are provided with the package, but users can generate their own pupil models with XARA or XAOSIM and use them in the pipeline. We provide a script showing how the default pupil models were generated. It can be used and adapted to generate custom pupil models. If you find a pupil model that performs better than the default one, feel free to open an Issue or a PR!

News

The most recent major update brings new functionality and simplified usage:

  • Both 2D cal and 3D calints data can now be processed.
  • There is a new trim frames step. It is possible to specify the center and the size of the trimmed frames. With this new step, the pipeline is now running the steps in the following order: trim frames, fix bad pixels, recenter frames, window frames, extract kerphase, empirical uncertainties.
  • It is now possible to provide a list of good frames and extract the kernel phase only from those.
  • Improved pupil models and new pupil models for the NIRCam coronagraphy Lyot stops.
  • Improved diagnostic plots.
  • Improved file outputs.
  • Simplification of the code by always transforming input data to 3D calints data.

Footnotes

  1. The main XARA version is hosted here: https://github.com/fmartinache/xara. At the time of writing this, the pipeline uses a forked version of XARA (https://github.com/kammerje/xara/tree/develop) that implements new functionality required for the JWST pipeline. โ†ฉ

jwst-kpi's People

Contributors

kammerje avatar katherinethibault avatar vandalt avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

jwst-kpi's Issues

Namespace TypeError when accessing `pupil_data` path with Python 3.7

It seems importing the package fails with Python 3.7. The __path__ of puil data is not subscriptable.There is likely a simple fix to work around this. I will look into it ASAP.

Error reported by Katherine:

PUPIL_DIR = pupil_data.__path__[0]
TypeError: '_NamespacePath' object is not subscriptable

Write steps and pipeline following JWST pipeline structure

Currently, the pipeline and its various steps are similar to the JWST pipeline from the user's perspective, but they don't follow the same code structure and inherit the same classes. Following the JWST structure should remove some complexity from the code and make it easier to eventually make this an official JWST pipeline.

There is documentation here writing a pipeline and a step.

I'm not self-assigning for now in case someone else wants to work on this in the short term, but I'm happy to look at this in the next few weeks.

Get filter properties directly from SVO

Currently, the filter properties are hardcoded at the beginning of the KPI3Pipeline script. In the future, they should be downloaded on the fly from the Spanish Virtual Observatory Filter Profile Service. I have code that does that, I just need to find the time to implement it here.

Option to skip saving intermediate products

It would be nice to be able to skip saving intermediate products from the pipeline. We might even want to make this the default option, given the size that intermediate FITS files can take.

I would see two complementary solutions here:

  • Option to skip saving the HDUL for each file (I think this would be fixed automatically by solving #11, as implemented in #17)
  • Option to save a "preprocessing" cube, where each HDU is a step of the pipeline. This might be an interesting solution if people want easy access to the different image pre-processing while reducing the output size (the required size is ~ 10% of what it is now from quick tests I did)

Update pupil model to latest hexagonal grid

Currently, the default pupil model is an old square grid one (used during commissioning). We can replace the default models by the updated hexagonal grid from @kammerje, and also upgrade the pupil model generation script to show how the model was created.

Loop over vectorized code

I think there is a loop over vectorized code in the trim step:

for i in range(nf):
data_trimmed = data[
:,
ww_max[0] - self.trim_halfsize : ww_max[0] + self.trim_halfsize,
ww_max[1] - self.trim_halfsize : ww_max[1] + self.trim_halfsize,
].copy()
erro_trimmed = erro[
:,
ww_max[0] - self.trim_halfsize : ww_max[0] + self.trim_halfsize,
ww_max[1] - self.trim_halfsize : ww_max[1] + self.trim_halfsize,
].copy()
pxdq_trimmed = pxdq[
:,
ww_max[0] - self.trim_halfsize : ww_max[0] + self.trim_halfsize,
ww_max[1] - self.trim_halfsize : ww_max[1] + self.trim_halfsize,
].copy()

The loop variable is not used and the code does the operation on all frames with : I believe.

Add offline cache/fallback for filter wavelengths

SVO seems down currently, which made me realize it might be good to have a "fallback" option for when SVO cannot be queried (either by saving the SVO list for JWST when users run a query or by including a static version with the package.

Update calwebb_kpi3.py to latest code

@kammerje has an updated version of calwebb_kpi3.py with his latest changes. The formatting and structure changed slightly in this repo compared to the old one. I can take care of merging the updates into this repo.

Add option to control overwriting files

Currently, files are overwritten by default. It might be good to have an option to fully skip the processing if the output already exist. Or maybe still run the processing, but skip saving the file if it exists.

More flexible workflow for pupil model & re-enable pupil rotation

Currently, the pupil model is used directly from the jwst subdirectory and the path is hardcoded. Two things that could add more flexbility would be:

  • Allow users to specify a path to a pupil model instead of using the one from the repo
  • Integrate a step in the pipeline to genreate a pupil model with specific settings

@kammerje let me know what you think. The first item is probably simple to implement. The second one is a bit more involved.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.