- Timestamp:
- Nov 30, 2008, 7:45:21 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branch_20081124/Ohana/src/opihi/dvo/mmextract.c
r20856 r20857 8 8 int Nsecfilt, VERBOSE, loadImages, mosaicMode; 9 9 char **cstack1, **cstack2, name1[1024], name2[1024]; 10 float*values, **table1, **table2;10 dbValue *values, **table1, **table2; 11 11 void *Signal; 12 12 … … 139 139 140 140 /* create storage vector */ 141 ALLOCATE (values, float, Nfields);141 ALLOCATE (values, dbValue, Nfields); 142 142 ALLOCATE (vec, Vector *, Nreturn); 143 143 … … 152 152 if ((vec[2*i+0] = SelectVector (name1, ANYVECTOR, TRUE)) == NULL) goto escape; 153 153 if ((vec[2*i+1] = SelectVector (name2, ANYVECTOR, TRUE)) == NULL) goto escape; 154 ResetVector (vec[2*i+0], fields[i].type, NNN);155 ResetVector (vec[2*i+1], fields[i].type, NNN);154 ResetVector (vec[2*i+0], fields[i].type, fields[i].type); 155 ResetVector (vec[2*i+1], fields[i].type, fields[i].type); 156 156 } 157 157 … … 160 160 161 161 // we save the selected measures for each average to temporary tables 1 and 2 162 // XXX need to deal with the INT / DBL difference here... 162 163 NTABLE = 100; 163 ALLOCATE (table1, float*, Nreturn_base);164 ALLOCATE (table2, float*, Nreturn_base);164 ALLOCATE (table1, dbValue *, Nreturn_base); 165 ALLOCATE (table2, dbValue *, Nreturn_base); 165 166 for (i = 0; i < Nreturn_base; i++) { 166 ALLOCATE (table1[i], float, NTABLE);167 ALLOCATE (table2[i], float, NTABLE);167 ALLOCATE (table1[i], dbValue, NTABLE); 168 ALLOCATE (table2[i], dbValue, NTABLE); 168 169 } 169 170 … … 196 197 NTABLE = catalog.average[j].Nmeasure; 197 198 for (n = 0; n < Nreturn_base; n++) { 198 REALLOCATE (table1[n], float, NTABLE);199 REALLOCATE (table2[n], float, NTABLE);199 REALLOCATE (table1[n], dbValue, NTABLE); 200 REALLOCATE (table2[n], dbValue, NTABLE); 200 201 } 201 202 } … … 208 209 dbExtractMeasuresInitMeas (); // reset counters for saved fields 209 210 for (n = 0; n < Nfields; n++) { 211 // values needs to be a pointer to a type with FLT and INT (with a union, we would save a bit of memory...) 210 212 values[n] = dbExtractMeasures (&catalog.average[j], &catalog.secfilt[j*Nsecfilt], &catalog.measure[m], &fields[n]); 211 213 } … … 234 236 for (n2 = 0; n2 < Nt2; n2++) { 235 237 for (n = 0; n < Nreturn_base; n++) { 236 vec[2*n+0][0].elements.Flt[Npts] = table1[n][n1]; 237 vec[2*n+1][0].elements.Flt[Npts] = table2[n][n2]; 238 if (vec[2*n+0][0].type == OPIHI_FLT) { 239 vec[2*n+0][0].elements.Flt[Npts] = table1[n][n1].Flt; 240 vec[2*n+1][0].elements.Flt[Npts] = table2[n][n2].Flt; 241 } else { 242 vec[2*n+0][0].elements.Int[Npts] = table1[n][n1].Int; 243 vec[2*n+1][0].elements.Int[Npts] = table2[n][n2].Int; 244 } 238 245 } 239 246 Npts++; … … 241 248 NPTS += 2000; 242 249 for (n = 0; n < Nreturn; n++) { 243 REALLOCATE (vec[n][0].elements.Flt, opihi_flt, NPTS); 250 if (vec[n][0].type == OPIHI_FLT) { 251 REALLOCATE (vec[n][0].elements.Flt, opihi_flt, NPTS); 252 } else { 253 REALLOCATE (vec[n][0].elements.Int, opihi_int, NPTS); 254 } 244 255 } 245 256 } … … 257 268 interrupt = FALSE; 258 269 270 // free excess memory 259 271 for (n = 0; n < Nreturn; n++) { 260 272 vec[n][0].Nelements = Npts; 261 REALLOCATE (vec[n][0].elements.Flt, opihi_flt, MAX(1,Npts)); 273 if (vec[n][0].type == OPIHI_FLT) { 274 REALLOCATE (vec[n][0].elements.Flt, opihi_flt, MAX(1,Npts)); 275 } else { 276 REALLOCATE (vec[n][0].elements.Int, opihi_int, MAX(1,Npts)); 277 } 262 278 } 263 279
Note:
See TracChangeset
for help on using the changeset viewer.
