Changeset 4585 for trunk/Ohana/src/opihi/dvo/dmagmeas.c
- Timestamp:
- Jul 20, 2005, 4:27:25 AM (21 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/opihi/dvo/dmagmeas.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/dvo/dmagmeas.c
r4470 r4585 1 1 # include "dvo1.h" 2 double *ExtractByDMag (PhotCode **code, int *mode, Average *average, SecFilt *secfilt, Measure *measure, int *nlist, int param);3 2 4 3 int dmagmeas (int argc, char **argv) { 5 4 5 char filename[256], catdir[256], *RegionName, *RegionList; 6 double Radius, *M1, *M3; 7 int i, j, k, m, i1, i3, N1, N3, N; 8 int Npts, NPTS, param, mode[3]; 9 int Ngraph, Nsec, Nregions; 10 6 11 Catalog catalog; 7 Graphdata graphsky;8 12 RegionFile *regions; 9 13 PhotCode *code[3]; 10 14 Vector *xvec, *yvec; 11 12 char filename[256], catdir[256], *CPTfile;13 double Radius, *M1, *M3;14 int i, j, k, m, N1, N3, N;15 int Npts, NPTS, param, mode[3];16 int Ngraph, Nsec, Nregions;17 15 18 16 /* defaults */ … … 21 19 catalog.secfilt = NULL; 22 20 catalog.measure = NULL; 21 RegionName = NULL; 22 RegionList = NULL; 23 23 24 24 /* load photcode information */ … … 26 26 Nsec = GetPhotcodeNsecfilt (); 27 27 28 /* load data about plot windows */29 Ngraph = 0;30 if (!GetGraphData (&graphsky, NULL, &Ngraph)) return (FALSE);31 32 28 /* find CATDIR in config system */ 33 VarConfig ("CATDIR", "%s", catdir); 34 35 /* check for CPT selection */ 36 CPTfile = NULL; 37 if (N = get_argument (argc, argv, "-cpt")) { 38 remove_argument (N, &argc, argv); 39 CPTfile = strcreate (argv[N]); 40 remove_argument (N, &argc, argv); 41 } 29 if (VarConfig ("CATDIR", "%s", catdir) == NULL) goto escape; 42 30 43 31 /* interpret command-line options */ 44 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 arguments: dmagmeas F1 - F2 : (value) */ 45 36 if (argc != 6) { goto usage; } 46 37 if (strcmp (argv[2], "-")) goto usage; 47 38 if (strcmp (argv[4], ":")) goto usage; 48 49 /* interpret command-line options */50 39 if (!GetPhotcodeInfo (argv[1], &code[0], &mode[0])) goto usage; 51 40 if (!GetPhotcodeInfo (argv[3], &code[1], &mode[1])) goto usage; 52 41 if ((param = GetMeasureParam (argv[5])) == MEAS_ZERO) goto usage; 42 if (!TestPhotSelections (&code[2], MEAS_ZERO)) goto escape; 53 43 54 /* test PhotSelections: is photcode specified if needed? */ 55 for (i = 0; i < 2; i++) { 56 if (!TestPhotSelections (&code[i])) { 57 fprintf (stderr, "photcode selection rules violated\n"); 58 fprintf (stderr, "average and ensemble restrictions require a corresponding photcode\n"); 59 goto escape; 60 } 61 } 62 63 /* determine region-file names */ 64 if (CPTfile == NULL) { 65 float Radius; 66 Radius = MAX (fabs(graphsky.xmax), fabs(graphsky.ymax)); 67 regions = find_regions (graphsky.coords.crval1, graphsky.coords.crval2, Radius, &Nregions); 68 } else { 69 Nregions = 1; 70 ALLOCATE (regions, RegionFile, 1); 71 strcpy (regions[0].name, CPTfile); 72 } 73 if (!SetImageSelection (param, &graphsky, TRUE)) return (FALSE); 44 /* load region corresponding to selection above */ 45 if ((regions = SelectRegions (RegionName, RegionList, &Nregions)) == NULL) goto escape; 46 if (!SetImageSelection (param)) goto escape; 74 47 75 48 /* init vectors to save data */ … … 101 74 m = catalog.average[i].offset; 102 75 76 SetSelectionParam (0); 103 77 M1 = ExtractDMag (code, mode, &catalog.average[i], &catalog.secfilt[i*Nsec], &catalog.measure[m], &N1); 104 78 if (N1 == 0) goto skip; 105 79 106 M3 = ExtractByDMag (code, mode, &catalog.average[i], &catalog.secfilt[i*Nsec], &catalog.measure[m], &N3, param); 107 if (N3 != N1) { fprintf (stderr, "mismatch: programming error\n"); goto escape; } 80 SetSelectionParam (2); 81 M3 = ExtractMeasures (code[2], mode[2], &catalog.average[i], &catalog.secfilt[i*Nsec], &catalog.measure[m], &N3, param); 82 if (N3 == 0) goto skip; 108 83 109 for (k = 0; k < N1; k++) { 110 xvec[0].elements[Npts] = M1[k]; 111 yvec[0].elements[Npts] = M3[k]; 112 Npts++; 113 if (Npts == NPTS) { 114 NPTS += 2000; 115 REALLOCATE (xvec[0].elements, float, NPTS); 116 REALLOCATE (yvec[0].elements, float, NPTS); 84 for (i1 = 0; i1 < N1; i1++) { 85 for (i3 = 0; i3 < N3; i3++) { 86 xvec[0].elements[Npts] = M1[i1]; 87 yvec[0].elements[Npts] = M3[i3]; 88 Npts++; 89 if (Npts >= NPTS) { 90 NPTS += 2000; 91 REALLOCATE (xvec[0].elements, float, NPTS); 92 REALLOCATE (yvec[0].elements, float, NPTS); 93 } 117 94 } 118 95 } … … 143 120 if (catalog.secfilt != NULL) free (catalog.secfilt); 144 121 if (catalog.measure != NULL) free (catalog.measure); 122 if (RegionName != NULL) free (RegionName); 123 if (RegionList != NULL) free (RegionList); 145 124 return (FALSE); 146 125 }
Note:
See TracChangeset
for help on using the changeset viewer.
