# Pipeline for source injection on CSST images

## Installation
1. First make sure CSST simulation package is installed
2. Install the source injection packages:
```
    python setup.py install --user
 ```

## Usage
### Run L1 Detrending pipeline (optional)
* If the L1 images are not available, we need first to run the CSST detrending pipeline on the raw images to get the L1 calibrated products. Otherwise this step can be ignored.
* This step removes all the instrumental related effects as well as cosmoic rays
* modify the corresponding ```config_detrending.yaml``` file to configure all running options
```
    python ./measurement_pipeline/run_csst_msc_instrument.py /path/to/config_detrending.yaml
```
* Products:
    * L1 calibrated images (detrended + cosmic rays removed)
    * Weight maps
    * Flag maps

### Run Source Injection
* Inject souces onto the L1 calibrated images
* modify the corresponding ```config_injection.yaml``` file to configure all running options
```
    python ./injection_pipeline/injection_pipeline.py /path/to/config_injection.yaml
```
* Products:
    * L1 calibrated images with synthetic sources injected
    * Truth catalogs for injected sources

### Run L1 Detection & Photometry pipeline
* CSST detection and photometry pipeline, can be used to:
    * Detect and do photometry measurements on the L1 calibrated images
    * Re-detect and redo photometry measurements on the injected images
* modify the corresponding ```config_photometry.yaml``` file to configure all running options
```
    python ./measurement_pipeline/run_csst_msc_mbi_photometry.py /path/to/config_photometry.yaml
```
* Products:
    * Detection catalogs with photometric information
    * Flux maps
    * PSF models (in psfex format)
    * Segmentation maps
    * Sky maps

### Evaluation
* ```evaluation```package provided tools and example notebooks for evaluating:
    * Injected objects
    * Detection completeness
    * Photometric accuracy