diff --git a/README.rst b/README.rst index 75f0ff2..83a80d1 100644 --- a/README.rst +++ b/README.rst @@ -16,11 +16,77 @@ for installation instructions and a guide to the ``petrofit`` module. Installation ------------ + You can install PetroFit using ``pip install petrofit``. Please see the `petrofit documentation `_ for detailed installation instructions. +Examples +-------- + +Please see the `petrofit documentation `_ +for detailed examples, a quick stat guide and instructions. + +**Photometry and Petrosian**: + +Given a 2D image (`image`) the following code snippet demonstrates how to create a Petrosian profile: + +.. code-block:: python + + import petrofit as pf + + # Make a segmentation map and catalog using Photutils wrapper + cat, segm, segm_deblend = pf.make_catalog( + image, + threshold=image.std()*3, + wcs=None, deblend=True, + npixels=npixels, nlevels=30, contrast=0.001, + ) + + # Photomerty on first source in catalog + r_list = pf.make_radius_list(max_pix=50, n=50) + flux_arr, area_arr, error_arr = pf.source_photometry( + cat[0], # Source (`photutils.segmentation.catalog.SourceCatalog`) + image, # Image as 2D array + segm_deblend, # Deblended segmentation map of image + r_list, # list of aperture radii + cutout_size=max(r_list)*2, # Cutout out size, set to double the max radius + ) + + # Make a Petrosian profile + p = pf.Petrosian(r_list, area_arr, flux_arr) + print("{:0.4f} pix".format(p.r_half_light)) + + +**Image Fitting**: + +PetroFit can be used with ``astropy`` models to fit psf convolved galaxy light profiles. Given a 2D image (``image``) and a psf (``PSF``), the following code snippet demonstrates how to fit a Sérsic model to the image: + +.. code-block:: python + + import petrofit as pf + from astropy.modeling import models + + sersic_model = models.Sersic2D( + amplitude=1, + r_eff=10, + n=4, + x_0=0, y_0=0, + ellip=0.2, + theta=25, + bounds = pf.get_default_sersic_bounds(), + ) + + psf_sersic_model = pf.PSFConvolvedModel2D( + sersic_model, psf=PSF, oversample=4, psf_oversample=1 + ) + + fitted_model, fit_info = pf.fit_model( + image, psf_sersic_model, + ) + Citation -------- + Please see the `petrofit documentation `_ for citation instructions. This information is also available in the `CITATION.rst`` file in the PetroFit repo.