Changeset 4585 for trunk/Ohana/src/opihi/dvo/dmagaves.c
- Timestamp:
- Jul 20, 2005, 4:27:25 AM (21 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/opihi/dvo/dmagaves.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/dvo/dmagaves.c
r4470 r4585 3 3 int dmagaves (int argc, char **argv) { 4 4 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; 12 6 double Radius, *M1, M2; 13 7 int i, j, k, m, N1, N; 14 8 int Npts, NPTS, param, mode[3]; 15 9 int Ngraph, Nsec, Nregions; 10 11 Catalog catalog; 12 RegionFile *regions; 13 PhotCode *code[3]; 14 Vector *xvec, *yvec; 16 15 17 16 /* defaults */ … … 20 19 catalog.secfilt = NULL; 21 20 catalog.measure = NULL; 21 RegionName = NULL; 22 RegionList = NULL; 22 23 23 24 /* load photcode information */ … … 25 26 Nsec = GetPhotcodeNsecfilt (); 26 27 27 /* load data about plot windows */28 Ngraph = 0;29 if (!GetGraphData (&graphsky, NULL, &Ngraph)) return (FALSE);30 31 28 /* 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; 41 30 42 31 /* 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) */ 44 36 if (argc != 6) { goto usage; } 45 37 if (strcmp (argv[2], "-")) goto usage; 46 38 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; 47 43 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; 77 46 78 47 /* init vectors to save data */ … … 103 72 m = catalog.average[i].offset; 104 73 74 SetSelectionParam (0); 105 75 M1 = ExtractDMag (code, mode, &catalog.average[i], &catalog.secfilt[i*Nsec], &catalog.measure[m], &N1); 106 76 if (N1 == 0) goto skip; 107 77 78 SetSelectionParam (2); 108 79 M2 = ExtractAverages (code[2], mode[2], &catalog.average[i], &catalog.secfilt[i*Nsec], &catalog.measure[m], param); 109 80 … … 112 83 yvec[0].elements[Npts] = M2; 113 84 Npts++; 114 if (Npts == NPTS) {85 if (Npts >= NPTS) { 115 86 NPTS += 2000; 116 87 REALLOCATE (xvec[0].elements, float, NPTS); … … 128 99 catalog.measure = (Measure *) NULL; 129 100 } 130 FreeImageSelection ();131 101 if (regions != NULL) free (regions); 132 102 xvec[0].Nelements = yvec[0].Nelements = Npts; … … 138 108 139 109 escape: 140 FreeImageSelection ();141 110 if (regions != NULL) free (regions); 142 111 if (catalog.average != NULL) free (catalog.average); 143 112 if (catalog.secfilt != NULL) free (catalog.secfilt); 144 113 if (catalog.measure != NULL) free (catalog.measure); 114 if (RegionName != NULL) free (RegionName); 115 if (RegionList != NULL) free (RegionList); 145 116 return (FALSE); 146 117 }
Note:
See TracChangeset
for help on using the changeset viewer.
