IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 15509


Ignore:
Timestamp:
Nov 7, 2007, 6:28:03 PM (19 years ago)
Author:
eugene
Message:

converted internal NO_MAG and NO_ERR to NAN, NAN_S_SHORT, etc as appropriate

Location:
trunk/Ohana/src
Files:
43 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/addstar/src/FilterStars.c

    r15487 r15509  
    4949    }
    5050
    51     if (stars[N].M >= 0.001*NO_MAG) {
    52       stars[N].M       = 0.001*NO_MAG;
    53     } else {
    54       stars[N].M       = stars[N].M + MTIME;
     51    // stars->M is either NAN or a valid inst magnitude
     52    // stars->dM is either NAN or a valid error
     53
     54    dMs  = 0.0;
     55    dMx = 0.0;
     56    if (SUBPIX) {
     57      dMs = get_subpix (stars[N].X, stars[N].Y);
     58      dMx = scat_subpix (stars[N].X, stars[N].Y);
     59      if (!isnan(stars[N].dM)) {
     60        stars[N].dM = hypot (stars[N].dM, dMx);
     61      }
    5562    }
    5663
    57     if (stars[N].M > 32.77) {
    58       fprintf (stderr, "*");
     64    if (!isnan(stars[N].M)) {
     65      stars[N].M += MTIME - dMs;
    5966    }
    60 
    61     stars[N].dM      = MIN (stars[N].dM, NO_ERR);
    62 
    63     stars[N].Mgal    = MIN (stars[N].Mgal + MTIME, 0.001*NO_MAG);
     67    if (!isnan(stars[N].Mgal)) {
     68      stars[N].Mgal += MTIME - dMs;
     69    }
     70    if (!isnan(stars[N].Map)) {
     71      stars[N].Map += MTIME - dMs;
     72    }
    6473   
    65     if (SUBPIX) {
    66       dMs = get_subpix (stars[N].X, stars[N].Y);
    67       stars[N].M    -= dMs;
    68       stars[N].Mgal -= dMs;
    69       stars[N].Map  -= dMs;
    70       dMs = scat_subpix (stars[N].X, stars[N].Y);
    71       stars[N].dM = hypot (stars[N].dM, dMs);
    72     }
    7374    N ++;
    7475  }
  • trunk/Ohana/src/addstar/src/ReadImageHeader.c

    r15036 r15509  
    135135  image[0].trate = 10000 * tmp;
    136136
    137   tmp = 0;
    138   gfits_scan (header, AirmassKeyword, "%lf", 1, &tmp);
    139   image[0].secz = MIN (NO_MAG, tmp);
     137  image[0].secz = NAN;
     138  if (gfits_scan (header, AirmassKeyword, "%lf", 1, &tmp)) {
     139    image[0].secz = tmp;
     140  }
    140141
    141142  if (!gfits_scan (header, CCDNumKeyword, "%d", 1, &ccdnum)) {
  • trunk/Ohana/src/addstar/src/ReadStarsFITS.c

    r15487 r15509  
    5454
    5555  int i, Nstars, swapped;
     56  double ZeroPt;
    5657  Stars *stars = NULL;
    5758  SMPData *smpdata = NULL;
     
    5960  swapped = FALSE;
    6061  smpdata = gfits_table_get_SMPData (table, &Nstars, &swapped);
     62  ZeroPt = GetZeroPoint();
     63
    6164  /* XXX we need to check at least the size of the loaded table */
    62 
    6365  // XXX use memset to zero-out the elements before setting
     66
    6467  ALLOCATE (stars, Stars, Nstars);
    6568  for (i = 0; i < Nstars; i++) {
    6669    stars[i].X      = smpdata[i].X;
    6770    stars[i].Y      = smpdata[i].Y;
    68     stars[i].M      = smpdata[i].M;
     71
     72    if ((smpdata[i].M >= ZeroPt) || isnan(smpdata[i].M)) {
     73      stars[i].M    = NAN;
     74      stars[i].Mgal = NAN;
     75      stars[i].Map  = NAN;
     76    } else {
     77      stars[i].M    = smpdata[i].M;
     78      stars[i].Mgal = smpdata[i].M;
     79      stars[i].Map  = smpdata[i].M;
     80    }
     81
    6982    stars[i].dM     = smpdata[i].dM*0.001;
    7083    stars[i].dophot = smpdata[i].dophot;
    7184
    72     stars[i].Mgal   = smpdata[i].M;
    73     stars[i].Map    = smpdata[i].dM;
    7485    stars[i].fx     = smpdata[i].fx;
    7586    stars[i].fy     = smpdata[i].fy;
     
    8899
    89100  ps1data = gfits_table_get_PS1_DEV_0 (table, &Nstars, NULL);
     101  ZeroPt = GetZeroPoint();
     102
     103  ALLOCATE (stars, Stars, Nstars);
     104  for (i = 0; i < Nstars; i++) {
     105    stars[i].X       = ps1data[i].X;
     106    stars[i].Y       = ps1data[i].Y;
     107    stars[i].dX      = ps1data[i].dX;
     108    stars[i].dY      = ps1data[i].dY;
     109    if ((ps1data[i].M >= 0.0) || isnan(ps1data[i].M)) {
     110      stars[i].M     = NAN;
     111    } else {
     112      stars[i].M     = ps1data[i].M + ZeroPt;
     113    }
     114    stars[i].dM      = ps1data[i].dM;
     115    stars[i].Mpeak   = ps1data[i].Mpeak;
     116
     117    stars[i].sky     = ps1data[i].sky;
     118    stars[i].dsky    = ps1data[i].dSky;
     119
     120    stars[i].fx      = ps1data[i].fx;
     121    stars[i].fy      = ps1data[i].fy;
     122    stars[i].df      = ps1data[i].df;
     123
     124    stars[i].psfProb = ps1data[i].psfProb;
     125    stars[i].psfQual = ps1data[i].psfQual;
     126
     127    stars[i].detID   = ps1data[i].detID;
     128
     129    /* these are set elsewhere */
     130    stars[i].R       = 0.0;
     131    stars[i].D       = 0.0;
     132    stars[i].dR      = 0.0;
     133    stars[i].dD      = 0.0;
     134
     135    stars[i].uR      = 0.0;
     136    stars[i].uD      = 0.0;
     137    stars[i].duR     = 0.0;
     138    stars[i].duD     = 0.0;
     139
     140    stars[i].P       = 0.0;
     141    stars[i].dP      = 0.0;
     142
     143    stars[i].Mcal    = 0;
     144    stars[i].t       = 0;
     145    stars[i].dt      = 0;
     146    stars[i].airmass = 0;
     147    stars[i].code    = 0;
     148    stars[i].found   = 0;
     149
     150    /* these are not used */
     151    stars[i].Map     = NAN;
     152    stars[i].Mgal    = NAN;
     153    stars[i].dophot  = 0;
     154  }   
     155  *nstars = Nstars;
     156  return (stars);
     157}
     158
     159// XXX I need to make the IPP I/O functions and these functions
     160// consistent wrt ZERO_POINT....
     161Stars *Convert_PS1_DEV_1 (FTable *table, int *nstars) {
     162
     163  int i, Nstars;
     164  double ZeroPt;
     165  Stars *stars;
     166  PS1_DEV_1 *ps1data;
     167
     168  ps1data = gfits_table_get_PS1_DEV_1 (table, &Nstars, NULL);
    90169  ZeroPt = GetZeroPoint();
    91170
     
    111190    stars[i].df      = ps1data[i].df;
    112191
    113     stars[i].psfProb = ps1data[i].psfProb;
    114     stars[i].psfQual = ps1data[i].psfQual;
    115 
    116     stars[i].detID   = ps1data[i].detID;
    117 
    118     /* these are set elsewhere */
    119     stars[i].R       = 0.0;
    120     stars[i].D       = 0.0;
    121     stars[i].dR      = 0.0;
    122     stars[i].dD      = 0.0;
    123 
    124     stars[i].uR      = 0.0;
    125     stars[i].uD      = 0.0;
    126     stars[i].duR     = 0.0;
    127     stars[i].duD     = 0.0;
    128 
    129     stars[i].P       = 0.0;
    130     stars[i].dP      = 0.0;
    131 
    132     stars[i].Mcal    = 0;
    133     stars[i].t       = 0;
    134     stars[i].dt      = 0;
    135     stars[i].airmass = 0;
    136     stars[i].code    = 0;
    137     stars[i].found   = 0;
    138 
    139     /* these are not used */
    140     stars[i].Map     = 0.001*NO_MAG;
    141     stars[i].Mgal    = 0.001*NO_MAG;
    142     stars[i].dophot  = 0;
    143   }   
    144   *nstars = Nstars;
    145   return (stars);
    146 }
    147 
    148 // XXX I need to make the IPP I/O functions and these functions
    149 // consistent wrt ZERO_POINT....
    150 Stars *Convert_PS1_DEV_1 (FTable *table, int *nstars) {
    151 
    152   int i, Nstars;
    153   double ZeroPt;
    154   Stars *stars;
    155   PS1_DEV_1 *ps1data;
    156 
    157   ps1data = gfits_table_get_PS1_DEV_1 (table, &Nstars, NULL);
    158   ZeroPt = GetZeroPoint();
    159 
    160   ALLOCATE (stars, Stars, Nstars);
    161   for (i = 0; i < Nstars; i++) {
    162     stars[i].X       = ps1data[i].X;
    163     stars[i].Y       = ps1data[i].Y;
    164     stars[i].dX      = ps1data[i].dX;
    165     stars[i].dY      = ps1data[i].dY;
    166     if ((ps1data[i].M >= 0.0) || isnan(ps1data[i].M)) {
    167         stars[i].M   = 0.001*NO_MAG;
    168     } else {
    169         stars[i].M   = ps1data[i].M + ZeroPt;
    170     }
    171     stars[i].dM      = ps1data[i].dM;
    172     stars[i].Mpeak   = ps1data[i].Mpeak;
    173 
    174     stars[i].sky     = ps1data[i].sky;
    175     stars[i].dsky    = ps1data[i].dSky;
    176 
    177     stars[i].fx      = ps1data[i].fx;
    178     stars[i].fy      = ps1data[i].fy;
    179     stars[i].df      = ps1data[i].df;
    180 
    181192    stars[i].psfProb   = ps1data[i].psfProb;
    182193    stars[i].psfQual   = ps1data[i].psfQual;
     
    213224
    214225    /* these are not used */
    215     stars[i].Map     = 0.001*NO_MAG;
    216     stars[i].Mgal    = 0.001*NO_MAG;
     226    stars[i].Map     = NAN;
     227    stars[i].Mgal    = NAN;
    217228    stars[i].dophot  = 0;
    218229  }   
  • trunk/Ohana/src/addstar/src/ReadStarsTEXT.c

    r15036 r15509  
    1010  char *buffer, *c, *c2;
    1111  double tmp;
     12  double ZeroPt;
    1213  Stars *stars;
    1314 
     15  ZeroPt = GetZeroPoint();
     16
    1417  /* load in stars by blocks of 1000 */
    1518  N = 0;
     
    6669      dparse (&stars[N].Y,  2, &buffer[j*BYTES_STAR]);
    6770      dparse (&stars[N].M,  3, &buffer[j*BYTES_STAR]);
     71      if ((stars[N].M > ZeroPt) || isnan(stars[N].M)) {
     72        stars[N].M = NAN;
     73      }
    6874
    6975      /* cmp files carry dM in millimags */
  • trunk/Ohana/src/addstar/src/SEDfit.c

    r15038 r15509  
    161161    outcat[0].average[Nave].Nm        = 0;
    162162    outcat[0].average[Nave].Nn        = 0;
    163     outcat[0].average[Nave].Xp        = NO_MAG;
     163    outcat[0].average[Nave].Xp        = NAN_S_SHORT;
    164164    outcat[0].average[Nave].offset    = Nmeas;
    165165    outcat[0].average[Nave].missing   = -1;
     
    167167
    168168    for (j = 0; j < Nsec; j++) {
    169       outcat[0].secfilt[Nave*Nsec+j].M  = NO_MAG;
    170       outcat[0].secfilt[Nave*Nsec+j].dM = NO_MAG;
    171       outcat[0].secfilt[Nave*Nsec+j].Xm    = NO_MAG;
     169      outcat[0].secfilt[Nave*Nsec+j].M  = NAN;
     170      outcat[0].secfilt[Nave*Nsec+j].dM = NAN;
     171      outcat[0].secfilt[Nave*Nsec+j].Xm = NAN_S_SHORT;
    172172    }
    173173
     
    183183      outcat[0].measure[Nmeas].dR       = 0.0;
    184184      outcat[0].measure[Nmeas].dD       = 0.0;
    185       outcat[0].measure[Nmeas].M        = MIN (table[0].row[minFit.row][0].mags[n] + minFit.Md,  NO_MAG);
     185      outcat[0].measure[Nmeas].M        = table[0].row[minFit.row][0].mags[n] + minFit.Md;
    186186      outcat[0].measure[Nmeas].dM       = 0.0;
    187187      outcat[0].measure[Nmeas].Mcal     = 0;
     
    193193      outcat[0].measure[Nmeas].dt       = 0xffff;
    194194
    195       outcat[0].measure[Nmeas].Mgal     = NO_MAG;
     195      outcat[0].measure[Nmeas].Mgal     = NAN;
    196196      outcat[0].measure[Nmeas].airmass  = 0;
    197       outcat[0].measure[Nmeas].FWx         = NO_MAG;
    198       outcat[0].measure[Nmeas].FWy         = NO_ERR;
    199       outcat[0].measure[Nmeas].theta       = NO_ERR;
     197      outcat[0].measure[Nmeas].FWx      = NAN_S_SHORT;
     198      outcat[0].measure[Nmeas].FWy      = NAN_S_SHORT;
     199      outcat[0].measure[Nmeas].theta    = NAN_S_SHORT;
    200200
    201201      outcat[0].average[Nave].Nm++;
  • trunk/Ohana/src/addstar/src/calibrate.c

    r15036 r15509  
    5454
    5555  found0 = found1 = found2 = FALSE;
    56   CalM0 = CalM1 = CalM2 = dCalM = NO_MAG;
     56  CalM0 = CalM1 = CalM2 = dCalM = NAN;
    5757
    5858  // we have two options here:
  • trunk/Ohana/src/addstar/src/fakeimage.c

    r15036 r15509  
    128128
    129129    image[i+1].Mcal = 0.0;
    130     image[i+1].Xm   = NO_MAG;
     130    image[i+1].Xm   = NAN_S_SHORT;
    131131    image[i+1].code = 0;
    132132    memset (image[i+1].dummy, 0, sizeof(image[i+1].dummy));
     
    187187  image[0].ccdnum = 0xff;
    188188  image[0].Mcal = 0.0;
    189   image[0].Xm   = NO_MAG;
     189  image[0].Xm   = NAN_S_SHORT;
    190190  image[0].code = 0;
    191191  memset (image[0].dummy, 0, sizeof(image[0].dummy));
  • trunk/Ohana/src/addstar/src/find_matches.c

    r15038 r15509  
    194194
    195195      catalog[0].measure[Nmeas].Mgal     = stars[N].Mgal;
    196       catalog[0].measure[Nmeas].FWx      = MIN (100*stars[N].fx, NO_MAG);
    197       catalog[0].measure[Nmeas].FWy      = MIN (100*stars[N].fy, NO_MAG);
    198       catalog[0].measure[Nmeas].theta    = MIN ((0xffff/360.0)*stars[N].df, NO_MAG);
     196      catalog[0].measure[Nmeas].FWx      = 100*stars[N].fx;
     197      catalog[0].measure[Nmeas].FWy      = 100*stars[N].fy;
     198      catalog[0].measure[Nmeas].theta    = (0xffff/360.0)*stars[N].df;
    199199       
    200200      /* adds the measurement to the calibration if appropriate color terms are found */
     
    207207      /* in UPDATE mode, this value is not saved; use relphot to recalculate */
    208208      if (Nsec > -1) {
    209           if (catalog[0].secfilt[n*Nsecfilt+Nsec].M != NO_MAG) {
    210               catalog[0].secfilt[n*Nsecfilt+Nsec].M = PhotCat (&catalog[0].measure[Nmeas]);
    211           }
     209        if (isnan(catalog[0].secfilt[n*Nsecfilt+Nsec].M)) {
     210          catalog[0].secfilt[n*Nsecfilt+Nsec].M = PhotCat (&catalog[0].measure[Nmeas]);
     211        }
    212212      }
    213213
     
    282282
    283283    for (j = 0; j < Nsecfilt; j++) {
    284       catalog[0].secfilt[Nave*Nsecfilt+j].M  = NO_MAG;
    285       catalog[0].secfilt[Nave*Nsecfilt+j].dM = NO_MAG;
    286       catalog[0].secfilt[Nave*Nsecfilt+j].Xm = NO_MAG;
     284      catalog[0].secfilt[Nave*Nsecfilt+j].M  = NAN;
     285      catalog[0].secfilt[Nave*Nsecfilt+j].dM = NAN;
     286      catalog[0].secfilt[Nave*Nsecfilt+j].Xm = NAN_S_SHORT;
    287287    }
    288288
     
    320320
    321321    catalog[0].measure[Nmeas].Mgal      = stars[N].Mgal;
    322     catalog[0].measure[Nmeas].FWx       = MIN (100*stars[N].fx, NO_MAG);
    323     catalog[0].measure[Nmeas].FWy       = MIN (100*stars[N].fy, NO_MAG);
    324     catalog[0].measure[Nmeas].theta     = MIN ((0xffff/360.0)*stars[N].df, NO_MAG);
     322    catalog[0].measure[Nmeas].FWx       = 100*stars[N].fx;
     323    catalog[0].measure[Nmeas].FWy       = 100*stars[N].fy;
     324    catalog[0].measure[Nmeas].theta     = (0xffff/360.0)*stars[N].df;
    325325    /* XXX replace df here with theta, right? */
    326326
  • trunk/Ohana/src/addstar/src/find_matches_closest.c

    r15038 r15509  
    214214
    215215    catalog[0].measure[Nmeas].Mgal     = stars[N].Mgal;
    216     catalog[0].measure[Nmeas].FWx      = MIN (100*stars[N].fx, NO_MAG);
    217     catalog[0].measure[Nmeas].FWy      = MIN (100*stars[N].fy, NO_MAG);
    218     catalog[0].measure[Nmeas].theta    = MIN ((0xffff/360.0)*stars[N].df, NO_MAG);
     216
     217    // XXX saturate range for FWx, FWy, theta
     218    // XXX convert to unsigned int for these...
     219    catalog[0].measure[Nmeas].FWx      = 100*stars[N].fx;
     220    catalog[0].measure[Nmeas].FWy      = 100*stars[N].fy;
     221    catalog[0].measure[Nmeas].theta    = (0xffff/360.0)*stars[N].df;
    219222       
    220223    /* set the average magnitude if not already set and the photcode.equiv is not 0 */
    221224    /* in UPDATE mode, this value is not saved; use relphot to recalculate */
    222225    if (Nsec > -1) {
    223         if (catalog[0].secfilt[n*Nsecfilt+Nsec].M != NO_MAG) {
    224             catalog[0].secfilt[n*Nsecfilt+Nsec].M = PhotCat (&catalog[0].measure[Nmeas]);
    225         }
     226      if (isnan(catalog[0].secfilt[n*Nsecfilt+Nsec].M)) {
     227        catalog[0].secfilt[n*Nsecfilt+Nsec].M = PhotCat (&catalog[0].measure[Nmeas]);
     228      }
    226229    }
    227230
     
    281284
    282285    for (j = 0; j < Nsecfilt; j++) {
    283       catalog[0].secfilt[Nave*Nsecfilt+j].M  = NO_MAG;
    284       catalog[0].secfilt[Nave*Nsecfilt+j].dM = NO_MAG;
    285       catalog[0].secfilt[Nave*Nsecfilt+j].Xm    = NO_MAG;
     286      catalog[0].secfilt[Nave*Nsecfilt+j].M  = NAN;
     287      catalog[0].secfilt[Nave*Nsecfilt+j].dM = NAN;
     288      catalog[0].secfilt[Nave*Nsecfilt+j].Xm = NAN_S_SHORT;
    286289    }
    287290
     
    319322
    320323    catalog[0].measure[Nmeas].Mgal     = stars[N].Mgal;
    321     catalog[0].measure[Nmeas].FWx      = MIN (100*stars[N].fx, NO_MAG);
    322     catalog[0].measure[Nmeas].FWy      = MIN (100*stars[N].fy, NO_MAG);
    323     catalog[0].measure[Nmeas].theta    = MIN ((0xffff/360.0)*stars[N].df, NO_ERR);
     324    catalog[0].measure[Nmeas].FWx      = 100*stars[N].fx;
     325    catalog[0].measure[Nmeas].FWy      = 100*stars[N].fy;
     326    catalog[0].measure[Nmeas].theta    = (0xffff/360.0)*stars[N].df;
    324327
    325328    /* set the average magnitude if not already set and the photcode.equiv is not 0 */
  • trunk/Ohana/src/addstar/src/find_matches_refstars.c

    r15038 r15509  
    133133      catalog[0].measure[Nmeas].dR       = 3600.0*(catalog[0].average[n].R - stars[N][0].R);
    134134      catalog[0].measure[Nmeas].dD       = 3600.0*(catalog[0].average[n].D - stars[N][0].D);
    135       catalog[0].measure[Nmeas].M        = MIN (stars[N][0].M,  NO_MAG);
    136       catalog[0].measure[Nmeas].dM       = MIN (stars[N][0].dM, NO_ERR);
     135      catalog[0].measure[Nmeas].M        = stars[N][0].M;
     136      catalog[0].measure[Nmeas].dM       = stars[N][0].dM;
    137137      catalog[0].measure[Nmeas].Mcal     = 0;
    138138      catalog[0].measure[Nmeas].t        = (TIMEREF == 0) ? stars[N][0].t : TIMEREF; /** careful : time_t vs e_time **/
     
    143143      catalog[0].measure[Nmeas].dt       = 0xffff;
    144144
    145       catalog[0].measure[Nmeas].Mgal     = NO_MAG;
     145      catalog[0].measure[Nmeas].Mgal     = NAN;
    146146      catalog[0].measure[Nmeas].airmass  = 0;
    147       catalog[0].measure[Nmeas].FWx      = NO_MAG;
    148       catalog[0].measure[Nmeas].FWy      = NO_MAG;
    149       catalog[0].measure[Nmeas].theta    = NO_MAG;
     147      catalog[0].measure[Nmeas].FWx      = NAN_S_SHORT;
     148      catalog[0].measure[Nmeas].FWy      = NAN_S_SHORT;
     149      catalog[0].measure[Nmeas].theta    = NAN_S_SHORT;
    150150       
    151151      catalog[0].measure[Nmeas].photFlags = 0;
     
    254254
    255255    for (j = 0; j < Nsecfilt; j++) {
    256       catalog[0].secfilt[Nave*Nsecfilt+j].M  = NO_MAG;
    257       catalog[0].secfilt[Nave*Nsecfilt+j].dM = NO_MAG;
    258       catalog[0].secfilt[Nave*Nsecfilt+j].Xm = NO_MAG;
     256      catalog[0].secfilt[Nave*Nsecfilt+j].M  = NAN;
     257      catalog[0].secfilt[Nave*Nsecfilt+j].dM = NAN;
     258      catalog[0].secfilt[Nave*Nsecfilt+j].Xm = NAN_S_SHORT;
    259259    }
    260260
    261261    catalog[0].measure[Nmeas].dR       = 0.0;
    262262    catalog[0].measure[Nmeas].dD       = 0.0;
    263     catalog[0].measure[Nmeas].M        = MIN (stars[N][0].M,  NO_MAG);
    264     catalog[0].measure[Nmeas].dM       = MIN (stars[N][0].dM, NO_ERR);
     263    catalog[0].measure[Nmeas].M        = stars[N][0].M;
     264    catalog[0].measure[Nmeas].dM       = stars[N][0].dM;
    265265    catalog[0].measure[Nmeas].Mcal     = 0;
    266266    catalog[0].measure[Nmeas].t        = (stars[N][0].t == 0) ? TIMEREF : stars[N][0].t; /** careful : time_t vs e_time **/
     
    291291
    292292    catalog[0].measure[Nmeas].airmass  = 0;
    293     catalog[0].measure[Nmeas].Mgal     = NO_MAG;
    294     catalog[0].measure[Nmeas].FWx      = NO_MAG;
    295     catalog[0].measure[Nmeas].FWy      = NO_MAG;
    296     catalog[0].measure[Nmeas].theta    = NO_MAG;
     293    catalog[0].measure[Nmeas].Mgal     = NAN;
     294    catalog[0].measure[Nmeas].FWx      = NAN_S_SHORT;
     295    catalog[0].measure[Nmeas].FWy      = NAN_S_SHORT;
     296    catalog[0].measure[Nmeas].theta    = NAN_S_SHORT;
    297297
    298298    catalog[0].measure[Nmeas].Xccd     = 0.0;
  • trunk/Ohana/src/addstar/src/load2mass_catalog.c

    r15038 r15509  
    3434    catalog[0].average[Nave].Nm        = 0;
    3535    catalog[0].average[Nave].Nn        = 0;
    36     catalog[0].average[Nave].Xp        = NO_MAG;
     36    catalog[0].average[Nave].Xp        = NAN_S_SHORT;
    3737    catalog[0].average[Nave].offset    = Nmeas;
    3838    catalog[0].average[Nave].missing   = -1;
     
    4040
    4141    for (j = 0; j < Nsec; j++) {
    42       catalog[0].secfilt[Nave*Nsec+j].M  = NO_MAG;
    43       catalog[0].secfilt[Nave*Nsec+j].dM = NO_MAG;
    44       catalog[0].secfilt[Nave*Nsec+j].Xm    = NO_MAG;
     42      catalog[0].secfilt[Nave*Nsec+j].M  = NAN;
     43      catalog[0].secfilt[Nave*Nsec+j].dM = NAN;
     44      catalog[0].secfilt[Nave*Nsec+j].Xm = NAN_S_SHORT;
    4545    }
    4646
     
    4949      catalog[0].measure[Nmeas].dR       = 0.0;
    5050      catalog[0].measure[Nmeas].dD       = 0.0;
    51       catalog[0].measure[Nmeas].M        = MIN (stars[i+j].M,  NO_MAG);
    52       catalog[0].measure[Nmeas].dM       = MIN (stars[i+j].dM,  NO_ERR);
     51      catalog[0].measure[Nmeas].M        = stars[i+j].M;
     52      catalog[0].measure[Nmeas].dM       = stars[i+j].dM;
    5353      catalog[0].measure[Nmeas].Mcal     = 0;
    5454      catalog[0].measure[Nmeas].t        = stars[i+j].t;
     
    5959      catalog[0].measure[Nmeas].dt       = 0xffff;
    6060
    61       catalog[0].measure[Nmeas].Mgal     = NO_MAG;
     61      catalog[0].measure[Nmeas].Mgal     = NAN;
    6262      catalog[0].measure[Nmeas].airmass  = 0;
    63       catalog[0].measure[Nmeas].FWx         = NO_MAG;
    64       catalog[0].measure[Nmeas].FWy         = NO_ERR;
    65       catalog[0].measure[Nmeas].theta       = NO_ERR;
     63      catalog[0].measure[Nmeas].FWx      = NAN_S_SHORT;
     64      catalog[0].measure[Nmeas].FWy      = NAN_S_SHORT;
     65      catalog[0].measure[Nmeas].theta    = NAN_S_SHORT;
    6666
    6767      catalog[0].average[Nave].Nm++;
  • trunk/Ohana/src/addstar/src/replace_match.c

    r12332 r15509  
    88  for (i = 0; i < average[0].Nm; i++) {
    99    if (measure[i].photcode != star[0].code) continue;
    10     measure[i].dR       = 3600.0*(average[0].R - star[0].R);
    11     measure[i].dD       = 3600.0*(average[0].D - star[0].D);
    12     measure[i].M        = MIN (star[0].M,  NO_MAG);
    13     measure[i].dM       = MIN (star[0].dM, NO_ERR);
    14     star[0].found          = average[0].offset + i;
     10    measure[i].dR = 3600.0*(average[0].R - star[0].R);
     11    measure[i].dD = 3600.0*(average[0].D - star[0].D);
     12    measure[i].M  = star[0].M;
     13    measure[i].dM = star[0].dM;
     14    star[0].found = average[0].offset + i;
    1515    return (TRUE);
    1616  }
  • trunk/Ohana/src/delstar/src/gimages.c

    r12332 r15509  
    7979
    8080  /* secz is in units milli-airmass */
    81   image[0].Mcal =  ALPHA*(image[0].secz - 1.000);
    82   image[0].Xm   = NO_MAG;
     81  image[0].Mcal = ALPHA*(image[0].secz - 1.000);
     82  image[0].Xm   = NAN_S_SHORT;
    8383
    8484  free (header.buffer);
  • trunk/Ohana/src/getstar/src/ReadImageHeader.c

    r14590 r15509  
    9090  image[0].fwhm_y = tmp * 25.0 * image[0].coords.cdelt1 * 3600.0;
    9191
    92   image[0].trate = 0.0;
    93   image[0].secz = NO_MAG;
     92  image[0].trate  = 0.0;
     93  image[0].secz   = NAN;
    9494  image[0].ccdnum = 0;
    9595
    9696  /* secz is in units milli-airmass */
    9797  image[0].Mcal = 0.0;
    98   image[0].Xm   = NO_MAG;
     98  image[0].Xm   = NAN_S_SHORT;
    9999  image[0].code = 0;
    100100  bzero (image[0].dummy, sizeof(image[0].dummy));
  • trunk/Ohana/src/libdvo/include/dvo.h

    r15035 r15509  
    55# ifndef DVO_H
    66# define DVO_H
    7 
    8 /*
    9   # define ELIXIR 1
    10   # define PANSTARRS 0
    11   # define LONEOS 0
    12 */
    13 
    14 /*** named data values (convert all to enums?) ***/
    157
    168/* DVO table modes */
     
    5547} OhanaProjectionMode;
    5648
     49// these are used as NAN for types of int values
     50typedef enum {
     51    NAN_S_CHAR  = 0x7f,
     52    NAN_U_CHAR  = 0xff,   // was NO_ERR
     53    NAN_S_SHORT = 0x7fff, // was NO_MAG
     54    NAN_U_SHORT = 0xffff,
     55    NAN_S_INT   = 0x7fffffff,
     56    NAN_U_INT   = 0xffffffff,
     57} DVO_INT_NAN;
     58
     59# ifndef (NAN)
     60# ifndef (BYTE_SWAP)
     61#  define __nan_bytes           { 0x7f, 0xc0, 0, 0 }
     62# else
     63#  define __nan_bytes           { 0, 0, 0xc0, 0x7f }
     64# endif
     65static union { unsigned char __c[4]; float __d; } __nan_union
     66    __attribute_used__ = { __nan_bytes };
     67# define NAN    (__nan_union.__d)
     68# endif
     69
    5770/* RegImage.flag values */
    5871# define IMREG_DIST  0x01 /* image distributed, only imregister-3.0 */
     
    6477# define LOAD_SECF      0x08
    6578# define LOAD_MEAS_META 0x10
    66 
    67 /* invalid mag value */
    68 # define NO_MAG    0x7fff
    69 # define NO_ERR    0xff
    7079
    7180/* photometry code types */
  • trunk/Ohana/src/libdvo/src/dvo_catalog.c

    r15035 r15509  
    352352      }
    353353      for (j = 0; j < Nextra; j++, out++) {
    354         outsec[out].M  = NO_MAG;
    355         outsec[out].dM = NO_MAG;
    356         outsec[out].Xm    = NO_MAG;
     354        outsec[out].M  = NAN;
     355        outsec[out].dM = NAN;
     356        outsec[out].Xm = NAN_S_SHORT;
    357357      }
    358358    }
  • trunk/Ohana/src/libdvo/src/dvo_photcode_ops.c

    r15035 r15509  
    221221
    222222  Np = photcodes[0].hashcode[measure[0].photcode];
    223   if (Np == -1) return (NO_MAG);
     223  if (Np == -1) return (NAN);
    224224
    225225  if (photcodes[0].code[Np].type == PHOT_REF) {
     
    241241
    242242  Np = photcodes[0].hashcode[measure[0].photcode];
    243   if (Np == -1) return (NO_MAG);
     243  if (Np == -1) return (NAN);
    244244
    245245  if (photcodes[0].code[Np].type == PHOT_REF) {
     
    260260
    261261  Np = photcodes[0].hashcode[measure[0].photcode];
    262   if (Np == -1) return (NO_MAG);
     262  if (Np == -1) return (NAN);
    263263
    264264  if (photcodes[0].code[Np].type == PHOT_REF) {
     
    271271  /* for DEP, color must be made of PRI/SEC */
    272272  mc = PhotColorForCode (average, secfilt, NULL, code);
    273   if (mc == NO_MAG) return (Mcat);
     273  if (isnan(mc)) return (Mcat);
    274274  mc = mc - SCALE*code[0].dX;
    275275
     
    291291
    292292  Np = photcodes[0].hashcode[measure[0].photcode];
    293   if (Np == -1) return (NO_MAG);
     293  if (Np == -1) return (NAN);
    294294
    295295  if (photcodes[0].code[Np].type == PHOT_REF) {
     
    302302  /* for DEP, color must be made of PRI/SEC */
    303303  mc = PhotColorForCode (average, secfilt, NULL, code);
    304   if (mc == NO_MAG) return (Mrel);
     304  if (isnan(mc)) return (Mrel);
    305305  mc = mc - SCALE*code[0].dX;
    306306
     
    323323  /* code must be the matching PRI/SEC code for this measurement or an equivalent ALT */
    324324  Np = photcodes[0].hashcode[thisone[0].photcode];
    325   if (Np == -1) {
    326     return (NO_MAG);
    327   }
     325  if (Np == -1) return (NAN);
    328326
    329327  if (photcodes[0].code[Np].type == PHOT_REF) {
     
    331329    return (Mrel);
    332330  }
    333   if (code[0].code != photcodes[0].code[Np].equiv) {
    334     return (NO_MAG);
    335   }
     331  if (code[0].code != photcodes[0].code[Np].equiv) return (NAN);
    336332
    337333  Mcal = PhotRel (thisone, average, secfilt) + SCALE*code[0].C;
    338334
    339335  mc = PhotColorForCode (average, secfilt, measure, code);
    340   if (mc == NO_MAG) return (Mcal);
     336  if (isnan(mc)) return (Mcal);
    341337  mc = mc - SCALE*code[0].dX;
    342338
     
    358354  PhotCode *color;
    359355
    360   m1 = m2 = NO_MAG;
     356  m1 = m2 = NAN;
    361357
    362358  if (measure == NULL) {
     
    364360    Ns2 = photcodes[0].hashNsec[code[0].c2];
    365361 
    366     m1 = (Ns1 == -1) ? NO_MAG : secfilt[Ns1].M;
    367     m2 = (Ns2 == -1) ? NO_MAG : secfilt[Ns2].M;
    368     mc = ((m1 == NO_MAG) || (m2 == NO_MAG)) ? NO_MAG : (m1 - m2);
     362    m1 = (Ns1 == -1) ? NAN : secfilt[Ns1].M;
     363    m2 = (Ns2 == -1) ? NAN : secfilt[Ns2].M;
     364    mc = (isnan(m1) || isnan(m2)) ? NAN : (m1 - m2);
    369365    return (mc);
    370366  }
     
    372368  /* find magnitude matching first color term */
    373369  color = GetPhotcodebyCode (code[0].c1);
    374   if (color == NULL) return (NO_MAG);
     370  if (color == NULL) return (NAN);
    375371  if (color[0].type == PHOT_REF) {
    376     for (i = 0; (i < average[0].Nm) && (m1 == NO_MAG); i++) {
     372    for (i = 0; (i < average[0].Nm) && (isnan(m1)); i++) {
    377373      if (measure[i].photcode == color[0].code) {
    378374        m1 = measure[i].M;
     
    381377  } else {
    382378    Ns = photcodes[0].hashNsec[color[0].code];
    383     m1 = (Ns == -1) ? NO_MAG : secfilt[Ns].M;
     379    m1 = (Ns == -1) ? NAN : secfilt[Ns].M;
    384380  }     
    385381
    386382  /* find magnitude matching second color term */
    387383  color = GetPhotcodebyCode (code[0].c2);
    388   if (color == NULL) return (NO_MAG);
     384  if (color == NULL) return (NAN);
    389385  if (color[0].type == PHOT_REF) {
    390     for (i = 0; (i < average[0].Nm) && (m2 == NO_MAG); i++) {
     386    for (i = 0; (i < average[0].Nm) && (isnan(m2)); i++) {
    391387      if (measure[i].photcode == color[0].code) {
    392388        m2 = measure[i].M;
     
    395391  } else {
    396392    Ns = photcodes[0].hashNsec[color[0].code];
    397     m2 = (Ns == -1) ? NO_MAG : secfilt[Ns].M;
     393    m2 = (Ns == -1) ? NAN : secfilt[Ns].M;
    398394  }     
    399   mc = ((m1 == NO_MAG) || (m2 == NO_MAG)) ? NO_MAG : (m1 - m2);
     395  mc = (isnan(m1)) || isnan(m2))) ? NAN : (m1 - m2);
    400396  return (mc);
    401397}
     
    409405
    410406  Ns = photcodes[0].hashNsec[code[0].code];
    411   Mave = (Ns == -1) ? NO_MAG : secfilt[Ns].M;
     407  Mave = (Ns == -1) ? NAN : secfilt[Ns].M;
    412408  Mref = Mave + SCALE*code[0].C;
    413409
    414410  mc = PhotColorForCode (average, secfilt, measure, code);
    415   if (mc == NO_MAG) return (Mref);
     411  if (isnan(mc)) return (Mref);
    416412  mc = mc - SCALE*code[0].dX;
    417413
     
    433429
    434430  Ns = photcodes[0].hashNsec[code[0].code];
    435   Mave = (Ns == -1) ? NO_MAG : secfilt[Ns].M;
     431  Mave = (Ns == -1) ? NAN : secfilt[Ns].M;
    436432  return (Mave);
    437433}
     
    443439
    444440  Ns = photcodes[0].hashNsec[code[0].code];
    445   dM  = (Ns == -1) ? NO_MAG : secfilt[Ns].dM;
     441  dM  = (Ns == -1) ? NAN : secfilt[Ns].dM;
    446442  return (dM);
    447443}
    448444
     445// XXX return NAN or NAN_S_SHORT? (secfilt->Xm is short)
    449446float PhotXm (PhotCode *code, Average *average, SecFilt *secfilt) {
    450447
     
    454451
    455452  Ns = photcodes[0].hashNsec[code[0].code];
    456   Mi = (Ns == -1) ? NO_MAG : secfilt[Ns].Xm;
    457   Xm = (Mi == NO_MAG) ? -1.0 : pow (10.0, 0.01*Mi);
     453  Mi = (Ns == -1) ? NAN : secfilt[Ns].Xm;
     454  Xm = (isnan(Mi)) ? -1.0 : pow (10.0, 0.01*Mi);
    458455  return (Xm);
    459456}
     
    478475  } else {
    479476    Ns = photcodes[0].hashNsec[code[0].code];
    480     M1 = (Ns == -1) ? NO_MAG : secfilt[Ns].M;
     477    M1 = (Ns == -1) ? NAN : secfilt[Ns].M;
    481478  }     
    482479
     
    494491  } else {
    495492    Ns = photcodes[0].hashNsec[code[0].code];
    496     M2 = (Ns == -1) ? NO_MAG : secfilt[Ns].M;
     493    M2 = (Ns == -1) ? NAN : secfilt[Ns].M;
    497494  }     
    498495 
  • trunk/Ohana/src/libdvo/src/photfits.c

    r12332 r15509  
    3131    return (0);
    3232  }
    33   return (NO_MAG);
     33  return (NAN_S_SHORT);
    3434}
    3535
  • trunk/Ohana/src/opihi/dvo/calextract.c

    r14590 r15509  
    8282
    8383      /* find data for filter 2 (PHOT_REF) */
    84       M2 = NO_MAG;
    85       dM2 = NO_MAG;
     84      M2 = NAN;
     85      dM2 = NAN;
    8686      for (j = 0; j < catalog.average[i].Nm; j++) {
    8787        if (catalog.measure[m+j].photcode != code[1][0].code) continue;
     
    8989        dM2 = catalog.measure[m+j].dM;
    9090      }
    91       if (M2 == NO_MAG) continue;
     91      if (isnan(M2)) continue;
    9292
    9393      /* find data for filter 1 */
    9494      M1 = ExtractAverages (code[0], mode[0], &catalog.average[i], &catalog.secfilt[i*Nsecfilt], &catalog.measure[m], AVE_MAG);
    95       if (M1 == NO_MAG) continue;
     95      if (isnan(M1)) continue;
    9696
    9797      vec[Nd ][0].elements[N] = M1 - M2;
  • trunk/Ohana/src/opihi/dvo/calmextract.c

    r14590 r15509  
    9393
    9494      /* find data for filter 2 (REF) */
    95       M2 = NO_MAG;
    96       dM2 = NO_MAG;
     95      M2 = NAN;
     96      dM2 = NAN;
    9797      for (j = 0; j < catalog.average[i].Nm; j++) {
    9898        if (catalog.measure[m+j].photcode != code[1][0].code) continue;
     
    100100        dM2 = catalog.measure[m+j].dM;
    101101      }
    102       if (M2 == NO_MAG) continue;
     102      if (isnan(M2)) continue;
    103103     
    104104      /* find data for filter 1 */
  • trunk/Ohana/src/opihi/dvo/ccd.c

    r14401 r15509  
    8484          ALLOCATE (M2, double, 1);
    8585          N2 = 1;
    86           M2[0] = NO_MAG;
     86          M2[0] = NAN;
    8787        } else {
    8888          goto skip;
  • trunk/Ohana/src/opihi/dvo/cmd.c

    r14401 r15509  
    8282          ALLOCATE (M3, double, 1);
    8383          N3 = 1;
    84           M3[0] = NO_MAG;
     84          M3[0] = NAN;
    8585        } else {
    8686          goto skip;
  • trunk/Ohana/src/opihi/dvo/dbExtractAverages.c

    r14401 r15509  
    77  double value;
    88
    9   value = NO_MAG;
     9  value = NAN;
    1010
    1111  /* assign vector values */
     
    7171        case MAG_CAL:
    7272          // XXX need to code this correctly: this returns just the first matching value
    73           value = NO_MAG;
     73          value = NAN;
    7474          for (i = 0; i < average[0].Nm; i++) {
    7575            if (field->photcode->code != measure[i].photcode) continue;
  • trunk/Ohana/src/opihi/dvo/dbExtractMeasures.c

    r15208 r15509  
    1919  Coords *mosaic;
    2020
    21   value = NO_MAG;
     21  value = NAN;
    2222
    2323  switch (field->ID) {
     
    128128      break;
    129129    case MEAS_RA_OFFSET_ERR: /* OK */
    130       value = NO_MAG;
     130      value = NAN;
    131131      break;
    132132    case MEAS_DEC_OFFSET_ERR: /* OK */
    133       value = NO_MAG;
     133      value = NAN;
    134134      break;
    135135    case MEAS_AIRMASS: /* OK */
  • trunk/Ohana/src/opihi/dvo/ddmags.c

    r14401 r15509  
    9494          ALLOCATE (M2, double, 1);
    9595          N2 = 1;
    96           M2[0] = NO_MAG;
     96          M2[0] = NAN;
    9797        } else {
    9898          goto skip;
  • trunk/Ohana/src/opihi/dvo/dmagmeas.c

    r14401 r15509  
    9191          ALLOCATE (M3, double, 1);
    9292          N3 = 1;
    93           M3[0] = NO_MAG;
     93          M3[0] = NAN;
    9494        } else {
    9595          goto skip;
  • trunk/Ohana/src/opihi/dvo/dmags.c

    r14401 r15509  
    8989          ALLOCATE (M3, double, 1);
    9090          N3 = 1;
    91           M3[0] = NO_MAG;
     91          M3[0] = NAN;
    9292        } else {
    9393          goto skip;
  • trunk/Ohana/src/opihi/dvo/gstar.c

    r15208 r15509  
    274274}
    275275
    276 void print_value (double value, short int ival) {
    277   if (ival == NO_MAG)
     276void print_double (double value) {
     277  if (isnan(value))
     278    gprint (GP_LOG, "NaN    ");
     279  else
     280    gprint (GP_LOG, "%6.3f ", value);
     281}
     282
     283void print_short (double value, short int ival) {
     284  if (ival == NAN_S_SHORT)
    278285    gprint (GP_LOG, "NaN    ");
    279286  else
     
    320327    case 0: /* average mags */
    321328      if (seq == -1) {
    322         print_value (NO_MAG, NO_MAG);
     329        print_double (NAN);
    323330      } else {
    324         print_value (secfilt[seq].M, secfilt[seq].M);
     331        print_double (secfilt[seq].M);
    325332      }
    326333      break;
     
    328335    case 1: /* average mags errors */
    329336      if (seq == -1) {
    330         print_value (NO_MAG, NO_MAG);
     337        print_double (NAN);
    331338      } else {
    332         print_value (secfilt[seq].dM, secfilt[seq].dM);
     339        print_double (secfilt[seq].dM);
    333340      }
    334341      break;
     
    336343    case 2: /* average mag chisq */
    337344      if (seq == -1) {
    338         print_value (NO_MAG, NO_MAG);
     345        print_short (NAN_S_SHORT, NAN_S_SHORT);
    339346      } else {
    340         print_value (pow (10.0, 0.01*secfilt[seq].Xm), secfilt[seq].Xm);
     347        print_short (pow (10.0, 0.01*secfilt[seq].Xm), secfilt[seq].Xm);
    341348      }
    342349      break;
  • trunk/Ohana/src/opihi/dvo/photometry.c

    r15208 r15509  
    2828
    2929# define SETMAG(MOUT,MEAS,MODE) \
    30   MOUT = NO_MAG; \
     30  MOUT = NAN; \
    3131  if (MODE == MAG_INST) MOUT = PhotInst (&MEAS);  \
    3232  if (MODE == MAG_CAT)  MOUT = PhotCat  (&MEAS); \
     
    588588  double value;
    589589
    590   value = NO_MAG;
     590  value = NAN;
    591591
    592592  /* this function requires code set for certain value of param. 
     
    594594
    595595  /* filter by average quantities (eg, chisq, Nphot, etc) */
    596   if (!TestAverage (code, average, secfilt, measure)) return (NO_MAG);
     596  if (!TestAverage (code, average, secfilt, measure)) return (NAN);
    597597
    598598  /* assign vector values */
     
    657657        case MAG_REL:
    658658        case MAG_CAL:
    659           value = NO_MAG;
     659          value = NAN;
    660660          for (i = 0; i < average[0].Nm; i++) {
    661661              if (code[0].code != measure[i].photcode) continue;
     
    866866  if (ErrSelect) {
    867867    dM = PhotdM (code, average, secfilt);
    868     if (dM > ErrValue) return (NO_MAG);
     868    if (dM > ErrValue) return (NAN);
    869869  }
    870870 
     
    944944    ALLOCATE (M, double, 1);
    945945    mag = ExtractAverages (code, mode, average, secfilt, measure, AVE_MAG);
    946     if (mag == NO_MAG) {
     946    if (isnan(mag)) {
    947947      N = 0;
    948948    } else {
     
    962962
    963963  int i, j, A1, A2, N1, N2, Np, Nlist, NLIST;
    964   double *M1, *M2, *list, NoMag;
     964  double *M1, *M2, *list;
    965965
    966966  /* check for special case of measure-measure - this is needed to drop self-matches */
     
    977977  ALLOCATE (list, double, NLIST);
    978978  M1 = M2 = NULL;
    979   NoMag = NO_MAG * 0.001;
    980979
    981980  /* one of the two is an average, must do independently */
     
    988987  if (N2 == 0) goto skip;
    989988
    990   /* magnitudes may be NO_MAG : set delta to NO_MAG */
     989  /* magnitudes may be NAN : set delta to NAN */
    991990  for (i = 0; i < N1; i++) {
    992991    for (j = 0; j < N2; j++) {
    993       if ((M1[i] == NoMag) || (M2[j] == NoMag)) {
    994         list[Nlist] = NoMag;
     992      if (isnan(M1[i]) || isnan(M2[j])) {
     993        list[Nlist] = NAN;
    995994      } else {
    996995        list[Nlist] = M1[i] - M2[j];
     
    10121011
    10131012  int i, j, Np0, Np1, Nlist, NLIST;
    1014   double *list, M1, M2, NoMag;
     1013  double *list, M1, M2;
    10151014 
    10161015  *nlist = 0;
     
    10181017  NLIST = MAX (1, average[0].Nm*average[0].Nm);
    10191018  ALLOCATE (list, double, NLIST);
    1020   NoMag = NO_MAG * 0.001;
    10211019
    10221020  /* must have two code values - drop this test? this is programming case, not a user case */
     
    10441042      TESTMEASURE (measure[j]);
    10451043      SETMAG(M2, measure[j], mode[1]);
    1046       if ((M1 == NoMag) || (M2 == NoMag)) {
    1047         list[Nlist] = NoMag;
     1044      if (isnan(M1) || isnan(M2)) {
     1045        list[Nlist] = NAN;
    10481046      } else {
    10491047        list[Nlist] = M1 - M2;
  • trunk/Ohana/src/photdbc/src/get_mags.c

    r12332 r15509  
    1919  for (i = 0; i < catalog[0].Naverage; i++) {
    2020    Nlist = MAX (Nlist, catalog[0].average[i].Nm);
    21     catalog[0].average[i].M  = NO_MAG;
    22     catalog[0].average[i].dM = NO_MAG;
    23     catalog[0].average[i].Xm = NO_MAG;
    2421    for (j = 0; j < Nsecfilt; j++) {
    25       catalog[0].secfilt[i*Nsecfilt+j].M  = NO_MAG;
    26       catalog[0].secfilt[i*Nsecfilt+j].dM = NO_MAG;
    27       catalog[0].secfilt[i*Nsecfilt+j].Xm = NO_MAG;
     22      catalog[0].secfilt[i*Nsecfilt+j].M  = NAN;
     23      catalog[0].secfilt[i*Nsecfilt+j].dM = NAN;
     24      catalog[0].secfilt[i*Nsecfilt+j].Xm = NAN_S_SHORT;
    2825    }
    2926  }
  • trunk/Ohana/src/relastro/Makefile

    r12842 r15509  
    5555$(SRC)/write_coords.$(ARCH).o
    5656
    57 DROP = \
    58 $(SRC)/setMrelFinal.$(ARCH).o    \
    59 $(SRC)/StarOps.$(ARCH).o         
    60 
    61 
    6257$(RELASTRO): $(INC)/relastro.h
    6358$(BIN)/relastro.$(ARCH): $(RELASTRO)
  • trunk/Ohana/src/relastro/src/UpdateObjects.c

    r15038 r15509  
    196196      catalog[i].average[j].dP  = fit.dp; // parallax error in arcsec
    197197
    198       catalog[i].average[j].Xp  = (fit.Nfit > 1) ? 100.0*log10(fit.chisq) : NO_MAG;
     198      catalog[i].average[j].Xp  = (fit.Nfit > 1) ? 100.0*log10(fit.chisq) : NAN_S_SHORT;
    199199    }
    200200
  • trunk/Ohana/src/relastro/src/select_images.c

    r12731 r15509  
    142142      }
    143143      if (RESET) {
     144        // XXX do we need this in relastro?
    144145        assignMcal (&image[nimage], (double *) NULL, -1);
    145         image[nimage].dMcal = NO_MAG;
     146        image[nimage].dMcal = NAN;
    146147        image[nimage].code &= ~ID_IMAGE_POOR;
    147148      }
  • trunk/Ohana/src/relphot/include/relphot.h

    r12332 r15509  
    142142int           gcatalog            PROTO((Catalog *catalog, int FINAL));
    143143Coords       *getCoords           PROTO((int meas, int cat));
     144int           getImageEntry       PROTO((int meas, int cat));
    144145float         getMcal             PROTO((int meas, int cat));
    145146float         getMgrid            PROTO((int meas, int cat));
  • trunk/Ohana/src/relphot/src/GridOps.c

    r15038 r15509  
    239239  if (!USE_GRID) return (0);
    240240  i = bin[cat][meas];
    241   if (i == -1) return (NO_MAG);
     241  if (i == -1) return (NAN);
    242242
    243243  value = gridM[i];
     
    272272      if (catalog[c].measure[m].dbFlags & MEAS_BAD) continue;
    273273      Mcal = getMcal  (m, c);
    274       if (Mcal == NO_MAG) continue;
    275       if (Mcal == NO_IMAGE) continue;
     274      if (isnan(Mcal)) continue;
    276275      Mmos = getMmos  (m, c);
    277       if (Mmos == NO_MAG) continue;
    278       if (Mmos == NO_IMAGE) continue;
    279       if ((Mrel  = getMrel  (catalog, m, c)) == NO_MAG) continue;
     276      if (isnan(Mmos)) continue;
     277      Mrel  = getMrel  (catalog, m, c);
     278      if (isnan(Mrel)) continue;
    280279     
    281280      n = catalog[c].measure[m].averef;
     
    326325      }
    327326      Mcal  = getMcal  (m, c);
    328       if (Mcal == NO_MAG) continue;
    329       if (Mcal == NO_IMAGE) continue;
     327      if (isnan(Mcal)) continue;
    330328      Mmos  = getMmos  (m, c);
    331       if (Mmos == NO_MAG) continue;
    332       if (Mmos == NO_IMAGE) continue;
    333       if ((Mrel  = getMrel  (catalog, m, c)) == NO_MAG) continue;
     329      if (isnan(Mmos)) continue;
     330      Mrel  = getMrel  (catalog, m, c);
     331      if (isnan(Mrel)) continue;
    334332
    335333      n = catalog[c].measure[m].averef;
  • trunk/Ohana/src/relphot/src/ImageOps.c

    r15038 r15509  
    138138}
    139139
     140int getImageEntry (int meas, int cat) {
     141
     142  int i;
     143
     144  i = bin[cat][meas];
     145  return (i);
     146}
     147
    140148float getMcal (int meas, int cat) {
    141149
     
    144152
    145153  i = bin[cat][meas];
    146   if (i == -1) return (NO_IMAGE);
    147 
    148   if (image[i].code & IMAGE_BAD)  return (NO_MAG); 
     154  if (i == -1) return (NAN);
     155
     156  if (image[i].code & IMAGE_BAD) return (NAN); 
    149157  value = image[i].Mcal;
    150158  return (value);
     
    197205      if (catalog[c].measure[m].dbFlags & MEAS_BAD) continue;
    198206      Mmos  = getMmos  (m, c);
    199       if (Mmos == NO_MAG) continue;
    200       if (Mmos == NO_IMAGE) continue;
    201       if ((Mgrid = getMgrid (m, c)) == NO_MAG) continue;
    202       if ((Mrel  = getMrel  (catalog, m, c)) == NO_MAG) continue;
     207      if (isnan(Mmos)) continue;
     208      Mgrid = getMgrid (m, c);
     209      if (isnan(Mgrid)) continue;
     210      Mrel  = getMrel  (catalog, m, c);
     211      if (isnan(Mrel)) continue;
    203212     
    204213      n = catalog[c].measure[m].averef;
     
    338347  int i, j, m, c, n, N;
    339348  double *list, *dlist;
    340   float Mcal, Mmos;
     349  float Mcal, Mmos, Mgrid;
    341350  StatType stats;
    342351
     
    357366      c = clist[i][j];
    358367
    359       Mcal = getMcal  (m, c);
    360       if (Mcal == NO_MAG) continue;
    361       if (Mcal == NO_IMAGE) continue;
    362       Mmos = getMmos  (m, c);
    363       if (Mmos == NO_MAG) continue;
    364       if (Mmos == NO_IMAGE) continue;
    365       if (getMgrid (m, c) == NO_MAG) continue;
     368      Mcal  = getMcal  (m, c);
     369      if (isnan(Mcal)) continue;
     370      Mmos  = getMmos  (m, c);
     371      if (isnan(Mmos)) continue;
     372      Mgrid = getMgrid (m, c);
     373      if (isnan(Mgrid)) continue;
    366374      N++;
    367375    }
  • trunk/Ohana/src/relphot/src/MosaicOps.c

    r15038 r15509  
    134134      Dmin = MIN (Dmin, D);
    135135      Dmax = MAX (Dmax, D);
    136       Mcal += image[m].Mcal;
     136      Mcal  += image[m].Mcal;
    137137      dMcal += image[m].dMcal;
    138       Xm += image[m].Xm;
     138      Xm    += image[m].Xm;
    139139      /* we are using mosaic.Mcal, not image.Mcal. reset image.Mcal */
    140       image[m].Mcal = 0.0;
    141       image[m].dMcal = image[m].Xm = NO_MAG;
     140      image[m].Mcal  = 0.0;
     141      image[m].dMcal = NAN;
     142      image[m].Xm    = NAN_S_SHORT;
    142143    }
    143144    dS /= Nimlist[i];
     
    299300  if (!MOSAICNAME[0]) return (0);
    300301  i = bin[cat][meas];
    301   if (i == -1) return (NO_IMAGE);
    302 
    303   if (mosaic[i].code & IMAGE_BAD) return (NO_MAG); 
     302  if (i == -1) return (NAN);
     303
     304  if (mosaic[i].code & IMAGE_BAD) return (NAN); 
    304305  value = mosaic[i].Mcal;
    305306  return (value);
     
    345346      c = clist[i][j];
    346347     
     348      if (catalog[c].measure[m].dbFlags & MEAS_BAD) continue;
    347349      Mcal  = getMcal  (m, c);
    348       if (Mcal == NO_MAG) continue;
    349       if (Mcal == NO_IMAGE) continue;
    350       if (catalog[c].measure[m].dbFlags & MEAS_BAD) continue;
    351       if ((Mgrid = getMgrid (m, c)) == NO_MAG) continue;
    352       if ((Mrel  = getMrel  (catalog, m, c)) == NO_MAG) continue;
     350      if (isnan(Mcal)) continue;
     351      Mgrid = getMgrid (m, c);
     352      if (isnan(Mgrid)) continue;
     353      Mrel  = getMrel  (catalog, m, c);
     354      if (isnan(Mrel)) continue;
    353355     
    354356      n = catalog[c].measure[m].averef;
     
    469471
    470472      Mcal = getMcal  (m, c);
    471       if (Mcal == NO_MAG) continue;
    472       if (Mcal == NO_IMAGE) continue;
    473       if (getMgrid (m, c) == NO_MAG) continue;
    474       if (getMrel  (catalog, m, c) == NO_MAG) continue;
     473      if (isnan(Mcal)) continue;
     474      Mgrid = getMgrid (m, c);
     475      if (isnan(Mgrid)) continue;
     476      Mrel = getMrel  (catalog, m, c);
     477      if (isnan(Mrel)) continue;
    475478      N++;
    476479    }
  • trunk/Ohana/src/relphot/src/StarOps.c

    r15038 r15509  
    2626
    2727  ave = catalog[cat].measure[meas].averef;
    28   if (catalog[cat].average[ave].code & STAR_BAD) return (NO_MAG); 
     28  if (catalog[cat].average[ave].code & STAR_BAD) return (NAN); 
    2929 
    3030  value = catalog[cat].secfilt[PhotNsec*ave+PhotSec].M;
     
    4545      m = catalog[i].average[j].offset;
    4646
    47       // XXX allow REF stars to be included in the calculation
    48       // this should be optionally set, and should allow for
    49       // REF stars to be downweighted by more than their reported
    50       // errors.  how such info is carried is unclear...
    5147      N = 0;
    5248      for (k = 0; k < catalog[i].average[j].Nm; k++, m++) {
    5349        if (catalog[i].measure[m].dbFlags & MEAS_BAD) continue;
    54         Mcal  = getMcal  (m, i);
    55         if (Mcal == NO_MAG) continue;
    56         if (Mcal == NO_IMAGE) {
     50        // XXX allow REF stars (no Image Entry) to be included in the calculation this
     51        // should be optionally set, and should allow for REF stars to be downweighted by
     52        // more than their reported errors.  how such info is carried is unclear...
     53        if (getImageEntry (m, i) < 0) {
    5754          Mcal = Mmos = Mgrid = 0;
    5855        } else {
     56          Mcal  = getMcal  (m, i);
     57          if (isnan(Mcal)) continue;
    5958          Mmos  = getMmos  (m, i);
    60           if (Mmos == NO_MAG) continue;
    61           if (Mmos == NO_IMAGE) continue;
    62           if ((Mgrid = getMgrid (m, i)) == NO_MAG) continue;
     59          if (isnan(Mmos)) continue;
     60          Mgrid = getMgrid (m, i);
     61          if (isnan(Mgrid)) continue;
    6362        }
    6463
     
    7877      catalog[i].secfilt[PhotNsec*j+PhotSec].M  = stats.mean;
    7978      catalog[i].secfilt[PhotNsec*j+PhotSec].dM = stats.sigma;
    80       catalog[i].secfilt[PhotNsec*j+PhotSec].Xm = (stats.Nmeas > 1) ? 100.0*log10(stats.chisq) : NO_MAG;
     79      catalog[i].secfilt[PhotNsec*j+PhotSec].Xm = (stats.Nmeas > 1) ? 100.0*log10(stats.chisq) : NAN_S_SHORT;
    8180    }
    8281  }
     
    111110      for (k = 0; k < catalog[i].average[j].Nm; k++, m++) {
    112111        if (catalog[i].measure[m].dbFlags & MEAS_BAD) continue;
    113         Mcal  = getMcal  (m, i);
    114         if (Mcal == NO_MAG) continue;
    115         if (Mcal == NO_IMAGE) {
     112        // XXX allow REF stars (no Image Entry) to be included in the calculation this
     113        // should be optionally set, and should allow for REF stars to be downweighted by
     114        // more than their reported errors.  how such info is carried is unclear...
     115        if (getImageEntry (m, i) < 0) {
    116116          Mcal = Mmos = Mgrid = 0;
    117117        } else {
     118          Mcal  = getMcal  (m, i);
     119          if (isnan(Mcal)) continue;
    118120          Mmos  = getMmos  (m, i);
    119           if (Mmos == NO_MAG) continue;
    120           if (Mmos == NO_IMAGE) continue;
    121           if ((Mgrid = getMgrid (m, i)) == NO_MAG) continue;
     121          if (isnan(Mmos)) continue;
     122          Mgrid = getMgrid (m, i);
     123          if (isnan(Mgrid)) continue;
    122124        }
    123125
     
    135137      catalog[i].secfilt[PhotNsec*j+PhotSec].M  = stats.mean;
    136138      catalog[i].secfilt[PhotNsec*j+PhotSec].dM = MAX (stats.error, stats.sigma);
    137       catalog[i].secfilt[PhotNsec*j+PhotSec].Xm = (stats.Nmeas > 1) ? 100.0*log10(stats.chisq) : NO_MAG;
     139      catalog[i].secfilt[PhotNsec*j+PhotSec].Xm = (stats.Nmeas > 1) ? 100.0*log10(stats.chisq) : NAN_S_SHORT;
    138140    }
    139141  }
     
    160162        if (catalog[i].measure[m].dbFlags & MEAS_BAD) continue;
    161163        Mcal  = getMcal  (m, i);
    162         if (Mcal == NO_MAG) continue;
    163         if (Mcal == NO_IMAGE) continue;
     164        if (isnan(Mcal)) continue;
    164165        Mmos  = getMmos  (m, i);
    165         if (Mmos == NO_MAG) continue;
    166         if (Mmos == NO_IMAGE) continue;
    167         if ((Mgrid = getMgrid (m, i)) == NO_MAG) continue;
     166        if (isnan(Mmos)) continue;
     167        Mgrid = getMgrid (m, i);
     168        if (isnan(Mgrid)) continue;
    168169        catalog[i].measure[m].Mcal = Mcal + Mmos + Mgrid;
    169170      }
     
    216217      Xm = catalog[i].secfilt[PhotNsec*j+PhotSec].Xm;
    217218      Chisq = pow (10.0, 0.01*Xm);
    218       mark = (dM > MaxScatter) || (Xm == NO_MAG) || (Chisq > MaxChisq);
     219      mark = (dM > MaxScatter) || (Xm == NAN_S_SHORT) || (Chisq > MaxChisq);
    219220      if (mark) {
    220221        catalog[i].average[j].code |= ID_STAR_POOR;
     
    274275        /* if (catalog[i].measure[m].dbFlags & MEAS_BAD) continue; */
    275276        Mcal  = getMcal  (m, i);
    276         if (Mcal == NO_MAG) continue;
    277         if (Mcal == NO_IMAGE) continue;
     277        if (isnan(Mcal)) continue;
    278278        Mmos  = getMmos  (m, i);
    279         if (Mmos == NO_MAG) continue;
    280         if (Mmos == NO_IMAGE) continue;
    281         if ((Mgrid = getMgrid (m, i)) == NO_MAG) continue;
     279        if (isnan(Mmos)) continue;
     280        Mgrid = getMgrid (m, i);
     281        if (isnan(Mgrid)) continue;
    282282
    283283        Msys = PhotSys (&catalog[i].measure[m], &catalog[i].average[j], &catalog[i].secfilt[j*PhotNsec]);
     
    310310        /* if (catalog[i].measure[m].dbFlags & MEAS_BAD) continue; */
    311311        Mcal  = getMcal  (m, i);
    312         if (Mcal == NO_MAG) continue;
    313         if (Mcal == NO_IMAGE) continue;
     312        if (isnan(Mcal)) continue;
    314313        Mmos  = getMmos  (m, i);
    315         if (Mmos == NO_MAG) continue;
    316         if (Mmos == NO_IMAGE) continue;
    317         if ((Mgrid = getMgrid (m, i)) == NO_MAG) continue;
     314        if (isnan(Mmos)) continue;
     315        Mgrid = getMgrid (m, i);
     316        if (isnan(Mgrid)) continue;
    318317
    319318        Msys = PhotSys (&catalog[i].measure[m], &catalog[i].average[j], &catalog[i].secfilt[j*PhotNsec]);
     
    368367      for (k = 0; k < catalog[i].average[j].Nm; k++, m++) {
    369368        Mcal = getMcal  (m, i);
    370         if (Mcal == NO_MAG) continue;
    371         if (Mcal == NO_IMAGE) continue;
     369        if (isnan(Mcal)) continue;
    372370        Mmos = getMmos  (m, i);
    373         if (Mmos == NO_MAG) continue;
    374         if (Mmos == NO_IMAGE) continue;
    375         if (getMgrid (m, i) == NO_MAG) continue;
     371        if (isnan(Mmos)) continue;
     372        Mgrid = getMgrid (m, i);
     373        if (isnan(Mgrid)) continue;
    376374        N++;
    377375      }
     
    411409
    412410      Xm = catalog[i].secfilt[PhotNsec*j+PhotSec].Xm;
    413       if (Xm == NO_MAG) continue;
     411      if (Xm == NAN_S_SHORT) continue;
    414412      list[n] = pow (10.0, 0.01*Xm);
    415413      dlist[n] = 1;
     
    508506      xlist[N] = catalog[i].secfilt[PhotNsec*j+PhotSec].M;
    509507      value    = catalog[i].secfilt[PhotNsec*j+PhotSec].Xm;
    510       if (value == NO_MAG) continue;
     508      if (value == NAN_S_SHORT) continue;
    511509      ylist[N] = 0.01*value;
    512510      N++;
  • trunk/Ohana/src/relphot/src/bcatalog.c

    r15038 r15509  
    2727
    2828    if (RESET) {
    29       subcatalog[0].secfilt[PhotNsec*Naverage+PhotSec].M  = NO_MAG;
    30       subcatalog[0].secfilt[PhotNsec*Naverage+PhotSec].dM = NO_MAG;
     29      subcatalog[0].secfilt[PhotNsec*Naverage+PhotSec].M  = NAN;
     30      subcatalog[0].secfilt[PhotNsec*Naverage+PhotSec].dM = NAN;
    3131      subcatalog[0].average[Naverage].code &= ~ID_STAR_FEW;
    3232      subcatalog[0].average[Naverage].code &= ~ID_STAR_POOR;
  • trunk/Ohana/src/relphot/src/plot_scatter.c

    r15038 r15509  
    2828      for (k = 0; k < catalog[i].average[j].Nm; k++, m++) {
    2929        if (catalog[i].measure[m].dbFlags & MEAS_BAD) continue;
    30         Mcal  = getMcal  (m, i);
    31         if (Mcal == NO_MAG) continue;
    32         if (Mcal == NO_IMAGE) continue;
    33         Mmos  = getMmos  (m, i);
    34         if (Mmos == NO_MAG) continue;
    35         if (Mmos == NO_IMAGE) continue;
    36         if ((Mgrid = getMgrid (m, i)) == NO_MAG) continue;
     30        Mcal = getMcal  (m, i);
     31        if (isnan(Mcal)) continue;
     32        Mmos = getMmos  (m, i);
     33        if (isnan(Mmos)) continue;
     34        Mgrid = getMgrid (m, i);
     35        if (isnan(Mgrid)) continue;
    3736
    3837        Mrel = catalog[i].secfilt[PhotNsec*j+PhotSec].M;
  • trunk/Ohana/src/relphot/src/select_images.c

    r12726 r15509  
    138138      if (RESET) {
    139139        assignMcal (&image[nimage], (double *) NULL, -1);
    140         image[nimage].dMcal = NO_MAG;
     140        image[nimage].dMcal = NAN;
    141141        image[nimage].code &= ~ID_IMAGE_POOR;
    142142      }
  • trunk/Ohana/src/relphot/src/setMrelFinal.c

    r15038 r15509  
    99
    1010    for (i = 0; i < catalog[0].Naverage; i++) {
    11       catalog[0].secfilt[PhotNsec*i+PhotSec].M = NO_MAG;
    12       catalog[0].secfilt[PhotNsec*i+PhotSec].dM = NO_MAG;
    13       catalog[0].secfilt[PhotNsec*i+PhotSec].Xm = NO_MAG;
     11      catalog[0].secfilt[PhotNsec*i+PhotSec].M  = NAN;
     12      catalog[0].secfilt[PhotNsec*i+PhotSec].dM = NAN;
     13      catalog[0].secfilt[PhotNsec*i+PhotSec].Xm = NAN_S_SHORT;
    1414
    1515      m = catalog[0].average[i].offset;
     
    106106      /* skip measurements from BAD images and mosaics */
    107107      /* do NOT skip measurements without a matching image */
    108       if ((getMcal  (m, 0)) == NO_MAG) goto skip;
    109       if ((getMmos  (m, 0)) == NO_MAG) goto skip;
     108      if (isnan(getMcal (m, 0))) goto skip;
     109      if (isnan(getMmos (m, 0))) goto skip;
    110110
    111111      /* skip measurements by inst mag limit */
  • trunk/Ohana/src/uniphot/src/update_catalog.c

    r12332 r15509  
    1313  for (i = 0; i < catalog[0].Naverage; i++) {
    1414   
    15     if (catalog[0].secfilt[i*Nsecfilt+Nsec].M != NO_MAG) {
     15    if (!isnan(catalog[0].secfilt[i*Nsecfilt+Nsec].M)) {
    1616      catalog[0].secfilt[i*Nsecfilt+Nsec].M += sgroup[0].M;
    1717    }
Note: See TracChangeset for help on using the changeset viewer.