# Light Curve

How to extract a light curve (a time dependence of magnitude) of a variable source.

# Blazar 0716+714

Blazar 0716+714 is a bright quasi-stellar extra-galactic object in Camelopardalis. The observed light has origin in a synchrotron radiation emitted by relativistics electrons forming a jet. The jet is oriented directly to the Earth. A non-periodic light variations can be observed. The origin of the variations is only partially understood.

## Sample Data

A sample data are available as munipack-data-0716.tar.gz.

We are preparing working directory and downloading of data. It is highly recommended to use a new empty directory to prevent any losts (especially of original images!). Use commands

    $ mkdir ~/tmp
    $ cd ~/tmp
    $ wget ftp://munipack.physics.muni.cz/pub/munipack/munipack-data-0716.tar.gz
    $ tar zxf munipack-data-0716.tar.gz

to unpack it to a desired directory in your home. We will assume that the sample data are unpacked to `~/tmp` (the name does not matter) directory as the subdirectory `munipack-data-0716/`. This tutorial will take about 2GB of disk space.

The sample dataset includes an observation of this blazar together with correction frames (flat-fields and dark-frames). The data has been acquired at MonteBoo Observatory by Lucie Sixtová.

Data overview
Description | Filemask | Exposure
--- | --- | ---
scientific images | `0716_*[VR].fits` | 120 sec
dark-frames of scientific images | `d120_*.fits` | 120 sec
flat-fields | `f30_*[VR].fits` | 30 sec
dark-frames of flat-fields | `d30_*.fits` | 30 sec

## Photometry Pre-processing

Prepare corrected data as is described in Photometric Corrections Tutorial.

    $ munipack dark -o d30.fits d30_*.fits
    $ munipack dark -o d120.fits d120_*.fits
    $ munipack flat -o f_V.fits -dark d30.fits f30_*V.fits
    $ munipack flat -o f_R.fits -dark d30.fits f30_*R.fits
    $ munipack phcorr -dark d120.fits -flat f_V.fits 0716_*V.fits
    $ munipack phcorr -dark d120.fits -flat f_R.fits 0716_*R.fits

## Detection of Stars And The Aperture Photometry

For detection and photometry, run the commands:

    $ munipack find -f 3 0716_*.fits
    $ munipack aphot 0716_*.fits
    $ munipack gphot 0716_*.fits

This routines detect stars on all frames and prepares both aperture and growth-curve photometry. Results are stored in FITS files with images as an additional part (extension). Backups of original frames are saved with the tilde (~) filename suffix.

Stars are modelled as peaks with near-Gaussian profile and the full width at half of maximum (FWHM) given as a parameter -f. The default value is suitable for usual optical images.

The number of detected stars is affected by `-th` parameter designed as a threshold over the sky level in sigma-sky values. Default value will detect faint stars but not the most faint stars. Values under -th 1 will implicate detection of defects.

By default, the first aperture with radius greater than FWHM is used for subsequent processing.

## Astrometry Calibration

The astrometry calibration will be done with

    $ munipack cone --Johnson-patch --magmin 11 --magmax 15 -r 0.2 -- 110.5 71.3
    $ munipack astrometry -c cone.fits 0716_*.fits

It will run for a while. The routine use detected stars to determine mutual association (match) between stars on images and in the catalogue (result of default run of cone is sample from UCAC4 catalogue). The set of stars establishes transformation from pixel coordinates to sky coordinates which is the astrometry calibration.

For particular frame, the match sometimes has failed. This commonly indicates these source of problems: clouds, bad frame, etc. For example, the processing will report (see affected frames to understand why):

    ...
    =C> Mutual match for files `0716_145R.fits' and `cone.fits' failed.
    ...

## Photometry Calibration

Photometry calibration is essential for valuable results of light curves. Photometry precision will be demonstrated on these calibration methods:

- Manual calibration.
- Calibration on base of known photometric sequence.
- Calibration on base of a photometry catalogue.
- Calibration on base of already calibrated frame.

Description Of Common Parameters There are some important parameters which will commonly used:

`--photsys-ref Johnson`
  Identifier of our photometric system must be provided because it is used for computation of reference photons. In real, used filters are only an good approximation.
`-f, --filters`
  The option sets filter of the calibrated frame.
`--area 0.3`
  An approximation of input area of the telescope.
`-O --mask '\1_cal.\2'`
  This magic option adds suffix to input frame name and set the new name as output. The input filename is split on part preceding (referenced as \1) and following (\2) the dot. We are insert the string _cal between the first and final parts. For example, filename `0716_666R.fits` will produce \1=0716_666R, \2=fits, so output will be `0716_666R_cal.fits`. For details, see Advanced Output Filenames.

Processing Large Dataset Photometry calibration is implemented for single frames only. Because typical observation run produces a lot of frames, shell scripting can help very much. We will use loops which are coded with command for. Following loop shows how to print all fits frames in current directory:

    for A in *.fits; do
       echo $A
    done

### Manual Calibration

Manual calibration means, that we are specifying directly the constant r (see Photometry Calibration). Manual calibration uses provided value without any changes and computes output quantities like photons. That mean that user is fully responsible for input values which affects also results.

We will use this method to provide "instrumental quantities" which has been used by our photometry predecessors. The instrumental magnitudes will be produced by setting of r=1 (no absolute calibration). Another choice can approximately fit absolute magnitudes. For instance, as we will see later, the r is approx 20 and area of telescope is 0.3 m² so r=20/0.3 = 60 will give approximate good absolute magnitudes.

    $ FILTER=V   # also set R
    $ for A in 0716_*${FILTER}.fits; do
        munipack phcal -C 1 --photsys-ref Johnson -f ${FILTER} \
            -O --mask '\1_mancal.\2' $A;
      done

(Frames with no astrometry are reported again.)

The result instrumental values are not calibrated at all. We will use it only to construct differential magnitudes.

### Standard Field As A Catalogue

Instrumental magnitudes can be considered as an intermediate product. If we are preferring calibrated magnitudes, the photometry calibration must be performed. The calibration determines r (see Photometry Calibration) from a set of calibration stars.

Identification chart for stars on field of 0716+71.

Already calibrated stars must be known before. The most typical situation is known calibration sequence which had been measured by our predecessors. For the purpose, we are get the calibration sequence from Finding Charts for AGN by Landessternwarte Heidelberg-Königstuhl and prepared the file 0716+71.lst. (see also González-Pérez et al (2001)). The photometry input catalogue can be created as

    $ munipack fits --restore 0716+71.lst

The calibration stars can be used to calibrate of our frames:

    $ FILTER=V   # also set R
    $ for A in 0716_*${FILTER}.fits; do
          munipack phcal \
            --photsys-ref Johnson --area 0.3 \
            -f ${FILTER} --col-mag ${FILTER}mag --col-magerr e_${FILTER}mag  \
            -c 0716+71.fits
            -O --mask '\1_catcal.\2'
            $A;
      done

Note, that we are supposed that the filters are exactly in Johnson UBVR(..) system (`--photsys-ref Johnson`). If the filters are significantly different, the transformation table must be applied on instrumental data.

### UCAC4 As A Catalogue

There is only one catalogue which covers whole sky with photometry measurements in magnitudes in BV (Johnson) and gri (Bessel) filters: UCAC4 catalogue.

There is way how to use UCAC4 on calibration:

    $ FILTER=V   # also set R
    $ for A in 0716_*${FILTER}.fits; do
         munipack phcal \
           --photsys-ref Johnson --area 0.3 \
           -f ${FILTER} --col-mag ${FILTER}mag --col-magerr e_${FILTER}mag  \
           -c cone.fits \
           -O --mask '\1_ucacal.\2' \
           $A;
      done

### Reference Frame

As the reference, we are using our frame. The approach will give the most precise results for relative photometry. An systematic offsets can be supposed in absolute calibration.

    $ FILTER=V   # also set R
    $ for A in 0716_*${FILTER}.fits; do \
          munipack phcal \
            --photsys-ref Johnson --area 0.3 \
            -f ${FILTER}  \
            -r 0716_006${FILTER}_catcal.fits -O --mask '\1_refcal.\2' $A;
      done

## Light Curves

The frames are calibrated in photons. The standard magnitudes can be get with different choices of filters V,R and calibration types (manual, catalogue,reference frame):

    $ munipack timeseries -c "110.473,71.343 110.389,71.322 110.468,71.305" \
                -l MAG,MAGERR -o mancal_R.fits  0716_*R_mancal.fits

Light curve of 0716+71 determined by various methods. Ones for standard field and UCAC4 are shifted for ±0.1 magnitude.
Light curve of calibration star A (difference is plotted for A and B with added constant). Ones for standard field and UCAC4 are shifted for ±0.1 magnitude.

## Conclusions

Light curves of 0716+71 exhibits these properties:

- Instrumental calibration, by using of a constant, produces results strongly depending on observation conditions. In the graph, the offset 4.5 was added (which is equivalent to use of `-C 20 --area 0.3`, see CTPH keyword in FITS files *_catcal). This calibration can't be reccomended for additional processing by any way.
- Other kinds of calibrations gives consistent results within their statistical errors. Features: 0.25-0.5 (brightnening of blazar), 0.42, 0.57, above 0.65 (clouds).
- Light curve with minimal noise is produced by (carefully) selecting of reference frame.
- The precision of UCAC4 is significantly lower than both the reference frame and the standard field.
- Points with large differences are due to clouds and other instrumental problems (inspect the frames visually).

Light curves of calibration stars exhibits another properties:

- The differential magnitude successfully suppress large changes in extinction due to clouds because both the stars are attenuated by the similar way.
- The reference frame again offers the best results because one much more better suppress potential deviations (clouds, flat-fields imperfections, etc.) thansk to averaging more objects. Some trends, perhaps due to colour extinction, are still visible
- The variations in light curves on level of a few hundredth are significant. The change in blazar flux can be declared as real.
- The strongly deviated measurements are due seriously bad frames.

## Tips

- The approach can be generalized for any objects exhibiting similar light variations as variable stars, exoplanets, etc
- Object coordinates can be specified also in a table.
- Parameter `-T phase --epoch 2453759 --period 1.0` can be used to generate phase curve.
- The best way to get calibrated magnitudes is to prepare own photometry catalogue as the average of all frames.

## See Also

Manuals: Timeseries, Astrometry, Aperture Photometry, Photometry Calibration, Photometric corrections. Data Formats: Time Serie Tables.

lctut.sh is a bash script summarizing of this tutorial, ucac_jmuc.py is Python utility (requires Astropy) which converts UCAC4 r,i magnitudes in Gunn to R,I Johnson photometry system (an equivalent of `--Johnson-patch`).