Changeset 13440
- Timestamp:
- May 21, 2007, 7:48:06 AM (19 years ago)
- Location:
- branches/kapa-mods-2007-05/Ohana/src/opihi/dvo
- Files:
-
- 5 added
- 3 edited
-
avextract.c (modified) (2 diffs)
-
dbStackMath.c (added)
-
db_check_stack.c (added)
-
db_convert_to_RPN.c (added)
-
dvoBooleanElements.c (added)
-
dvoEvaluateStack.c (added)
-
dvodb.c (modified) (2 diffs)
-
dvofields.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/kapa-mods-2007-05/Ohana/src/opihi/dvo/avextract.c
r13439 r13440 24 24 Nsecfilt = GetPhotcodeNsecfilt (); 25 25 26 // command-line is of the form: avextract field,field, field [where (field op value)...] 27 28 // parse the fields to be extracted and returned 29 narg = argc; 30 fields = ParseCmdlineFields (argc, argv, DVO_TABLE_AVERAGE, &last, &Nfields); 31 if (fields == NULL) return (FALSE); 32 33 // require 'where' before boolean math 34 if ((last != argc) && (strcasecmp(argv[last], "where") || (last >= argc - 2))) { 35 gprint (GP_ERR, "syntax error\n"); 36 free (fields); 37 return (FALSE); 38 } 39 40 // parse the remainder of the line as a boolean math expression 41 cstack = isolate_elements (argv-last, &argv[last+1], &Ncstack); 42 43 // construct the db Boolean math stack 44 dbStack = db_convert_to_RPN (Ncstack, cstack, &NdbStack); 45 46 Nreturn = Nfields; 47 db_check_stack (dbStack, NdbStack, DVO_TABLE_AVERAGE, fields, &Nfields); 48 26 49 /* interpret command-line options */ 27 50 SetSelectionParam (0); 28 51 if (!SetRegionSelection (&argc, argv, &RegionName, &RegionList)) goto escape; 29 if (!SetPhotSelections (&argc, argv, 1)) goto usage;30 31 /* interpret required command-line arguments: mextract (value) */32 if (argc != 2) { goto usage; }33 param = GetAverageParam (argv[1]);34 if (param == AVE_ZERO) {35 if (!GetPhotcodeInfo (argv[1], &code, &mode)) {36 GetAverageParamHelp ();37 goto escape;38 }39 param = AVE_MAG;40 for (p = argv[1]; *p != 0; p++) {41 if (*p == '.') *p = ':';42 }43 }44 if (!TestPhotSelections (&code, &mode, param)) goto escape;45 52 46 53 /* load region corresponding to selection above */ 47 54 if ((skylist = SelectRegions (RegionName, RegionList)) == NULL) goto escape; 48 55 49 /* create storage vector */ 50 N = 0; 56 /* create output storage vectors */ 57 ALLOCATE (return, float, Nreturn); 58 ALLOCATE (vec, Vector, Nreturn); 59 for (i = 0; i < Nreturn; i++) { 60 if ((vec[i] = SelectVector (fields[i].name, ANYVECTOR, TRUE)) == NULL) goto escape; 61 } 62 63 Npts = 0; 51 64 NPTS = 1; 52 if ((vec = SelectVector (argv[1], ANYVECTOR, TRUE)) == NULL) goto escape;53 65 54 66 // XXX need to add interrupt test to this loop … … 70 82 // extract the relevant values 71 83 for (n = 0; n < Nfields; n++) { 72 value [n] = ExtractAveragesNew (&catalog.average[j], &catalog.secfilt[j*Nsecfilt], &catalog.measure[m], field[n]);84 values[n] = ExtractAveragesNew (&catalog.average[j], &catalog.secfilt[j*Nsecfilt], &catalog.measure[m], fields[n]); 73 85 } 74 86 // test the conditional statement 75 if (!CheckBooleanCond ( stack, Nstack, value, field, Nfield)) continue;76 for (n = 0; n < N fields; n++) {77 vec[n].elements[N] = value [n];87 if (!CheckBooleanCond (dbStack, NdbStack, values, fields, Nfields)) continue; 88 for (n = 0; n < Nreturn; n++) { 89 vec[n].elements[N] = values[n]; 78 90 } 79 91 N++; -
branches/kapa-mods-2007-05/Ohana/src/opihi/dvo/dvodb.c
r13439 r13440 8 8 */ 9 9 10 enum {DVO_TABLE_AVERAGE, DVO_TABLE_MEASURE}; 11 10 12 // a single db field 11 13 typedef struct { 12 int fieldNumber; 14 char *name; 15 int extract; 16 int table; 17 int ID; 13 18 int magMode; 14 19 PhotCode *photcode; 15 20 } dvoField; 16 21 17 ParseFields (int argc, char **argv) { 22 // db boolean operations 23 typedef struct { 24 char *name; 25 char type; 26 int field; 27 float Float; 28 } dvoStack; 29 30 dvoField *ParseCmdlineFields (int argc, char **argv, int table, int *last, int *nfields) { 31 32 int i, Nfields, NFIELDS, 33 34 *nfields = 0; 35 Nfields = 0; 36 NFIELDS = 10; 37 ALLOCATE (fields, dvoField, NFIELDS); 18 38 19 39 // examine each argv[i] entry until we reach a where 20 for (i = 0; (i < argc) && strcasecmp (argv[i], "where"); i++) {40 for (i = 1; (i < argc) && strcasecmp (argv[i], "where"); i++) { 21 41 // split the word by "," 22 42 p = argv[i]; … … 32 52 // identify field for word 33 53 // need to know which type of fields to look for... 34 ParseAverageField (); 54 // xxx extend this more generally later 55 if (table == DVO_TABLE_MEASURE) { 56 status = ParseMeasureField (&fields[Nfields], field); 57 } 58 if (table == DVO_TABLE_AVERAGE) { 59 status = ParseAverageField (&fields[Nfields], field); 60 } 61 if (!status) { 62 gprint (GP_ERR, "unknown database field %s\n", field); 63 free (field); 64 free (fields); 65 return (NULL); 66 } 35 67 free (field); 68 69 Nfields ++; 70 CHECK_REALLOCATE (fields, dvoField, NFIELDS, Nfields, 10); 36 71 } 37 72 } 38 73 74 *last = i; 75 *nfields = Nfields; 76 return (fields); 77 } -
branches/kapa-mods-2007-05/Ohana/src/opihi/dvo/dvofields.c
r13439 r13440 1 2 # define ESCAPE(F,M) { \3 field->fieldNumber = (F); \4 field->magMode = (M); \5 field->photcode = NULL; \6 return (TRUE);7 1 8 2 int GetMagMode (char *string) { … … 20 14 } 21 15 16 PhotCode *ParsePhotcodeField (char *field, int *mode, int default) { 17 18 char *tmpstring, *p; 19 PhotCode *code; 20 21 *mode = default; 22 23 p = strchr (field, ':'); 24 if (p != NULL) { 25 *mode = GetMagMode (p + 1); 26 if (*mode == MAG_NONE) return (NULL); 27 tmpstring = strncreate (field, p - field); 28 } else { 29 tmpstring = strcreate (field); 30 } 31 code = GetPhotcodebyName (tmpstring); 32 free (tmpstring); 33 34 return (code); 35 } 36 37 # define ESCAPE(F,M) { \ 38 field->ID = (F); \ 39 field->magMode = (M); \ 40 field->photcode = NULL; \ 41 return (TRUE); 42 22 43 int ParseMeasureField (dvoField *field, char *fieldName) { 23 44 24 45 PhotCode *code; 46 47 field->table = DVO_TABLE_MEASURE; 48 field->name = strcreate (fieldName); 25 49 26 50 if (!strcasecmp (fieldName, "RA")) ESCAPE (MEAS_RA, MAG_NONE); … … 45 69 46 70 // check for code:mode in photcode name 47 mode = MAG_REL; 48 p = strchr (fieldName, ':'); 49 if (p != NULL) { 50 mode = GetMagMode (p + 1); 51 if (mode == MAG_NONE) return (FALSE); 52 tmpstring = strncreate (fieldName, p - fieldName); 53 } else { 54 tmpstring = strcreate (fieldName); 55 } 56 code = GetPhotcodebyName (tmpstring); 57 free (tmpstring); 58 71 code = ParsePhotcodeField (&mode, MAG_REL); 59 72 if (code == NULL) return (FALSE); 60 73 61 74 if (mode == MAG_ERR) { 62 field-> fieldNumber= MEAS_dMAG;75 field->ID = MEAS_dMAG; 63 76 } else { 64 field-> fieldNumber= MEAS_MAG;77 field->ID = MEAS_MAG; 65 78 } 66 79 80 field->magMode = mode; 67 81 field->photcode = code; 68 82 return (TRUE); … … 72 86 73 87 PhotCode *code; 88 89 field->table = DVO_TABLE_AVERAGE; 74 90 75 91 if (!strcasecmp (fieldName, "RA")) ESCAPE (AVE_RA, MAG_NONE); … … 98 114 99 115 // check for code:mode in photcode name 100 mode = MAG_AVE; 101 p = strchr (fieldName, ':'); 102 if (p != NULL) { 103 mode = GetMagMode (p + 1); 104 if (mode == MAG_NONE) return (FALSE); 105 tmpstring = strncreate (fieldName, p - fieldName); 106 } else { 107 tmpstring = strcreate (fieldName); 108 } 109 code = GetPhotcodebyName (tmpstring); 110 free (tmpstring); 111 116 code = ParsePhotcodeField (&mode, MAG_AVE); 112 117 if (code == NULL) return (FALSE); 113 118 114 119 // need to distinguish phot, sys errors and scatter 115 120 if (mode == MAG_ERR) { 116 field-> fieldNumber= MEAS_dMAG;121 field->ID = MEAS_dMAG; 117 122 } else { 118 field-> fieldNumber= MEAS_MAG;123 field->ID = MEAS_MAG; 119 124 } 120 125 126 field->magMode = mode; 121 127 field->photcode = code; 122 128 return (TRUE);
Note:
See TracChangeset
for help on using the changeset viewer.
