pmelchior / scarlet2

Scarlet, all new and shiny
MIT License
15 stars 4 forks source link

Executable scripts #77

Open pmelchior opened 3 months ago

pmelchior commented 3 months ago

To make it easier for users to run scarlet and to better understand what they are running when they report problems, I think we need to make executable version of our main workflows. This is in addition to people constructing their own pipelines e.g. in notebooks.

I think these two would be a good start:

  1. scarlet2.py gets a number of FITS files for images, weights, and PFSs; runs sep to perform background estimation and source detection; initializes everything as Source; runs the fitter, possibly with neural priors; reports a set of user-specified measurements.
  2. scarlet2-td.py gets a number of FITS files, weights and PSFs; runs sep to perform background estimation and source detection; searches for transient; initializes StaticSource and Sources; runs the fitter, possibly with neural priors; reports a set of user-specified measurements.

Under the hood, we would have to unpack the information from the FITS files. Probably best to require that the order of these files is consistent, e.g.

scarlet2 -i img_b.fits,img_r.fits -w weight_b.fits,weight_r.fits -p psf_b.fits,psf_r.fits

Depending on WCS information in the image files, we'd have consistent pixel grids or require resampling to align them; we can determine the sky area and bands over which we fit the data; and for scarlet2-td we'd get the time frame as well.

In both cases, we could get the same bands multiple times. We need to make sure that we create the model_frame.channels correctly, especially for the TD case.

We probably need some configuration to be passed, including the source model types and possible priors as well as the measurements to be reported:

scarlet2 -i ... -w ... -p ... -c config.json -o output.fits

If no outfile is given, just dump to stdout, otherwise save catalog in requested format.