Photometric correction and photometry, light curve plotting
Dr. Jie Zheng (National Astronomical Observatories (NAOC), CAS) @rapidlzj
This is a pipeline to extract light curve from a serial of fits images.
This pipeline will merge bias and flat, correct science images, and then extract stars and their magnitudes, finally it can provide a light curve.
Install packages by pip or conda, or other package management command
- numpy
- astropy
- photutils
- matplotlib
A list of bias files should be provided, and then a merged bias fits file will be generated. A median function is used to evaluated the bias of each pixel.
A list of flat files and the merged bias fits file should be provided, and then a merged flat fits file will be generated. We normalize each flat image with its median, and then use the median function to merge the flat.
Correct science fits with the given merged bias and flat files. For each pixel, bias is substracted, and then the flat if divided.
Use SExtractor or photutils package to detect sources and evaluate their flux.
Stars with
Find pointing offset between images, compared with the specified image. A big enough initial offset tolerance will be used in matching stars between images. And then the tolerance will be shrinked, until the error is lower enough for target identifying.
Differential Calibrate the flux of target (giving x & y) with reference stars (also x & y).
A global flux offset between each image and the reference image is measured, using the 3 sigma clipped median of offsets of all matched stars. A local flux offset is also measured by the given refernce stars.
Then the flux changing of the target star by the two offsets are both extracted. Finally the differential flux report is generated.
Plotting the light curve
Use ls
or other approachs to create a fits file list.
Each line in the list is a filename, without path.
The common part of path will be provided with a parameter.
import lc
# initial variables
raw_path = 'raw/' # path for raw files
out_path = 'red/' # path for output files
bias_lst = 'bias.lst' # list file name of bias files
bias_fits = 'bias.fits' # merged bias file name
flat_lst = 'flat.lst' # list file name of flat files
flat_fits = 'flat.fits' # merged flat file name
sci_lst = 'sci.lst' # list file name of scientific fits files
sci_corr_suffix = 'corr' # suffix added to corrected fits files
catalog_suffix = 'cat' # output catalog suffix
diff_file = 'diff.txt' # the output differential calibration flux (mag) file name
curve_fig = 'diff.png' # differential light curve figure (pdf/eps/png)
lc.biascomb(
raw_path, # path of raw files
out_path, # path of out files
bias_lst, # list file of bias fits files
bias_fits, # merged bias fits files
)
lc.flatcomb(
raw_path, # path of raw files
out_path, # path of out files
flat_lst,
bias_fits, # merged bias fits files
flat_fits, # merged flat fits files
)
lc.imgproc(
raw_path, # path of raw files
out_path, # path of out files
sci_lst, # list file of scientific fits files
bias_fits, # merged flat fits files
flat_fits, # merged flat fits files
sci_corr_suffix, # suffix of corrected files
)
lc.phot(
out_path, # path of out files
sci_lst, # list file of scientific fits files
sci_corr_suffix, # suffix of corrected files
catalog_suffix, # suffix of catalog files
)
offset = lc.align(
out_path, # path of out files
sci_lst, # list file of scientific fits files
catalog_suffix, # suffix of corrected files
ref_img_id, # reference image id, default is 0
)
lc.diffcali(
out_path, # path of out files
sci_lst, # list file of scientific fits files
catalog_suffix, # suffix of catalog files
(x, y), # x/y coordination of target star
[(x1, y1), (x2, y2), ...], # list of x/y coordinations of reference stars
(xc, yc), # x/y coordination of check star
diff_file, # the output differential calibration flux (mag) file name
offset, # offset between iamges
)
lc.curve(
outpath, # path of out files
diff_file, # the output differential calibration flux (mag) file name
curve_fig, # differential light curve figure (pdf/eps/png)
)