Photometric keyword issues - 20130819

EFOSC2 imaging

Bugs for Dave/Cosimo to check/correct in purple / Bugs for Stefano to correct in next version of pipeline in red

ESO request that the EFOSC2 acquisition images are submitted as science files. Hence we need to make sure the photometric keywords are set correctly, there are a few bugs in these and in the photometric science files. 

There are 1152 acquisition images in /data/psdb2data1/pessto_eso_phaseIII/validated_pessto_files/efsoc/spectra
There are also 1309 photometric science images. 

Problem 1 
99 files have ABMAGLIM = INF.0 or 9999.0 set
Cause : the median background (MBKG) is a negative number, hence Eqn A.7 takes sqrt of -ve number

But 80 are through slit images. Easy purge of files  -  if "HIERARCH ESO INS SLIT1 NAME"  does not equal "Free" then a slit is used and it is a through-slit acquisition image. We don't submit these.  (Dave to always do this in the future before SSDR is sent to ESO. But data reducers to check and purge during reduction process). 

143 files do not have PHOTZP set, have ABMAGLIM=9999.0 and a nonsense value for ABMAGSAT 
These are all unfiltered images, so we should not submit those as science files, as they are uncalibrated.
Easy purge of files :
if FILTER = Free  
than do not submit these as science files.  (Dave to always do this in the future before SSDR is sent to ESO - but data reducers to check these and purge during the reduction proces ). 

Problem 2
19 files have no FWHM set, and hence 9999 set for ABMAGSAT. In all of these cases the photometry failed. Hence they are not submitted as as science files, as they cannot be calibrated. (Dave to purge these, get list from Cosimo)

Problem 3
In equation A.7 (in PESSTO paper), AGMAGLIM is defined. However if the meadian background is negative, then this will be sqrt(-ve number). This equation assumes images are background limited. For short exposures the MBKG can be negative, due to bias drifts and being read noise dominated.
Solution is to replace the old equation A.7 with the general form which accounts for frames which are read noise dominated. The new version of the paper (v13 and above) has the new equation. 
Dave to correct the ABMAGLIM for all the files for SSDR1
Stefano - to correct this calculation in the next version of the pipeline

SOFI imaging
213 SOFI science images. 

Problem 4
There are only 191 weight images, and I would have expected the same number of weight images as science images. Where are the missing ones ? Or is there a reason why they don't exist ? 

Problem 5
52 of them do not have PHOTZP set, or PSF_FWHM set. Hence ABMAGSAT and ABMAGLIM canot be calculated either. 
Major problem - it looks like the astrometry fails, hence no 2MASS match, no zero point and not FWHM. But it doesn't seem to be a problem with the  data. For example look at these three files :
The Ks file is fine, the other two have astrometric headers but they are incorrect. Need the reductions of these checked - Cosimo

[sne@psweb imaging]$ dfits * | fitsort TEXPTIME FILTER PHOTZP | grep 9999.0
2013am_20130403_H_merge_56475_1.fits                       120.0   H       9999.0          
2013am_20130411_H_merge_56475_1.fits                       120.0   H       9999.0          
2013am_20130411_J_merge_56475_1.fits                       48.0     J       9999.0          
2013am_20130411_Ks_merge_56475_1.fits                     128.0   Ks       9999.0          
2013am_20130417_J_merge_56475_1.fits                       48.0     J       9999.0          
2013am_20130417_Ks_merge_56475_1.fits                     128.0   Ks       9999.0          
BD174708003_20120915_J_merge_56474_1.fits                 24.0     J       9999.0          
CSS130118105323+1646_20130103_H_merge_56475_1.fits         32.0     H       9999.0          
CSS130118105323+1646_20130113_J_merge_56475_1.fits         64.0     J       9999.0          
LSQ12dwl_20120908_Ks_merge_56474_1.fits                   160.0   Ks       9999.0          
LSQ12dwl_20120915_H_merge_56474_1.fits                     144.0   H       9999.0          
LSQ13fn_20130113_Ks_merge_56475_1.fits                     1440.0   Ks       9999.0          
LSQ13sj_20130403_H_merge_56475_1.fits                     576.0   H       9999.0          
LSQ13sj_20130403_Ks_merge_56475_1.fits                     768.0   Ks       9999.0          
SN2009ip_20121204_Ks_merge_56475_1.fits                   160.0   Ks       9999.0          
SN2012dy_20120916_H_merge_56474_1.fits                     144.0   H       9999.0          
SN2012dy_20121121_H_merge_56475_1.fits                     1920.0   H       9999.0          
SN2012ec_20120825_H_merge_56474_1.fits                     160.0   H       9999.0          
SN2012ec_20120825_J_merge_56474_1.fits                     160.0   J       9999.0          
SN2012ec_20120825_Ks_merge_56474_1.fits                   200.0   Ks       9999.0          
SN2012ec_20120924_H_merge_56474_1.fits                     144.0   H       9999.0          
SN2012ec_20121015_H_merge_56474_1.fits                     144.0   H       9999.0          
SN2012ec_20121015_J_merge_56474_1.fits                     60.0     J       9999.0          
SN2012ec_20121015_Ks_merge_56474_1.fits                   160.0   Ks       9999.0          
SN2012ec_20121204_H_merge_56475_1.fits                     360.0   H       9999.0          
SN2012ec_20121204_J_merge_56475_1.fits                     320.0   J       9999.0          
SN2012ec_20121221_Ks_merge_56475_1.fits                   360.0   Ks       9999.0          
SN2012ec_20130103_J_merge_56475_1.fits                     400.0   J       9999.0          
SN2012ec_20130103_Ks_merge_56475_1.fits                   360.0   Ks       9999.0          
SN2012ec_20130113_H_merge_56475_1.fits                     360.0   H       9999.0          
SN2012ec_20130113_Ks_merge_56475_1.fits                   720.0   Ks       9999.0          
SN2012ec_20130128_H_merge_56475_1.fits                     360.0   H       9999.0          
SN2012ec_20130128_Ks_merge_56475_1.fits                   360.0   Ks       9999.0          
SN2012ec_20130221_J_merge_56475_1.fits                     400.0   J       9999.0          
SN2012ec_20130221_Ks_merge_56475_1.fits                   720.0   Ks       9999.0          
SN2012fr_20121113_H_merge_56475_1.fits                     32.0     H       9999.0          
SN2012fr_20121113_J_merge_56475_1.fits                     32.0     J       9999.0          
SN2012fr_20121113_Ks_merge_56475_1.fits                   60.0     Ks       9999.0          
SN2012fr_20121121_Ks_merge_56475_1.fits                   60.0     Ks       9999.0          
SN2012fr_20121204_H_merge_56475_1.fits                     32.0     H       9999.0          
SN2013F_20130113_H_merge_56475_1.fits                     144.0   H       9999.0          
SN2013F_20130113_Ks_merge_56475_1.fits                     160.0   Ks       9999.0          
SN2013F_20130128_J_merge_56475_1.fits                     160.0   J       9999.0          
SN2013F_20130128_Ks_merge_56475_1.fits                     240.0   Ks       9999.0          
SN2013K_20130128_H_merge_56475_1.fits                     360.0   H       9999.0          
SN2013K_20130128_J_merge_56475_1.fits                     400.0   J       9999.0          
SN2013K_20130207_J_merge_56475_1.fits                     400.0   J       9999.0          
SN2013K_20130221_H_merge_56475_1.fits                     360.0   H       9999.0          
SN2013K_20130403_J_merge_56475_1.fits                     400.0   J       9999.0          
SN2013K_20130403_Ks_merge_56475_1.fits                     720.0   Ks       9999.0          
SN2013K_20130417_H_merge_56475_1.fits                     480.0   H       9999.0          
SN2013K_20130417_J_merge_56475_1.fits                     360.0   J       9999.0