An example of a mido calculation
Last updated: Apr15,2018

Here are some notes I made on Apr15,2018. I

  

Development notes for usno_photcal with wcs-calibrated image: 
20180206T022042.6_acm_sci_proc.fits

% usno_photcal ./S/20180206T022042.6_acm_sci_proc.fits Y 
arg1 - Name of FITS image (can be full path)
arg2 - run in debug mode (Y/N)

I'm set up to run this in: 
/home/sco/play
/home/sco/A_wcsf/zp0

At the most basic level I need a star with standard (USNO) and 
instrumental magnitudes. 
Recall my mido magnitude:     MAG30ZP = 30.0 - 2.5 log (F) 
where F is the sky-subtracted total signal in aperture (in ADU) 

For a basic test set, when I use "Blue 16.0" I get 5 stars. I 
remove the stars labeled:   2,3,4
I also add one sky box. 

At the end of this, I get the following table:     midodata.2.table   (see midodata.2.parlab) 
# Contents of:  midodata.2
Col01 = X pixels (aperture X center)                   
Col02 = Y pixels (aperture Y center)                   
Col03 = X center, pixels (intensity weighted centroid) 
Col04 = Y center, pixels (intensity weighted centroid) 
Col05 = magnitude (assuming zp=30)                     
Col06 = Average value per pixel in aperture            
Col07 = Average value per pixel in annulus             
Col08 = number of pixels in aperture                   
Col09 = Peak pixel value (no bkg-sub, image ADU)       
Col10 = marker code (1=circle,2=box,3=ellipse)         
   203.26    264.65    202.57    263.56  17.066   180.301    41.740     1076.0    4114.00   1      # star 1 
   516.98    624.06    517.31    624.67  15.703   527.447    43.506     1081.0   14402.50   1      # star 5 
   555.84    446.55    553.31    443.36  21.982    39.476    39.337    11550.0     983.50   2

Recall that star name is the line number in the cdfp file = 20180206T022042.6_acm_sci_proc-usno.cdfp

I can retrieve the standard mag values with the routine:
% cdfp_getline.sh 20180206T022042.6_acm_sci_proc-usno.cdfp Blue 1 
15.8000
% cdfp_getline.sh 20180206T022042.6_acm_sci_proc-usno.cdfp Blue 5
cdfp_getline.sh 20180206T022042.6_acm_sci_proc-usno.cdfp Blue 5
14.0800

**** Just looking at the cdfp file I see that these are correct. 
Hence, the ZP values are: 
    
Star   MAG30ZP     MAGSTAN 
 1      17.066      15.800 
 5      15.703      14.080 

To see how Mag20ZP is computed in the code: 
  SCOLIB   m2048ims.f
      measure_circle_simple       compuets Npix Average SIGMA MERR min max  TCOUNT (=total flux) 
      measure_aper_wbkg (m2048ims.f:1052)   like above, but handles the local sky subtraction 


  I use measure_circle_simple in mido.f  (mopo code) 
    measure_aper_wbkg    In this routine I gather both the aperture and annulus stats. 

Here is the code I use to get the magnitude in aperture: 
c predict background in aperture    (line 1289 i m2048ims.f)
      Tap_bkg = xnp*averageA
      Tfcorr = sum - Tap_bkg
      xMagZP30 = -99.0
      if( Tfcorr.gt.0.0 ) xMagZP30 = 30.0 - 2.5*alog10(Tfcorr)
where, 
c sum      = total flux in aperture
c xnp      = number of pixels in aperture
c xnpA     = number of pixels in annulus
c averageA = average flux per pixel in annulus

======================================================================================================================
In my example for star 1, here are the values as they appear in the *.info file: 
Nap     =               1076.0 / Number of pixels in aperture
AVann   =          41.73976898 / Average pixel value in annulus        # this is averageA    
AVap    =         180.30111694 / Average pixel value in aperture       # average in aperture ----> in midodata2 table 
Tap     = 0.19400400000000E+06 / Total summed pixel flux in aperture   # total sum = 194004.000
MagZP30 =              17.0664 / BKG-corrected aperture magnitude (ZP=30)
======================================================================================================================

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Here I confirm how my mag is computed  
   Tap_bkg  =  1076.0 * 41.7397   =   44909.98

what I write to my table is average pixel value in aperture (not the sum total)
   AVap     =   180.3011
   sum      =   194004.0
   Nap      = 1076 
     Do I get the same average?      Avap = 194004 / 1076.0 =  180.301    Yes!!!!
     Total flux = 1076.0 * 180.3011 =  194003.98 

   To get total sky subtracted flux from my midodata2 values alone? 
      Flux in ap due to sky   =  44909.98
      Total flux in ap        =  194003.98
      Total ap flux above sky =  149094.0   adu 

    mag = 30 - 2.5 log( 149094.0 ) 
        = 30 - 2.5 (5.1735) 
        = 30 - 12.9337
 Mag30  = 17.0663                    Yes!!!! This is what was stored above.

So, here is my midodata2 table line with variabe names as column headings:
                                          Mag30    Avap       AVann      Bpix  
   203.26    264.65    202.57    263.56  17.066   180.301    41.740     1076.0    4114.00   1

  So,   star_flux = (180.301-41.740) * 1076 
                  = 138.561 * 1076 
                  =  149091.636 
  Hence, 
          Mag30ZP = 30 - 2.5 * log(149091.636) 
                  = 30 - 2.5 * 5.17345 
                  = 30 - 12.93362
                  = 17.066                         **** This is the magnitude reported in the midodata2 table!!!! 
 
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
   

In m2048ims.f line 1201 I compute 
      average = -999.0
      if( xnp.gt.0.0 ) average = sum/xnp
where    xnp = 1076      sum = Tap

======================
Where I packed the values: 
# Number of pixels in aperture 
      ncd=ncd+1
      kw  = "Nap     "
      com = "Number of pixels in aperture                  "
      keyword(ncd) = kw
      comhold(ncd) = com
      write(b20,1200) xnp

# Store the total sum in aperture 
      ncd=ncd+1
      kw  = "Tap     "
      com = "Total summed pixel flux in aperture           "
      keyword(ncd) = kw
      comhold(ncd) = com
      write(b20,1202) sum

# Store the average in background annulus
      ncd=ncd+1
      kw  = "AVann   "
      com = "Average pixel value in annulus                "
      keyword(ncd) = kw
      comhold(ncd) = com
      write(b20,1201) averageA
      b20hold(ncd) = b20

--------------------------
# I store both the average in apertur and the sum total  
# Store the average in aperture
      ncd=ncd+1
      kw  = "AVap    "
      com = "Average pixel value in aperture               "
      keyword(ncd) = kw
      comhold(ncd) = com
      write(b20,1201) average
      b20hold(ncd) = b20

# Store the summed total in aperture 
      ncd=ncd+1
      kw  = "Tap     "
      com = "Total summed pixel flux in aperture           "
      keyword(ncd) = kw
      comhold(ncd) = com
      write(b20,1202) sum
      b20hold(ncd) = b20
--------------------------

# Finally, I store the background -subtracted magnitude
      ncd=ncd+1
      kw  = "MagZP30 "
      com = "BKG-corrected aperture magnitude (ZP=30)      "
      keyword(ncd) = kw
      comhold(ncd) = com
      write(b20,1203) xMagZP30
      b20hold(ncd) = b20






Back to SCO code page