Changeset 5485 for anuga_core/source
- Timestamp:
- Jul 10, 2008, 2:14:22 PM (17 years ago)
- Location:
- anuga_core/source/anuga/shallow_water
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/shallow_water/data_manager.py
r5474 r5485 48 48 49 49 """ 50 51 # This file was reverted from changeset:5484 to changeset:5470 on 10th July 52 # by Ole. 50 53 51 54 import exceptions … … 4838 4841 NORTH_VELOCITY_MUX2_LABEL = '-n-mux2' 4839 4842 4840 def read_mux2_py(filenames,weights,permutation=None,verbose=False): 4841 """ 4842 Access the mux files specified in the filenames list. Combine the 4843 data found therin as a weighted linear sum as specifed by the weights. 4844 If permutation is None extract timeseries data for all gauges within the 4845 files. 4846 4847 Input: 4848 filenames: List of filenames specifiying the file containing the 4849 timeseries data (mux2 format) for each source 4850 weights: Weights associated with each source 4851 permutation: Specifies the gauge numbers that for which data is to be 4852 extracted 4853 """ 4843 def read_mux2_py(filenames,weights,verbose=False): 4844 4854 4845 from Numeric import ones,Float,compress,zeros,arange 4855 4846 from urs_ext import read_mux2 … … 4865 4856 verbose=0 4866 4857 4867 data=read_mux2(numSrc,filenames,weights,file_params, permutation,verbose)4858 data=read_mux2(numSrc,filenames,weights,file_params,verbose) 4868 4859 4869 4860 msg='File parameter values were not read in correctly from c file' … … 5046 5037 raise IOError, msg 5047 5038 5048 if ordering_filename is not None: 5049 # Read ordering file 5050 5051 try: 5052 fid=open(ordering_filename, 'r') 5053 file_header=fid.readline().split(',') 5054 ordering_lines=fid.readlines() 5055 fid.close() 5056 except: 5057 msg = 'Cannot open %s'%ordering_filename 5058 raise Exception, msg 5059 5060 reference_header = 'index, longitude, latitude\n' 5061 reference_header_split = reference_header.split(',') 5062 for i in range(3): 5063 if not file_header[i].strip() == reference_header_split[i].strip(): 5064 msg = 'File must contain header: '+reference_header+'\n' 5065 raise Exception, msg 5066 5067 if len(ordering_lines)<2: 5068 msg = 'File must contain at least two points' 5069 raise Exception, msg 5070 5071 5072 5073 permutation = [int(line.split(',')[0]) for line in ordering_lines] 5074 else: 5075 permutation = None 5076 5039 #need to do this for velocity-e-mux2 and velocity-n-mux2 files as well 5040 #for now set x_momentum and y_moentum quantities to zero 5077 5041 if (verbose): print 'reading mux2 file' 5078 5042 mux={} 5079 5043 for i,quantity in enumerate(quantities): 5080 5044 # For each quantity read the associated list of source mux2 file with extenstion associated with that quantity 5081 times, latitudes_urs, longitudes_urs, elevation, mux[quantity],starttime = read_mux2_py(files_in[i],weights, permutation=permutation,verbose=verbose)5045 times, latitudes_urs, longitudes_urs, elevation, mux[quantity],starttime = read_mux2_py(files_in[i],weights,verbose=verbose) 5082 5046 if quantity!=quantities[0]: 5083 5047 msg='%s, %s and %s have inconsitent gauge data'%(files_in[0],files_in[1],files_in[2]) … … 5092 5056 elevation_old=elevation 5093 5057 starttime_old=starttime 5058 5094 5059 5095 5060 if ordering_filename is not None: 5096 latitudes = latitudes_urs 5097 longitudes = longitudes_urs 5061 # Read ordering file 5062 5063 try: 5064 fid=open(ordering_filename, 'r') 5065 file_header=fid.readline().split(',') 5066 ordering_lines=fid.readlines() 5067 fid.close() 5068 except: 5069 msg = 'Cannot open %s'%ordering_filename 5070 raise Exception, msg 5071 5072 reference_header = 'index, longitude, latitude\n' 5073 reference_header_split = reference_header.split(',') 5074 for i in range(3): 5075 if not file_header[i] == reference_header_split[i]: 5076 msg = 'File must contain header: '+reference_header+'\n' 5077 raise Exception, msg 5078 5079 if len(ordering_lines)<2: 5080 msg = 'File must contain at least two points' 5081 raise Exception, msg 5082 5083 5084 5085 permutation = [int(line.split(',')[0]) for line in ordering_lines] 5086 5087 latitudes = take(latitudes_urs, permutation) 5088 longitudes = take(longitudes_urs, permutation) 5098 5089 5099 5090 # Self check - can be removed to improve speed … … 5128 5119 longitudes=longitudes_urs 5129 5120 permutation = range(latitudes.shape[0]) 5121 5130 5122 5131 5123 msg='File is empty and or clipped region not in file region' … … 5189 5181 if verbose: print 'Converting quantities' 5190 5182 for j in range(len(times)): 5191 for i in range(number_of_points):5192 w = zscale*mux['HA'][i ,j] + mean_stage5193 h=w-elevation[i ]5183 for i, index in enumerate(permutation): 5184 w = zscale*mux['HA'][index,j] + mean_stage 5185 h=w-elevation[index] 5194 5186 stage[j,i] = w 5195 5187 5196 xmomentum[j,i] = mux['UA'][i ,j]*h5197 ymomentum[j,i] = mux['VA'][i ,j]*h5188 xmomentum[j,i] = mux['UA'][index,j]*h 5189 ymomentum[j,i] = mux['VA'][index,j]*h 5198 5190 5199 5191 outfile.close() -
anuga_core/source/anuga/shallow_water/test_data_manager.py
r5473 r5485 2 2 # 3 3 4 # This file was reverted from changeset:5484 to changeset:5470 on 10th July 5 # by Ole. 4 6 5 7 import unittest … … 6105 6107 return base_name, files 6106 6108 6107 def test_read_mux2_py 0(self):6109 def test_read_mux2_pyI(self): 6108 6110 """Constant stage,momentum at each gauge 6109 6111 """ … … 6543 6545 """Test multiple sources with ordering file 6544 6546 """ 6547 6545 6548 tide=0 6546 6549 time_step_count = 3 … … 6944 6947 fid.write(line) 6945 6948 fid.close() 6946 6949 6947 6950 sts_file=base_name 6948 6951 urs2sts(base_name, basename_out=sts_file, … … 8888 8891 if __name__ == "__main__": 8889 8892 8890 #suite = unittest.makeSuite(Test_Data_Manager,'test_read_mux2_py0')8891 8893 suite = unittest.makeSuite(Test_Data_Manager,'test') 8892 8894 #suite = unittest.makeSuite(Test_Data_Manager,'test_export_gridII') -
anuga_core/source/anuga/shallow_water/urs_ext.c
r5482 r5485 3 3 gcc -shared urs_ext.o -o urs_ext.so 4 4 */ 5 6 /* 7 This file was reverted from changeset:5484 to changeset:5470 on 10th July 8 by Ole. 9 */ 10 5 11 #include "Python.h" 6 12 #include "Numeric/arrayobject.h" … … 23 29 char isdata(float); 24 30 void wrttxt(char *, float, int, float *, float, float, float, float, float, int, int, int); 25 PyArrayObject *_read_mux2(int, char **, float *, double *, PyObject*, int);31 float** _read_mux2(int, char **, float *, double *, int); 26 32 27 33 PyObject *read_mux2(PyObject *self, PyObject *args){ … … 29 35 30 36 Python call: 31 read_mux2(numSrc,filenames,weights,file_params, permutation,verbose)37 read_mux2(numSrc,filenames,weights,file_params,verbose) 32 38 33 39 NOTE: … … 37 43 PyObject *filenames; 38 44 PyArrayObject *pyweights,*file_params; 39 PyArrayObject *sts_data; 40 PyObject *permutation; 45 PyArrayObject *pydata; 41 46 PyObject *fname; 42 47 … … 46 51 long verbose; 47 52 53 float **cdata; 54 int dimensions[2]; 48 55 int nsta0; 49 56 int nt; 50 57 double dt; 51 int i; 58 int i,j; 59 int start_tstep; 60 int finish_tstep; 61 int it,time; 62 int num_ts; 52 63 53 64 // Convert Python arguments to C 54 if (!PyArg_ParseTuple(args, "iOOO Oi",55 &numSrc,&filenames,&pyweights,&file_params,& permutation,&verbose)) {65 if (!PyArg_ParseTuple(args, "iOOOi", 66 &numSrc,&filenames,&pyweights,&file_params,&verbose)) { 56 67 57 68 PyErr_SetString(PyExc_RuntimeError, … … 83 94 muxFileNameArray = (char **) malloc((int)numSrc*sizeof(char *)); 84 95 if (muxFileNameArray == NULL) { 85 PyErr_SetString(PyExc_RuntimeError,"Memory for muxFileNameArray could not be allocated");86 return NULL;96 printf("ERROR: Memory for muxFileNameArray could not be allocated.\n"); 97 exit(-1); 87 98 } 88 99 for (i=0;i<PyList_Size(filenames);i++){ 89 100 muxFileNameArray[i] = (char *) malloc((MAX_FILE_NAME_LENGTH+1)*sizeof(char)); 90 101 if (muxFileNameArray[i] == NULL) { 91 PyErr_SetString(PyExc_RuntimeError,"Memory for muxFileNameArray could not be allocated");92 return NULL;102 printf("ERROR: Memory for muxFileNameArray could not be allocated.\n"); 103 exit(-1); 93 104 } 94 105 fname=PyList_GetItem(filenames, i); 95 106 if (!PyString_Check(fname)) { 96 107 PyErr_SetString(PyExc_ValueError, "filename not a string"); 97 return NULL;98 108 } 99 109 muxFileNameArray[i]=PyString_AsString(fname); … … 113 123 114 124 // Read in mux2 data from file 115 sts_data=_read_mux2((int)numSrc,muxFileNameArray,weights,(double*)file_params->data,permutation,(int)verbose); 125 cdata=_read_mux2((int)numSrc,muxFileNameArray,weights,(double*)file_params->data,(int)verbose); 126 116 127 117 128 // Allocate space for return vector … … 120 131 nt=(int)*(double *) (file_params -> data+2*file_params->strides[0]); 121 132 133 134 // Find min and max start times of all gauges 135 start_tstep=nt+1; 136 finish_tstep=-1; 137 for (i=0;i<nsta0;i++){ 138 if ((int)cdata[i][nt+3] < start_tstep){ 139 start_tstep=(int)cdata[i][nt+3]; 140 } 141 if ((int)cdata[i][nt+4] > finish_tstep){ 142 finish_tstep=(int)cdata[i][nt+4]; 143 } 144 } 145 146 if ((start_tstep>nt) | (finish_tstep < 0)){ 147 printf("ERROR: Gauge data has incorrect start and finsh times\n"); 148 return NULL; 149 } 150 151 if (start_tstep>=finish_tstep){ 152 printf("ERROR: Gauge data has non-postive_length\n"); 153 return NULL; 154 } 155 156 num_ts=finish_tstep-start_tstep+1; 157 dimensions[0]=nsta0; 158 dimensions[1]=num_ts+POFFSET; 159 pydata = (PyArrayObject *) PyArray_FromDims(2, dimensions, PyArray_DOUBLE); 160 if(pydata == NULL){ 161 printf("ERROR: Memory for pydata array could not be allocated.\n"); 162 return NULL; 163 } 164 165 // Each gauge begins and ends recording at different times. When a gauge is 166 // not recording but at least one other gauge is. Pad the non-recording gauge 167 // array with zeros. 168 for (i=0;i<nsta0;i++){ 169 time=0; 170 for (it=0;it<finish_tstep;it++){ 171 if((it+1>=start_tstep)&&(it+1<=finish_tstep)){ 172 if (it+1>(int)cdata[i][nt+4]){ 173 //This gauge has stopped recording but others are still recording 174 *(double *) (pydata -> data+i*pydata->strides[0]+time*pydata->strides[1])=0.0; 175 }else{ 176 *(double *) (pydata -> data+i*pydata->strides[0]+time*pydata->strides[1])=cdata[i][it]; 177 } 178 time++; 179 } 180 } 181 // Pass back lat,lon,elevation 182 for (j=0; j<POFFSET; j++){ 183 *(double *) (pydata -> data+i*pydata->strides[0]+(num_ts+j)*pydata->strides[1])=cdata[i][nt+j]; 184 } 185 } 186 122 187 free(weights); 123 188 free(muxFileNameArray); 124 return PyArray_Return(sts_data); 189 free(cdata); 190 return PyArray_Return(pydata); 125 191 126 192 } 127 193 128 PyArrayObject *_read_mux2(int numSrc, char **muxFileNameArray, float *weights, double *params, PyObject *permutation, int verbose)194 float** _read_mux2(int numSrc, char **muxFileNameArray, float *weights, double *params, int verbose) 129 195 { 130 196 FILE *fp; 131 int nsta, nsta0, i, j, t, isrc, ista, N;197 int nsta, nsta0, i, isrc, ista; 132 198 struct tgsrwg *mytgs, *mytgs0; 133 199 char *muxFileName; … … 138 204 long numData; 139 205 140 int start_tstep; 141 int finish_tstep; 142 int num_ts; 143 int dimensions[2]; 206 144 207 int len_sts_data; 208 float **sts_data; 145 209 float *temp_sts_data; 146 147 PyArrayObject *sts_data; 148 149 int permuation_dimensions[1]; 150 PyArrayObject *permutation_array; 151 152 long int offset; 210 211 long int offset; 212 213 /* Allocate space for the names and the weights and pointers to the data*/ 153 214 154 215 /* Check that the input files have mux2 extension*/ … … 177 238 /* Open the first muxfile */ 178 239 if((fp=fopen(muxFileNameArray[0],"r"))==NULL){ 179 fprintf(stderr,"Cannot open file %s\n", muxFileNameArray[0]); 180 PyErr_SetString(PyExc_RuntimeError,""); 181 return NULL; 240 fprintf(stderr, "cannot open file %s\n", muxFileNameArray[0]); 241 exit(-1); 182 242 } 183 243 … … 192 252 /*make an array to hold the start and stop steps for each station for each 193 253 source*/ 254 //FIXME: Should only store start and stop times for one source 194 255 fros = (int *) malloc(nsta0*numSrc*sizeof(int)); 195 256 lros = (int *) malloc(nsta0*numSrc*sizeof(int)); … … 201 262 /* compute the size of the data block for source 0 */ 202 263 numData = getNumData(fros, lros, nsta0); 203 num_ts = mytgs0[0].nt; 204 264 205 265 /* Burbidge: Added a sanity check here */ 206 266 if (numData < 0) { 207 267 fprintf(stderr,"Size of data block appears to be negative!\n"); 208 PyErr_SetString(PyExc_RuntimeError,""); 209 return NULL; 268 exit(-1); 210 269 } 211 270 fclose(fp); 212 271 213 272 // Allocate header array for each remaining source file. 273 // FIXME: only need to store for one source and which is compared to all subsequent 274 // source headers 214 275 if(numSrc > 1){ 215 276 /* allocate space for tgsrwg for the other sources */ … … 217 278 } else { 218 279 /* FIXME (JJ): What should happen in case the are no source files?*/ 219 /* If we exit here, tests will break */ 220 } 221 222 /* loop over remaining sources and read headers */ 280 /* If we exit here, tests will break */ 281 // fprintf(stderr, "No source file specified\n"); 282 // exit(-1); 283 } 284 285 /* loop over remaining sources, check compatibility, and read them into 286 *muxData */ 223 287 for(isrc=1; isrc<numSrc; isrc++){ 224 288 muxFileName = muxFileNameArray[isrc]; … … 228 292 { 229 293 fprintf(stderr, "cannot open file %s\n", muxFileName); 230 PyErr_SetString(PyExc_RuntimeError,""); 231 return NULL; 294 exit(-1); 232 295 } 233 296 … … 236 299 if(nsta != nsta0){ 237 300 fprintf(stderr,"%s has different number of stations to %s\n", muxFileName, muxFileNameArray[0]); 238 PyErr_SetString(PyExc_RuntimeError,"");239 301 fclose(fp); 240 return NULL;302 exit(-1); 241 303 } 242 304 fread(&mytgs[0], nsta*sizeof(struct tgsrwg), 1, fp); … … 245 307 fprintf(stderr,"%s has different sampling rate to %s\n", muxFileName, muxFileNameArray[0]); 246 308 fclose(fp); 247 return NULL;309 exit(-1); 248 310 } 249 if(mytgs[ista].nt != num_ts){311 if(mytgs[ista].nt != mytgs0[ista].nt){ 250 312 fprintf(stderr,"%s has different series length to %s\n", muxFileName, muxFileNameArray[0]); 251 PyErr_SetString(PyExc_RuntimeError,"");252 313 fclose(fp); 253 return NULL;314 exit(-1); 254 315 } 255 316 } … … 262 323 numData = getNumData(fros+isrc*nsta0, lros+isrc*nsta0, nsta0); 263 324 325 /* Burbidge: Added a sanity check here */ 264 326 if (numData < 0){ 265 327 fprintf(stderr,"Size of data block appears to be negative!\n"); 266 PyErr_SetString(PyExc_RuntimeError,""); 267 return NULL; 328 exit(-1); 268 329 } 269 330 fclose(fp); 270 331 } 271 272 /* 273 for (i=0;i<nsta0*numSrc;i++){ 274 printf("%d, fros %d\n",i,fros[i]); 275 printf("%d, lros %d\n",i,lros[i]); 276 }*/ 277 278 if (permutation == Py_None){ 279 // if no permutation is specified return the times series of all the gauges in the mux file 280 permuation_dimensions[0]=nsta0; 281 permutation_array=(PyArrayObject *) PyArray_FromDims(1, permuation_dimensions, PyArray_INT); 282 for (ista=0; ista<nsta0; ista++){ 283 *(long *) (permutation_array -> data+ista*permutation_array->strides[0])=ista; 284 } 285 }else{ 286 // Specifies the gauge numbers that for which data is to be extracted 287 permutation_array=(PyArrayObject *) PyArray_ContiguousFromObject(permutation,PyArray_INT,1,1); 288 N = permutation_array->dimensions[0]; //FIXME: this is overwritten below 289 for (ista=0; ista<N; ista++){ 290 if ((int)*(long *) (permutation_array -> data+ista*permutation_array->strides[0])>=nsta0){ 291 printf("Maximum index = %d, you had %d\n",nsta0-1,(int)*(long *) (permutation_array -> data+ista*permutation_array->strides[0])); 292 PyErr_SetString(PyExc_RuntimeError,"The permutation specified is out of bounds"); 293 return NULL; 294 } 295 } 296 } 297 if(permutation_array == NULL){ 298 PyErr_SetString(PyExc_RuntimeError,"Memory for permutation_array array could not be allocated"); 299 return NULL; 300 } 301 302 N = permutation_array->dimensions[0]; 303 304 params[0]=(double)N; 332 params[0]=(double)nsta0; 305 333 params[1]=(double)mytgs0[0].dt; 306 params[2]=(double)num_ts; 307 308 309 // Find min and max start times of all gauges 310 start_tstep=num_ts+1; 311 finish_tstep=-1; 312 for (i=0;i<N;i++){ 313 ista = *(long *) (permutation_array -> data+i*permutation_array->strides[0]); 314 if (fros[ista]< start_tstep){ 315 start_tstep=fros[ista]; 316 } 317 if (lros[0+nsta0*ista] > finish_tstep){ 318 finish_tstep=lros[ista]; 319 } 320 } 321 322 if ((start_tstep>num_ts) | (finish_tstep < 0)){ 323 printf("s=%d,f=%d,num_ts=%d\n",start_tstep,finish_tstep,num_ts); 324 PyErr_SetString(PyExc_RuntimeError,"Gauge data has incorrect start and finsh times"); 325 return NULL; 326 } 327 328 if (start_tstep>=finish_tstep){ 329 PyErr_SetString(PyExc_RuntimeError,"Gauge data has non-postive_length"); 330 return NULL; 331 } 332 333 /* Make array(s) to hold the demuxed data */ 334 len_sts_data=num_ts+POFFSET; 335 dimensions[0]=N; 336 dimensions[1]=len_sts_data; 337 sts_data = (PyArrayObject *) PyArray_FromDims(2, dimensions, PyArray_DOUBLE); 338 if(sts_data == NULL){ 339 PyErr_SetString(PyExc_RuntimeError,"Memory for pydata array could not be allocated"); 340 return NULL; 341 } 342 343 /* Initialise sts data to zero */ 344 for(i=0; i<N; i++){ 345 ista = *(long *) (permutation_array -> data+i*permutation_array->strides[0]); 346 for (t=0;t<num_ts;t++){ 347 *(double *) (sts_data -> data+i*sts_data->strides[0]+t*sts_data->strides[1])=0.0; 348 } 349 *(double *) (sts_data -> data+i*sts_data->strides[0]+(num_ts)*sts_data->strides[1])=(float)mytgs0[ista].geolat; 350 *(double *) (sts_data -> data+i*sts_data->strides[0]+(num_ts+1)*sts_data->strides[1])=(float)mytgs0[ista].geolon; 351 *(double *) (sts_data -> data+i*sts_data->strides[0]+(num_ts+2)*sts_data->strides[1])=(float)mytgs0[ista].z; 352 *(double *) (sts_data -> data+i*sts_data->strides[0]+(num_ts+3)*sts_data->strides[1])=(float)fros[ista]; 353 *(double *) (sts_data -> data+i*sts_data->strides[0]+(num_ts+4)*sts_data->strides[1])=(float)lros[ista]; 354 } 334 params[2]=(double)mytgs0[0].nt; 335 336 /* make array(s) to hold the demuxed data */ 337 //FIXME: This can be reduced to only contain stations in order file 338 sts_data = (float **)malloc (nsta0 * sizeof(float *)); 339 340 if (sts_data == NULL){ 341 printf("ERROR: Memory for sts_data could not be allocated.\n"); 342 exit(-1); 343 } 344 345 len_sts_data=mytgs0[0].nt + POFFSET; 346 for (ista=0; ista<nsta0; ista++){ 347 // Initialise sts_data to zero 348 sts_data[ista] = (float *)calloc(len_sts_data, sizeof(float) ); 349 if (sts_data[ista] == NULL){ 350 printf("ERROR: Memory for sts_data could not be allocated.\n"); 351 exit(-1); 352 } 353 sts_data[ista][mytgs0[0].nt]=(float)mytgs0[ista].geolat; 354 sts_data[ista][mytgs0[0].nt+1]=(float)mytgs0[ista].geolon; 355 sts_data[ista][mytgs0[0].nt+2]=(float)mytgs0[ista].z; 356 sts_data[ista][mytgs0[0].nt+3]=(float)fros[ista]; 357 sts_data[ista][mytgs0[0].nt+4]=(float)lros[ista]; 358 } 355 359 356 360 temp_sts_data = (float *)calloc(len_sts_data, sizeof(float) ); … … 365 369 if((fp=fopen(muxFileName,"r"))==NULL) 366 370 { 367 fprintf(stderr, "Cannot open file %s\n", muxFileName);368 PyErr_SetString(PyExc_RuntimeError,"");369 return NULL;371 //fprintf(stderr, "%s: cannot open file %s\n", av[0], muxFileName); 372 fprintf(stderr, "cannot open file %s\n", muxFileName); 373 exit(-1); 370 374 } 371 375 … … 383 387 384 388 /* loop over stations */ 385 for(j=0; j<N; j++){ 386 ista = *(long *) (permutation_array -> data+j*permutation_array->strides[0]); 387 //printf("%d\n",(int)*(long *) (permutation_array -> data+j*permutation_array->strides[0])); 389 for(ista=0; ista<nsta0; ista++){ 388 390 389 391 /* fill the data0 array from the mux file, and weight it */ 390 fillDataArray(ista, nsta0, num_ts, mytgs0[ista].ig, fros+isrc*nsta0, lros+isrc*nsta0, temp_sts_data, &istart, &istop, muxData);392 fillDataArray(ista, nsta0, mytgs0[ista].nt, mytgs0[ista].ig, fros+isrc*nsta0, lros+isrc*nsta0, temp_sts_data, &istart, &istop, muxData); 391 393 392 394 /* weight appropriately and add */ 393 for(t=0; t<num_ts; t++){ 394 if((isdata(*(double *) (sts_data -> data+j*sts_data->strides[0]+t*sts_data->strides[1]))) && isdata(temp_sts_data[t])){ 395 *(double *) (sts_data -> data+j*sts_data->strides[0]+t*sts_data->strides[1]) += temp_sts_data[t] * weights[isrc]; 395 for(i=0; i<mytgs0[ista].nt; i++){ 396 if((isdata(sts_data[ista][i])) && isdata(temp_sts_data[i])){ 397 sts_data[ista][i] += temp_sts_data[i] * weights[isrc]; 398 //printf("%d,%d,%f\n",ista,i,sts_data[ista][i]); 396 399 }else{ 397 *(double *) (sts_data -> data+j*sts_data->strides[0]+t*sts_data->strides[1]) = 0.0;400 sts_data[ista][i] = NODATA; 398 401 } 399 402 } 400 403 } 401 } 404 } 402 405 free(muxData); 403 406 free(temp_sts_data); 404 free(fros);405 free(lros);406 407 return sts_data; 407 408 } … … 484 485 } 485 486 486 487 /* Burbidge: No "offset" is sent. Replace with max. Added grid_id */ 488 void wrttxt( fname, dt, nt, x, beg, lat, lon, max, depth, grid_id, istart, istop ) 489 char *fname; 490 float dt, *x, beg, max, lat, lon, depth; 491 int grid_id; 492 int nt; 493 int istart, istop; 494 { 495 int it; 496 float t; 497 FILE *fp; 498 499 fp = fopen(fname,"w"); 500 fprintf(fp,"> lat %g lon %g depth %g max %g start_time %g stop_time %g grid_id %d\n", lat, lon, depth, max, 501 istart*dt, istop*dt, grid_id ); 502 for(it=0;it<nt;it++) 503 { 504 t=beg+it*dt; 505 fprintf(fp,"%9.3f %g\n", t, x[it]); 506 } 507 fclose(fp); 508 } 509 487 510 char isdata(float x) 488 511 {
Note: See TracChangeset
for help on using the changeset viewer.