Skip to content

CosmoStat/mccd

Repository files navigation

Build Status PyPI version PyPI pyversions PyPI pyversions arXiv

MCCD PSF Modelling

Multi-CCD Point Spread Function Modelling.


Main contributor: Tobias Liaudat
Email: [email protected]
Documentation: https://cosmostat.github.io/mccd/
Article: DOI - A&A
Current release: 17/02/2023


The non-parametric MCCD PSF modelling, or MCCD for short, is a Point Spread Function modelling pure python package.
It is used to generate a PSF model based on stars observations in the field of view. Once trained, the MCCD PSF model can then recover the PSF at any position in the field of view.

Contents

  1. Dependencies
  2. Installation
  3. Quick usage
  4. Recommendations

Dependencies

The following python packages should be installed with their specific dependencies:

It is of utmost importance that the PySAP package is correctly installed as we will be using the wavelet transforms provided by it.

Note: The GalSim package was removed from requirements.txt, it is expected to be installed (preferably with conda) before installing the MCCD package.

Installation

After installing all the dependencies one can perform the MCCD package installation:

Locally

git clone https://github.com/CosmoStat/mccd.git
cd mccd
python setup.py install

To verify that the PySAP package is correctly installed and that the MCCD package is accessing the needed wavelet transforms one can run: python setup.py test and check that all the tests are passed.

From Pypi

pip install mccd

Quick usage

The easiest usage of the method is to go through the configuration file config_MCCD.ini using the helper classes found in auxiliary_fun.py (documentation). Description of the parameters can be found directly in the configuration file config_MCCD.ini. The MCCD method can handle SExtractor dataset as input catalogs given that they follow an appropriate naming convention.

The main MCCD model parameters are:

  • LOC_MODEL: Indicating the type of local model to be used (MCCD-HYB, MCCD-RCA, or MCCD-POL),
  • N_COMP_LOC: Indicating the number of eigenPSFs to use in the local model.
  • D_COMP_GLOB: Indicating the maximum polynomial degree for the global model.

After setting up all the parameters from the configuration file there are three main functions, one to fit the model, one to validate the model and the last one to fit and then validate the model. The usage is as follows:

import mccd

config_file_path = 'path_to_config_file.ini'

run_mccd_instance = mccd.auxiliary_fun.RunMCCD(config_file_path,
                                               fits_table_pos=1)

run_mccd_instance.fit_MCCD_models()

For the validation one should replace the last line with:

run_mccd_instance.validate_MCCD_models()

Finally for the fit and validation one should change the last line to:

run_mccd_instance.run_MCCD()

All the output file will be saved on the directories specified on the configuration files.

PSF recovery

To recover PSFs from the model at specific positions test_pos from the CCD ccd_id one could use the following example:

import numpy as np
import mccd

config_file_path = 'path_to_config_file.ini'
mccd_model_path = 'path_to_fitted_mccd_model.npy'
test_pos = np.load(..)
ccd_id = np.load(..)
local_pos = True

mccd_instance = mccd.auxiliary_fun.RunMCCD(
    config_file_path,
    fits_table_pos=1
)

rec_PSFs = mccd_instance.recover_MCCD_PSFs(
    mccd_model_path,
    positions=test_pos,
    ccd_id=ccd_id,
    local_pos=local_pos
)

See the documentation of the recover_MCCD_PSFs() function for more information.

Recommendations

Some notebook examples can be found here.

Changelog

  • Changed from travis deployment to github actions. Changed the github pages template. Now using the one from pyralid-template from sfarrens.

  • Added new module for realisitic simulations dataset_generation.py. It is capable of simulating realistic simulations from the UNIONS/CFIS survey, including realistic atmospherical simulations following a realisation of a Von Kármán model. See the above-mentioned module documentation for more information. See also the testing-realistic-data.ipynb in the notebook folder for an example.

  • Added outlier rejection based on a pixel residual criterion. The main parameters, RMSE_THRESH and CCD_STAR_THRESH can be found in the MCCD config file. See then parameter documentation for more information.

  • For usage inside shape measurement pipelines: new PSF interpolation function included in the MCCD model interpolate_psf_pipeline(). This function allows to output interpolated PSFs with a specific centroid.

  • New handling of position polynomials, local as well as global polynomials. Increased model performance.

  • New functionalities added. Handling of the max polynomial degree in the local hybrid model by the D_HYB_LOC. Also adding a parameter MIN_D_COMP_GLOB to remove lower polynomial degrees in the global polynomial model.

  • Increased default number of iterations to have a better convergence in the PSF wings.

  • Algorithm updates to increase performance: Dropping the normalisation proximal operator. Harder sparsity constraint for spatial variations. Forcing RBF interpolation for the global part. Skipping the last weight optimization so that we always finish with a features/components optimization.

  • Set default denoising to zero as wavelet denoising (using starlets) introduce an important bias in the ellipticity estimates of the model.