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 nBands -desc "Number of bands in which the source is detected." "toShort(sum(array(NULL_r?0:1,NULL_i?0:1,NULL_ha?0:1)))"
  
  # Reliable
  addcol reliable -desc "True if the source is detected in all three bands at >5-sigma and errBits <= 1." "nBands == 3 & rErr<0.198 & iErr<0.198 & haErr<0.198 & errBits <= 1"
  
  
  # night
  colmeta -name night night_1
  replacecol night "NULL_night?night_2:night"
  replacecol night "NULL_night?night_3:night"
  
  # seeing
  addcol -desc "Worst seeing amongst the three bands." seeing "toFloat( maximum(array(NULL_rSeeing ? 0 : rSeeing, NULL_iSeeing ? 0 : iSeeing, NULL_haSeeing ? 0 : haSeeing)) )"
  
negative.code: colmeta -name haDec dec_3
  # Fill in RA/Dec if not provided by the r-band
  replacecol ra "NULL_ra?iRA:ra"
  replacecol ra -desc "J2000 Right Ascension with respect to the 2MASS PSC reference frame (which is consistent with ICRS to within 0.1 arcsec). The coordinate given is obtained from the astrometric measurement in the r'-band exposure. If the source is undetected in r', then the i' or H-alpha coordinate is given."  "NULL_ra?haRA:ra"
  replacecol dec "NULL_dec?iDec:dec"
  replacecol dec -desc "J2000 Declination. See comments for ra."  "NULL_dec?haDec:dec"
  colmeta -name posErr posErr_1
  replacecol posErr "NULL_posErr?posErr_2:posErr"
  replacecol posErr -desc "Astrometric fit error (RMS). Be aware that the error might be significantly larger than this near CCD edges." "NULL_posErr?posErr_3:posErr"
  # Add galactic coordinates
  addskycoords -inunit deg -outunit deg icrs galactic ra dec l b;
  
  