IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 25033


Ignore:
Timestamp:
Aug 10, 2009, 3:43:50 AM (17 years ago)
Author:
eugene
Message:

more tests of robust petrosian analysis

Location:
branches/eam_branches/20090715/Ohana/src/opihi/cmd.astro
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/20090715/Ohana/src/opihi/cmd.astro/Makefile

    r25018 r25033  
    3838$(SRC)/mksersic.$(ARCH).o          \
    3939$(SRC)/galradius.$(ARCH).o         \
     40$(SRC)/galradbins.$(ARCH).o        \
    4041$(SRC)/galsectors.$(ARCH).o        \
    4142$(SRC)/galprofiles.$(ARCH).o       \
  • branches/eam_branches/20090715/Ohana/src/opihi/cmd.astro/galradius.c

    r25018 r25033  
    1111  opihi_flt *flux, *radius, *values;
    1212  Buffer *buf;
    13   Vector *fvec, *rvec, *tvec;
     13  Vector *fvec, *rvec, *tvec, *Fvec, *Rvec;
    1414  char name[128];
    1515
     
    2222  if ((rvec = SelectVector (argv[1], OLDVECTOR, TRUE)) == NULL) return (FALSE);
    2323  if ((fvec = SelectVector (argv[2], OLDVECTOR, TRUE)) == NULL) return (FALSE);
     24
     25  if ((Rvec = SelectVector ("rg", ANYVECTOR, TRUE)) == NULL) return (FALSE);
     26  if ((Fvec = SelectVector ("fg", ANYVECTOR, TRUE)) == NULL) return (FALSE);
     27
    2428  Fmin = atof(argv[3]);
    2529  Fmax = atof(argv[4]);
     
    5054    Rbin = 1;
    5155  } else {
    52     Rbin = MAX(1, Rsum / Rnpt);
     56    Rbin = MAX(1, 0.5*(Rsum / Rnpt));
    5357  }
    5458
     
    5660  if (Rbin <= 2) {
    5761    Nout   = fvec[0].Nelements;
     62    ResetVector (Rvec, OPIHI_FLT, Nout);
     63    ResetVector (Fvec, OPIHI_FLT, Nout);
     64    memcpy (Fvec[0].elements.Flt, fvec[0].elements.Flt, Fvec[0].Nelements*sizeof(opihi_flt));
     65    memcpy (Rvec[0].elements.Flt, rvec[0].elements.Flt, Rvec[0].Nelements*sizeof(opihi_flt));
    5866    flux   = fvec[0].elements.Flt;
    5967    radius = rvec[0].elements.Flt;
    60     // XXX handle the necessary free below
    6168  } else {
    6269    // rebin the vectors by Rbin values:
    6370    Nout = fvec[0].Nelements / Rbin + 1;
    64     ALLOCATE (flux,   opihi_flt, Nout);
    65     ALLOCATE (radius, opihi_flt, Nout);
    6671    ALLOCATE (values, opihi_flt, fvec[0].Nelements);
    6772 
     73    ResetVector (Rvec, OPIHI_FLT, Nout);
     74    ResetVector (Fvec, OPIHI_FLT, Nout);
     75    flux   = Fvec[0].elements.Flt;
     76    radius = Rvec[0].elements.Flt;
     77
    6878    for (i = 0; i < Nout; i++) {
    6979      radius[i] = (i + 0.5)*Rbin;
     
    7383      N = 0;
    7484      for (j = 0; j < fvec[0].Nelements; j++) {
    75         if (rvec[0].elements.Flt[i] < Rmin) continue;
    76         if (rvec[0].elements.Flt[i] > Rmax) continue;
    77         values[N] = fvec[0].elements.Flt[i];
     85        if (rvec[0].elements.Flt[j] < Rmin) continue;
     86        if (rvec[0].elements.Flt[j] > Rmax) continue;
     87        values[N] = fvec[0].elements.Flt[j];
    7888        N++;
    7989      }
     
    8797      }
    8898    }
     99    free (values);
    89100  }
    90101
  • branches/eam_branches/20090715/Ohana/src/opihi/cmd.astro/init.c

    r25018 r25033  
    2525int galprofiles             PROTO((int, char **));
    2626int galradius               PROTO((int, char **));
     27int galradbins              PROTO((int, char **));
    2728int elliprofile             PROTO((int, char **));
    2829int petrosian               PROTO((int, char **));
     
    7172  {1, "galprofiles", galprofiles,  "generate radial vectors with interpolation along paths"},
    7273  {1, "galradius",   galradius,    "generate radial vectors with interpolation along paths"},
     74  {1, "galradbins",  galradbins,   "generate radial vectors with interpolation along paths"},
    7375  {1, "elliprofile", elliprofile,  "generate radial vectors with interpolation along paths"},
    7476  {1, "petrosian",   petrosian,    "petrosian parameters given radial bins"},
  • branches/eam_branches/20090715/Ohana/src/opihi/cmd.astro/petrosian.c

    r25018 r25033  
    55  int i, above;
    66  float *in;
    7   double Fsum, R_90, rad_90, flux_90;
    8   Vector *rvec, *fvec, *Rvec, *Fvec;
     7  double Fsum, Asum, Area, R_90, rad_90, flux_90;
     8  Vector *rvec, *avec, *fvec, *Rvec, *Fvec, *Svec, *Avec;
    99
    10   if (argc != 2) {
    11     gprint (GP_ERR, "USAGE: petrosian (radius) (flux) (P_ratio) (P_flux)\n");
     10  if (argc != 8) {
     11    gprint (GP_ERR, "USAGE: petrosian (radius) (area) (flux) (P_ratio) (P_flux) (P_sb) (P_area)\n");
    1212    return (FALSE);
    1313  }
     
    1515  /* select input vectors */
    1616  if ((rvec = SelectVector (argv[1], OLDVECTOR, TRUE)) == NULL) return (FALSE);
    17   if ((fvec = SelectVector (argv[2], OLDVECTOR, TRUE)) == NULL) return (FALSE);
    18   if ((Rvec = SelectVector (argv[3], ANYVECTOR, TRUE)) == NULL) return (FALSE);
    19   if ((Fvec = SelectVector (argv[4], ANYVECTOR, TRUE)) == NULL) return (FALSE);
     17  if ((avec = SelectVector (argv[2], OLDVECTOR, TRUE)) == NULL) return (FALSE);
     18  if ((fvec = SelectVector (argv[3], OLDVECTOR, TRUE)) == NULL) return (FALSE);
     19  if ((Rvec = SelectVector (argv[4], ANYVECTOR, TRUE)) == NULL) return (FALSE);
     20  if ((Fvec = SelectVector (argv[5], ANYVECTOR, TRUE)) == NULL) return (FALSE);
     21  if ((Svec = SelectVector (argv[6], ANYVECTOR, TRUE)) == NULL) return (FALSE);
     22  if ((Avec = SelectVector (argv[7], ANYVECTOR, TRUE)) == NULL) return (FALSE);
    2023
    2124  // difficult work goes into cleaning the input galaxy profile:
     
    3437  ResetVector (Fvec, OPIHI_FLT, fvec[0].Nelements);
    3538  ResetVector (Rvec, OPIHI_FLT, fvec[0].Nelements);
     39  ResetVector (Svec, OPIHI_FLT, fvec[0].Nelements);
     40  ResetVector (Avec, OPIHI_FLT, fvec[0].Nelements);
    3641
    3742  above = TRUE;
    3843  Fsum = 0.0;
     44  Asum = 0.0;
     45  Area = avec[0].elements.Flt[0];
    3946  for (i = 0; i < fvec[0].Nelements; i++) {
    40     Fsum += fvec[0].elements.Flt[i] * M_PI * SQ(rvec[0].elements.Flt[i]);
    41     Rvec[0].elements.Flt[i] = Fsum / fvec[0].elements.Flt[i];
     47    // for nan bins, we keep the area for use with the next valid bin
     48    if (isnan(fvec[0].elements.Flt[i])) {
     49      Area += avec[0].elements.Flt[i];
     50      continue;
     51    }
     52    Fsum += fvec[0].elements.Flt[i] * Area;
     53    Asum += Area;
     54    if (i+1 < fvec[0].Nelements) {
     55      Area = avec[0].elements.Flt[i+1];
     56    }
     57
     58    Rvec[0].elements.Flt[i] = Asum * fvec[0].elements.Flt[i] / Fsum;
    4259    Fvec[0].elements.Flt[i] = Fsum;
     60    Svec[0].elements.Flt[i] = Fsum / Asum;
     61    Avec[0].elements.Flt[i] = Asum;
    4362
    4463    // anytime we transition below the petrosian ratio R_90, calculate the radius and flux
Note: See TracChangeset for help on using the changeset viewer.