IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 20266


Ignore:
Timestamp:
Oct 19, 2008, 1:51:08 PM (18 years ago)
Author:
eugene
Message:

adding -max-density and -minmag options; limiting total number of stars based on desired max density above the mag min cutoff

Location:
trunk/Ohana/src/getstar
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/getstar/include/getstar.h

    r16061 r20266  
    2727int  SKY_DEPTH;
    2828
     29int MaxDensityUse;
     30float MaxDensityValue;
     31int MinMagUse;
     32float MinMagValue;
    2933int  MagLimitUse;
    3034float MagLimitValue;
  • trunk/Ohana/src/getstar/src/args.c

    r19823 r20266  
    4444    remove_argument (N, &argc, argv);
    4545    MagLimitValue = atof (argv[N]);
     46    remove_argument (N, &argc, argv);
     47  }
     48
     49  MaxDensityUse = FALSE;
     50  if ((N = get_argument (argc, argv, "-max-density"))) {
     51    if (MagLimitUse) {
     52      fprintf (stderr, "-maglim and -max-density are mutually exclusive; ignoring -maglim");
     53      // MagLimitValue will be overridded by a density-based limit
     54    }
     55    MaxDensityUse = TRUE;
     56    remove_argument (N, &argc, argv);
     57    MaxDensityValue = atof (argv[N]);
     58    remove_argument (N, &argc, argv);
     59  }
     60
     61  MinMagUse = FALSE;
     62  if ((N = get_argument (argc, argv, "-minmag"))) {
     63    MinMagUse = TRUE;
     64    remove_argument (N, &argc, argv);
     65    MinMagValue = atof (argv[N]);
    4666    remove_argument (N, &argc, argv);
    4767  }
  • trunk/Ohana/src/getstar/src/select_by_region.c

    r16810 r20266  
    66  int i, j, n, Nm, offset, m, Nsecfilt, code, Nsec;
    77  int Nave, NAVE, Nmeas, NMEAS;
    8   double R, D;
     8  double R, D, AREA;
    99  float mag;
    1010
     
    3737  NMEAS = output[0].Nmeasure + 1000;
    3838  REALLOCATE (output[0].measure, Measure, NMEAS);
     39
     40  // if MaxDensityUse is set, we need to determine the MagLimitValue for this catalog by
     41  // examining the magnitude distribution.  generate a magnitude histogram
     42  if (MaxDensityUse) {
     43    int bin, Nmax, Nbins, Nsum, *Nmag;
     44    float MagMin, MagMax, dMag;
     45    double Rmin, Rmax, Dmin, Dmax;
     46
     47    MagLimitUse = TRUE; // we will use the MagLimit implied by the mag distribution below
     48
     49    gfits_scan (&catalog[0].header, "RA0",  "%lf", 1, &Rmin);
     50    gfits_scan (&catalog[0].header, "DEC0", "%lf", 1, &Dmin);
     51    gfits_scan (&catalog[0].header, "RA1",  "%lf", 1, &Rmax);
     52    gfits_scan (&catalog[0].header, "DEC1", "%lf", 1, &Dmax);
     53
     54    if (VERBOSE) fprintf (stderr, "extracting from catalog covering region %f,%f to %f,%f\n", Rmin, Dmin, Rmax, Dmax);
     55
     56    AREA = fabs(Dmax - Dmin) * fabs(Rmax - Rmin) * cos (0.5*RAD_DEG*(Dmax + Dmin)); 
     57    assert (AREA > 0);
     58
     59    Nmax = MaxDensityValue * AREA;
     60
     61    dMag = 0.1;
     62    MagMin = 0.0;
     63    MagMax = 32.0;
     64    Nbins = (MagMax - MagMin) / dMag;
     65    ALLOCATE (Nmag, int, Nbins);
     66    bzero (Nmag, Nbins * sizeof(int));
     67
     68    for (i = 0; i < catalog[0].Naverage; i++) {
     69      n = catalog[0].measure[i].averef;
     70      mag = NAN;
     71      if (Nsec != -1) {
     72        mag = catalog[0].secfilt[i*Nsecfilt + Nsec].M;
     73      } else {
     74        offset = catalog[0].average[i].measureOffset;
     75        for (m = 0; m < catalog[0].average[i].Nmeasure; m++) {
     76          if (catalog[0].measure[offset + m].photcode == code) {
     77            mag = PhotRel (&catalog[0].measure[offset + m], &catalog[0].average[i], &catalog[0].secfilt[i*Nsecfilt]);
     78            break;
     79          }
     80        }
     81      }
     82      if (isnan(mag)) continue;
     83
     84      bin = (mag - MagMin) / dMag;
     85      if (bin < 0) continue;
     86      if (bin >= Nbins) continue;
     87
     88      Nmag[bin] ++;
     89    }
     90     
     91    if (!MinMagUse) MinMagValue = MagMin;
     92    bin = (MinMagValue - MagMin) / dMag;
     93    bin = MIN (MAX (0, bin), Nbins);
     94
     95    Nsum = 0;
     96    for (i = bin; (i < Nbins) && (Nsum < Nmax); i++) {
     97      Nsum += Nmag[i];
     98    }
     99    MagLimitValue = i*dMag + MagMin;
     100    if (VERBOSE) fprintf (stderr, "using %d stars in mag range %f - %f\n", Nsum, MinMagValue, MagLimitValue);
     101  }
    39102
    40103  for (i = 0; i < catalog[0].Naverage; i++) {
Note: See TracChangeset for help on using the changeset viewer.