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

    r4470 r4585  
    33int ccd (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], *CPTfile;
     5  char filename[256], catdir[256], *RegionName, *RegionList;
    126  double Radius;
    137  double *M1, *M2;
    148  int i, m, k, Npts, NPTS, N;
    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;
     22  RegionName = NULL;
     23  RegionList = NULL;
    2324
    2425  /* load photcode information */
     
    2627  Nsec = GetPhotcodeNsecfilt ();
    2728
    28   /* load data about plot windows */
    29   Ngraph = 0;
    30   if (!GetGraphData (&graphsky, NULL, &Ngraph)) return (FALSE);
    31  
    3229  /* find CATDIR in config system */
    33   VarConfig ("CATDIR", "%s", catdir);
    34 
    35   /* check for CPT selection */
    36   CPTfile = NULL;
    37   if (N = get_argument (argc, argv, "-cpt")) {
    38     remove_argument (N, &argc, argv);
    39     CPTfile = strcreate (argv[N]);
    40     remove_argument (N, &argc, argv);
    41   }   
     30  if (VarConfig ("CATDIR", "%s", catdir) == NULL) goto escape;
    4231
    4332  /* interpret command-line options */
    44   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 */
    4537  if (argc != 8) goto usage;
    4638  if (strcmp (argv[2], "-")) goto usage;
    4739  if (strcmp (argv[4], ":")) goto usage;
    4840  if (strcmp (argv[6], "-")) goto usage;
    49 
    50   /* interpret command-line options */
    5141  if (!GetPhotcodeInfo (argv[1], &code[0], &mode[0])) return (FALSE);
    5242  if (!GetPhotcodeInfo (argv[3], &code[1], &mode[1])) return (FALSE);
    5343  if (!GetPhotcodeInfo (argv[5], &code[2], &mode[2])) return (FALSE);
    5444  if (!GetPhotcodeInfo (argv[7], &code[3], &mode[3])) return (FALSE);
    55   if ((mode[2] == MAG_AVE) || (mode[2] == MAG_REF)) UseAverages = TRUE;
     45  if (!TestPhotSelections (&code[0], MEAS_ZERO)) goto escape;
    5646
    57   /* determine region-file names */
    58   if (CPTfile == NULL) {
    59     float Radius;
    60     Radius = MAX (fabs(graphsky.xmax), fabs(graphsky.ymax));
    61     regions = find_regions (graphsky.coords.crval1, graphsky.coords.crval2, Radius, &Nregions);
    62   } else {
    63     Nregions = 1;
    64     ALLOCATE (regions, RegionFile, 1);
    65     strcpy (regions[0].name, CPTfile);
    66   }
     47  /* load region corresponding to selection above */
     48  if ((regions = SelectRegions (RegionName, RegionList, &Nregions)) == NULL) goto escape;
    6749
    6850  /* init vectors to save data */
     
    9476      m = catalog.average[i].offset;
    9577
     78      SetSelectionParam (0);
    9679      M1 = ExtractDMag (&code[0], &mode[0], &catalog.average[i], &catalog.secfilt[i*Nsec], &catalog.measure[m], &N1);
    9780      if (N1 == 0) goto skip;
    9881
     82      SetSelectionParam (2);
    9983      M2 = ExtractDMag (&code[2], &mode[2], &catalog.average[i], &catalog.secfilt[i*Nsec], &catalog.measure[m], &N2);
    10084      if (N2 == 0) goto skip;
     
    10589          yvec[0].elements[Npts] = M2[i2];
    10690          Npts++;
    107           if (Npts == NPTS) {
     91          if (Npts >= NPTS) {
    10892            NPTS += 2000;
    10993            REALLOCATE (xvec[0].elements, float, NPTS);
     
    128112
    129113usage:
    130   fprintf (stderr, "USAGE: ccd F - F : measure.param\n");
     114  fprintf (stderr, "USAGE: ccd F - F : F - F\n");
    131115  return (FALSE);
    132116
     
    136120  if (catalog.secfilt != NULL) free (catalog.secfilt);
    137121  if (catalog.measure != NULL) free (catalog.measure);
     122  if (RegionName != NULL) free (RegionName);
     123  if (RegionList != NULL) free (RegionList);
    138124  return (FALSE);
    139125}
Note: See TracChangeset for help on using the changeset viewer.