IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 4585


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

substantial cleanup of photometry extraction functions

Location:
trunk/Ohana/src/opihi
Files:
1 added
18 edited

Legend:

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

    r3462 r4585  
    22
    33void image_subset (Image *image, int Nimage, int **Subset, int *Nsubset,
    4               Graphdata *graph, int RegionSelect,
    5               unsigned long int tzero, double trange, int TimeSelect)
     4                   Graphdata *graph, int RegionSelect,
     5                   unsigned long int tzero, double trange, int TimeSelect)
    66{
    77
  • trunk/Ohana/src/opihi/dvo/Makefile

    r3688 r4585  
    2828$(SDIR)/init.$(ARCH).o                  \
    2929$(SDIR)/ImageOps.$(ARCH).o              \
     30$(SDIR)/ImageSelection.$(ARCH).o        \
    3031$(SDIR)/LoadImages.$(ARCH).o            \
    3132$(SDIR)/aregion.$(ARCH).o               \
  • trunk/Ohana/src/opihi/dvo/avextract.c

    r4420 r4585  
    33int avextract (int argc, char **argv) {
    44 
     5  int i, j, m, N, NPTS, param;
     6  int Ngraph, Nsec, Nregions, mode;
     7  char filename[256], catdir[256], *RegionName, *RegionList, *p;
     8
    59  Catalog catalog;
    6   Graphdata graphsky;
    710  RegionFile *regions;
    811  PhotCode *code;
    912  Vector *vec;
    1013
    11   char filename[256], catdir[256], *p;
    12   int i, j, m, N, NPTS, param;
    13   int Ngraph, Nsec, Nregions, mode;
    14 
     14  /* defaults */
    1515  regions = NULL;
    1616  catalog.average = NULL;
    1717  catalog.secfilt = NULL;
    1818  catalog.measure = NULL;
     19  RegionName = NULL;
     20  RegionList = NULL;
     21  code = NULL;
     22  mode = MAG_AVE;
    1923
    2024  /* load photcode information */
     
    2226  Nsec = GetPhotcodeNsecfilt ();
    2327
    24   /* load data about plot windows */
    25   Ngraph = 0;
    26   if (!GetGraphData (&graphsky, NULL, &Ngraph)) goto escape;
    27  
    2828  /* find CATDIR in config system */
    29   VarConfig ("CATDIR", "%s", catdir);
    30 
    31   /* grab value of photcode, if available */
    32   code = NULL;
    33   mode = MAG_AVE;
    34   if (N = get_argument (argc, argv, "-photcode")) {
    35     remove_argument (N, &argc, argv);
    36     code = GetPhotcodebyName (argv[N]);
    37     if (code == NULL) {
    38       fprintf (stderr, "photcode not found in photcode table\n");
    39       goto usage;
    40     }
    41     remove_argument (N, &argc, argv);
    42   }
     29  if (VarConfig ("CATDIR", "%s", catdir) == NULL) goto escape;
    4330
    4431  /* interpret command-line options */
    45   if (!SetPhotSelections (&argc, argv)) goto usage;
    46   if (argc != 3) { goto usage; }
     32  SetSelectionParam (0);
     33  if (!SetRegionSelection (&argc, argv, &RegionName, &RegionList)) goto escape;
     34  if (!SetPhotSelections (&argc, argv, 1)) goto usage;
    4735
    48   /* identify selection */
    49   param = GetAverageParam (argv[2]);
     36  /* interpret required command-line arguments: mextract (value) */
     37  if (argc != 2) { goto usage; }
     38  param = GetAverageParam (argv[1]);
    5039  if (param == AVE_ZERO) {
    51     if (!GetPhotcodeInfo (argv[2], &code, &mode)) {
     40    if (!GetPhotcodeInfo (argv[1], &code, &mode)) {
    5241      GetAverageParamHelp ();
    5342      goto escape;
    5443    }
    5544    param = AVE_MAG;
    56     for (p = argv[2]; *p != 0; p++) {
     45    for (p = argv[1]; *p != 0; p++) {
    5746      if (*p == '.') *p = ':';
    5847    }
    5948  }
    60   if ((vec = SelectVector (argv[2], ANYVECTOR, TRUE)) == NULL) goto escape;
     49  if (!TestPhotSelections (&code, param)) goto escape;
    6150
    62   /* Need valid code for some params: */
    63   switch (param) {
    64     case AVE_MAG:
    65     case AVE_dMAG:
    66     case AVE_Xm:
    67     case AVE_TYPE:
    68     case AVE_NCODE:
    69     case AVE_NPHOT:
    70       if (code == NULL) goto escape;
    71       if (code[0].type == PHOT_DEP) goto escape;
    72       if (code[0].type == PHOT_REF) goto escape;
    73       break;
    74     default:
    75       break;
    76   }
    77 
    78   /* determine region-file names */
    79   if (!strcmp (argv[1], "all")) {
    80     float Radius;
    81     Radius = MAX (fabs(graphsky.xmax), fabs(graphsky.ymax));
    82     regions = find_regions (graphsky.coords.crval1, graphsky.coords.crval2, Radius, &Nregions);
    83     if (!SetImageSelection (param, &graphsky, TRUE)) goto escape;
    84     /* this is not really used by avextract -- no parameters require images */
    85   } else {
    86     Nregions = 1;
    87     ALLOCATE (regions, RegionFile, 1);
    88     strcpy (regions[0].name, argv[1]);
    89     if (!SetImageSelection (param, NULL, FALSE)) goto escape;
    90   }
     51  /* load region corresponding to selection above */
     52  if ((regions = SelectRegions (RegionName, RegionList, &Nregions)) == NULL) goto escape;
    9153
    9254  /* create storage vector */
    9355  N = 0;
    94   NPTS = 1000;
    95   REALLOCATE (vec[0].elements, float, NPTS);
     56  NPTS = 1;
     57  if ((vec = SelectVector (argv[1], ANYVECTOR, TRUE)) == NULL) goto escape;
    9658
    9759  for (i = 0; i < Nregions; i++) {
     
    11577      vec[0].elements[N] = ExtractAverages (code, mode, &catalog.average[j], &catalog.secfilt[j*Nsec], &catalog.measure[m], param);
    11678      N++;
    117       if (N == NPTS - 1) {
    118         NPTS += 2000;
    119         REALLOCATE (vec[0].elements, float, NPTS);
    120       }
     79      CHECK_REALLOCATE (vec[0].elements, float, NPTS, N, 2000);
    12180    }
    12281    if (catalog.average != NULL) free (catalog.average);
     
    13190
    13291  if (regions != NULL) free (regions);
    133   FreeImageSelection ();
    13492  return (TRUE);
    13593
    13694usage:
    137   fprintf (stderr, "USAGE: avextract (from) (value) [options]\n");
    138   fprintf (stderr, "  from: cpt name or 'all'\n");
     95  fprintf (stderr, "USAGE: avextract (value) [options]\n");
    13996  fprintf (stderr, "  value: average.parameter or photcode\n");
    140   return (FALSE);
    14197
    14298escape:
    143   fprintf (stderr, "error in avextract\n");
    14499  if (regions != NULL) free (regions);
    145   FreeImageSelection ();
    146100  if (catalog.average != NULL) free (catalog.average);
    147101  if (catalog.secfilt != NULL) free (catalog.secfilt);
    148102  if (catalog.measure != NULL) free (catalog.measure);
     103  if (RegionName != NULL) free (RegionName);
     104  if (RegionList != NULL) free (RegionList);
    149105  return (FALSE);
    150106}
  • trunk/Ohana/src/opihi/dvo/calextract.c

    r3689 r4585  
    55int calextract (int argc, char **argv) {
    66 
     7  int i, j, m, N, Nr, Nregions, mode[2];
     8  int Nsec, NSTAR;
     9  char filename[256], catdir[256], *RegionName, *RegionList;
     10  double Radius, M1, M2, dM2, color;
     11
    712  Catalog catalog;
    8   Graphdata graphsky;
    913  RegionFile *regions;
    1014  PhotCode *code[2];
    1115  Vector **vec;
    12 
    13   int i, j, m, N, Nr, Nregions, mode[2];
    14   int RegionList, Ngraph, Nsec, NSTAR;
    15   char filename[256], catdir[256], RegionListFile[256];
    16   double Radius, M1, M2, dM2, color;
    1716
    1817  /* these need to be freed in the end */
     
    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)) goto escape;
    31 
    3229  /* find CATDIR in config system */
    33   VarConfig ("CATDIR", "%s", catdir);
    34 
    35   /* specify catalog files */
    36   RegionList = FALSE;
    37   if (N = get_argument (argc, argv, "-list")) {
    38     RegionList = TRUE;
    39     remove_argument (N, &argc, argv);
    40     strcpy (RegionListFile, argv[N]);
    41     remove_argument (N, &argc, argv);
    42   }
     30  if (VarConfig ("CATDIR", "%s", catdir) == NULL) goto escape;
    4331
    4432  /* command line arguments */
    45   if (!SetPhotSelections (&argc, argv)) goto usage;
     33  SetSelectionParam (0);
     34  if (!SetRegionSelection (&argc, argv, &RegionName, &RegionList)) goto escape;
     35  if (!SetPhotSelections (&argc, argv, 2)) goto usage;
     36
    4637  if (argc != 4) goto usage;
    4738  if (strcmp (argv[2], "-")) goto usage;
     
    6657  if ((vec[Nd2] = SelectVector ("cal:dm2",      ANYVECTOR, TRUE)) == NULL) goto escape;
    6758
    68   /* select region files */
    69   if (RegionList) {
    70     regions = region_list (RegionListFile, &Nregions);
    71   } else {
    72     Radius = MAX (fabs(graphsky.xmax), fabs(graphsky.ymax));
    73     regions = find_regions (graphsky.coords.crval1, graphsky.coords.crval2, Radius, &Nregions);
    74   }
     59  /* load region corresponding to selection above */
     60  if ((regions = SelectRegions (RegionName, RegionList, &Nregions)) == NULL) goto escape;
    7561
    7662  for (Nr = 0; Nr < Nregions; Nr++) {
     
    150136 escape:
    151137 
     138  if (RegionName != NULL) free (RegionName);
     139  if (RegionList != NULL) free (RegionList);
    152140  if (regions != NULL) free (regions); 
    153141  for (i = 0; i < NVEC; i++) {
  • 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++) {
  • 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}
  • 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}
  • 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}
  • trunk/Ohana/src/opihi/dvo/dmagaves.c

    r4470 r4585  
    33int dmagaves (int argc, char **argv) {
    44 
    5   Catalog catalog;
    6   Graphdata graphsky;
    7   RegionFile *regions;
    8   PhotCode *code[3];
    9   Vector *xvec, *yvec;
    10 
    11   char filename[256], catdir[256], *CPTfile;
     5  char filename[256], catdir[256], *RegionName, *RegionList;
    126  double Radius, *M1, M2;
    137  int i, j, k, m, N1, N;
    148  int Npts, NPTS, param, mode[3];
    159  int Ngraph, Nsec, Nregions;
     10
     11  Catalog catalog;
     12  RegionFile *regions;
     13  PhotCode *code[3];
     14  Vector *xvec, *yvec;
    1615
    1716  /* defaults */
     
    2019  catalog.secfilt = NULL;
    2120  catalog.measure = NULL;
     21  RegionName = NULL;
     22  RegionList = NULL;
    2223
    2324  /* load photcode information */
     
    2526  Nsec = GetPhotcodeNsecfilt ();
    2627
    27   /* load data about plot windows */
    28   Ngraph = 0;
    29   if (!GetGraphData (&graphsky, NULL, &Ngraph)) return (FALSE);
    30  
    3128  /* 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   }   
     29  if (VarConfig ("CATDIR", "%s", catdir) == NULL) goto escape;
    4130
    4231  /* interpret command-line options */
    43   if (!SetPhotSelections (&argc, argv)) goto usage;
     32  if (!SetRegionSelection (&argc, argv, &RegionName, &RegionList)) goto escape;
     33  if (!SetPhotSelections (&argc, argv, 3)) goto usage;
     34
     35  /* interpret command-line options: dmagaves F1 - F2 : (value) */
    4436  if (argc != 6) { goto usage; }
    4537  if (strcmp (argv[2], "-")) goto usage;
    4638  if (strcmp (argv[4], ":")) goto usage;
     39  if (!GetPhotcodeInfo (argv[1], &code[0], &mode[0])) goto usage;
     40  if (!GetPhotcodeInfo (argv[3], &code[1], &mode[1])) goto usage;
     41  if ((param = GetAverageParam (argv[5])) == AVE_ZERO) goto usage;
     42  if (!TestPhotSelections (&code[2], param)) goto escape;
    4743
    48   /* interpret command-line options */
    49   if (!GetPhotcodeInfo (argv[1], &code[0], &mode[0])) return (FALSE);
    50   if (!GetPhotcodeInfo (argv[3], &code[1], &mode[1])) return (FALSE);
    51   if ((param = GetAverageParam (argv[5])) == AVE_ZERO) {
    52     GetAverageParamHelp ();
    53     return (FALSE);
    54   }
    55   code[2] = GetPhotcodeEquivbyCode (code[0][0].code);
    56   mode[2] = mode[0];
    57 
    58   /* test PhotSelections: is photcode specified if needed? */
    59   for (i = 0; i < 3; i++) {
    60     if (!TestPhotSelections (&code[i])) {
    61       fprintf (stderr, "photcode selection rules violated\n");
    62       fprintf (stderr, "average and ensemble restrictions require a corresponding photcode\n");
    63       goto escape;
    64     }
    65   }
    66 
    67   /* determine region-file names */
    68   if (CPTfile == NULL) {
    69     float Radius;
    70     Radius = MAX (fabs(graphsky.xmax), fabs(graphsky.ymax));
    71     regions = find_regions (graphsky.coords.crval1, graphsky.coords.crval2, Radius, &Nregions);
    72   } else {
    73     Nregions = 1;
    74     ALLOCATE (regions, RegionFile, 1);
    75     strcpy (regions[0].name, CPTfile);
    76   }
     44  /* load region corresponding to selection above */
     45  if ((regions = SelectRegions (RegionName, RegionList, &Nregions)) == NULL) goto escape;
    7746
    7847  /* init vectors to save data */
     
    10372      m = catalog.average[i].offset;
    10473
     74      SetSelectionParam (0);
    10575      M1 = ExtractDMag (code, mode, &catalog.average[i], &catalog.secfilt[i*Nsec], &catalog.measure[m], &N1);
    10676      if (N1 == 0) goto skip;
    10777
     78      SetSelectionParam (2);
    10879      M2 = ExtractAverages (code[2], mode[2], &catalog.average[i], &catalog.secfilt[i*Nsec], &catalog.measure[m], param);
    10980
     
    11283        yvec[0].elements[Npts] = M2;
    11384        Npts++;
    114         if (Npts == NPTS) {
     85        if (Npts >= NPTS) {
    11586          NPTS += 2000;
    11687          REALLOCATE (xvec[0].elements, float, NPTS);
     
    12899    catalog.measure = (Measure *) NULL;
    129100  }
    130   FreeImageSelection ();
    131101  if (regions != NULL) free (regions);
    132102  xvec[0].Nelements = yvec[0].Nelements = Npts;
     
    138108
    139109escape:
    140   FreeImageSelection ();
    141110  if (regions != NULL) free (regions);
    142111  if (catalog.average != NULL) free (catalog.average);
    143112  if (catalog.secfilt != NULL) free (catalog.secfilt);
    144113  if (catalog.measure != NULL) free (catalog.measure);
     114  if (RegionName != NULL) free (RegionName);
     115  if (RegionList != NULL) free (RegionList);
    145116  return (FALSE);
    146117}
  • trunk/Ohana/src/opihi/dvo/dmagmeas.c

    r4470 r4585  
    11# include "dvo1.h"
    2 double *ExtractByDMag (PhotCode **code, int *mode, Average *average, SecFilt *secfilt, Measure *measure, int *nlist, int param);
    32
    43int dmagmeas (int argc, char **argv) {
    54 
     5  char filename[256], catdir[256], *RegionName, *RegionList;
     6  double Radius, *M1, *M3;
     7  int i, j, k, m, i1, i3, N1, N3, N;
     8  int Npts, NPTS, param, mode[3];
     9  int Ngraph, Nsec, Nregions;
     10
    611  Catalog catalog;
    7   Graphdata graphsky;
    812  RegionFile *regions;
    913  PhotCode *code[3];
    1014  Vector *xvec, *yvec;
    11 
    12   char filename[256], catdir[256], *CPTfile;
    13   double Radius, *M1, *M3;
    14   int i, j, k, m, N1, N3, N;
    15   int Npts, NPTS, param, mode[3];
    16   int Ngraph, Nsec, Nregions;
    1715
    1816  /* defaults */
     
    2119  catalog.secfilt = NULL;
    2220  catalog.measure = NULL;
     21  RegionName = NULL;
     22  RegionList = NULL;
    2323
    2424  /* load photcode information */
     
    2626  Nsec = GetPhotcodeNsecfilt ();
    2727
    28   /* load data about plot windows */
    29   Ngraph = 0;
    30   if (!GetGraphData (&graphsky, NULL, &Ngraph)) return (FALSE);
    31  
    3228  /* 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   }   
     29  if (VarConfig ("CATDIR", "%s", catdir) == NULL) goto escape;
    4230
    4331  /* interpret command-line options */
    44   if (!SetPhotSelections (&argc, argv)) goto usage;
     32  if (!SetRegionSelection (&argc, argv, &RegionName, &RegionList)) goto escape;
     33  if (!SetPhotSelections (&argc, argv, 3)) goto usage;
     34
     35  /* interpret command-line arguments: dmagmeas F1 - F2 : (value) */
    4536  if (argc != 6) { goto usage; }
    4637  if (strcmp (argv[2], "-")) goto usage;
    4738  if (strcmp (argv[4], ":")) goto usage;
    48 
    49   /* interpret command-line options */
    5039  if (!GetPhotcodeInfo (argv[1], &code[0], &mode[0])) goto usage;
    5140  if (!GetPhotcodeInfo (argv[3], &code[1], &mode[1])) goto usage;
    5241  if ((param = GetMeasureParam (argv[5])) == MEAS_ZERO) goto usage;
     42  if (!TestPhotSelections (&code[2], MEAS_ZERO)) goto escape;
    5343
    54   /* test PhotSelections: is photcode specified if needed? */
    55   for (i = 0; i < 2; i++) {
    56     if (!TestPhotSelections (&code[i])) {
    57       fprintf (stderr, "photcode selection rules violated\n");
    58       fprintf (stderr, "average and ensemble restrictions require a corresponding photcode\n");
    59       goto escape;
    60     }
    61   }
    62 
    63   /* determine region-file names */
    64   if (CPTfile == NULL) {
    65     float Radius;
    66     Radius = MAX (fabs(graphsky.xmax), fabs(graphsky.ymax));
    67     regions = find_regions (graphsky.coords.crval1, graphsky.coords.crval2, Radius, &Nregions);
    68   } else {
    69     Nregions = 1;
    70     ALLOCATE (regions, RegionFile, 1);
    71     strcpy (regions[0].name, CPTfile);
    72   }
    73   if (!SetImageSelection (param, &graphsky, TRUE)) return (FALSE);
     44  /* load region corresponding to selection above */
     45  if ((regions = SelectRegions (RegionName, RegionList, &Nregions)) == NULL) goto escape;
     46  if (!SetImageSelection (param)) goto escape;
    7447
    7548  /* init vectors to save data */
     
    10174      m = catalog.average[i].offset;
    10275
     76      SetSelectionParam (0);
    10377      M1 = ExtractDMag (code, mode, &catalog.average[i], &catalog.secfilt[i*Nsec], &catalog.measure[m], &N1);
    10478      if (N1 == 0) goto skip;
    10579
    106       M3 = ExtractByDMag (code, mode, &catalog.average[i], &catalog.secfilt[i*Nsec], &catalog.measure[m], &N3, param);
    107       if (N3 != N1) { fprintf (stderr, "mismatch: programming error\n"); goto escape; }
     80      SetSelectionParam (2);
     81      M3 = ExtractMeasures (code[2], mode[2], &catalog.average[i], &catalog.secfilt[i*Nsec], &catalog.measure[m], &N3, param);
     82      if (N3 == 0) goto skip;
    10883
    109       for (k = 0; k < N1; k++) {
    110         xvec[0].elements[Npts] = M1[k];
    111         yvec[0].elements[Npts] = M3[k];
    112         Npts++;
    113         if (Npts == NPTS) {
    114           NPTS += 2000;
    115           REALLOCATE (xvec[0].elements, float, NPTS);
    116           REALLOCATE (yvec[0].elements, float, NPTS);
     84      for (i1 = 0; i1 < N1; i1++) {
     85        for (i3 = 0; i3 < N3; i3++) {
     86          xvec[0].elements[Npts] = M1[i1];
     87          yvec[0].elements[Npts] = M3[i3];
     88          Npts++;
     89          if (Npts >= NPTS) {
     90            NPTS += 2000;
     91            REALLOCATE (xvec[0].elements, float, NPTS);
     92            REALLOCATE (yvec[0].elements, float, NPTS);
     93          }
    11794        }
    11895      }
     
    143120  if (catalog.secfilt != NULL) free (catalog.secfilt);
    144121  if (catalog.measure != NULL) free (catalog.measure);
     122  if (RegionName != NULL) free (RegionName);
     123  if (RegionList != NULL) free (RegionList);
    145124  return (FALSE);
    146125}
  • trunk/Ohana/src/opihi/dvo/dmags.c

    r4470 r4585  
    33int dmags (int argc, char **argv) {
    44 
    5   Catalog catalog;
    6   Graphdata graphsky;
    7   RegionFile *regions;
    8   PhotCode *code[3];
    9   Vector *xvec, *yvec;
    10 
    11   char filename[256], catdir[256], *CPTfile;
     5  char filename[256], catdir[256], *RegionName, *RegionList;
    126  double Radius, *M1, *M3;
    137  int i, j, m, i1, i3, N1, N3, N;
    148  int Npts, NPTS, mode[3];
    15   int Ngraph, Nsec, Nregions;
     9  int Nsec, Nregions;
     10
     11  PhotCode *code[3];
     12  Catalog catalog;
     13  RegionFile *regions;
     14  Vector *xvec, *yvec;
    1615
    1716  /* defaults */
     
    2019  catalog.secfilt = NULL;
    2120  catalog.measure = NULL;
     21  RegionName = NULL;
     22  RegionList = NULL;
    2223
    2324  /* load photcode information */
     
    2526  Nsec = GetPhotcodeNsecfilt ();
    2627
    27   /* load data about plot windows */
    28   Ngraph = 0;
    29   if (!GetGraphData (&graphsky, NULL, &Ngraph)) return (FALSE);
    30  
    3128  /* 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   }   
     29  if (VarConfig ("CATDIR", "%s", catdir) == NULL) goto escape;
    4130
    4231  /* interpret command-line options */
    43   if (!SetPhotSelections (&argc, argv)) goto usage;
     32  if (!SetRegionSelection (&argc, argv, &RegionName, &RegionList)) goto escape;
     33  if (!SetPhotSelections (&argc, argv, 3)) goto usage;
     34
     35  /* interpret required command-line arguments: dmags F1 - F2 : F3 */
    4436  if (argc != 6) { goto usage; }
    4537  if (strcmp (argv[2], "-")) goto usage;
    4638  if (strcmp (argv[4], ":")) goto usage;
    47 
    48   /* interpret command-line options */
    4939  if (!GetPhotcodeInfo (argv[1], &code[0], &mode[0])) goto usage;
    5040  if (!GetPhotcodeInfo (argv[3], &code[1], &mode[1])) goto usage;
    5141  if (!GetPhotcodeInfo (argv[5], &code[2], &mode[2])) goto usage;
     42  if (!TestPhotSelections (&code[0], MEAS_ZERO)) goto escape;
    5243
    53   /* test PhotSelections: is photcode specified if needed? */
    54   for (i = 0; i < 3; i++) {
    55     if (!TestPhotSelections (&code[i])) {
    56       fprintf (stderr, "photcode selection rules violated\n");
    57       fprintf (stderr, "average and ensemble restrictions require a corresponding photcode\n");
    58       goto escape;
    59     }
    60   }
    61 
    62   /* determine region-file names */
    63   if (CPTfile == NULL) {
    64     float Radius;
    65     Radius = MAX (fabs(graphsky.xmax), fabs(graphsky.ymax));
    66     regions = find_regions (graphsky.coords.crval1, graphsky.coords.crval2, Radius, &Nregions);
    67   } else {
    68     Nregions = 1;
    69     ALLOCATE (regions, RegionFile, 1);
    70     strcpy (regions[0].name, CPTfile);
    71   }
     44  /* load region corresponding to selection above */
     45  if ((regions = SelectRegions (RegionName, RegionList, &Nregions)) == NULL) goto escape;
    7246
    7347  /* init vectors to save data */
     
    9973      m = catalog.average[i].offset;
    10074
     75      SetSelectionParam (0);
    10176      M1 = ExtractDMag (code, mode, &catalog.average[i], &catalog.secfilt[i*Nsec], &catalog.measure[m], &N1);
    10277      if (N1 == 0) goto skip;
    10378
     79      SetSelectionParam (2);
    10480      M3 = ExtractMagnitudes (code[2], mode[2], &catalog.average[i], &catalog.secfilt[i*Nsec], &catalog.measure[m], &N3);
    10581      if (N3 == 0) goto skip;
     
    11086          yvec[0].elements[Npts] = M3[i3];
    11187          Npts++;
    112           if (Npts == NPTS) {
     88          if (Npts >= NPTS) {
    11389            NPTS += 2000;
    11490            REALLOCATE (xvec[0].elements, float, NPTS);
     
    134110usage:
    135111  fprintf (stderr, "USAGE: dmags F - F : F\n");
    136   fprintf (stderr, "  F : any photcodes with matched qualifiers:\n");
     112  fprintf (stderr, "    F : any photcodes with matched qualifiers:\n");
    137113  fprintf (stderr, "    pri: F:inst, F:cat, F:sys, F:rel, F:cal, F:ave, F:ref\n");
    138114  fprintf (stderr, "    sec: F:inst, F:cat, F:sys, F:rel, F:cal, F:ave, F:ref\n");
    139115  fprintf (stderr, "    dep: F:inst, F:cat, F:sys, F:rel, F:cal\n");
    140116  fprintf (stderr, "    ref: F:cat\n");
    141   return (FALSE);
    142117
    143118escape:
     
    146121  if (catalog.secfilt != NULL) free (catalog.secfilt);
    147122  if (catalog.measure != NULL) free (catalog.measure);
     123  if (RegionName != NULL) free (RegionName);
     124  if (RegionList != NULL) free (RegionList);
    148125  return (FALSE);
    149126}
  • trunk/Ohana/src/opihi/dvo/elixir.c

    r3648 r4585  
    129129
    130130  mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
    131   chmod (f, mode);
     131  chmod (fifo, mode);
    132132  fclearlockfile (fifo, f, LCK_XCLD, &state);
    133133
  • trunk/Ohana/src/opihi/dvo/fitcolors.c

    r3688 r4585  
    1313  int i, k, m, NP1, NP2, NP, Np, Npts, NPTS;
    1414  int N1, N2, i1, i2, mode[4];
    15   int Nsec, Ngraph, Nregions, Ncatalog, status;
    16   char catdir[256], filename[256];
     15  int Nsec, Nregions, Ncatalog, status;
     16  char catdir[256], filename[256], *RegionName, *RegionList;
    1717  char *cmd, *outcmd, *camera;
    1818  double Radius;
    1919  double *M1, *M2;
    2020  float *out;
     21
    2122  Catalog *catalog;
    22   Graphdata graphsky;
    2323  RegionFile *regions;
    2424  PhotCode **codelist, *tcode, *code[4];
     
    3232  xvec = yvec = NULL;
    3333
    34   /* find CATDIR in config system */
    35   VarConfig ("CATDIR", "%s", catdir);
    36 
    3734  /* load photcode information */
    3835  if (!InitPhotcodes ()) goto escape;
    3936  Nsec = GetPhotcodeNsecfilt ();
    4037
    41   /*** determine appropriate catalog files (find_regions) ***/
    42   /* load data about plot windows */
    43   Ngraph = 0;
    44   if (!GetGraphData (&graphsky, NULL, &Ngraph)) return (FALSE);
    45   /* find catalog files which overlap this region */
    46   Radius = MAX (fabs(graphsky.xmax), fabs(graphsky.ymax));
    47   regions = find_regions (graphsky.coords.crval1, graphsky.coords.crval2, Radius, &Nregions);
     38  /* find CATDIR in config system */
     39  if (VarConfig ("CATDIR", "%s", catdir) == NULL) goto escape;
    4840
    4941  /* interpret command-line options */
    50   /*** determine any restrictions (time, ?) ***/
    51   if (!SetPhotSelections (&argc, argv)) goto usage;
     42  if (!SetRegionSelection (&argc, argv, &RegionName, &RegionList)) goto escape;
     43  if (!SetPhotSelections (&argc, argv, 1)) goto usage;
     44
     45  /* interpret command-line options */
    5246  if (argc != 4) goto usage;
    53 
    54   /* vectors to save data */
    55   Npts = 0;
    56   NPTS = 1;
    57   if ((xvec = SelectVector ("tmp_x", ANYVECTOR, TRUE)) == NULL) goto escape;
    58   if ((yvec = SelectVector ("tmp_y", ANYVECTOR, TRUE)) == NULL) goto escape;
    5947
    6048  /* determine relevant photcodes, colors */
     
    10896    out[i] = -1;
    10997  }
     98
     99  /* load region corresponding to selection above */
     100  if ((regions = SelectRegions (RegionName, RegionList, &Nregions)) == NULL) goto escape;
    110101
    111102  /* loop over regions, extract data for each region */
     
    131122  fprintf (stderr, "using %d regions\n", Nregions);
    132123
     124  /* vectors to save data */
     125  Npts = 0;
     126  NPTS = 1;
     127  if ((xvec = SelectVector ("tmp_x", ANYVECTOR, TRUE)) == NULL) goto escape;
     128  if ((yvec = SelectVector ("tmp_y", ANYVECTOR, TRUE)) == NULL) goto escape;
     129
    133130  /*** generate the color-color vectors for the pairs ***/
    134131  /* loop over chip photcode pairs */
     
    159156              xvec[0].elements[Npts] = M2[i2];
    160157              Npts++;
    161               if (Npts == NPTS) {
     158              if (Npts >= NPTS) {
    162159                NPTS += 2000;
    163160                REALLOCATE (xvec[0].elements, float, NPTS);
  • trunk/Ohana/src/opihi/dvo/imdata.c

    r3462 r4585  
    135135        vec[0].elements[N] = catalog.average[n].R - catalog.measure[i].dR / 360000.0;
    136136        N++;
    137         if (N == NPTS - 1) {
    138           NPTS += 1000;
    139           REALLOCATE (vec[0].elements, float, NPTS);
    140         }
     137        CHECK_REALLOCATE (vec[0].elements, float, NPTS, N, 1000);
    141138      }
    142139      break;
     
    147144        vec[0].elements[N] = catalog.average[n].D - catalog.measure[i].dD / 360000.0;
    148145        N++;
    149         if (N == NPTS - 1) {
    150           NPTS += 1000;
    151           REALLOCATE (vec[0].elements, float, NPTS);
    152         }
     146        CHECK_REALLOCATE (vec[0].elements, float, NPTS, N, 1000);
    153147      }
    154148      break;
     
    158152        vec[0].elements[N] = catalog.measure[i].M / 1000.0;
    159153        N++;
    160         if (N == NPTS - 1) {
    161           NPTS += 1000;
    162           REALLOCATE (vec[0].elements, float, NPTS);
    163         }
     154        CHECK_REALLOCATE (vec[0].elements, float, NPTS, N, 1000);
    164155      }
    165156      break;
     
    169160        vec[0].elements[N] = catalog.measure[i].dM / 1000.0;
    170161        N++;
    171         if (N == NPTS - 1) {
    172           NPTS += 1000;
    173           REALLOCATE (vec[0].elements, float, NPTS);
    174         }
     162        CHECK_REALLOCATE (vec[0].elements, float, NPTS, N, 1000);
    175163      }
    176164      break;
     
    180168        vec[0].elements[N] = catalog.measure[i].Mcal / 1000.0;
    181169        N++;
    182         if (N == NPTS - 1) {
    183           NPTS += 1000;
    184           REALLOCATE (vec[0].elements, float, NPTS);
    185         }
     170        CHECK_REALLOCATE (vec[0].elements, float, NPTS, N, 1000);
    186171      }
    187172      break;
     
    192177        vec[0].elements[N] = catalog.average[n].M / 1000.0;
    193178        N++;
    194         if (N == NPTS - 1) {
    195           NPTS += 1000;
    196           REALLOCATE (vec[0].elements, float, NPTS);
    197         }
    198179      }
    199180      break;
     
    203184        vec[0].elements[N] = catalog.measure[i].source;
    204185        N++;
    205         if (N == NPTS - 1) {
    206           NPTS += 1000;
    207           REALLOCATE (vec[0].elements, float, NPTS);
    208         }
     186        CHECK_REALLOCATE (vec[0].elements, float, NPTS, N, 1000);
    209187      }
    210188      break;
     
    214192        vec[0].elements[N] = TimeValue (catalog.measure[i].t, TimeReference, TimeFormat);
    215193        N++;
    216         if (N == NPTS - 1) {
    217           NPTS += 1000;
    218           REALLOCATE (vec[0].elements, float, NPTS);
    219         }
     194        CHECK_REALLOCATE (vec[0].elements, float, NPTS, N, 1000);
    220195      }
    221196      break;
  • trunk/Ohana/src/opihi/dvo/mextract.c

    r3462 r4585  
    44 
    55  int i, j, k, m, N, N1, NPTS;
    6   int param, mode, Nregions, Ngraph, Nsec;
    7   char filename[128], catdir[256], *p;
    8   double *M1;
     6  int param, mode, Nregions, Nsec;
     7  char filename[128], catdir[256], *RegionName, *RegionList, *p;
     8  double Radius, *M1;
    99
    1010  PhotCode *code;
    1111  Catalog catalog;
    1212  RegionFile *regions;
    13   Graphdata graphsky;
    1413  Vector *vec;
    1514
     15  /* defaults */
    1616  regions = NULL;
    1717  catalog.average = (Average *) NULL;
    1818  catalog.secfilt = (SecFilt *) NULL;
    1919  catalog.measure = (Measure *) NULL;
     20  RegionName = NULL;
     21  RegionList = NULL;
     22  code = NULL;
     23  mode = MAG_REL;
    2024
    2125  /* load photcode information */
     
    2327  Nsec = GetPhotcodeNsecfilt ();
    2428
    25   /* load data about plot windows */
    26   Ngraph = 0;
    27   if (!GetGraphData (&graphsky, NULL, &Ngraph)) goto escape;
    28  
    2929  /* find CATDIR in config system */
    30   VarConfig ("CATDIR", "%s", catdir);
    31 
    32   /* specify catalog files
    33   RegionList = FALSE;
    34   if (N = get_argument (argc, argv, "-list")) {
    35     RegionList = TRUE;
    36     remove_argument (N, &argc, argv);
    37     strcpy (RegionListFile, argv[N]);
    38     remove_argument (N, &argc, argv);
    39   } */
     30  if (VarConfig ("CATDIR", "%s", catdir) == NULL) goto escape;
    4031
    4132  /* interpret command-line options */
    42   if (!SetPhotSelections (&argc, argv)) goto usage;
    43   if (argc != 3) goto usage;
     33  SetSelectionParam (0);
     34  if (!SetRegionSelection (&argc, argv, &RegionName, &RegionList)) goto escape;
     35  if (!SetPhotSelections (&argc, argv, 1)) goto usage;
    4436
    45   /* identify selection */
    46   code = NULL;
    47   mode = MAG_REL;
    48   param = GetMeasureParam (argv[2]);
     37  /* interpret required command-line arguments: mextract (value) */
     38  if (argc != 2) goto usage;
     39  param = GetMeasureParam (argv[1]);
    4940  if (param == MEAS_ZERO) {
    50     if (!GetPhotcodeInfo (argv[2], &code, &mode)) {
     41    if (!GetPhotcodeInfo (argv[1], &code, &mode)) {
    5142      GetMeasureParam ("help");
    52       fprintf (stderr, "value may also be a valid photcode\n");
    53       fprintf (stderr, "photcodes or 'mag' may have optional magnitude type: mag,[Minst, Mcat, Msys, Mrel, Mcal]\n");
    5443      goto escape;
    5544    }
    5645    param = MEAS_MAG;
    57     for (p = argv[2]; *p != 0; p++) {
     46    for (p = argv[1]; *p != 0; p++) {
    5847      if (*p == '.') *p = ':';
    5948    }
    60   }
    61   /* test PhotSelections: is photcode specified if needed? */
    62   if (!TestPhotSelections (&code)) {
    63     fprintf (stderr, "photcode selection rules violated\n");
    64     fprintf (stderr, "average and ensemble restrictions require a corresponding photcode\n");
    65     goto escape;
    6649  }
     50  if (!TestPhotSelections (&code, MEAS_ZERO)) goto escape;
    6751
    68   if ((vec = SelectVector (argv[2], ANYVECTOR, TRUE)) == NULL) goto escape;
    69 
    70   /* determine region-file names */
    71   if (!strcmp (argv[1], "all")) {
    72     float Radius;
    73     Radius = MAX (fabs(graphsky.xmax), fabs(graphsky.ymax));
    74     regions = find_regions (graphsky.coords.crval1, graphsky.coords.crval2, Radius, &Nregions);
    75     /* I don't have a tool to select images by the overlapping region */
    76     if (!SetImageSelection (param, &graphsky, TRUE)) goto escape;
    77   } else {
    78     Nregions = 1;
    79     ALLOCATE (regions, RegionFile, 1);
    80     strcpy (regions[0].name, argv[1]);
    81     if (!SetImageSelection (param, NULL, FALSE)) goto escape;
    82   }
     52  /* load region corresponding to selection above */
     53  if ((regions = SelectRegions (RegionName, RegionList, &Nregions)) == NULL) goto escape;
     54  if (!SetImageSelection (param)) goto escape;
    8355
    8456  /* create storage vector */
    85   NPTS = 1000;
    86   REALLOCATE (vec[0].elements, float, NPTS);
    87   vec[0].Nelements = N = 0;
     57  N = 0;
     58  NPTS = 1;
     59  if ((vec = SelectVector (argv[1], ANYVECTOR, TRUE)) == NULL) goto escape;
    8860
    8961  for (i = 0; i < Nregions; i++) {
     
    11082        vec[0].elements[N] = M1[k];
    11183        N++;
    112         if (N == NPTS - 1) {
    113           NPTS += 2000;
    114           REALLOCATE (vec[0].elements, float, NPTS);
    115         }
     84        CHECK_REALLOCATE (vec[0].elements, float, NPTS, N, 2000);
    11685      }
    11786      if (M1 != NULL) free (M1);
     
    132101
    133102usage:
    134   fprintf (stderr, "USAGE: mextract (from) (value) [options]\n");
    135   fprintf (stderr, "  from: cpt name or 'all'\n");
     103  fprintf (stderr, "USAGE: mextract (value) [options]\n");
    136104  fprintf (stderr, "  value: measure.parameter or photcode\n");
    137105  return (FALSE);
    138106
    139107escape:
     108  FreeImageSelection ();
    140109  if (regions != NULL) free (regions);
    141   FreeImageSelection ();
    142110  if (catalog.average != NULL) free (catalog.average);
    143111  if (catalog.secfilt != NULL) free (catalog.secfilt);
    144112  if (catalog.measure != NULL) free (catalog.measure);
     113  if (RegionName != NULL) free (RegionName);
     114  if (RegionList != NULL) free (RegionList);
    145115  return (FALSE);
    146116}
  • trunk/Ohana/src/opihi/dvo/photometry.c

    r4420 r4585  
    33/* match code to measure  */
    44# define TESTCODE(C,M) \
    5   switch (C[0].type) { \
    6   case PHOT_DEP: \
    7   case PHOT_REF: \
    8     if (C[0].code != M.source) continue; \
    9     break; \
    10   case PHOT_PRI: \
    11   case PHOT_SEC: \
    12     if (C[0].code != GetPhotcodeEquivCodebyCode (M.source)) continue; \
    13     break; \
    14   default: \
    15     break; \
    16 }
     5  if ((C != NULL) && ApplySelections[SelectionParam]) { \
     6    switch (C[0].type) { \
     7    case PHOT_DEP: \
     8    case PHOT_REF: \
     9      if (C[0].code != M.source) continue; \
     10      break; \
     11    case PHOT_PRI: \
     12    case PHOT_SEC: \
     13      if (C[0].code != GetPhotcodeEquivCodebyCode (M.source)) continue; \
     14      break; \
     15    default: \
     16      break; \
     17  } }
    1718
    1819/* exclusions based on measure.params  */
    1920# define TESTMEASURE(M) \
    20   if (TimeSelect && (M.t < tzero)) continue; \
    21   if (TimeSelect && (M.t > tend)) continue; \
    22   if (ErrSelect  && (M.dM > ErrValue)) continue; \
    23   if (TypeSelect && (TypeValue != GetMeasureTypeCode (&M))) continue; \
    24   if (iMagSelect && (PhotInst (&M) < iMagMin)) continue; \
    25   if (FlagSelect && (M.flags != FlagValue)) continue;
     21  if (ApplySelections[SelectionParam]) { \
     22    if (TimeSelect && (M.t < tzero)) continue; \
     23    if (TimeSelect && (M.t > tend)) continue; \
     24    if (ErrSelect  && (M.dM > ErrValue)) continue; \
     25    if (TypeSelect && (TypeValue != GetMeasureTypeCode (&M))) continue; \
     26    if (iMagSelect && (PhotInst (&M) < iMagMin)) continue; \
     27    if (FlagSelect && (M.flags != FlagValue)) continue; \
     28  }
    2629
    2730# define SETMAG(MOUT,MEAS,MODE) \
     
    3437  if (MODE == MAG_AVE)  MOUT = PhotRel  (&MEAS, average, secfilt); \
    3538  if (MODE == MAG_REF)  MOUT = PhotCal  (&MEAS, average, secfilt, measure, GetPhotcodeEquivbyCode (MEAS.source)); \
    36   if (MagSelect && (MOUT > MagMax)) continue; \
    37   if (MagSelect && (MOUT < MagMin)) continue;
     39  if (ApplySelections[SelectionParam]) { \
     40    if (MagSelect && (MOUT > MagMax)) continue; \
     41    if (MagSelect && (MOUT < MagMin)) continue; \
     42  }
    3843
    3944/* selection criteria */
     
    5156static double TypefracValue;
    5257
     58/* apply selections or not */
     59static int ApplySelections[4];
     60static int SelectionParam;
     61
    5362/* applied to Average quantities */
    5463static int PhotcodeSelect;
     
    6978static int TimeFormat;
    7079
    71 /* db image table */
    72 static Image *image = NULL;
    73 static int *subset = NULL;
    74 static int Nimage = 0;
    75 static int Nsubset = 0;
    76 static Coords mosaic;
     80int GetTimeSelection (time_t *tz, time_t *te) {
     81  *tz = tzero;
     82  *te = tend;
     83  return (TimeSelect);
     84}
    7785
    7886int GetPhotcodeInfo (char *string, PhotCode **Code, int *Mode) {
     
    156164}
    157165 
     166int SetSelectionParam (int param) {
     167  SelectionParam = param;
     168  return (TRUE);
     169}
     170
     171int GetSelectionParam () {
     172  return (SelectionParam);
     173}
     174
    158175int GetMagMode (char *string) {
    159176
     
    196213    fprintf (stderr, "value may be one of the following:\n");
    197214    fprintf (stderr, " ra dR dec dD mag dmag Mrel Mcal photcode time fwhm dophot xccd yccd xmosaic ymosaic flags\n");
     215    fprintf (stderr, "value may also be a valid photcode\n");
     216    fprintf (stderr, "photcodes or 'mag' may have optional magnitude type: mag,[Minst, Mcat, Msys, Mrel, Mcal]\n");
    198217  }
    199218  return (param);
    200219}
    201220 
    202 int TestPhotSelections (PhotCode **code) {
    203 
    204   int NeedPhotcode;
    205 
    206   /* if i've supplied a photcode (code != NULL), i'm not allowed to restrict it */
    207   if ((code[0] != NULL) && PhotcodeSelect) return (FALSE);
    208 
    209   /* if I have an average or ensemble restriction, I must have a photcode */
    210   if (ChiSelect || NphotSelect || NcodeSelect || FWHMSelect) {
    211     if (code[0] != NULL) return (TRUE);
    212     if (PhotcodeSelect) {
    213       code[0] = PhotcodeValue;
    214       return (TRUE);
    215     }
    216     return (FALSE);
    217   }
    218 
    219   /* if I have a photcode restriction, apply it to the code */
    220   if (PhotcodeSelect) {
    221     code[0] = PhotcodeValue;
    222     return (TRUE);
    223   }
    224   return (TRUE);
    225 }
    226 
    227221int GetAverageParam (char *parname) {
    228222
     
    233227  if (!strcasecmp (parname, "dec"))   param = AVE_DEC;
    234228  if (!strcasecmp (parname, "dmag"))  param = AVE_dMAG;
     229  if (!strcasecmp (parname, "mag"))   param = AVE_MAG;
    235230  if (!strcasecmp (parname, "Nmeas")) param = AVE_NMEAS;
    236231  if (!strcasecmp (parname, "Nmiss")) param = AVE_NMISS;
     
    251246}
    252247
     248/* I've set some selections - if these require a photcode, check if I set one */
     249int TestPhotSelections (PhotCode **code, int param) {
     250
     251  int NeedPhotcode;
     252
     253  /* if i've supplied a photcode (code != NULL), i'm not allowed to restrict it */
     254  if (code[0] != NULL) {
     255    if (PhotcodeSelect) {
     256      fprintf (stderr, "photcode selection rules violated: cannot restrict photcode with a photcode\n");
     257      return (FALSE);
     258    } else {
     259      return (TRUE);
     260    }
     261  }
     262
     263  /* if I have an average or ensemble restriction, I must have a photcode */
     264  NeedPhotcode = FALSE;
     265  NeedPhotcode |= ChiSelect;
     266  NeedPhotcode |= NphotSelect;
     267  NeedPhotcode |= NcodeSelect;
     268  NeedPhotcode |= ErrSelect;
     269  NeedPhotcode |= TypeSelect;
     270  NeedPhotcode |= TypefracSelect;
     271 
     272  /* for measure tests, supply MEAS_ZERO */
     273  NeedPhotcode |= (param == AVE_Xm);
     274  NeedPhotcode |= (param == AVE_MAG);
     275  NeedPhotcode |= (param == AVE_dMAG);
     276  NeedPhotcode |= (param == AVE_TYPE);
     277  NeedPhotcode |= (param == AVE_NPHOT);
     278  NeedPhotcode |= (param == AVE_NCODE);
     279
     280  if (NeedPhotcode || PhotcodeSelect) {
     281    if (!PhotcodeSelect) return (FALSE);
     282    code[0] = PhotcodeValue;
     283    if (code[0][0].type == PHOT_DEP) return (FALSE);
     284    if (code[0][0].type == PHOT_REF) return (FALSE);
     285  }
     286  return (TRUE);
     287}
     288
    253289void GetAverageParamHelp () {
    254290  fprintf (stderr, "value may be one of the following:\n");
     
    259295}
    260296
    261 /* load images based on parameters and region, etc */
    262 int SetImageSelection (int mode, Graphdata *graphsky, int RegionSelect) {
    263 
    264   image = NULL;
    265   subset = NULL;
    266  
    267   switch (mode) {
    268     case MEAS_XCCD:
    269     case MEAS_YCCD:
    270       break;
    271     case MEAS_XMOSAIC:
    272     case MEAS_YMOSAIC:
    273       /* mosaic defines a frame with 0,0 at the mosaic center, and 1 arcsec / pixel */
    274       mosaic.crpix1 = mosaic.crpix2 = 0.0;
    275       mosaic.cdelt1 = mosaic.cdelt2 = 1.0 / 3600;
    276       mosaic.pc1_1  = mosaic.pc2_2  = 1.0;
    277       mosaic.pc1_2  = mosaic.pc2_1  = 0.0;
    278       mosaic.Npolyterms = 0;
    279       strcpy (mosaic.ctype, "RA---SIN");
    280       break;
    281     default:
    282       return (TRUE);
    283   }
    284 
    285   if ((image = LoadImages (&Nimage)) == NULL) return (FALSE);
    286   BuildChipMatch (image, Nimage);
    287   image_subset (image, Nimage, &subset, &Nsubset, graphsky, RegionSelect, tzero, (double) tend - tzero, TimeSelect);
    288   sort_image_subset (image, subset, Nsubset);
    289   return (TRUE);
    290 }
    291 
    292 /* free loaded images */
    293 void FreeImageSelection () {
    294   if (image != NULL) free (image);
    295   if (subset != NULL) free (subset);
    296   image = NULL;
    297   subset = NULL;
    298   return;
    299 }
    300 
    301297/* (re)load photcodes from photcode table */
    302298int InitPhotcodes () {
     
    318314/* remove standard photometry filtering options, set selections */
    319315/* not all functions respect all selections... */
    320 int SetPhotSelections (int *argc, char **argv) {
    321 
    322   int N;
     316int SetPhotSelections (int *argc, char **argv, int Nparams) {
     317
     318  int i, N;
    323319  double trange;
    324320
     
    367363  }
    368364
    369   /* select on value of flag (MEASURE ONLY) */
    370   ChiSelect = FALSE;
    371   if (N = get_argument (*argc, argv, "-chisq")) {
    372     ChiSelect = TRUE;
    373     remove_argument (N, argc, argv);
    374     ChiLimit = atof (argv[N]);
     365  /* select on value of Chisq (AVERAGE ONLY) */
     366  for (i = 0; i < 4; i++) ApplySelections[i] = TRUE;
     367  if (N = get_argument (*argc, argv, "-apply")) {
     368    remove_argument (N, argc, argv);
     369    if (strlen(argv[N]) != Nparams) {
     370      fprintf (stderr, "-apply selection must define all parameter choices\n");
     371      return (FALSE);
     372    }
     373    for (i = 0; i < Nparams; i++) {
     374      if (toupper(argv[N][i]) == 'Y') {
     375        ApplySelections[i] = TRUE;
     376      } else {
     377        ApplySelections[i] = FALSE;
     378      }
     379    }
    375380    remove_argument (N, argc, argv);
    376381  }
     
    384389    if (PhotcodeValue == NULL) {
    385390      fprintf (stderr, "photcode not found in photcode table\n");
    386       PhotcodeSelect = FALSE;
     391      return (FALSE);;
    387392    }
    388393    remove_argument (N, argc, argv);
     
    422427  }
    423428
     429  /* select on value of Chisq (AVERAGE ONLY) */
     430  ChiSelect = FALSE;
     431  if (N = get_argument (*argc, argv, "-chisq")) {
     432    ChiSelect = TRUE;
     433    remove_argument (N, argc, argv);
     434    ChiLimit = atof (argv[N]);
     435    remove_argument (N, argc, argv);
     436  }
     437
    424438  /* select on measurement type: 1,2,3 (AVERAGE ONLY) */
    425439  TypeSelect = FALSE;
     
    508522  ALLOCATE (list, double, NLIST);
    509523
    510   /* chisq, fwhm, Nphot, Ncode */
    511   /* if (!TestAverage (code, average, secfilt, measure)) return (list); */
     524  /* check selections based on averages & ensembles: chisq, Nphot, etc */
     525  if (!TestAverage (code, average, secfilt, measure)) return (list);
    512526
    513527  /* look for measures */
    514528  for (i = 0; i < average[0].Nm; i++) {
    515     if (code != NULL) {
    516       TESTCODE (code, measure[i]);
    517     }
    518     /* exclusions based on measure.params  */
    519     TESTMEASURE (measure[i]);
    520 
    521     /* need to have the mag value to test MagSelect */
    522     SETMAG (M, measure[i], mode);
     529    TESTCODE (code, measure[i]);  /* skip measurements not matching photcode */
     530    TESTMEASURE (measure[i]);     /* exclusions based on measure.params  */
     531    SETMAG (M, measure[i], mode); /* set appropriate magnitude (also does MagSelect) */
    523532
    524533    /* assign value */
    525     value = 0;
    526     switch (param) {
    527       case MEAS_MAG: /* magnitudes are already determined above */
    528         value = M;
    529         break;
    530       case MEAS_RA: /* OK */
    531         value = average[0].R - measure[i].dR / 360000.0;
    532         break;
    533       case MEAS_DEC: /* OK */
    534         value = average[0].D - measure[i].dD / 360000.0;
    535         break;
    536       case MEAS_dMAG: /* OK */
    537         value = 0.001*measure[i].dM;
    538         break;
    539       case MEAS_AIRMASS: /* OK */
    540         value = 0.001*measure[i].airmass;
    541         break;
    542       case MEAS_EXPTIME: /* OK */
    543         value = pow (10.0, measure[i].dt * 0.0004);
    544         break;
    545       case MEAS_PHOTCODE: /* OK */
    546         value = measure[i].source;
    547         break;
    548       case MEAS_TIME: /* OK */
    549         value = TimeValue (measure[i].t, TimeReference, TimeFormat);
    550         break;
    551       case MEAS_dR: /* OK */
    552         value = 0.01*measure[i].dR;
    553         break;
    554       case MEAS_dD: /* OK */
    555         value = 0.01*measure[i].dD;
    556         break;
    557       case MEAS_FWHM: /* OK */
    558         value = 0.01*measure[i].FWx;
    559         break;
    560       case MEAS_DOPHOT: /* OK */
    561         value = measure[i].dophot;
    562         break;
    563       case MEAS_FLAGS: /* ? */
    564         value = measure[i].flags;
    565         break;
    566       case MEAS_XCCD: /* OK */
    567         ra  = average[0].R - measure[i].dR / 360000.0;
    568         dec = average[0].D - measure[i].dD / 360000.0;
    569         m = match_image_subset (image, subset, Nsubset, measure[i].t, measure[i].source);
    570         if (m == -1) break;
    571         if (!FindMosaicForImage (image, Nimage, m)) break;
    572         RD_to_XY (&x, &y, ra, dec, &image[m].coords);
    573         value = x;
    574         break;
    575       case MEAS_YCCD: /* OK */
    576         ra  = average[0].R - measure[i].dR / 360000.0;
    577         dec = average[0].D - measure[i].dD / 360000.0;
    578         m = match_image_subset (image, subset, Nsubset, measure[i].t, measure[i].source);
    579         if (m == -1) break;
    580         if (!FindMosaicForImage (image, Nimage, m)) break;
    581         RD_to_XY (&x, &y, ra, dec, &image[m].coords);
    582         value = y;
    583         break;
    584       case MEAS_XMOSAIC: /* OK */
    585         ra  = average[0].R - measure[i].dR / 360000.0;
    586         dec = average[0].D - measure[i].dD / 360000.0;
    587         m = match_image_subset (image, subset, Nsubset, measure[i].t, measure[i].source);
    588         if (m == -1) break;
    589         /* this should use the mosaic assoicated with the image */
    590         /* the solution here depends on image.coords having crref1,2 set to match the boresite center */
    591         /* XXX set the mosaic.coords to have a unity WRP transformation in which x,y = ra,dec */
    592         mosaic.crval1 = image[m].coords.crval1;
    593         mosaic.crval2 = image[m].coords.crval2;
    594         RD_to_XY (&x, &y, ra, dec, &mosaic);
    595         value = x;
    596         break;
    597       case MEAS_YMOSAIC: /* OK */
    598         ra  = average[0].R - measure[i].dR / 360000.0;
    599         dec = average[0].D - measure[i].dD / 360000.0;
    600         m = match_image_subset (image, subset, Nsubset, measure[i].t, measure[i].source);
    601         if (m == -1) break;
    602         /* same comments as above */
    603         mosaic.crval1 = image[m].coords.crval1;
    604         mosaic.crval2 = image[m].coords.crval2;
    605         RD_to_XY (&x, &y, ra, dec, &mosaic);
    606         value = y;
    607         break;
    608     }
    609     list[Nlist] = value;
     534    list[Nlist] = GetMeasure (param, &average[0], &measure[i], M);
    610535    Nlist ++;
    611536  }
     
    622547  value = NO_MAG;
    623548
    624   /* need valid code if param is: */
    625   switch (param) {
    626     case AVE_MAG:
    627     case AVE_dMAG:
    628     case AVE_Xm:
    629     case AVE_TYPE:
    630     case AVE_NCODE:
    631     case AVE_NPHOT:
    632       if (code == NULL) return (NO_MAG);
    633       break;
    634     default:
    635       break;
    636   }
    637 
    638   /* chisq, fwhm, Nphot, Ncode */
     549  /* this function requires code set for certain value of param. 
     550     use TestPhotSelectionsAverage to validate code/param choices */
     551
     552  /* filter by average quantities (eg, chisq, Nphot, etc) */
    639553  if (!TestAverage (code, average, secfilt, measure)) return (NO_MAG);
    640554
     
    728642}
    729643
    730 /* determine the representative dophot type for this photcode */
     644/* determine the representative dophot type for this photcode (must be PRI/SEC) */
    731645int DetermineTypeCode (Average *average, Measure *measure, int code) {
    732646
     
    785699}
    786700
     701/* test if this average object meets the specified selection criteria.
     702   for photcode-dependent quantities, only test for PRI/SEC photcodes */
    787703int TestAverage (PhotCode *code, Average *average, SecFilt *secfilt, Measure *measure) {
    788704
    789   int i, Nm, Type;
     705  int i, Nm, Type, Select;
    790706  double fwhm, typefrac, dM, Xm;
    791707
    792   /* exclusions based on average.params  */
    793   if (ChiSelect) {
    794     /* some average.params need a valid photcode for reference */
    795     if (code == NULL) return (FALSE);
    796     Xm = PhotXm (code, average, secfilt);
    797     if (Xm == -1) return (FALSE);
    798     if (Xm > ChiLimit) return (FALSE);
    799   }
    800  
    801   /* for ErrSelect, check average errors */
    802   if (ErrSelect) {
    803     if (code == NULL) return (FALSE);  /* need a valid code */
    804     dM = iPhotdM (code, average, secfilt);
    805     if (dM > ErrValue) return (NO_MAG);
    806   }
    807  
     708  if (!ApplySelections[SelectionParam]) return (TRUE);
     709
    808710  /* pass objects with more than FWHMfrac points with FWHM above / below FWHMvalue */
    809711  if (FWHMSelect) {
     
    827729  }
    828730
     731  /* all selections below require a valid photcode */
     732  Select = ChiSelect || ErrSelect || NcodeSelect || NphotSelect || TypeSelect || TypefracSelect;
     733  if (!Select) return (TRUE);
     734
     735  /* must have a valid code of some kind */
     736  if (code == NULL) return (FALSE);
     737
     738  /* only PRI/SEC photcodes apply the filter */
     739  if (code[0].type == PHOT_DEP) return (TRUE);
     740  if (code[0].type == PHOT_REF) return (TRUE);
     741
     742  /* exclusions based on average.params  */
     743  if (ChiSelect) {
     744    Xm = PhotXm (code, average, secfilt);
     745    if (Xm == -1) return (FALSE);
     746    if (Xm > ChiLimit) return (FALSE);
     747  }
     748 
     749  /* for ErrSelect, check average errors */
     750  if (ErrSelect) {
     751    dM = iPhotdM (code, average, secfilt);
     752    if (dM > ErrValue) return (NO_MAG);
     753  }
     754 
    829755  /* for NcodeSelect, count Nmeas for appropriate photcode */
    830756  if (NcodeSelect) {
     
    937863}
    938864
     865/* extract delta-mag pairs applying specified selections */
    939866double *ExtractDMag (PhotCode **code, int *mode, Average *average, SecFilt *secfilt, Measure *measure, int *nlist) {
    940867
    941   int i, j, A1, A2, N1, N2, Nlist, NLIST;
    942   double *M1, *M2, *list;
    943 
    944   /* check for special case of measure-measure */
     868  int i, j, A1, A2, N1, N2, Np, Nlist, NLIST;
     869  double *M1, *M2, *list, NoMag;
     870
     871  /* check for special case of measure-measure - this is needed to drop self-matches */
    945872  A1 = ((mode[0] == MAG_AVE) || (mode[0] == MAG_REF));
    946873  A2 = ((mode[1] == MAG_AVE) || (mode[1] == MAG_REF));
     
    955882  ALLOCATE (list, double, NLIST);
    956883  M1 = M2 = NULL;
     884  NoMag = NO_MAG * 0.001;
    957885
    958886  /* one of the two is an average, must do independently */
     
    960888  if (N1 == 0) goto skip;
    961889 
     890  Np = GetSelectionParam ();
     891  SetSelectionParam (Np + 1);
    962892  M2 = ExtractMagnitudes (code[1], mode[1], average, secfilt, measure, &N2);
    963893  if (N2 == 0) goto skip;
    964894
    965   /* average mags can return NO_MAG : skip them? */
     895  /* magnitudes may be NO_MAG : set delta to NO_MAG */
    966896  for (i = 0; i < N1; i++) {
    967897    for (j = 0; j < N2; j++) {
    968       list[Nlist] = M1[i] - M2[j];
     898      if ((M1[i] == NoMag) || (M2[j] == NoMag)) {
     899        list[Nlist] = NoMag;
     900      } else {
     901        list[Nlist] = M1[i] - M2[j];
     902      }
    969903      Nlist ++;
    970904    }
    971905  }
    972   *nlist = Nlist;
    973   return (list);
    974906
    975907 skip:
    976908  if (M1 != NULL) free (M1);
    977909  if (M2 != NULL) free (M2);
    978   M1 = M2 = NULL;
     910  *nlist = Nlist;
    979911  return (list);
    980912}
    981913 
    982 /* extract a list of delta-measure-mags from the specified average entry based on the pre-set selections */
     914/* extract a list of delta-measure-mags from the specified average entry based on the
     915   pre-set selections - does not return self-matched measurements */
    983916double *ExtractMeasuresDMag (PhotCode **code, int *mode, Average *average, SecFilt *secfilt, Measure *measure, int *nlist) {
    984917
    985   int i, j, Nlist, NLIST;
    986   double *list, M1, M2, value;
     918  int i, j, Np0, Np1, Nlist, NLIST;
     919  double *list, M1, M2, value, NoMag;
    987920 
    988921  *nlist = 0;
     
    990923  NLIST = MAX (1, average[0].Nm*average[0].Nm);
    991924  ALLOCATE (list, double, NLIST);
    992 
    993   /* must have two code values */
     925  NoMag = NO_MAG * 0.001;
     926
     927  /* must have two code values - drop this test? this is programming case, not a user case */
    994928  if (code == NULL) return (list);
    995929  if (code[0] == NULL) return (list);
    996930  if (code[1] == NULL) return (list);
    997931
    998   /* exclude based on chisq for both codes  */
    999   if (ChiSelect) {
    1000     value = PhotXm (code[0], average, secfilt);
    1001     if (value == -1) return (list);
    1002     if (value > ChiLimit) return (list);
    1003     value = PhotXm (code[1], average, secfilt);
    1004     if (value == -1) return (list);
    1005     if (value > ChiLimit) return (list);
    1006   }
     932  /* exclude based on average parameters for both codes  */
     933  if (!TestAverage (code[0], average, secfilt, measure)) return (list);
     934  if (!TestAverage (code[1], average, secfilt, measure)) return (list);
     935
     936  Np0 = GetSelectionParam ();
     937  Np1 = Np0 + 1;
    1007938
    1008939  /* loop twice over all measures */
    1009940  for (i = 0; i < average[0].Nm; i++) {
     941    SetSelectionParam (Np0);
    1010942    TESTCODE (code[0], measure[i]);
    1011943    TESTMEASURE (measure[i]);
     
    1013945    for (j = 0; j < average[0].Nm; j++) {
    1014946      if (i == j) continue;
     947      SetSelectionParam (Np1);
    1015948      TESTCODE (code[1], measure[j]);
    1016949      TESTMEASURE (measure[j]);
    1017950      SETMAG(M2, measure[j], mode[1]);
    1018       list[Nlist] = M1 - M2;
     951      if ((M1 == NoMag) || (M2 == NoMag)) {
     952        list[Nlist] = NoMag;
     953      } else {
     954        list[Nlist] = M1 - M2;
     955      }
    1019956      Nlist ++;
    1020957    }
     
    1024961}
    1025962
     963/* extract a measurement list matching the number of dmag entries */
    1026964double *ExtractByDMag (PhotCode **code, int *mode, Average *average, SecFilt *secfilt, Measure *measure, int *nlist, int param) {
    1027965
     
    1037975  }
    1038976
     977  /* one of the two entries results in a single element. extract the other */
    1039978  if (A1) {
    1040979    list = ExtractMeasures (code[1], mode[1], average, secfilt, measure, &N1, param);
     
    1049988double *ExtractMeasuresByDMag (PhotCode **code, int *mode, int use_first, Average *average, SecFilt *secfilt, Measure *measure, int *nlist, int param) {
    1050989
    1051   int i, j, k, m, n, Nlist, NLIST;
     990  int i, j, k, n, Nlist, NLIST;
    1052991  time_t t;
    1053992  int np, found;
    1054993  double *list, M1, M2, value;
    1055   double ra, dec, x, y;
    1056994 
    1057995  *nlist = 0;
     
    10821020
    10831021      /* assign value */
    1084       value = 0;
    1085       switch (param) {
    1086         case MEAS_MAG: /* magnitudes are already determined above */
    1087           value = use_first ? M1 : M2;
    1088           break;
    1089         case MEAS_RA: /* OK */
    1090           value = average[0].R - measure[n].dR / 360000.0;
    1091           break;
    1092         case MEAS_DEC: /* OK */
    1093           value = average[0].D - measure[n].dD / 360000.0;
    1094           break;
    1095         case MEAS_dMAG: /* OK */
    1096           value = 0.001*measure[n].dM;
    1097           break;
    1098         case MEAS_AIRMASS: /* OK */
    1099           value = 0.001*measure[n].airmass;
    1100           break;
    1101         case MEAS_EXPTIME: /* OK */
    1102           value = pow (10.0, measure[n].dt * 0.0004);
    1103           break;
    1104         case MEAS_PHOTCODE: /* OK */
    1105           value = measure[n].source;
    1106           break;
    1107         case MEAS_TIME: /* OK */
    1108           value = TimeValue (measure[n].t, TimeReference, TimeFormat);
    1109           break;
    1110         case MEAS_dR: /* OK */
    1111           value = 0.01*measure[n].dR;
    1112           break;
    1113         case MEAS_dD: /* OK */
    1114           value = 0.01*measure[n].dD;
    1115           break;
    1116         case MEAS_FWHM: /* OK */
    1117           value = 0.01*measure[n].FWx;
    1118           break;
    1119         case MEAS_DOPHOT: /* OK */
    1120           value = measure[n].dophot;
    1121           break;
    1122         case MEAS_FLAGS: /* ? */
    1123           value = measure[n].flags;
    1124           break;
    1125         case MEAS_XCCD: /* OK */
    1126           ra  = average[0].R - measure[n].dR / 360000.0;
    1127           dec = average[0].D - measure[n].dD / 360000.0;
    1128           m = match_image_subset (image, subset, Nsubset, measure[n].t, measure[n].source);
    1129           if (m == -1) break;
    1130           if (!FindMosaicForImage (image, Nimage, m)) break;
    1131           RD_to_XY (&x, &y, ra, dec, &image[m].coords);
    1132           value = x;
    1133           break;
    1134         case MEAS_YCCD: /* OK */
    1135           ra  = average[0].R - measure[n].dR / 360000.0;
    1136           dec = average[0].D - measure[n].dD / 360000.0;
    1137           m = match_image_subset (image, subset, Nsubset, measure[n].t, measure[n].source);
    1138           if (m == -1) break;
    1139           if (!FindMosaicForImage (image, Nimage, m)) break;
    1140           RD_to_XY (&x, &y, ra, dec, &image[m].coords);
    1141           value = y;
    1142           break;
    1143         case MEAS_XMOSAIC: /* OK */
    1144           ra  = average[0].R - measure[n].dR / 360000.0;
    1145           dec = average[0].D - measure[n].dD / 360000.0;
    1146           m = match_image_subset (image, subset, Nsubset, measure[n].t, measure[n].source);
    1147           if (m == -1) break;
    1148           mosaic.crval1 = image[m].coords.crval1;
    1149           mosaic.crval2 = image[m].coords.crval2;
    1150           RD_to_XY (&x, &y, ra, dec, &mosaic);
    1151           value = x;
    1152           break;
    1153         case MEAS_YMOSAIC: /* OK */
    1154           ra  = average[0].R - measure[n].dR / 360000.0;
    1155           dec = average[0].D - measure[n].dD / 360000.0;
    1156           m = match_image_subset (image, subset, Nsubset, measure[n].t, measure[n].source);
    1157           if (m == -1) break;
    1158           mosaic.crval1 = image[m].coords.crval1;
    1159           mosaic.crval2 = image[m].coords.crval2;
    1160           RD_to_XY (&x, &y, ra, dec, &mosaic);
    1161           value = y;
    1162           break;
    1163       }
    1164       list[Nlist] = value;
     1022      list[Nlist] = GetMeasure (param, &average[0], &measure[n], (use_first ? M1 : M2));
    11651023      Nlist ++;
    11661024    }
     
    11701028}
    11711029
     1030double GetMeasure (int param, Average *average, Measure *measure, double mag) {
     1031
     1032  int m;
     1033  double ra, dec, x, y;
     1034  double value;
     1035  Image *image;
     1036  Coords *mosaic;
     1037
     1038  value = 0;
     1039  switch (param) {
     1040    case MEAS_MAG: /* magnitudes are already determined above */
     1041      value = mag;
     1042      break;
     1043    case MEAS_RA: /* OK */
     1044      value = average[0].R - measure[0].dR / 360000.0;
     1045      break;
     1046    case MEAS_DEC: /* OK */
     1047      value = average[0].D - measure[0].dD / 360000.0;
     1048      break;
     1049    case MEAS_dMAG: /* OK */
     1050      value = 0.001*measure[0].dM;
     1051      break;
     1052    case MEAS_AIRMASS: /* OK */
     1053      value = 0.001*measure[0].airmass;
     1054      break;
     1055    case MEAS_EXPTIME: /* OK */
     1056      value = pow (10.0, measure[0].dt * 0.0004);
     1057      break;
     1058    case MEAS_PHOTCODE: /* OK */
     1059      value = measure[0].source;
     1060      break;
     1061    case MEAS_TIME: /* OK */
     1062      value = TimeValue (measure[0].t, TimeReference, TimeFormat);
     1063      break;
     1064    case MEAS_dR: /* OK */
     1065      value = 0.01*measure[0].dR;
     1066      break;
     1067    case MEAS_dD: /* OK */
     1068      value = 0.01*measure[0].dD;
     1069      break;
     1070    case MEAS_FWHM: /* OK */
     1071      value = 0.01*measure[0].FWx;
     1072      break;
     1073    case MEAS_DOPHOT: /* OK */
     1074      value = measure[0].dophot;
     1075      break;
     1076    case MEAS_FLAGS: /* ? */
     1077      value = measure[0].flags;
     1078      break;
     1079    case MEAS_XCCD: /* OK */
     1080      ra  = average[0].R - measure[0].dR / 360000.0;
     1081      dec = average[0].D - measure[0].dD / 360000.0;
     1082      image = MatchImage (measure[0].t, measure[0].source);
     1083      if (image == NULL) break;
     1084      RD_to_XY (&x, &y, ra, dec, &image[0].coords);
     1085      value = x;
     1086      break;
     1087    case MEAS_YCCD: /* OK */
     1088      ra  = average[0].R - measure[0].dR / 360000.0;
     1089      dec = average[0].D - measure[0].dD / 360000.0;
     1090      image = MatchImage (measure[0].t, measure[0].source);
     1091      if (image == NULL) break;
     1092      RD_to_XY (&x, &y, ra, dec, &image[0].coords);
     1093      value = y;
     1094      break;
     1095    case MEAS_XMOSAIC: /* OK */
     1096      ra  = average[0].R - measure[0].dR / 360000.0;
     1097      dec = average[0].D - measure[0].dD / 360000.0;
     1098      mosaic = MatchMosaic (measure[0].t, measure[0].source);
     1099      if (mosaic == NULL) break;
     1100      RD_to_XY (&x, &y, ra, dec, mosaic);
     1101      value = x;
     1102      break;
     1103    case MEAS_YMOSAIC: /* OK */
     1104      ra  = average[0].R - measure[0].dR / 360000.0;
     1105      dec = average[0].D - measure[0].dD / 360000.0;
     1106      mosaic = MatchMosaic (measure[0].t, measure[0].source);
     1107      if (mosaic == NULL) break;
     1108      RD_to_XY (&x, &y, ra, dec, mosaic);
     1109      value = y;
     1110      break;
     1111  }
     1112  return (value);
     1113}
     1114
     1115/** the mosaic entries do not use the registered mosaic found
     1116    by MatchImage (via FindMosaicForImage).  Rather, they use
     1117    a coordinate frame saved by SetImageSelection
     1118**/
  • trunk/Ohana/src/opihi/dvo/region_list.c

    r3462 r4585  
    11# include "dvo1.h"
     2
     3static int RegionSelect;
     4
     5int GetRegionSelection () {
     6  return (RegionSelect);
     7}
     8
     9int SetRegionSelection (int *argc, char **argv, char **RegionName, char **RegionList) {
     10 
     11  int N;
     12
     13  RegionSelect = FALSE;
     14
     15  /* check for Region selection */
     16  *RegionName = NULL;
     17  if (N = get_argument (*argc, argv, "-cpt")) {
     18    remove_argument (N, argc, argv);
     19    *RegionName = strcreate (argv[N]);
     20    remove_argument (N, argc, argv);
     21    return (TRUE);
     22  }   
     23  /* check for Region list */
     24  *RegionList = NULL;
     25  if (N = get_argument (*argc, argv, "-cptlist")) {
     26    remove_argument (N, argc, argv);
     27    *RegionList = strcreate (argv[N]);
     28    remove_argument (N, argc, argv);
     29    return (TRUE);
     30  }
     31  if ((*RegionName == NULL) && (*RegionList == NULL)) {
     32    RegionSelect = TRUE;
     33    return (TRUE);
     34  }
     35
     36  fprintf (stderr, "-cpt and -cptlist are incompatible\n");
     37  free (*RegionName);
     38  free (*RegionList);
     39  *RegionName = NULL;
     40  *RegionList = NULL;
     41  return (FALSE);
     42}
     43
     44RegionFile *SelectRegions (char *RegionName, char *RegionList, int *nregions) {
     45
     46  double Radius;
     47  int Ngraph;
     48  Graphdata graphsky;
     49  RegionFile *regions;
     50
     51  /* determine region-file names */
     52  if (RegionName != NULL) {
     53    *nregions = 1;
     54    ALLOCATE (regions, RegionFile, 1);
     55    strcpy (regions[0].name, RegionName);
     56    free (RegionName);
     57    RegionName = NULL;
     58    return (regions);
     59  }
     60  if (RegionList != NULL) {
     61    regions = region_list (RegionList, nregions);
     62    free (RegionList);
     63    RegionList = NULL;
     64    return (regions);
     65  }
     66
     67  Ngraph = 0;
     68  if (!GetGraphData (&graphsky, NULL, &Ngraph)) {
     69    fprintf (stderr, "region display not available\n");
     70    return (NULL);
     71  }
     72
     73  Radius = MAX (fabs(graphsky.xmax), fabs(graphsky.ymax));
     74  regions = find_regions (graphsky.coords.crval1, graphsky.coords.crval2, Radius, nregions);
     75  return (regions);
     76}
    277
    378/* returns a list of region files names from file */
     
    1287    fprintf (stderr, "ERROR: can't find region list file %s\n", filename);
    1388    *Nregions = 0;
    14     return ((RegionFile *) NULL);
     89    return (NULL);
    1590  }
    1691 
     
    28103
    29104  *Nregions = nregion;
    30 
    31105  return (regions);
    32 
    33106}
    34107
  • trunk/Ohana/src/opihi/include/dvo1.h

    r4420 r4585  
    4040
    4141/*** photometry functions ***/
    42 int           SetPhotSelections     PROTO((int *argc, char **argv));
    43 int           SetImageSelection     PROTO((int mode, Graphdata *graphsky, int state));
    44 void          FreeImageSelection    PROTO(());
     42double       *ExtractByDMag         PROTO((PhotCode **code, int *mode, Average *average, SecFilt *secfilt, Measure *measure, int *nlist, int param));
     43double       *ExtractDMag           PROTO((PhotCode **code, int *mode, Average *average, SecFilt *secfilt, Measure *measure, int *nlist));
     44double       *ExtractMagnitudes     PROTO((PhotCode *code, int mode, Average *average, SecFilt *secfilt, Measure *measure, int *n));
     45double       *ExtractMeasures       PROTO((PhotCode *code, int mode, Average *average, SecFilt *secfilt, Measure *measure, int *nlist, int param));
     46double       *ExtractMeasuresByDMag PROTO((PhotCode **code, int *mode, int use_first, Average *average, SecFilt *secfilt, Measure *measure, int *nlist, int param));
     47double       *ExtractMeasuresDMag   PROTO((PhotCode **code, int *mode, Average *average, SecFilt *secfilt, Measure *measure, int *nlist));
     48Image        *MatchImage            PROTO((unsigned int time, short int source));
     49Coords       *MatchMosaic           PROTO((unsigned int time, short int source));
     50int           DetermineTypeCode     PROTO((Average *average, Measure *measure, int code));
     51double        DetermineTypefrac     PROTO((Average *average, Measure *measure, PhotCode *code));
     52double        ExtractAverages       PROTO((PhotCode *code, int mode, Average *average, SecFilt *secfilt, Measure *measure, int param));
     53void          FreeImageSelection    PROTO(());
     54int           GetAverageParam       PROTO((char *parname));
     55void          GetAverageParamHelp   PROTO(());
     56int           GetMagMode            PROTO((char *string));
     57double        GetMeasure            PROTO((int param, Average *average, Measure *measure, double mag));
     58int           GetMeasureParam       PROTO((char *parname));
     59int           GetMeasureTypeCode    PROTO((Measure *measure));
     60int           GetPhotcodeInfo       PROTO((char *string, PhotCode **Code, int *Mode));
     61int           GetSelectionParam     PROTO(());
     62int           InitPhotcodes         PROTO(());
     63int           Quality               PROTO((Measure *measure, int IsDophot));
     64int           SelectMags            PROTO((int Nphot, int Tphot, int Ns, Average *average, Measure *measure, SecFilt *secfilt, int UL));
     65int           SetImageSelection     PROTO((int mode));
     66int           SetPhotSelections     PROTO((int *argc, char **argv, int Nparams));
     67int           SetSelectionParam     PROTO((int param));
     68int           TestAverage           PROTO((PhotCode *code, Average *average, SecFilt *secfilt, Measure *measure));
     69int           TestPhotSelections    PROTO((PhotCode **code, int param));
     70void          print_value           PROTO((FILE *f, double value, short int ival));
    4571
    46 int           InitPhotcodes         PROTO(());
    47 int           GetPhotcodeInfo       PROTO((char *string, PhotCode **Code, int *Mode));
    48 
    49 int           GetAverageParam       PROTO((char *parname));
    50 int           GetMeasureParam       PROTO((char *parname));
    51 int           GetMagMode            PROTO((char *string));
    52 int           SelectMags            PROTO((int Nphot, int Tphot, int Ns, Average *average, Measure *measure, SecFilt *secfilt, int UL));
    53 void          print_value           PROTO((FILE *f, double value, short int ival));
    54 int           GetMeasureTypeCode    PROTO((Measure *measure));
    55 int           DetermineTypeCode     PROTO((Average *average, Measure *measure, int Nphot));
    56 double        ExtractAverages       PROTO((PhotCode *code, int mode, Average *ave, SecFilt *sec, Measure *meas, int param));
    57 double       *ExtractMagnitudes     PROTO((PhotCode *code, int mode, Average *ave, SecFilt *sec, Measure *meas, int *n));
    58 double       *ExtractMeasures       PROTO((PhotCode *code, int mode, Average *ave, SecFilt *sec, Measure *meas, int *nlist, int param));
    59 double       *ExtractDMag           PROTO((PhotCode **code, int *mode, Average *average, SecFilt *secfilt, Measure *measure, int *nlist));
    60 double       *ExtractMeasuresDMag   PROTO((PhotCode **code, int *mode, Average *average, SecFilt *secfilt, Measure *measure, int *nlist));
    61 double       *ExtractMeasuresByDMag PROTO((PhotCode **code, int *mode, int use_first, Average *average, SecFilt *secfilt, Measure *measure, int *nlist, int param));
    62 double        DetermineTypefrac     PROTO((Average *average, Measure *measure, PhotCode *code));
    63 void          GetAverageParamHelp   PROTO(());
    64 
     72RegionFile   *SelectRegions         PROTO((char *RegionName, char *RegionList, int *nregions));
    6573
    6674# endif
Note: See TracChangeset for help on using the changeset viewer.