#############################################################
### Simulated NIRCam imaging mosaics for CEERS Pointing 5 ###
#############################################################

In this directory, we provide fully reduced mosaics in all 6 filters. 

These images were processed through The JWST Calibration Pipeline
(jwst) version 1.2.3, with custom steps developed to handle the 
specifics of the simulated data. To recreate these mosaics, follow 
the steps in CEERS5/part2/README.txt, but note the memory and 
storage requirements!

The mosaics are called ceers5_[filt]_i2d.fits, where filt is one of:
SWC filters: f115w, f150w, f200w
LWC filters: f277w, f356w, f444w

The mosaics are gzipped and unzip to 5 GB (SWC) and 1.2 GB (LWC).

The mosaics are on pixel scales of 0.015"/pix (SWC) and 0.03"/pix (LWC),
which we have determined are optimal for the CEERS observations and 
planned science goals. 

***Note that the images are NOT pixel-aligned, though they can be matched 
   by WCS. Pixel-aligned images across all filters will be part of our 
   next data release.

We also include a preliminary photometric catalogs, produced using
default options for the SourceCatalog step of the pipeline Stage 3.
The SourceCatalog parameters are not yet optimized, and so the photometric
catalogs are not final. We include them here as an example of the
pipeline outputs. 


####################
### File structure

The images are multi-extension fits files with 10 extensions:
  0. PRIMARY header
  1. SCI  - 2D science image and header 
  2. ERR  - 2D array of uncertainties, given as standard deviation
  3. CON  - 2D context image, encoding info about which input images 
            contribution to each output pixel
  4. WHT  - 2D weight image giving the relative weight of the output pixels
            (effectively a relative exposure time map)
  5. VAR_POISSON  - 2D variance array based on Poisson noise only
  6. VAR_RNOISE  - 2D variance array based on read noise only
  7. VAR_FLAT  - 2D variance array based on uncertainty in the flat-field
  8. HDRTAB  - table containing metadata (FITS keyword values) for all the 
               input images
  9. ASDF  - meta data for the JWST data model

For more information on JWST file names and extension explanations, see:
jwst-pipeline.readthedocs.io/en/latest/jwst/data_products/science_products.html


Images can be read in several ways. For example, with astropy:
  >>> from astropy.io import fits
  >>> with fits.open('ceers5_f115w_i2d.fits') as hdu:
  ...     hdu.info()

Or using the jwst datamodels:
  >>> from jwst.datamodels import ImageModel
  >>> with ImageModel('ceers5_f115w_i2d.fits') as im:
  ...     im.info()

For more information on JWST Data Models, see:
jwst-pipeline.readthedocs.io/en/latest/jwst/datamodels/index.html


################
### Photometry

The final step of the Stage 3 pipeline -- the SourceCatalog step -- performs 
photometry on the mosiacs using Photutils. The outputs of this step include 
a segmentation map showing the footprint of each detected source in the 
image (similar to that produced by Source Extractor), and a source catalog 
saved in ECSV format. 

The catalog contains one row for each source, with source coordinates, 
some size and shape measurements, circular aperture photometry in three 
aperture sizes, aperture-corrected photometry measured in a circular aperture, 
isophotal photometry, and information on each source's nearest neighbor.

***Note that the photometry has not been optimized. We are using all the
   default parameters of the SourceCatalog step. We will provide optimized 
   photometric catalogs as part of a future data release, describing in 
   detail the changes we make to the default method.

As a result, you may notice in the segmentation maps that some fainter 
sources are not recovered, or that the source footprints do not fully 
match the images. There are also some clusters of bad pixels that are 
detected as real sources. Finally, in ceers5_f356w_phot.png, we compare 
the input source magnitudes with those measured in the output catalog. 
We show magnitudes calculated within the 30% encircled energy (EE) 
circular aperture (red), the 50% EE circular aperture (orange), the 
70% EE circular aperture (green), and the total aperture-corrected 
magnitude based on the 70% EE aperture (blue). Even the aperture-corrected
magnitudes are ~0.5 mag fainter than the inputs. We show this comparison 
for F356W, though these trends are similar in all 6 filters. 


For more information on the SourceCatalog step of the Stage 3 pipeline 
as well as on the contents in the output catalogs, see:
jwst-pipeline.readthedocs.io/en/stable/jwst/source_catalog/main.html


########################
### Directory contents

ceers5_*_i2d.fits  - CEERS pointing 5 mosaic in each filter
ceers5_*_segm.fits  - Segmentation map associated with the mosaic
ceers5_*_cat.ecsv  - Catalog of detected source positions and photometry
ceers5_f356w_phot.png  - Figure comparing input and recovered photometry
                         in the F356W filter. This comparison is similar 
                         in other filters.