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

    r3462 r4585  
    66int calmextract (int argc, char **argv) {
    77 
     8  int i, j, k, m, N, N1, Nr, mode[2];
     9  int NSTAR, Nstar, Nsec, Nregions;
     10  char filename[256], catdir[256], *RegionName, *RegionList;
     11  double *M1, M2, dM2, color, Radius;
     12
    813  Catalog catalog;
    9   Graphdata graphsky;
    1014  RegionFile *regions;
    1115  PhotCode *code[2];
    1216  Vector **vec;
    13 
    14   int i, j, k, m, N, N1, Nr, mode[2];
    15   int Ngraph, NSTAR, Nstar, Nsec, Nregions, RegionList;
    16   char filename[256], catdir[256], RegionListFile[256];
    17   double *M1, M2, dM2, color, Radius;
    1817
    1918  /* these need to be freed in the end */
     
    2221  catalog.secfilt = NULL;
    2322  catalog.measure = NULL;
     23  RegionName = NULL;
     24  RegionList = NULL;
    2425
    2526  /* load photcode information */
    26   if (!InitPhotcodes ()) return (FALSE);
     27  if (!InitPhotcodes ()) goto escape;
    2728  Nsec = GetPhotcodeNsecfilt ();
    2829
    29   /* load data about plot windows */
    30   Ngraph = 0;
    31   if (!GetGraphData (&graphsky, NULL, &Ngraph)) goto escape;
    32 
    3330  /* find CATDIR in config system */
    34   VarConfig ("CATDIR", "%s", catdir);
    35 
    36   /* specify catalog files */
    37   RegionList = FALSE;
    38   if (N = get_argument (argc, argv, "-list")) {
    39     RegionList = TRUE;
    40     remove_argument (N, &argc, argv);
    41     strcpy (RegionListFile, argv[N]);
    42     remove_argument (N, &argc, argv);
    43   }
     31  if (VarConfig ("CATDIR", "%s", catdir) == NULL) goto escape;
    4432
    4533  /* command line arguments */
    46   if (!SetPhotSelections (&argc, argv)) goto usage;
     34  if (!SetRegionSelection (&argc, argv, &RegionName, &RegionList)) goto escape;
     35  if (!SetPhotSelections (&argc, argv, 2)) goto usage;
     36
     37  /* interpret required command-line arguments: calmextract F1 - F2 */
    4738  if (argc != 4) goto usage;
    4839  if (strcmp (argv[2], "-")) goto usage;
    4940  if (!GetPhotcodeInfo (argv[1], &code[0], &mode[0])) goto usage;
    5041  if (!GetPhotcodeInfo (argv[3], &code[1], &mode[1])) goto usage;
    51   /* code.type must be PHOT_REF */
    52 
    53   /* test PhotSelections: is photcode specified if needed? */
    54   if (!TestPhotSelections (&code)) {
    55     fprintf (stderr, "photcode selection rules violated\n");
    56     fprintf (stderr, "average and ensemble restrictions require a corresponding photcode\n");
    57     goto escape;
    58   }
    59 
     42  if (!TestPhotSelections (&code[0], MEAS_ZERO)) goto escape;
    6043
    6144  /* returned vectors are dmag, mag, color, time, airmass, ra, dec, x, y, exptime */
     
    8669  }
    8770
    88   /* select region files */
    89   if (RegionList) {
    90     regions = region_list (RegionListFile, &Nregions);
    91     if (!SetImageSelection (MEAS_XMOSAIC, NULL, FALSE)) goto escape;
    92   } else {
    93     Radius = MAX (fabs(graphsky.xmax), fabs(graphsky.ymax));
    94     regions = find_regions (graphsky.coords.crval1, graphsky.coords.crval2, Radius, &Nregions);
    95     if (!SetImageSelection (MEAS_XMOSAIC, &graphsky, TRUE)) goto escape;
    96   }
     71  /* load region corresponding to selection above */
     72  if ((regions = SelectRegions (RegionName, RegionList, &Nregions)) == NULL) goto escape;
     73  if (!SetImageSelection (MEAS_XMOSAIC)) goto escape;
    9774
    9875  for (Nr = 0; Nr < Nregions; Nr++) {
     
    177154    vec[i][0].Nelements = N;
    178155  }
     156  FreeImageSelection ();
    179157  return (TRUE);
    180158 
     
    185163 escape:
    186164 
     165  FreeImageSelection ();
    187166  if (regions != NULL) free (regions); 
    188167  for (i = 0; i < NVEC; i++) {
Note: See TracChangeset for help on using the changeset viewer.