Changeset 4585 for trunk/Ohana/src/opihi/dvo/mextract.c
- Timestamp:
- Jul 20, 2005, 4:27:25 AM (21 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/opihi/dvo/mextract.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/dvo/mextract.c
r3462 r4585 4 4 5 5 int i, j, k, m, N, N1, NPTS; 6 int param, mode, Nregions, N graph, Nsec;7 char filename[128], catdir[256], * p;8 double *M1;6 int param, mode, Nregions, Nsec; 7 char filename[128], catdir[256], *RegionName, *RegionList, *p; 8 double Radius, *M1; 9 9 10 10 PhotCode *code; 11 11 Catalog catalog; 12 12 RegionFile *regions; 13 Graphdata graphsky;14 13 Vector *vec; 15 14 15 /* defaults */ 16 16 regions = NULL; 17 17 catalog.average = (Average *) NULL; 18 18 catalog.secfilt = (SecFilt *) NULL; 19 19 catalog.measure = (Measure *) NULL; 20 RegionName = NULL; 21 RegionList = NULL; 22 code = NULL; 23 mode = MAG_REL; 20 24 21 25 /* load photcode information */ … … 23 27 Nsec = GetPhotcodeNsecfilt (); 24 28 25 /* load data about plot windows */26 Ngraph = 0;27 if (!GetGraphData (&graphsky, NULL, &Ngraph)) goto escape;28 29 29 /* find CATDIR in config system */ 30 VarConfig ("CATDIR", "%s", catdir); 31 32 /* specify catalog files 33 RegionList = FALSE; 34 if (N = get_argument (argc, argv, "-list")) { 35 RegionList = TRUE; 36 remove_argument (N, &argc, argv); 37 strcpy (RegionListFile, argv[N]); 38 remove_argument (N, &argc, argv); 39 } */ 30 if (VarConfig ("CATDIR", "%s", catdir) == NULL) goto escape; 40 31 41 32 /* interpret command-line options */ 42 if (!SetPhotSelections (&argc, argv)) goto usage; 43 if (argc != 3) goto usage; 33 SetSelectionParam (0); 34 if (!SetRegionSelection (&argc, argv, &RegionName, &RegionList)) goto escape; 35 if (!SetPhotSelections (&argc, argv, 1)) goto usage; 44 36 45 /* identify selection */ 46 code = NULL; 47 mode = MAG_REL; 48 param = GetMeasureParam (argv[2]); 37 /* interpret required command-line arguments: mextract (value) */ 38 if (argc != 2) goto usage; 39 param = GetMeasureParam (argv[1]); 49 40 if (param == MEAS_ZERO) { 50 if (!GetPhotcodeInfo (argv[ 2], &code, &mode)) {41 if (!GetPhotcodeInfo (argv[1], &code, &mode)) { 51 42 GetMeasureParam ("help"); 52 fprintf (stderr, "value may also be a valid photcode\n");53 fprintf (stderr, "photcodes or 'mag' may have optional magnitude type: mag,[Minst, Mcat, Msys, Mrel, Mcal]\n");54 43 goto escape; 55 44 } 56 45 param = MEAS_MAG; 57 for (p = argv[ 2]; *p != 0; p++) {46 for (p = argv[1]; *p != 0; p++) { 58 47 if (*p == '.') *p = ':'; 59 48 } 60 }61 /* test PhotSelections: is photcode specified if needed? */62 if (!TestPhotSelections (&code)) {63 fprintf (stderr, "photcode selection rules violated\n");64 fprintf (stderr, "average and ensemble restrictions require a corresponding photcode\n");65 goto escape;66 49 } 50 if (!TestPhotSelections (&code, MEAS_ZERO)) goto escape; 67 51 68 if ((vec = SelectVector (argv[2], ANYVECTOR, TRUE)) == NULL) goto escape; 69 70 /* determine region-file names */ 71 if (!strcmp (argv[1], "all")) { 72 float Radius; 73 Radius = MAX (fabs(graphsky.xmax), fabs(graphsky.ymax)); 74 regions = find_regions (graphsky.coords.crval1, graphsky.coords.crval2, Radius, &Nregions); 75 /* I don't have a tool to select images by the overlapping region */ 76 if (!SetImageSelection (param, &graphsky, TRUE)) goto escape; 77 } else { 78 Nregions = 1; 79 ALLOCATE (regions, RegionFile, 1); 80 strcpy (regions[0].name, argv[1]); 81 if (!SetImageSelection (param, NULL, FALSE)) goto escape; 82 } 52 /* load region corresponding to selection above */ 53 if ((regions = SelectRegions (RegionName, RegionList, &Nregions)) == NULL) goto escape; 54 if (!SetImageSelection (param)) goto escape; 83 55 84 56 /* create storage vector */ 85 N PTS = 1000;86 REALLOCATE (vec[0].elements, float, NPTS);87 vec[0].Nelements = N = 0;57 N = 0; 58 NPTS = 1; 59 if ((vec = SelectVector (argv[1], ANYVECTOR, TRUE)) == NULL) goto escape; 88 60 89 61 for (i = 0; i < Nregions; i++) { … … 110 82 vec[0].elements[N] = M1[k]; 111 83 N++; 112 if (N == NPTS - 1) { 113 NPTS += 2000; 114 REALLOCATE (vec[0].elements, float, NPTS); 115 } 84 CHECK_REALLOCATE (vec[0].elements, float, NPTS, N, 2000); 116 85 } 117 86 if (M1 != NULL) free (M1); … … 132 101 133 102 usage: 134 fprintf (stderr, "USAGE: mextract (from) (value) [options]\n"); 135 fprintf (stderr, " from: cpt name or 'all'\n"); 103 fprintf (stderr, "USAGE: mextract (value) [options]\n"); 136 104 fprintf (stderr, " value: measure.parameter or photcode\n"); 137 105 return (FALSE); 138 106 139 107 escape: 108 FreeImageSelection (); 140 109 if (regions != NULL) free (regions); 141 FreeImageSelection ();142 110 if (catalog.average != NULL) free (catalog.average); 143 111 if (catalog.secfilt != NULL) free (catalog.secfilt); 144 112 if (catalog.measure != NULL) free (catalog.measure); 113 if (RegionName != NULL) free (RegionName); 114 if (RegionList != NULL) free (RegionList); 145 115 return (FALSE); 146 116 }
Note:
See TracChangeset
for help on using the changeset viewer.
