Changeset 4585 for trunk/Ohana/src/opihi/dvo/dmags.c
- Timestamp:
- Jul 20, 2005, 4:27:25 AM (21 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/opihi/dvo/dmags.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/dvo/dmags.c
r4470 r4585 3 3 int dmags (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, *M3; 13 7 int i, j, m, i1, i3, N1, N3, N; 14 8 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; 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 required command-line arguments: dmags F1 - F2 : F3 */ 44 36 if (argc != 6) { goto usage; } 45 37 if (strcmp (argv[2], "-")) goto usage; 46 38 if (strcmp (argv[4], ":")) goto usage; 47 48 /* interpret command-line options */49 39 if (!GetPhotcodeInfo (argv[1], &code[0], &mode[0])) goto usage; 50 40 if (!GetPhotcodeInfo (argv[3], &code[1], &mode[1])) goto usage; 51 41 if (!GetPhotcodeInfo (argv[5], &code[2], &mode[2])) goto usage; 42 if (!TestPhotSelections (&code[0], MEAS_ZERO)) goto escape; 52 43 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; 72 46 73 47 /* init vectors to save data */ … … 99 73 m = catalog.average[i].offset; 100 74 75 SetSelectionParam (0); 101 76 M1 = ExtractDMag (code, mode, &catalog.average[i], &catalog.secfilt[i*Nsec], &catalog.measure[m], &N1); 102 77 if (N1 == 0) goto skip; 103 78 79 SetSelectionParam (2); 104 80 M3 = ExtractMagnitudes (code[2], mode[2], &catalog.average[i], &catalog.secfilt[i*Nsec], &catalog.measure[m], &N3); 105 81 if (N3 == 0) goto skip; … … 110 86 yvec[0].elements[Npts] = M3[i3]; 111 87 Npts++; 112 if (Npts == NPTS) {88 if (Npts >= NPTS) { 113 89 NPTS += 2000; 114 90 REALLOCATE (xvec[0].elements, float, NPTS); … … 134 110 usage: 135 111 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"); 137 113 fprintf (stderr, " pri: F:inst, F:cat, F:sys, F:rel, F:cal, F:ave, F:ref\n"); 138 114 fprintf (stderr, " sec: F:inst, F:cat, F:sys, F:rel, F:cal, F:ave, F:ref\n"); 139 115 fprintf (stderr, " dep: F:inst, F:cat, F:sys, F:rel, F:cal\n"); 140 116 fprintf (stderr, " ref: F:cat\n"); 141 return (FALSE);142 117 143 118 escape: … … 146 121 if (catalog.secfilt != NULL) free (catalog.secfilt); 147 122 if (catalog.measure != NULL) free (catalog.measure); 123 if (RegionName != NULL) free (RegionName); 124 if (RegionList != NULL) free (RegionList); 148 125 return (FALSE); 149 126 }
Note:
See TracChangeset
for help on using the changeset viewer.
