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/cmd.c

    r4470 r4585  
    33int cmd (int argc, char **argv) { /* really need to think about upper limits & how to represent them */
    44 
     5  char filename[256], catdir[256], *RegionName, *RegionList;
     6  double Radius, *M1, *M3;
     7  int i, j, m, i1, i3, N1, N3, N;
     8  int Npts, NPTS, mode[3];
     9  int Ngraph, Nsec, Nregions;
     10
    511  Catalog catalog;
    612  Graphdata graphsky;
     
    915  Vector *xvec, *yvec;
    1016
    11   char filename[256], catdir[256], *CPTfile;
    12   double Radius, *M1, *M3;
    13   int i, j, m, i1, i3, N1, N3, N;
    14   int Npts, NPTS, mode[3];
    15   int Ngraph, Nsec, Nregions;
    16 
    1717  /* defaults */
    1818  regions = NULL;
     
    2020  catalog.secfilt = NULL;
    2121  catalog.measure = NULL;
     22  RegionName = NULL;
     23  RegionList = NULL;
    2224
    2325  /* load photcode information */
     
    2527  Nsec = GetPhotcodeNsecfilt ();
    2628
    27   /* load data about plot windows */
    28   Ngraph = 0;
    29   if (!GetGraphData (&graphsky, NULL, &Ngraph)) return (FALSE);
    30  
    3129  /* find CATDIR in config system */
    32   VarConfig ("CATDIR", "%s", catdir);
    33 
    34   /* check for CPT selection */
    35   CPTfile = NULL;
    36   if (N = get_argument (argc, argv, "-cpt")) {
    37     remove_argument (N, &argc, argv);
    38     CPTfile = strcreate (argv[N]);
    39     remove_argument (N, &argc, argv);
    40   }   
     30  if (VarConfig ("CATDIR", "%s", catdir) == NULL) goto escape;
    4131
    4232  /* interpret command-line options */
    43   if (!SetPhotSelections (&argc, argv)) goto usage;
     33  if (!SetRegionSelection (&argc, argv, &RegionName, &RegionList)) goto escape;
     34  if (!SetPhotSelections (&argc, argv, 3)) goto usage;
     35
     36  /* interpret command-line options */
    4437  if (argc != 6) { goto usage; }
    4538  if (strcmp (argv[2], "-")) goto usage;
    4639  if (strcmp (argv[4], ":")) goto usage;
    47 
    48   /* interpret command-line options */
    4940  if (!GetPhotcodeInfo (argv[1], &code[0], &mode[0])) return (FALSE);
    5041  if (!GetPhotcodeInfo (argv[3], &code[1], &mode[1])) return (FALSE);
    5142  if (!GetPhotcodeInfo (argv[5], &code[2], &mode[2])) return (FALSE);
     43  if (!TestPhotSelections (&code[0], MEAS_ZERO)) goto escape;
    5244
    53   /* determine region-file names */
    54   if (CPTfile == NULL) {
    55     float Radius;
    56     Radius = MAX (fabs(graphsky.xmax), fabs(graphsky.ymax));
    57     regions = find_regions (graphsky.coords.crval1, graphsky.coords.crval2, Radius, &Nregions);
    58   } else {
    59     Nregions = 1;
    60     ALLOCATE (regions, RegionFile, 1);
    61     strcpy (regions[0].name, CPTfile);
    62   }
     45  /* load region corresponding to selection above */
     46  if ((regions = SelectRegions (RegionName, RegionList, &Nregions)) == NULL) goto escape;
    6347
    6448  /* init vectors to save data */
     
    9074      m = catalog.average[i].offset;
    9175
     76      SetSelectionParam (0);
    9277      M1 = ExtractDMag (code, mode, &catalog.average[i], &catalog.secfilt[i*Nsec], &catalog.measure[m], &N1);
    9378      if (N1 == 0) goto skip;
    9479
     80      SetSelectionParam (2);
    9581      M3 = ExtractMagnitudes (code[2], mode[2], &catalog.average[i], &catalog.secfilt[i*Nsec], &catalog.measure[m], &N3);
    9682      if (N3 == 0) goto skip;
     
    10187          yvec[0].elements[Npts] = M3[i3];
    10288          Npts++;
    103           if (Npts == NPTS) {
     89          if (Npts >= NPTS) {
    10490            NPTS += 2000;
    10591            REALLOCATE (xvec[0].elements, float, NPTS);
     
    132118  if (catalog.secfilt != NULL) free (catalog.secfilt);
    133119  if (catalog.measure != NULL) free (catalog.measure);
     120  if (RegionName != NULL) free (RegionName);
     121  if (RegionList != NULL) free (RegionList);
    134122  return (FALSE);
    135123}
Note: See TracChangeset for help on using the changeset viewer.