IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 20, 2005, 4:27:25 AM (21 years ago)
Author:
eugene
Message:

substantial cleanup of photometry extraction functions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/dvo/ddmags.c

    r3689 r4585  
    33int ddmags (int argc, char **argv) {
    44 
    5   Catalog catalog;
    6   Graphdata graphsky;
    7   RegionFile *regions;
    8   PhotCode *code[4];
    9   Vector *xvec, *yvec;
    10 
    11   char filename[256], catdir[256];
     5  char filename[256], catdir[256], *RegionName, *RegionList;
    126  double Radius;
    137  double *M1, *M2;
    148  int i, m, k, Npts, NPTS;
    159  int N1, N2, i1, i2, mode[4];
    16   int Ngraph, Nsec, Nregions, UseAverages;
     10  int Ngraph, Nsec, Nregions;
     11
     12  Catalog catalog;
     13  RegionFile *regions;
     14  PhotCode *code[4];
     15  Vector *xvec, *yvec;
    1716
    1817  /* defaults */
     
    2120  catalog.secfilt = NULL;
    2221  catalog.measure = NULL;
    23 
    24   /* find CATDIR in config system */
    25   VarConfig ("CATDIR", "%s", catdir);
     22  RegionName = NULL;
     23  RegionList = NULL;
    2624
    2725  /* load photcode information */
     
    2927  Nsec = GetPhotcodeNsecfilt ();
    3028
    31   /* load data about plot windows */
    32   Ngraph = 0;
    33   if (!GetGraphData (&graphsky, NULL, &Ngraph)) return (FALSE);
    34  
    35   /* find catalog files which overlap this region */
    36   Radius = MAX (fabs(graphsky.xmax), fabs(graphsky.ymax));
    37   regions = find_regions (graphsky.coords.crval1, graphsky.coords.crval2, Radius, &Nregions);
     29  /* find CATDIR in config system */
     30  if (VarConfig ("CATDIR", "%s", catdir) == NULL) goto escape;
    3831
    3932  /* interpret command-line options */
    40   if (!SetPhotSelections (&argc, argv)) goto usage;
     33  if (!SetRegionSelection (&argc, argv, &RegionName, &RegionList)) goto escape;
     34  if (!SetPhotSelections (&argc, argv, 4)) goto usage;
     35
     36  /* interpret command-line options */
    4137  if (argc != 8) goto usage;
    4238  if (strcmp (argv[2], "-")) goto usage;
    4339  if (strcmp (argv[4], ":")) goto usage;
    4440  if (strcmp (argv[6], "-")) goto usage;
    45 
    46   /* interpret command-line options */
    4741  if (!GetPhotcodeInfo (argv[1], &code[0], &mode[0])) return (FALSE);
    4842  if (!GetPhotcodeInfo (argv[3], &code[1], &mode[1])) return (FALSE);
    4943  if (!GetPhotcodeInfo (argv[5], &code[2], &mode[2])) return (FALSE);
    5044  if (!GetPhotcodeInfo (argv[7], &code[3], &mode[3])) return (FALSE);
    51   if ((mode[2] == MAG_AVE) || (mode[2] == MAG_REF)) UseAverages = TRUE;
     45  if (!TestPhotSelections (&code[0], MEAS_ZERO)) goto escape;
     46
     47  /* load region corresponding to selection above */
     48  if ((regions = SelectRegions (RegionName, RegionList, &Nregions)) == NULL) goto escape;
    5249
    5350  /* init vectors to save data */
     
    7976      m = catalog.average[i].offset;
    8077
     78      SetSelectionParam (0);
    8179      M1 = ExtractDMag (&code[0], &mode[0], &catalog.average[i], &catalog.secfilt[i*Nsec], &catalog.measure[m], &N1);
    8280      if (N1 == 0) goto skip;
    8381
     82      SetSelectionParam (2);
    8483      M2 = ExtractDMag (&code[2], &mode[2], &catalog.average[i], &catalog.secfilt[i*Nsec], &catalog.measure[m], &N2);
    8584      if (N2 == 0) goto skip;
     
    9089          yvec[0].elements[Npts] = M2[i2];
    9190          Npts++;
    92           if (Npts == NPTS) {
     91          if (Npts >= NPTS) {
    9392            NPTS += 2000;
    9493            REALLOCATE (xvec[0].elements, float, NPTS);
     
    120119  if (catalog.secfilt != NULL) free (catalog.secfilt);
    121120  if (catalog.measure != NULL) free (catalog.measure);
     121  if (RegionName != NULL) free (RegionName);
     122  if (RegionList != NULL) free (RegionList);
    122123  return (FALSE);
    123124}
Note: See TracChangeset for help on using the changeset viewer.