Changeset 16936
- Timestamp:
- Mar 11, 2008, 11:11:55 AM (18 years ago)
- Location:
- trunk/Ohana/src/opihi
- Files:
-
- 6 edited
-
dvo/avextract.c (modified) (1 diff)
-
dvo/dbExtractAverages.c (modified) (2 diffs)
-
dvo/dbExtractMeasures.c (modified) (2 diffs)
-
dvo/dbFields.c (modified) (3 diffs)
-
dvo/mextract.c (modified) (1 diff)
-
include/dvoshell.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/dvo/avextract.c
r16810 r16936 100 100 101 101 for (j = 0; (j < catalog.Naverage) && !interrupt; j++) { 102 m = catalog.average[j].measureOffset;103 102 // extract the relevant values 104 103 // XXX for measure values, this could be optimized for one loop over measures... 104 105 m = catalog.average[j].measureOffset; 106 dbExtractAveragesInit (); // reset counters for saved fields 105 107 for (n = 0; n < Nfields; n++) { 106 108 values[n] = dbExtractAverages (&catalog.average[j], &catalog.secfilt[j*Nsecfilt], &catalog.measure[m], &fields[n]); -
trunk/Ohana/src/opihi/dvo/dbExtractAverages.c
r16810 r16936 1 1 # include "dvoshell.h" 2 3 static CoordTransform *celestial_to_galactic = NULL; 4 static CoordTransform *celestial_to_ecliptic = NULL; 5 6 static int haveGalactic = FALSE; 7 static double GLON = 0.0; 8 static double GLAT = 0.0; 9 10 static int haveEcliptic = FALSE; 11 static double ELON = 0.0; 12 static double ELAT = 0.0; 13 14 // define a locally-static transform 15 int dbExtractAveragesInitTransform (CoordTransformSystem target) { 16 17 // galactic transform is kept forever 18 if (target == COORD_GALACTIC) { 19 if (celestial_to_galactic != NULL) return (TRUE); 20 celestial_to_galactic = InitTransform (COORD_CELESTIAL, target); 21 return (TRUE); 22 } 23 24 // ecliptic transform must be updated (is weakly time-dependent) 25 if (target == COORD_ECLIPTIC) { 26 if (celestial_to_ecliptic != NULL) { 27 free (celestial_to_ecliptic); 28 } 29 celestial_to_ecliptic = InitTransform (COORD_CELESTIAL, target); 30 return (TRUE); 31 } 32 return (FALSE); 33 } 34 35 int dbExtractAveragesInit () { 36 haveGalactic = FALSE; 37 haveEcliptic = FALSE; 38 return (TRUE); 39 } 2 40 3 41 /* return average.field based on the selection */ … … 16 54 case AVE_DEC: 17 55 value = average[0].D; 56 break; 57 case AVE_GLON: 58 if (!haveGalactic) { 59 ApplyTransform (&GLON, &GLAT, average[0].R, average[0].D, celestial_to_galactic); 60 haveGalactic = TRUE; 61 } 62 value = GLON; 63 break; 64 case AVE_GLAT: 65 if (!haveGalactic) { 66 ApplyTransform (&GLON, &GLAT, average[0].R, average[0].D, celestial_to_galactic); 67 haveGalactic = TRUE; 68 } 69 value = GLAT; 70 break; 71 case AVE_ELON: 72 if (!haveEcliptic) { 73 ApplyTransform (&ELON, &ELAT, average[0].R, average[0].D, celestial_to_ecliptic); 74 haveEcliptic = TRUE; 75 } 76 value = ELON; 77 break; 78 case AVE_ELAT: 79 if (!haveEcliptic) { 80 ApplyTransform (&ELON, &ELAT, average[0].R, average[0].D, celestial_to_ecliptic); 81 haveEcliptic = TRUE; 82 } 83 value = ELAT; 18 84 break; 19 85 case AVE_RA_ERR: -
trunk/Ohana/src/opihi/dvo/dbExtractMeasures.c
r16810 r16936 10 10 static int TimeFormat; 11 11 12 static CoordTransform *celestial_to_galactic = NULL; 13 static CoordTransform *celestial_to_ecliptic = NULL; 14 15 static int haveGalacticAve = FALSE; 16 static double GLON_AVE = 0.0; 17 static double GLAT_AVE = 0.0; 18 19 static int haveEclipticAve = FALSE; 20 static double ELON_AVE = 0.0; 21 static double ELAT_AVE = 0.0; 22 23 static int haveGalacticMeas = FALSE; 24 static double GLON_MEAS = 0.0; 25 static double GLAT_MEAS = 0.0; 26 27 static int haveEclipticMeas = FALSE; 28 static double ELON_MEAS = 0.0; 29 static double ELAT_MEAS = 0.0; 30 12 31 void dbExtractMeasuresInit () { 13 32 GetTimeFormat (&TimeReference, &TimeFormat); 33 } 34 35 // define a locally-static transform 36 int dbExtractMeasuresInitTransform (CoordTransformSystem target) { 37 38 // galactic transform is kept forever 39 if (target == COORD_GALACTIC) { 40 if (celestial_to_galactic != NULL) return (TRUE); 41 celestial_to_galactic = InitTransform (COORD_CELESTIAL, target); 42 return (TRUE); 43 } 44 45 // ecliptic transform must be updated (is weakly time-dependent) 46 if (target == COORD_ECLIPTIC) { 47 if (celestial_to_ecliptic != NULL) { 48 free (celestial_to_ecliptic); 49 } 50 celestial_to_ecliptic = InitTransform (COORD_CELESTIAL, target); 51 return (TRUE); 52 } 53 return (FALSE); 54 } 55 56 int dbExtractMeasuresInitAve () { 57 haveGalacticAve = FALSE; 58 haveEclipticAve = FALSE; 59 return (TRUE); 60 } 61 62 int dbExtractMeasuresInitMeas () { 63 haveGalacticMeas = FALSE; 64 haveEclipticMeas = FALSE; 65 return (TRUE); 14 66 } 15 67 … … 88 140 value = average[0].D; 89 141 break; 142 143 case MEAS_GLON: 144 if (!haveGalacticMeas) { 145 ApplyTransform (&GLON_MEAS, &GLAT_MEAS, average[0].R - measure[0].dR / 3600.0, average[0].D - measure[0].dD / 3600.0, celestial_to_galactic); 146 haveGalacticMeas = TRUE; 147 } 148 value = GLON_MEAS; 149 break; 150 case MEAS_GLAT: 151 if (!haveGalacticMeas) { 152 ApplyTransform (&GLON_MEAS, &GLAT_MEAS, average[0].R - measure[0].dR / 3600.0, average[0].D - measure[0].dD / 3600.0, celestial_to_galactic); 153 haveGalacticMeas = TRUE; 154 } 155 value = GLAT_MEAS; 156 break; 157 case MEAS_ELON: 158 if (!haveEclipticMeas) { 159 ApplyTransform (&ELON_MEAS, &ELAT_MEAS, average[0].R - measure[0].dR / 3600.0, average[0].D - measure[0].dD / 3600.0, celestial_to_ecliptic); 160 haveEclipticMeas = TRUE; 161 } 162 value = ELON_MEAS; 163 break; 164 case MEAS_ELAT: 165 if (!haveEclipticMeas) { 166 ApplyTransform (&ELON_MEAS, &ELAT_MEAS, average[0].R - measure[0].dR / 3600.0, average[0].D - measure[0].dD / 3600.0, celestial_to_ecliptic); 167 haveEclipticMeas = TRUE; 168 } 169 value = ELAT_MEAS; 170 break; 171 172 case MEAS_GLON_AVE: 173 if (!haveGalacticAve) { 174 ApplyTransform (&GLON_AVE, &GLAT_AVE, average[0].R, average[0].D, celestial_to_galactic); 175 haveGalacticAve = TRUE; 176 } 177 value = GLON_AVE; 178 break; 179 case MEAS_GLAT_AVE: 180 if (!haveGalacticAve) { 181 ApplyTransform (&GLON_AVE, &GLAT_AVE, average[0].R, average[0].D, celestial_to_galactic); 182 haveGalacticAve = TRUE; 183 } 184 value = GLAT_AVE; 185 break; 186 case MEAS_ELON_AVE: 187 if (!haveEclipticAve) { 188 ApplyTransform (&ELON_AVE, &ELAT_AVE, average[0].R, average[0].D, celestial_to_ecliptic); 189 haveEclipticAve = TRUE; 190 } 191 value = ELON_AVE; 192 break; 193 case MEAS_ELAT_AVE: 194 if (!haveEclipticAve) { 195 ApplyTransform (&ELON_AVE, &ELAT_AVE, average[0].R, average[0].D, celestial_to_ecliptic); 196 haveEclipticAve = TRUE; 197 } 198 value = ELAT_AVE; 199 break; 200 90 201 case MEAS_RA_AVE_ERR: /* OK */ 91 202 value = average[0].dR; -
trunk/Ohana/src/opihi/dvo/dbFields.c
r16810 r16936 103 103 field->name = strcreate (fieldName); 104 104 105 if (!strcasecmp (fieldName, "GLON")) { 106 dbExtractMeasuresInitTransform (COORD_GALACTIC); 107 ESCAPE (MEAS_GLON, MAG_NONE); 108 } 109 if (!strcasecmp (fieldName, "GLAT")) { 110 dbExtractMeasuresInitTransform (COORD_GALACTIC); 111 ESCAPE (MEAS_GLAT, MAG_NONE); 112 } 113 if (!strcasecmp (fieldName, "GLON:AVE")) { 114 dbExtractMeasuresInitTransform (COORD_GALACTIC); 115 ESCAPE (MEAS_GLON_AVE, MAG_NONE); 116 } 117 if (!strcasecmp (fieldName, "GLAT:AVE")) { 118 dbExtractMeasuresInitTransform (COORD_GALACTIC); 119 ESCAPE (MEAS_GLAT_AVE, MAG_NONE); 120 } 121 122 if (!strcasecmp (fieldName, "ELON")) { 123 dbExtractMeasuresInitTransform (COORD_ECLIPTIC); 124 ESCAPE (MEAS_ELON, MAG_NONE); 125 } 126 if (!strcasecmp (fieldName, "ELAT")) { 127 dbExtractMeasuresInitTransform (COORD_ECLIPTIC); 128 ESCAPE (MEAS_ELAT, MAG_NONE); 129 } 130 if (!strcasecmp (fieldName, "ELON:AVE")) { 131 dbExtractMeasuresInitTransform (COORD_ECLIPTIC); 132 ESCAPE (MEAS_ELON_AVE, MAG_NONE); 133 } 134 if (!strcasecmp (fieldName, "ELAT:AVE")) { 135 dbExtractMeasuresInitTransform (COORD_ECLIPTIC); 136 ESCAPE (MEAS_ELAT_AVE, MAG_NONE); 137 } 138 105 139 if (!strcasecmp (fieldName, "RA")) ESCAPE (MEAS_RA, MAG_NONE); 106 140 if (!strcasecmp (fieldName, "DEC")) ESCAPE (MEAS_DEC, MAG_NONE); … … 109 143 if (!strcasecmp (fieldName, "RA:ERR")) ESCAPE (MEAS_RA_AVE_ERR, MAG_NONE); 110 144 if (!strcasecmp (fieldName, "DEC:ERR")) ESCAPE (MEAS_DEC_AVE_ERR, MAG_NONE); 145 111 146 if (!strcasecmp (fieldName, "uRA")) ESCAPE (MEAS_U_RA, MAG_NONE); 112 147 if (!strcasecmp (fieldName, "uDEC")) ESCAPE (MEAS_U_DEC, MAG_NONE); … … 175 210 field->name = strcreate (fieldName); 176 211 212 // if either GLON or GLAT is requested, we set up a static tranformation 213 // at prepare to calculate the values only once for each row 214 if (!strcasecmp (fieldName, "GLON")) { 215 dbExtractAveragesInitTransform (COORD_GALACTIC); 216 ESCAPE (AVE_GLON, MAG_NONE); 217 } 218 if (!strcasecmp (fieldName, "GLAT")) { 219 dbExtractAveragesInitTransform (COORD_GALACTIC); 220 ESCAPE (AVE_GLAT, MAG_NONE); 221 } 222 223 // if either ELON or ELAT is requested, we set up a static tranformation 224 // at prepare to calculate the values only once for each row 225 if (!strcasecmp (fieldName, "ELON")) { 226 dbExtractAveragesInitTransform (COORD_ECLIPTIC); 227 ESCAPE (AVE_ELON, MAG_NONE); 228 } 229 if (!strcasecmp (fieldName, "ELAT")) { 230 dbExtractAveragesInitTransform (COORD_ECLIPTIC); 231 ESCAPE (AVE_ELAT, MAG_NONE); 232 } 233 177 234 if (!strcasecmp (fieldName, "RA")) ESCAPE (AVE_RA, MAG_NONE); 178 235 if (!strcasecmp (fieldName, "DEC")) ESCAPE (AVE_DEC, MAG_NONE); -
trunk/Ohana/src/opihi/dvo/mextract.c
r16810 r16936 121 121 for (j = 0; (j < catalog.Naverage) && !interrupt; j++) { 122 122 m = catalog.average[j].measureOffset; 123 dbExtractMeasuresInitAve (); // reset counters for saved fields 124 123 125 for (k = 0; (k < catalog.average[j].Nmeasure); k++, m++) { 124 126 125 127 // extract the relevant values for this measurement 128 dbExtractMeasuresInitMeas (); // reset counters for saved fields 126 129 for (n = 0; n < Nfields; n++) { 127 130 values[n] = dbExtractMeasures (&catalog.average[j], &catalog.secfilt[j*Nsecfilt], &catalog.measure[m], &fields[n]); -
trunk/Ohana/src/opihi/include/dvoshell.h
r16810 r16936 23 23 /* measure fields */ 24 24 enum {MEAS_ZERO, 25 MEAS_GLON, 26 MEAS_GLAT, 27 MEAS_GLON_AVE, 28 MEAS_GLAT_AVE, 29 MEAS_ELON, 30 MEAS_ELAT, 31 MEAS_ELON_AVE, 32 MEAS_ELAT_AVE, 25 33 MEAS_RA, 26 34 MEAS_DEC, … … 84 92 AVE_RA_ERR, 85 93 AVE_DEC_ERR, 94 AVE_GLON, 95 AVE_GLAT, 96 AVE_ELON, 97 AVE_ELAT, 86 98 AVE_U_RA, 87 99 AVE_U_DEC, … … 241 253 int wordhash (char *word); 242 254 255 int dbExtractAverageInitTransform (CoordTransformSystem target); 256 int dbExtractAverageInit (); 257 258 int dbExtractMeasuresInitTransform (CoordTransformSystem target); 259 int dbExtractMeasuresInitAve (); 260 int dbExtractMeasuresInitMeas (); 261 243 262 # endif
Note:
See TracChangeset
for help on using the changeset viewer.
