36 #include "CpuTimerC.h"
37 #include "GeoTessMetaDataC.h"
38 #include "GeoTessModelC.h"
39 #include "GeoTessUtilsC.h"
40 #include "PointMapC.h"
42 #include "GeoTessGridC.h"
43 #include "InterpolatorTypeC.h"
47 #include "DataTypeC.h"
48 #include "ErrorHandler.h"
54 static const double rtd = 180./3.1415926535897932384626;
55 static const double dtr = 3.1415926535897932384626/180.;
57 double integrate2D(GeoTessModelC* model,
double* pointA,
double* pointB,
int attributeIndex);
64 int main(
int argc,
char** argv)
70 EarthShapeC* ellipsoid;
72 double station[3],
event[3];
74 double pathIntegral_seconds;
86 ellipsoid = geomodel_getEarthShape(model);
88 earthshape_getVectorDegrees(ellipsoid, 0., 30., station);
90 earthshape_getVectorDegrees(ellipsoid, 0., 40., event);
92 pathIntegral_seconds =
integrate2D(model, station, event, 0);
94 printf(
"pathIntegral_seconds = %1.3f\n", pathIntegral_seconds);
96 earthshape_destroy(ellipsoid);
99 geomodel_destroy(model);
104 printf(
"Integrate2D completed successfully.\n");
108 double integrate2D(GeoTessModelC* model,
double* pointA,
double* pointB,
int attributeIndex)
113 double pointSpacing = 0.1 *
dtr;
115 double earthRadius = -1.;
119 double sumWeights = 0;
125 int* pointIndices=NULL;
126 double* weights=NULL;
128 geomodel_getWeights2D(model, pointA, pointB, pointSpacing, earthRadius, LINEAR, &pointIndices, &weights, &allocatedSize, &nWeights);
133 for (j=0; j<nWeights; ++j)
136 sumWeights += weights[j];
139 integral += weights[j] / geomodel_getValueDouble(model, pointIndices[j], 0, 0, attributeIndex);
143 printf(
"Sum of weights (length of ray path) = %10.4f km \n\n", sumWeights);
146 printf(
"Path integral = %10.4f sec \n\n", integral);
149 if (pointIndices) free(pointIndices);
150 if (weights) free(weights);
171 GeoTessMetaDataC* metaData;
172 GeoTessModelC* model;
183 metaData = geometadata_create();
188 geometadata_setEarthShape(metaData,
"WGS84");
190 geometadata_setDescription(metaData,
"GeoTessModel for example program Integrate2D\n");
195 geometadata_setLayerNames1(metaData,
"surface");
199 geometadata_setAttributes1(metaData,
"velocity",
"km/sec");
203 geometadata_setDataType1(metaData, FLOAT);
208 geometadata_setModelSoftwareVersion(metaData,
"GeoTessCExamples.Integrate2D 1.0.0");
213 geometadata_setModelGenerationDate(metaData, str);
219 model = geomodel_create3(gridFile, metaData);
230 geometadata_destroy(metaData);
235 for (i = 0; i < geomodel_getNVertices(model); ++i)
236 geomodel_setProfSurfFloats(model, i, &velocity, 1);
254 while (error_exists())
256 fprintf(stderr,
"%s\n", error_getMessage());