anchor.diff:  addcol mergedClass -desc "See http://surveys.roe.ac.uk/wsa/www/gloss_m.html#gpssource_mergedclass" "toShort( pStar>0.899?-1:pStar>=0.699?-2:pGalaxy>=0.899?1:pGalaxy>=0.699?-3:pNoise>=0.899?0:pSaturated>=0.899?-9:NULL )"
   
   # mergedClassStat
  -addcol mergedClassStat "toFloat( mean(array(rClassStat, iClassStat, haClassStat)) * sqrt(count(array(rClassStat, iClassStat, haClassStat))) )"
  +addcol mergedClassStat -desc "See http://surveys.roe.ac.uk/wsa/www/gloss_m.html#gpssource_mergedclassstat" "toFloat( mean(array(rClassStat, iClassStat, haClassStat)) * sqrt(count(array(rClassStat, iClassStat, haClassStat))) )"
   
   
   # merged quality flags
  
positive.code: addcol -desc "Position offset of the Ha-band detection in DEC" haEta "toFloat(3600.0*(haDec-dec))"
  
  # Rename r-band columns
  colmeta -name r aperMag2_1
  colmeta -name rErr aperMag2Err_1
  colmeta -name rPeakMag peakMag_1
  colmeta -name rPeakMagErr peakMagErr_1
  colmeta -name rAperMag1 aperMag1_1
  colmeta -name rAperMag1Err aperMag1Err_1
  colmeta -name rAperMag3 aperMag3_1
  colmeta -name rAperMag3Err aperMag3Err_1
  colmeta -name rGauSig gauSig_1
  colmeta -name rEll ell_1
  colmeta -name rPA pa_1
  colmeta -name rClass class_1
  colmeta -name rClassStat classStat_1
  colmeta -name rBrightNeighb brightNeighb_1
  colmeta -name rDeblend deblend_1
  colmeta -name rSaturated saturated_1
  colmeta -name rVignetted vignetted_1
  colmeta -name rTruncated truncated_1
  colmeta -name rBadPix badPix_1
  colmeta -name rErrBits errBits_1
  colmeta -name rMJD mjd_1
  colmeta -name rSeeing seeing_1
  colmeta -name rDetectionID detectionID_1
  colmeta -name rCCD ccd_1
  colmeta -name rX x_1
  colmeta -name rY y_1
  colmeta -name rPlaneX planeX_1
  colmeta -name rPlaneY planeY_1
  
  # Rename i-band columns
  colmeta -name i aperMag2_2
  colmeta -name iErr aperMag2Err_2
  colmeta -name iPeakMag peakMag_2
  colmeta -name iPeakMagErr peakMagErr_2
  colmeta -name iAperMag1 aperMag1_2
  colmeta -name iAperMag1Err aperMag1Err_2
  colmeta -name iAperMag3 aperMag3_2
  colmeta -name iAperMag3Err aperMag3Err_2
  colmeta -name iGauSig gauSig_2
  colmeta -name iEll ell_2
  colmeta -name iPA pa_2
  colmeta -name iClass class_2
  colmeta -name iClassStat classStat_2
  colmeta -name iBrightNeighb brightNeighb_2
  colmeta -name iDeblend deblend_2
  colmeta -name iSaturated saturated_2
  colmeta -name iVignetted vignetted_2
  colmeta -name iTruncated truncated_2
  colmeta -name iBadPix badPix_2
  colmeta -name iErrBits errBits_2
  colmeta -name iMJD mjd_2
  colmeta -name iSeeing seeing_2
  colmeta -name iDetectionID detectionID_2
  colmeta -name iCCD ccd_2
  colmeta -name iX x_2
  colmeta -name iY y_2
  colmeta -name iPlaneX planeX_2
  colmeta -name iPlaneY planeY_2
  
  # Rename H-alpha columns
  colmeta -name ha aperMag2_3
  colmeta -name haErr aperMag2Err_3
  colmeta -name haPeakMag peakMag_3
  colmeta -name haPeakMagErr peakMagErr_3
  colmeta -name haAperMag1 aperMag1_3
  colmeta -name haAperMag1Err aperMag1Err_3
  colmeta -name haAperMag3 aperMag3_3
  colmeta -name haAperMag3Err aperMag3Err_3
  colmeta -name haGauSig gauSig_3
  colmeta -name haEll ell_3
  colmeta -name haPA pa_3
  colmeta -name haClass class_3
  colmeta -name haClassStat classStat_3
  colmeta -name haBrightNeighb brightNeighb_3
  colmeta -name haDeblend deblend_3
  colmeta -name haSaturated saturated_3
  colmeta -name haVignetted vignetted_3
  colmeta -name haTruncated truncated_3
  colmeta -name haBadPix badPix_3
  colmeta -name haErrBits errBits_3
  colmeta -name haMJD mjd_3
  colmeta -name haSeeing seeing_3
  colmeta -name haDetectionID detectionID_3
  colmeta -name haCCD ccd_3
  colmeta -name haX x_3
  colmeta -name haY y_3
  colmeta -name haPlaneX planeX_3
  colmeta -name haPlaneY planeY_3
  
  
negative.code: # sourceID (use the first non-NULL value of detectionID_1/2/3)
  addcol sourceID "detectionID_1"
  replacecol sourceID "NULL_sourceID?detectionID_2:sourceID"
  replacecol sourceID -desc "Unique identification number of the source. Identical to rDetectionID if the source was detected in the r-band; identical to iDetectionID or haDetectionID otherwise." "NULL_sourceID?detectionID_3:sourceID"
  
  # Rename RA/Dec
  colmeta -name ra ra_1
  