IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 12276


Ignore:
Timestamp:
Mar 6, 2007, 8:55:39 AM (19 years ago)
Author:
eugene
Message:

lots of work to get initial compilation going

Location:
branches/dvo-mods-2007-02/Ohana/src/relastro
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • branches/dvo-mods-2007-02/Ohana/src/relastro/Makefile

    r12220 r12276  
    1515FULL_CFLAGS   = $(BASE_CFLAGS)
    1616FULL_CPPFLAGS = $(BASE_CPPFLAGS)
    17 FULL_LDFLAGS  = -ldvo -lFITS -lohana $(BASE_LDFLAGS)
     17FULL_LDFLAGS  = -lkapa -ldvo -lFITS -lohana $(BASE_LDFLAGS)
    1818
    1919relastro: $(BIN)/relastro.$(ARCH)
     
    3232$(SRC)/SetSignals.$(ARCH).o      \
    3333$(SRC)/Shutdown.$(ARCH).o        \
    34 $(SRC)/StarOps.$(ARCH).o         \
    3534$(SRC)/UpdateChips.$(ARCH).o     \
    3635$(SRC)/UpdateMosaic.$(ARCH).o    \
     
    4140$(SRC)/dvo_astrom_ops.$(ARCH).o  \
    4241$(SRC)/fitpoly.$(ARCH).o         \
    43 $(SRC)/global_stats.$(ARCH).o    \
    4442$(SRC)/initialize.$(ARCH).o      \
    4543$(SRC)/liststats.$(ARCH).o       \
     
    4947$(SRC)/plot_scatter.$(ARCH).o    \
    5048$(SRC)/plotstuff.$(ARCH).o       \
     49$(SRC)/select_images.$(ARCH).o   \
     50$(SRC)/sort.$(ARCH).o            \
    5151$(SRC)/relastro.$(ARCH).o        \
    5252$(SRC)/reload_catalogs.$(ARCH).o \
     
    5656DROP = \
    5757$(SRC)/setMrelFinal.$(ARCH).o    \
     58$(SRC)/StarOps.$(ARCH).o         
    5859
    5960
  • branches/dvo-mods-2007-02/Ohana/src/relastro/include/relastro.h

    r12220 r12276  
    107107int    RELPHOT_GRID_BINNING;
    108108
    109 PhotCode      *photcode;
     109char          *PHOTCODE_LIST;
     110int           Nphotcodes;
     111PhotCode     **photcodes;
    110112int            PhotPrimary;
    111113int            PhotNsec;
    112 int            PhotSec;
    113114
    114115int AreaSelect;
     
    129130
    130131SkyRegion UserPatch;
    131 int UserPatchSelect;
    132132
    133133int DoUpdateObjects;
     
    189189int           liststats           PROTO((double *value, double *dvalue, int N, StatType *stats));
    190190Catalog      *load_catalogs       PROTO((SkyList *skylist, int *Ncatalog));
    191 SkyList      *load_images         PROTO((FITS_DB *db, char *regionName, SkyRegion *region, int RegionSelect));
     191SkyList      *load_images         PROTO((FITS_DB *db, SkyRegion *region));
    192192Image        *select_images       PROTO((SkyList *skylist, Image *timage, int Ntimage, int **LineNumber, int *Nimage));
    193193
     
    272272int FitPMandPar (PMFit *fit, double *X, double *dX, double *Y, double *dY, time_t *T, double *pR, double *pD, int Npts);
    273273
    274 Coords *getMosaicForImage (int N);
     274Image *getMosaicForImage (int N);
    275275
    276276StarData *getImageRef (Catalog *catalog, int Ncatalog, int im, int *Nstars, int isMosaic);
  • branches/dvo-mods-2007-02/Ohana/src/relastro/src/ImageOps.c

    r12220 r12276  
    7777}
    7878
    79 /* select all image equivalent to the current photcode */
     79/* match measurements to images */
    8080void findImages (Catalog *catalog, int Ncatalog) {
    8181
    82   int i, j, ecode;
     82  int i, j;
    8383
    8484  for (i = 0; i < Ncatalog; i++) {
    8585    for (j = 0; j < catalog[i].Nmeasure; j++) {
    86       ecode = GetPhotcodeEquivCodebyCode (catalog[i].measure[j].photcode);
    87       if (photcode[0].code != ecode) continue;
    8886      matchImage (catalog, j, i);
    8987    }
     
    181179  int i, m, c;
    182180
    183   Coords *mosaic;
     181  Image *mosaic;
     182  Coords *moscoords;
    184183  StarData *raw;
    185184 
     
    187186
    188187  mosaic = NULL;
     188  moscoords = NULL;
    189189  if (isMosaic) {
    190190    mosaic = getMosaicForImage (im);
     191    moscoords = &mosaic[0].coords;
    191192  }
    192193
     
    205206    XY_to_LM (&raw[i].L, &raw[i].M, raw[i].X, raw[i].Y, &image[im].coords);
    206207    if (isMosaic) {
    207       XY_to_LM (&raw[i].P, &raw[i].Q, raw[i].L, raw[i].M, mosaic);
    208       LM_to_RD (&raw[i].R, &raw[i].D, raw[i].P, raw[i].Q, mosaic);
     208      XY_to_LM (&raw[i].P, &raw[i].Q, raw[i].L, raw[i].M, moscoords);
     209      LM_to_RD (&raw[i].R, &raw[i].D, raw[i].P, raw[i].Q, moscoords);
    209210    } else {
    210211      raw[i].P = raw[i].L;
     
    222223  int i, m, c, n;
    223224
    224   Coords *mosaic;
     225  Image *mosaic;
     226  Coords *moscoords;
    225227  StarData *ref;
    226228 
     
    228230
    229231  mosaic = NULL;
     232  moscoords = NULL;
    230233  if (isMosaic) {
    231234    mosaic = getMosaicForImage (im);
     235    moscoords = &mosaic[0].coords;
    232236  }
    233237
     
    244248    RD_to_LM (&ref[i].P, &ref[i].Q, ref[i].R, ref[i].D, &image[im].coords);
    245249    if (isMosaic) {
    246       LM_to_XY (&ref[i].M, &ref[i].L, ref[i].P, ref[i].Q, mosaic);
    247       LM_to_XY (&ref[i].X, &ref[i].Y, ref[i].L, ref[i].M, mosaic);
     250      LM_to_XY (&ref[i].M, &ref[i].L, ref[i].P, ref[i].Q, moscoords);
     251      LM_to_XY (&ref[i].X, &ref[i].Y, ref[i].L, ref[i].M, moscoords);
    248252    } else {
    249253      ref[i].L = ref[i].P;
  • branches/dvo-mods-2007-02/Ohana/src/relastro/src/MosaicOps.c

    r12048 r12276  
    1616
    1717/* find mosaic frames (unique time periods & photcode name matches mosaic) */
     18/* XXX what is a mosaic?  do we need to use the 'DIS/WRP' info to track? */
    1819void initMosaics (Image *image, int Nimage) {
    1920
     
    8687    }
    8788  }
    88 
    89   initMosaicGrid (image, Nimage);
    9089  return;
    91 }
    92 
    93 void initMosaicGrid (Image *image, int Nimage) {
    94 
    95   /* find max dR, dD range for all mosaics */
    96   /* define mosaic.coords to cover dR, dD */
    97   /* send results to initGridBins */
    98 
    99   int i, j, m, NX, NY;
    100   int dXmax, dYmax;
    101   double dS, dX, dY;
    102   double R, D, Rmin, Rmax, Dmin, Dmax;
    103   double Mcal, dMcal, Xm;
    104 
    105   dXmax = dYmax = 0.0;
    106   for (i = 0; i < Nmosaic; i++) {
    107     Dmin = Rmin =  360.0;
    108     Dmax = Rmax = -360.0;
    109     dS = 0.0;
    110     Mcal = dMcal = Xm = 0;
    111     for (j = 0; j < Nimlist[i]; j++) {
    112       m = imlist[i][j];
    113       NX = image[m].NX;
    114       NY = image[m].NY;
    115       dS += hypot (image[m].coords.cdelt1*image[m].coords.pc1_1, image[m].coords.cdelt1*image[m].coords.pc2_1);
    116       XY_to_RD (&R, &D, 0.0, 0.0, &image[m].coords);
    117       Rmin = MIN (Rmin, R);
    118       Rmax = MAX (Rmax, R);
    119       Dmin = MIN (Dmin, D);
    120       Dmax = MAX (Dmax, D);
    121       XY_to_RD (&R, &D, (double) NX, 0.0, &image[m].coords);
    122       Rmin = MIN (Rmin, R);
    123       Rmax = MAX (Rmax, R);
    124       Dmin = MIN (Dmin, D);
    125       Dmax = MAX (Dmax, D);
    126       XY_to_RD (&R, &D, (double) NX, (double) NY, &image[m].coords);
    127       Rmin = MIN (Rmin, R);
    128       Rmax = MAX (Rmax, R);
    129       Dmin = MIN (Dmin, D);
    130       Dmax = MAX (Dmax, D);
    131       XY_to_RD (&R, &D, 0.0, (double) NY, &image[m].coords);
    132       Rmin = MIN (Rmin, R);
    133       Rmax = MAX (Rmax, R);
    134       Dmin = MIN (Dmin, D);
    135       Dmax = MAX (Dmax, D);
    136       Mcal += image[m].Mcal;
    137       dMcal += image[m].dMcal;
    138       Xm += image[m].Xm;
    139       /* 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;
    142     }
    143     dS /= Nimlist[i];
    144     strcpy (mosaic[i].coords.ctype, "RA---TAN");
    145     mosaic[i].coords.crval1 = Rmin;
    146     mosaic[i].coords.crval2 = Dmin;
    147     mosaic[i].coords.crpix1 = 0.0;
    148     mosaic[i].coords.crpix2 = 0.0;
    149     mosaic[i].coords.cdelt1 = dS;
    150     mosaic[i].coords.cdelt2 = dS;
    151     mosaic[i].coords.pc1_1  = 1.0;
    152     mosaic[i].coords.pc2_2  = 1.0;
    153     mosaic[i].coords.pc1_2  = 0.0;
    154     mosaic[i].coords.pc2_1  = 0.0;
    155     RD_to_XY (&dX, &dY, Rmax, Dmax, &mosaic[i].coords);
    156 
    157     mosaic[i].Mcal  = Mcal / Nimlist[i];
    158     mosaic[i].dMcal = dMcal / Nimlist[i];
    159     mosaic[i].Xm    = Xm / Nimlist[i];
    160   }
    161   if (!USE_GRID) return;
    162 
    163   dXmax = MAX (dXmax, dX);
    164   dYmax = MAX (dYmax, dY);
    165   initGrid (dXmax, dYmax);
    166   return;
    167 }
    168 
    169 void setMcalFinal () {
    170 
    171   int i, j, im, Nimage;
    172   Image *image;
    173 
    174   if (!MOSAICNAME[0]) return;
    175 
    176   image = getimages (&Nimage);
    177 
    178   for (i = 0; i < Nmosaic; i++) {
    179     for (j = 0; j < Nimlist[i]; j++) {
    180       im = imlist[i][j];
    181       image[im].Mcal = mosaic[i].Mcal;
    182       image[im].dMcal = mosaic[i].dMcal;
    183       image[im].Xm = mosaic[i].Xm;
    184       image[im].code |= (mosaic[i].code & ID_IMAGE_FEW);
    185       image[im].code |= (mosaic[i].code & ID_IMAGE_POOR);
    186     }
    187   }     
    18890}
    18991
     
    238140int findMosaics (Catalog *catalog, int Ncatalog) {
    239141 
    240   int i, j, ecode;
     142  int i, j;
    241143
    242144  if (!MOSAICNAME[0]) return (FALSE);
     
    247149        if (catalog[i].measure[j].t > TSTOP) continue;
    248150      }
    249       ecode = GetPhotcodeEquivCodebyCode (catalog[i].measure[j].photcode);
    250       if (photcode[0].code != ecode) continue;
    251151      matchMosaics (catalog, j, i);
    252152    }
     
    255155}
    256156
     157/* modify this function to use the measure->imageID field ? */
    257158void matchMosaics (Catalog *catalog, int meas, int cat) {
    258159
     
    263164    if (catalog[cat].measure[meas].t > mosaic[i].stop) continue;
    264165   
    265 # ifdef GRID_V1
    266     if (USE_GRID) {
    267       ave = catalog[cat].measure[meas].averef;
    268       ra  = catalog[cat].average[ave].R - catalog[cat].measure[meas].dR / 3600.0;
    269       dec = catalog[cat].average[ave].D - catalog[cat].measure[meas].dD / 3600.0;
    270 
    271       /* X,Y always positive-definite in range 0,0 - dX, dY */
    272       RD_to_XY (&X, &Y, ra, dec, &mosaic[i].coords);
    273       setGridMeasure (meas, cat, X, Y);
    274     }
    275 # endif
    276 
    277166    bin[cat][meas] = i;
    278167
     
    288177    return;
    289178  }
    290   fprintf (stderr, "missed measurement\n");
    291179  return;
    292 }
    293 
    294 float getMmos (int meas, int cat) {
    295 
    296   int i;
    297   float value;
    298 
    299   if (!MOSAICNAME[0]) return (0);
    300   i = bin[cat][meas];
    301   if (i == -1) return (NO_MAG);
    302 
    303   if (mosaic[i].code & IMAGE_BAD) return (NO_MAG); 
    304   value = mosaic[i].Mcal;
    305   return (value);
    306 }
    307 
    308 int setMmos (Catalog *catalog, int PoorImages) {
    309 
    310   int i, j, m, c, n, N, Nmax, mark, bad;
    311   float Msys, Mrel, Mcal, Mgrid;
    312   double *list, *dlist, *Mlist, *dMlist;
    313   StatType stats;
    314   Image *image;
    315 
    316   if (!MOSAICNAME[0]) return (FALSE);
    317 
    318   image = getimages (&N);
    319 
    320   if (PoorImages) {
    321     IMAGE_BAD = 0;
    322   }
    323 
    324   Nmax = 0;
    325   for (i = 0; i < Nmosaic; i++) {
    326     Nmax = MAX (Nmax, Nlist[i]);
    327   }
    328   ALLOCATE (list, double, Nmax);
    329   ALLOCATE (dlist, double, Nmax);
    330   ALLOCATE (Mlist, double, Nmax);
    331   ALLOCATE (dMlist, double, Nmax);
    332 
    333   for (i = 0; i < Nmosaic; i++) {
    334    
    335     /* on PoorImages run, skip good images */
    336     if (PoorImages) {
    337       bad = mosaic[i].code & (ID_IMAGE_FEW | ID_IMAGE_POOR | ID_IMAGE_SKIP);
    338       if (!bad) continue;
    339     }     
    340 
    341     N = 0;
    342     for (j = 0; j < Nlist[i]; j++) {
    343      
    344       m = mlist[i][j];
    345       c = clist[i][j];
    346      
    347       if (catalog[c].measure[m].flags & MEAS_BAD) continue;
    348       if ((Mcal  = getMcal  (m, c)) == NO_MAG) continue;
    349       if ((Mgrid = getMgrid (m, c)) == NO_MAG) continue;
    350       if ((Mrel  = getMrel  (catalog, m, c)) == NO_MAG) continue;
    351      
    352       n = catalog[c].measure[m].averef;
    353       Msys = PhotSys (&catalog[c].measure[m], &catalog[c].average[n], &catalog[c].secfilt[n*PhotNsec]);
    354       list[N]  = Msys - Mrel - Mcal - Mgrid;
    355       dlist[N] = MAX (catalog[c].measure[m].dM, MIN_ERROR);
    356       Mlist[N] = Msys;
    357       dMlist[N] = list[N];
    358       N++;
    359     }
    360     /* Nlist[i] is all measurements, N is good measurements */
    361 
    362     /* too few good measurements or too many bad measurements (skip in PoorImages run) */
    363 
    364     if (!PoorImages) {
    365       mark = (N < IMAGE_TOOFEW) || (N < IMAGE_GOOD_FRACTION*Nlist[i]);
    366       if (mark) {
    367         fprintf (stderr, "marked image %s (%d), (%d < %d) || (%d < %f*%d)\n", image[imlist[i][0]].name, i, N, IMAGE_TOOFEW, N, IMAGE_GOOD_FRACTION, Nlist[i]);
    368         mosaic[i].code |= ID_IMAGE_FEW;
    369       } else {
    370         mosaic[i].code &= ~ID_IMAGE_FEW;
    371       }
    372     }
    373     liststats (list, dlist, N, &stats);
    374     if (PoorImages) fprintf (stderr, "Mmos: %f %f %d %d\n", stats.mean, stats.sigma, stats.Nmeas, N);
    375     mosaic[i].Mcal  = stats.mean;
    376     mosaic[i].dMcal = stats.sigma;
    377     mosaic[i].Xm    = 100.0*log10(stats.chisq);
    378   }
    379   free (list);
    380   free (dlist);
    381   free (Mlist);
    382   free (dMlist);
    383 
    384   if (PoorImages) {
    385     IMAGE_BAD = ID_IMAGE_POOR | ID_IMAGE_FEW | ID_IMAGE_SKIP;
    386     STAR_BAD  = ID_STAR_POOR | ID_STAR_FEW;
    387     MEAS_BAD  = ID_MEAS_NOCAL | ID_MEAS_POOR | ID_MEAS_SKIP | ID_MEAS_AREA;
    388   }
    389   return (TRUE);
    390 }
    391  
    392 StatType statsMosaicM (Catalog *catalog) {
    393 
    394   int i, n;
    395   double *list, *dlist;
    396   StatType stats;
    397 
    398   bzero (&stats, sizeof (StatType));
    399   if (!MOSAICNAME[0]) return (stats);
    400 
    401   ALLOCATE (list, double, Nmosaic);
    402   ALLOCATE (dlist, double, Nmosaic);
    403 
    404   n = 0;
    405   for (i = 0; i < Nmosaic; i++) {
    406     if (mosaic[i].code & IMAGE_BAD) continue;
    407     list[n] = mosaic[i].Mcal;
    408     dlist[n] = 1;
    409     n++;
    410   }
    411 
    412   liststats (list, dlist, n, &stats);
    413   free (list);
    414   free (dlist);
    415   return (stats);
    416 }
    417 
    418 StatType statsMosaicdM (Catalog *catalog) {
    419 
    420   int i, n;
    421   double *list, *dlist;
    422   StatType stats;
    423 
    424   bzero (&stats, sizeof (StatType));
    425   if (!MOSAICNAME[0]) return (stats);
    426 
    427   ALLOCATE (list, double, Nmosaic);
    428   ALLOCATE (dlist, double, Nmosaic);
    429 
    430   n = 0;
    431   for (i = 0; i < Nmosaic; i++) {
    432 
    433     if (mosaic[i].code & IMAGE_BAD) continue;
    434     list[n] = mosaic[i].dMcal;
    435     dlist[n] = 1;
    436     n++;
    437   }
    438 
    439   liststats (list, dlist, n, &stats);
    440   free (list);
    441   free (dlist);
    442   return (stats);
    443 }
    444 
    445 StatType statsMosaicN (Catalog *catalog) {
    446 
    447   int i, j, m, c, n, N;
    448   double *list, *dlist;
    449   StatType stats;
    450 
    451   bzero (&stats, sizeof (StatType));
    452   if (!MOSAICNAME[0]) return (stats);
    453 
    454   ALLOCATE (list, double, Nmosaic);
    455   ALLOCATE (dlist, double, Nmosaic);
    456 
    457   n = 0;
    458   for (i = 0; i < Nmosaic; i++) {
    459     if (mosaic[i].code & IMAGE_BAD)  continue;
    460 
    461     N = 0;
    462     for (j = 0; j < Nlist[i]; j++) {
    463 
    464       m = mlist[i][j];
    465       c = clist[i][j];
    466 
    467       if (getMcal  (m, c) == NO_MAG) continue;
    468       if (getMgrid (m, c) == NO_MAG) continue;
    469       if (getMrel  (catalog, m, c) == NO_MAG) continue;
    470       N++;
    471     }
    472     list[n] = N;
    473     dlist[n] = 1;
    474     n++;
    475   }
    476   fprintf (stderr, "Nmosaic: %d, n: %d\n", Nmosaic, n);
    477 
    478   liststats (list, dlist, n, &stats);
    479   free (list);
    480   free (dlist);
    481   return (stats);
    482 }
    483 
    484 StatType statsMosaicX (Catalog *catalog) {
    485 
    486   int i, n;
    487   double *list, *dlist;
    488   StatType stats;
    489 
    490   bzero (&stats, sizeof (StatType));
    491   if (!MOSAICNAME[0]) return (stats);
    492 
    493   ALLOCATE (list, double, Nmosaic);
    494   ALLOCATE (dlist, double, Nmosaic);
    495 
    496   n = 0;
    497   for (i = 0; i < Nmosaic; i++) {
    498 
    499     if (mosaic[i].code & IMAGE_BAD) continue;
    500     list[n] = pow(10.0, 0.01*mosaic[i].Xm);
    501     dlist[n] = 1;
    502     n++;
    503   }
    504 
    505   liststats (list, dlist, n, &stats);
    506   free (list);
    507   free (dlist);
    508   return (stats);
    509 }
    510 
    511 /* mark mosaic if: abs(Mcal - <Mcal>) too large, dMcal too large */
    512 void clean_mosaics () {
    513 
    514   int i, N, mark, Nmark;
    515   double *mlist, *slist, *dlist;
    516   double MaxOffset, MedOffset, MaxScatter;
    517   StatType stats;
    518 
    519   if (!MOSAICNAME[0]) return;
    520 
    521   if (VERBOSE) fprintf (stderr, "marking poor mosaics\n");
    522 
    523   ALLOCATE (mlist, double, Nmosaic);
    524   ALLOCATE (slist, double, Nmosaic);
    525   ALLOCATE (dlist, double, Nmosaic);
    526 
    527   for (i = N = 0; i < Nmosaic; i++) {
    528     if (mosaic[i].code & IMAGE_BAD) continue;
    529     mlist[N] = mosaic[i].Mcal;
    530     slist[N] = mosaic[i].dMcal;
    531     dlist[N] = 1;
    532     N++;
    533   }
    534   initstats ("MEAN");
    535   liststats (mlist, dlist, N, &stats);
    536   MaxOffset = MAX (IMAGE_OFFSET, 2*stats.sigma);
    537   MedOffset = stats.median;
    538   liststats (slist, dlist, N, &stats);
    539   MaxScatter = MAX (IMAGE_SCATTER, 2*stats.median);
    540   fprintf (stderr, "Mrel: %f, dMrel: %f, Max Scatter: %f, Max Offset: %f\n", MedOffset, stats.median, MaxScatter, MaxOffset);
    541  
    542   Nmark = 0;
    543   for (i = 0; i < Nmosaic; i++) {
    544     mark = FALSE;
    545     mark = (mosaic[i].dMcal > MaxScatter) || (fabs(mosaic[i].Mcal - MedOffset) > MaxOffset);
    546     if (mark) {
    547       Nmark ++;
    548       mosaic[i].code |= ID_IMAGE_POOR;
    549     } else {
    550       mosaic[i].code &= ~ID_IMAGE_POOR;
    551     }
    552   }
    553 
    554   fprintf (stderr, "%d mosaics marked poor\n", Nmark);
    555   initstats (STATMODE);
    556   free (mlist);
    557   free (slist);
    558   free (dlist);
    559180}
    560181
     
    655276}
    656277
     278Image *getMosaicForImage (int Nim) {
     279
     280    Image *mosaic;
     281
     282    mosaic = NULL;
     283    return mosaic;
     284}
     285
    657286int *SelectRefMosaic (Mosaic **refmosaic, int *Nimage) {
    658287
  • branches/dvo-mods-2007-02/Ohana/src/relastro/src/Shutdown.c

    r12048 r12276  
    2727}
    2828
     29
     30/* XXX this is probably not needed anymore : just protect the write statements */
  • branches/dvo-mods-2007-02/Ohana/src/relastro/src/args.c

    r12220 r12276  
    3434  }
    3535
    36   /* specify portion of the sky */
     36  /* specify portion of the sky : allow default of all sky? */
    3737  UserPatch.Rmin = 0;
    3838  UserPatch.Rmax = 360;
    3939  UserPatch.Dmin = -90;
    4040  UserPatch.Dmax = +90;
    41   UserPatchSelect = FALSE;
    4241  if ((N = get_argument (argc, argv, "-region"))) {
    4342    remove_argument (N, &argc, argv);
     
    5049    UserPatch.Dmax = atof (argv[N]);
    5150    remove_argument (N, &argc, argv);
    52     UserPatchSelect = TRUE;
     51  } else {
     52    usage ();
     53  }
     54
     55  PHOTCODE_LIST = NULL;
     56  if ((N = get_argument (argc, argv, "-photcode"))) {
     57    remove_argument (N, &argc, argv);
     58    PHOTCODE_LIST = strcreate(argv[N]);
     59    remove_argument (N, &argc, argv);
    5360  }
    5461
     
    7279  }
    7380
     81# if (0)
     82  /* XXX is this still relevant?? */
    7483  strcpy (STATMODE, "CHI_INNER_WTMEAN");
    7584  if ((N = get_argument (argc, argv, "-statmode"))) {
     
    7887    remove_argument (N, &argc, argv);
    7988  }
    80 
    81   NLOOP = 8;
    82   if ((N = get_argument (argc, argv, "-n"))) {
    83     remove_argument (N, &argc, argv);
    84     NLOOP = atof (argv[N]);
    85     remove_argument (N, &argc, argv);
    86   }
     89# endif
    8790
    8891  RESET = FALSE;
     
    104107  }
    105108
     109  /* XXX update these for relevant plots */
    106110  PlotMmin = 10.0; PlotMmax = 20.0; PlotdMmin = -1.0; PlotdMmax = 1.0;
    107111  if ((N = get_argument (argc, argv, "-plrange"))) {
     
    117121  }
    118122
    119   /* group images by mosaic, find Mmos */
    120   MOSAICNAME[0] = 0;
    121   if ((N = get_argument (argc, argv, "-mosaic"))) {
    122     remove_argument (N, &argc, argv);
    123     strcpy (MOSAICNAME, argv[N]);
    124     remove_argument (N, &argc, argv);
    125   }
    126 
    127   FREEZE_IMAGES = FALSE;
    128   if ((N = get_argument (argc, argv, "-imfreeze"))) {
    129     remove_argument (N, &argc, argv);
    130     FREEZE_IMAGES = TRUE;
    131   }
    132 
    133   USE_GRID = FALSE;
    134   if ((N = get_argument (argc, argv, "-grid"))) {
    135     remove_argument (N, &argc, argv);
    136     USE_GRID = TRUE;
    137     if (!MOSAICNAME[0]) {
    138       fprintf (stderr, "-grid is only valid with -mosaic\n");
    139       exit (2);
    140     }
    141   }
    142 
     123  /* XXX update this */
    143124  MIN_ERROR = 0.001;
    144125  if ((N = get_argument (argc, argv, "-minerror"))) {
     
    195176  }
    196177
     178  /* XXX drop this? */
    197179  DophotSelect = FALSE;
    198180  if ((N = get_argument (argc, argv, "-dophot"))) {
     
    203185  }
    204186
    205   if ( UserPatchSelect && (argc != 2)) usage ();
    206   if (!UserPatchSelect && (argc != 3)) usage ();
    207 
     187  if (argc != 1) usage ();
    208188  return TRUE;
    209189}
    210190
    211191void usage () {
    212   fprintf (stderr, "ERROR: USAGE: relphot (region) (photcode)\n");
    213   fprintf (stderr, "       or:    relphot (photcode) -region RA RA DEC DEC\n");
    214   fprintf (stderr, "  options: \n");
     192  fprintf (stderr, "ERROR: USAGE: relastro -region RA RA DEC DEC\n");
     193  fprintf (stderr, "  working options: \n");
    215194  fprintf (stderr, "  -time (start) (stop)\n");
    216195  fprintf (stderr, "  -v\n");
    217196  fprintf (stderr, "  -plot\n");
    218197  fprintf (stderr, "  -plotdelay (seconds)\n");
    219   fprintf (stderr, "  -statmode (mode)\n");
    220   fprintf (stderr, "  -n (nloop)\n");
    221   fprintf (stderr, "  -reset\n");
    222198  fprintf (stderr, "  -update\n");
    223199  fprintf (stderr, "  -params\n");
    224   fprintf (stderr, "  -mosaic (mosaic)\n");
    225   fprintf (stderr, "  -imfreeze\n");
    226   fprintf (stderr, "  -grid\n");
     200  fprintf (stderr, "  -reset\n");
    227201  fprintf (stderr, "  -area Xmin Xmax Ymin Ymax\n");
    228   fprintf (stderr, "  -instmag min max\n");
     202  fprintf (stderr, "  -instmag min max\n\n");
     203  fprintf (stderr, "  planned options: \n");
     204  fprintf (stderr, "  -photcode code[,code,code,..]\n");
    229205  fprintf (stderr, "  \n");
    230206  exit (2);
  • branches/dvo-mods-2007-02/Ohana/src/relastro/src/bcatalog.c

    r12220 r12276  
    33int bcatalog (Catalog *subcatalog, Catalog *catalog) {
    44 
    5   int i, j, offset, ecode;
     5  int i, j, k, offset, found;
    66  int NAVERAGE, NMEASURE, Naverage, Nmeasure, Nm;
    77  float mag;
     
    3737      offset = catalog[0].average[i].offset + j;
    3838
    39       /* select measurements by photcode */
    40       ecode = GetPhotcodeEquivCodebyCode (catalog[0].measure[offset].photcode);
    41       if (ecode != photcode[0].code) continue;
     39      /* select measurements by photcode, if specified */
     40      if (Nphotcodes > 0) {
     41        found = FALSE;
     42        for (k = 0; (k < Nphotcodes) && !found; k++) {
     43          if (photcodes[k][0].code == catalog[0].measure[offset].photcode) found = TRUE;
     44        }
     45        if (!found) continue;
     46      }
    4247
    4348      /* select measurements by time */
  • branches/dvo-mods-2007-02/Ohana/src/relastro/src/initialize.c

    r12048 r12276  
    33void initialize (int argc, char **argv) {
    44
    5   int N;
     5  int NPHOTCODES;
     6  char *codename, *ptr;
    67
    78  ConfigInit (&argc, argv);
    89  args (argc, argv);
    910
    10   N = UserPatchSelect ? 1 : 2;
    11   if ((photcode = GetPhotcodebyName (argv[N])) == NULL) {
    12     fprintf (stderr, "ERROR: photcode %s not found in photcode table\n", argv[N]);
    13     exit (1);
     11  /* XXX we need to build a list of accepted photcodes. these will be used by bcatalog to accept or
     12     reject loaded data */
     13
     14  Nphotcodes = 0;
     15  photcodes = NULL;
     16  if (PHOTCODE_LIST != NULL) {
     17    NPHOTCODES = 10;
     18    ALLOCATE (photcodes, PhotCode *, NPHOTCODES);
     19
     20    /* parse the comma-separated list of photcodes */
     21    strtok_r (PHOTCODE_LIST, ",", &ptr);
     22    while ((codename = strtok_r (NULL, ",", &ptr)) != NULL) {
     23      fprintf (stderr, "PHOTCODE_LIST: %s\n", PHOTCODE_LIST);
     24      fprintf (stderr, "codename: %s\n", codename);
     25      if ((photcodes[Nphotcodes] = GetPhotcodebyName (codename)) == NULL) {
     26        fprintf (stderr, "ERROR: photcode %s not found in photcode table\n", codename);
     27        exit (1);
     28      }
     29      Nphotcodes ++;
     30      CHECK_REALLOCATE (photcodes, PhotCode *, NPHOTCODES, Nphotcodes, 10);
     31    }
    1432  }
    15   if (photcode[0].type != PHOT_SEC) {
    16     fprintf (stderr, "photcode %s is not a primary or secondary filter\n", argv[N]);
    17     exit (1);
    18   }
    19 
    2033  PhotNsec = GetPhotcodeNsecfilt ();
    21   PhotSec = GetPhotcodeNsec (photcode[0].code);
    2234
    2335  initstats (STATMODE);
     
    2739  MEAS_BAD  = ID_MEAS_NOCAL | ID_MEAS_POOR | ID_MEAS_SKIP | ID_MEAS_AREA;
    2840
     41  /* XXX drop irrelevant entries */
    2942  if (SHOW_PARAMS) {
    3043    fprintf (stderr, "current parameter settings:\n");
  • branches/dvo-mods-2007-02/Ohana/src/relastro/src/load_images.c

    r12068 r12276  
    11# include "relastro.h"
    22
    3 SkyList *load_images (FITS_DB *db, char *regionName, SkyRegion *region, int RegionSelect) {
     3SkyList *load_images (FITS_DB *db, SkyRegion *region) {
    44
    55  Image     *image, *subset;
    6   int        Nimage, Nsubset, Nchar;
     6  int        Nimage, Nsubset;
    77  int       *LineNumber;
    88
     
    1515 
    1616  // determine the populated SkyRegions overlapping the requested area
    17   if (RegionSelect) {
    18     skylist = SkyListByPatch (sky, -1, region);
    19   } else {
    20     Nchar = strlen(regionName);
    21     if (!strcmp (&regionName[Nchar-4], ".cpt")) regionName[Nchar-4] = 0;
    22     skylist = SkyListByName (sky, regionName);
    23   }
     17  skylist = SkyListByPatch (sky, -1, region);
    2418
    2519  // convert database table to internal structure
  • branches/dvo-mods-2007-02/Ohana/src/relastro/src/plot_scatter.c

    r12220 r12276  
    33void plot_scatter (Catalog *catalog, int Ncatalog) {
    44
     5# if (0)   
    56  int i, j, k, m, N, Ntot;
    67  float Mrel, Mcal, Mmos, Mgrid;
     
    2829      for (k = 0; k < catalog[i].average[j].Nm; k++, m++) {
    2930        if (catalog[i].measure[m].flags & MEAS_BAD) continue;
    30         if ((Mcal  = getMcal  (m, i)) == NO_MAG) continue;
    31         if ((Mmos  = getMmos  (m, i)) == NO_MAG) continue;
    32         if ((Mgrid = getMgrid (m, i)) == NO_MAG) continue;
    3331
    3432        Mrel = catalog[i].secfilt[PhotNsec*j+PhotSec].M;
     
    5553  free (ylist);
    5654  free (ilist);
     55
     56# endif
    5757}
     58
     59/* XXX this should become astrometrically relevant */
  • branches/dvo-mods-2007-02/Ohana/src/relastro/src/relastro.c

    r12220 r12276  
    2222
    2323  /* load regions and images based on specified sky patch */
    24   // XXX need to mimic old-style load by passing patch name
    25   // XXX need to reduce number of global variables in use.
    26   // XXX this is fairly lame: argv[1] is photcode if UserPatchSelect is true
    27   skylist = load_images (&db, argv[1], &UserPatch, UserPatchSelect);
     24  skylist = load_images (&db, &UserPatch);
    2825
    2926  /* load catalog data from region files */
     
    3835
    3936  if (PLOTSTUFF) {
    40     plot_star_coords (catalog, Ncatalog);
     37    // plot_star_coords (catalog, Ncatalog);
    4138    plot_mosaic_fields (catalog);
    4239  }
  • branches/dvo-mods-2007-02/Ohana/src/relastro/src/reload_catalogs.c

    r12048 r12276  
    3838    initImageBins  (&catalog, 1);
    3939    initMosaicBins (&catalog, 1);
    40     initGridBins   (&catalog, 1);
    4140
    4241    findImages (&catalog, 1);
    4342    findMosaics (&catalog, 1);
    4443
    45     setMrelFinal (&catalog);
    4644    dvo_catalog_save (&catalog, VERBOSE);
    4745    dvo_catalog_unlock (&catalog);
     
    5048    freeImageBins (1);
    5149    freeMosaicBins (1);
    52     freeGridBins (1);
    5350  }
    5451}
  • branches/dvo-mods-2007-02/Ohana/src/relastro/src/select_images.c

    r12048 r12276  
    1717  Image *image;
    1818  int i, j, k, m, found, nimage, NIMAGE;
    19   int InRange, ecode;
     19  int InRange;
    2020  double Ri[5], Di[5], Xi[5], Yi[5], dx, dy;
    2121  int *line_number;
     
    7575  for (i = 0; i < Ntimage; i++) {
    7676     
    77     /* exclude images by photcode */
    78     ecode = GetPhotcodeEquivCodebyCode (timage[i].photcode);
    79     if (ecode != photcode[0].code) continue;
     77    /* exclude images by photcode, if selected */
     78    if (Nphotcodes > 0) {
     79      found = FALSE;
     80      for (j = 0; (j < Nphotcodes) && !found; j++) {
     81        if (photcodes[j][0].code == timage[i].photcode) found = TRUE;
     82      }
     83      if (!found) continue;
     84    }
    8085
    8186    /* exclude images by time */
  • branches/dvo-mods-2007-02/Ohana/src/relastro/src/setExclusions.c

    r12068 r12276  
    44int setExclusions (Catalog *catalog, int Ncatalog) {
    55
    6   int i, j, k, m, Narea, Nnocal, ecode;
     6  int i, j, k, m, Narea, Nnocal;
    77  Coords *coords;
    88  double r, d, x, y;
     
    1515
    1616        /* select measurements by photcode */
    17         ecode = GetPhotcodeEquivCodebyCode (catalog[i].measure[m].photcode);
    18         if (ecode != photcode[0].code) goto mark_nocal;
     17        // XXXX is this done when loaded, or is it needed for reload?
     18        // ecode = GetPhotcodeEquivCodebyCode (catalog[i].measure[m].photcode);
     19        // if (ecode != photcode[0].code) goto mark_nocal;
    1920       
    2021        /* select measurements by time */
Note: See TracChangeset for help on using the changeset viewer.