Changeset 25033
- Timestamp:
- Aug 10, 2009, 3:43:50 AM (17 years ago)
- Location:
- branches/eam_branches/20090715/Ohana/src/opihi/cmd.astro
- Files:
-
- 1 added
- 4 edited
-
Makefile (modified) (1 diff)
-
galradbins.c (added)
-
galradius.c (modified) (6 diffs)
-
init.c (modified) (2 diffs)
-
petrosian.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/20090715/Ohana/src/opihi/cmd.astro/Makefile
r25018 r25033 38 38 $(SRC)/mksersic.$(ARCH).o \ 39 39 $(SRC)/galradius.$(ARCH).o \ 40 $(SRC)/galradbins.$(ARCH).o \ 40 41 $(SRC)/galsectors.$(ARCH).o \ 41 42 $(SRC)/galprofiles.$(ARCH).o \ -
branches/eam_branches/20090715/Ohana/src/opihi/cmd.astro/galradius.c
r25018 r25033 11 11 opihi_flt *flux, *radius, *values; 12 12 Buffer *buf; 13 Vector *fvec, *rvec, *tvec ;13 Vector *fvec, *rvec, *tvec, *Fvec, *Rvec; 14 14 char name[128]; 15 15 … … 22 22 if ((rvec = SelectVector (argv[1], OLDVECTOR, TRUE)) == NULL) return (FALSE); 23 23 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 24 28 Fmin = atof(argv[3]); 25 29 Fmax = atof(argv[4]); … … 50 54 Rbin = 1; 51 55 } else { 52 Rbin = MAX(1, Rsum / Rnpt);56 Rbin = MAX(1, 0.5*(Rsum / Rnpt)); 53 57 } 54 58 … … 56 60 if (Rbin <= 2) { 57 61 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)); 58 66 flux = fvec[0].elements.Flt; 59 67 radius = rvec[0].elements.Flt; 60 // XXX handle the necessary free below61 68 } else { 62 69 // rebin the vectors by Rbin values: 63 70 Nout = fvec[0].Nelements / Rbin + 1; 64 ALLOCATE (flux, opihi_flt, Nout);65 ALLOCATE (radius, opihi_flt, Nout);66 71 ALLOCATE (values, opihi_flt, fvec[0].Nelements); 67 72 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 68 78 for (i = 0; i < Nout; i++) { 69 79 radius[i] = (i + 0.5)*Rbin; … … 73 83 N = 0; 74 84 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]; 78 88 N++; 79 89 } … … 87 97 } 88 98 } 99 free (values); 89 100 } 90 101 -
branches/eam_branches/20090715/Ohana/src/opihi/cmd.astro/init.c
r25018 r25033 25 25 int galprofiles PROTO((int, char **)); 26 26 int galradius PROTO((int, char **)); 27 int galradbins PROTO((int, char **)); 27 28 int elliprofile PROTO((int, char **)); 28 29 int petrosian PROTO((int, char **)); … … 71 72 {1, "galprofiles", galprofiles, "generate radial vectors with interpolation along paths"}, 72 73 {1, "galradius", galradius, "generate radial vectors with interpolation along paths"}, 74 {1, "galradbins", galradbins, "generate radial vectors with interpolation along paths"}, 73 75 {1, "elliprofile", elliprofile, "generate radial vectors with interpolation along paths"}, 74 76 {1, "petrosian", petrosian, "petrosian parameters given radial bins"}, -
branches/eam_branches/20090715/Ohana/src/opihi/cmd.astro/petrosian.c
r25018 r25033 5 5 int i, above; 6 6 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; 9 9 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"); 12 12 return (FALSE); 13 13 } … … 15 15 /* select input vectors */ 16 16 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); 20 23 21 24 // difficult work goes into cleaning the input galaxy profile: … … 34 37 ResetVector (Fvec, OPIHI_FLT, fvec[0].Nelements); 35 38 ResetVector (Rvec, OPIHI_FLT, fvec[0].Nelements); 39 ResetVector (Svec, OPIHI_FLT, fvec[0].Nelements); 40 ResetVector (Avec, OPIHI_FLT, fvec[0].Nelements); 36 41 37 42 above = TRUE; 38 43 Fsum = 0.0; 44 Asum = 0.0; 45 Area = avec[0].elements.Flt[0]; 39 46 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; 42 59 Fvec[0].elements.Flt[i] = Fsum; 60 Svec[0].elements.Flt[i] = Fsum / Asum; 61 Avec[0].elements.Flt[i] = Asum; 43 62 44 63 // anytime we transition below the petrosian ratio R_90, calculate the radius and flux
Note:
See TracChangeset
for help on using the changeset viewer.
