36 package gov.sandia.geotess.examples;
41 import gov.
sandia.gmp.util.globals.DataType;
42 import gov.
sandia.gmp.util.numerical.vector.VectorGeo;
45 import java.util.Date;
77 public static void main(String[] args)
83 "\nMust specify a single command line argument specifying " +
84 "the path to the file small_model_grid.geotess\n");
86 System.out.println(
"Example that illustrates how to populate a 3D model.");
91 GeoTessMetaData metaData =
new GeoTessMetaData();
96 metaData.setDescription(String
97 .format(
"Simple example of populating a 3D GeoTess model%n" +
98 "comprised of 3 multi-level tessellations%n"
99 +
"author: Sandy Ballard%n"
100 +
"contact: sballar@sandia.gov"));
103 metaData.setLayerNames(
"INNER_CORE; OUTER_CORE; LOWER_MANTLE; " +
104 "TRANSITION_ZONE; UPPER_MANTLE; LOWER_CRUST; UPPER_CRUST");
116 metaData.setLayerTessIds(
new int[] {0, 0, 1, 1, 1, 2, 2});
120 metaData.setAttributes(
"Vp; Vs; rho",
"km/sec; km/sec; g/cc");
125 metaData.setDataType(DataType.FLOAT);
129 metaData.setModelSoftwareVersion(
"PopulateModel3D 1.0.0");
133 metaData.setModelGenerationDate(
new Date().toString());
143 File gridFile =
new File(args[0]);
148 GeoTessModel model =
new GeoTessModel(gridFile.getCanonicalPath(), metaData);
156 for (
int vtx = 0; vtx < model.getNVertices(); ++vtx)
159 double[] vertex = model.getGrid().getVertex(vtx);
162 double lat = VectorGeo.getLatDegrees(vertex);
163 double lon = VectorGeo.getLonDegrees(vertex);
166 for (
int layer=0; layer<model.getNLayers(); ++layer)
174 float[] radii =
getRadii(lat, lon, layer);
181 float[][] rawData =
getRawData(lat, lon, layer);
183 model.setProfile(vtx, layer, radii, rawData);
193 System.out.println(model.toString());
196 System.out.println(GeoTessModelUtils.profileToString(model, 1));
200 System.out.println(
"Done.");
204 ex.printStackTrace();
223 protected static float[]
getRadii(
double lat,
double lon,
int layer)
226 double[] vertex = VectorGeo.getVectorDegrees(lat, lon);
229 double earthRadius = VectorGeo.getEarthRadius(vertex);
235 float stretch = (float)(earthRadius / 6371.);
237 float[] radii =
new float[ak135[layer].length];
238 for (
int i=0; i<radii.length; ++i)
239 radii[i] = ak135[layer][i][0] * stretch;
261 protected static float[][]
getRawData(
double lat,
double lon,
int layer)
264 float[][] ak135Layer = ak135[layer];
268 int nNodes = ak135Layer.length;
271 float[][] data =
null;
273 if (nNodes == 2 && ak135Layer[0][1] == ak135Layer[1][1])
278 data =
new float[1][3];
279 data[0][0] = ak135Layer[0][1];
280 data[0][1] = ak135Layer[0][2];
281 data[0][2] = ak135Layer[0][3];
288 data =
new float[nNodes][3];
289 for (
int i=0; i<nNodes; ++i)
291 data[i][0] = ak135Layer[i][1];
292 data[i][1] = ak135Layer[i][2];
293 data[i][2] = ak135Layer[i][3];
308 static float[][][] ak135 =
new float[][][] {{
311 { 0.000F, 11.2622F, 3.6678F, 13.0122F},
312 { 50.710F, 11.2618F, 3.6675F, 13.0117F},
313 { 101.430F, 11.2606F, 3.6667F, 13.0100F},
314 { 152.140F, 11.2586F, 3.6653F, 13.0074F},
315 { 202.850F, 11.2557F, 3.6633F, 13.0036F},
316 { 253.560F, 11.2521F, 3.6608F, 12.9988F},
317 { 304.280F, 11.2477F, 3.6577F, 12.9929F},
318 { 354.990F, 11.2424F, 3.6540F, 12.9859F},
319 { 405.700F, 11.2364F, 3.6498F, 12.9779F},
320 { 456.410F, 11.2295F, 3.6450F, 12.9688F},
321 { 507.130F, 11.2219F, 3.6396F, 12.9586F},
322 { 557.840F, 11.2134F, 3.6337F, 12.9474F},
323 { 659.260F, 11.1941F, 3.6202F, 12.9217F},
324 { 709.980F, 11.1832F, 3.6126F, 12.9072F},
325 { 760.690F, 11.1715F, 3.6044F, 12.8917F},
326 { 811.400F, 11.1590F, 3.5957F, 12.8751F},
327 { 862.110F, 11.1457F, 3.5864F, 12.8574F},
328 { 912.830F, 11.1316F, 3.5765F, 12.8387F},
329 { 963.540F, 11.1166F, 3.5661F, 12.8188F},
330 {1014.250F, 11.0983F, 3.5551F, 12.7980F},
331 {1064.960F, 11.0850F, 3.5435F, 12.7760F},
332 {1115.680F, 11.0718F, 3.5314F, 12.7530F},
333 {1166.390F, 11.0585F, 3.5187F, 12.7289F},
334 {1217.500F, 11.0427F, 3.5043F, 12.7037F}
339 {1217.500F, 10.2890F, 0.0000F, 12.1391F},
340 {1267.430F, 10.2854F, 0.0000F, 12.1133F},
341 {1317.760F, 10.2745F, 0.0000F, 12.0867F},
342 {1368.090F, 10.2565F, 0.0000F, 12.0593F},
343 {1418.420F, 10.2329F, 0.0000F, 12.0311F},
344 {1468.760F, 10.2049F, 0.0000F, 12.0001F},
345 {1519.090F, 10.1739F, 0.0000F, 11.9722F},
346 {1569.420F, 10.1415F, 0.0000F, 11.9414F},
347 {1670.080F, 10.0768F, 0.0000F, 11.8772F},
348 {1720.410F, 10.0439F, 0.0000F, 11.8437F},
349 {1770.740F, 10.0103F, 0.0000F, 11.8092F},
350 {1821.070F, 9.9761F, 0.0000F, 11.7737F},
351 {1871.400F, 9.9410F, 0.0000F, 11.7373F},
352 {1921.740F, 9.9051F, 0.0000F, 11.6998F},
353 {1972.070F, 9.8682F, 0.0000F, 11.6612F},
354 {2022.400F, 9.8304F, 0.0000F, 11.6216F},
355 {2072.730F, 9.7914F, 0.0000F, 11.5809F},
356 {2123.060F, 9.7513F, 0.0000F, 11.5391F},
357 {2173.390F, 9.7100F, 0.0000F, 11.4962F},
358 {2223.720F, 9.6673F, 0.0000F, 11.4521F},
359 {2274.050F, 9.6232F, 0.0000F, 11.4069F},
360 {2324.380F, 9.5777F, 0.0000F, 11.3604F},
361 {2374.720F, 9.5306F, 0.0000F, 11.3127F},
362 {2425.050F, 9.4814F, 0.0000F, 11.2639F},
363 {2475.380F, 9.4297F, 0.0000F, 11.2137F},
364 {2525.710F, 9.3760F, 0.0000F, 11.1623F},
365 {2576.040F, 9.3205F, 0.0000F, 11.1095F},
366 {2626.370F, 9.2634F, 0.0000F, 11.0555F},
367 {2676.700F, 9.2042F, 0.0000F, 11.0001F},
368 {2727.030F, 9.1426F, 0.0000F, 10.9434F},
369 {2777.360F, 9.0792F, 0.0000F, 10.8852F},
370 {2827.700F, 9.0138F, 0.0000F, 10.8257F},
371 {2878.030F, 8.9461F, 0.0000F, 10.7647F},
372 {2928.360F, 8.8761F, 0.0000F, 10.7023F},
373 {2978.690F, 8.8036F, 0.0000F, 10.6385F},
374 {3029.020F, 8.7283F, 0.0000F, 10.5731F},
375 {3079.350F, 8.6496F, 0.0000F, 10.5062F},
376 {3129.680F, 8.5692F, 0.0000F, 10.4378F},
377 {3180.010F, 8.4861F, 0.0000F, 10.3679F},
378 {3230.340F, 8.4001F, 0.0000F, 10.2964F},
379 {3280.680F, 8.3122F, 0.0000F, 10.2233F},
380 {3331.010F, 8.2213F, 0.0000F, 10.1485F},
381 {3381.340F, 8.1283F, 0.0000F, 10.0722F},
382 {3431.670F, 8.0382F, 0.0000F, 9.9942F},
383 {3479.500F, 8.0000F, 0.0000F, 9.9145F}
388 {3479.500F, 13.6602F, 7.2811F, 5.5515F},
389 {3531.670F, 13.6566F, 7.2704F, 5.5284F},
390 {3581.330F, 13.6530F, 7.2597F, 5.5051F},
391 {3631.000F, 13.6494F, 7.2490F, 5.4817F},
392 {3681.000F, 13.5900F, 7.2258F, 5.4582F},
393 {3731.000F, 13.5312F, 7.2031F, 5.4345F},
394 {3779.500F, 13.4741F, 7.1807F, 5.4108F},
395 {3829.000F, 13.4156F, 7.1586F, 5.3869F},
396 {3878.500F, 13.3585F, 7.1369F, 5.3628F},
397 {3928.000F, 13.3018F, 7.1144F, 5.3386F},
398 {3977.500F, 13.2465F, 7.0931F, 5.3142F},
399 {4027.000F, 13.1894F, 7.0720F, 5.2898F},
400 {4076.500F, 13.1336F, 7.0500F, 5.2651F},
401 {4126.000F, 13.0783F, 7.0281F, 5.2403F},
402 {4175.500F, 13.0222F, 7.0063F, 5.2154F},
403 {4225.000F, 12.9668F, 6.9855F, 5.1904F},
404 {4274.500F, 12.9096F, 6.9627F, 5.1652F},
405 {4324.000F, 12.8526F, 6.9418F, 5.1398F},
406 {4373.500F, 12.7956F, 6.9194F, 5.1143F},
407 {4423.000F, 12.7382F, 6.8972F, 5.0887F},
408 {4472.500F, 12.6804F, 6.8742F, 5.0629F},
409 {4522.000F, 12.6221F, 6.8515F, 5.0370F},
410 {4571.500F, 12.5631F, 6.8286F, 5.0109F},
411 {4621.000F, 12.5031F, 6.8052F, 4.9847F},
412 {4670.500F, 12.4426F, 6.7815F, 4.9584F},
413 {4720.000F, 12.3819F, 6.7573F, 4.9319F},
414 {4769.500F, 12.3185F, 6.7326F, 4.9052F},
415 {4819.000F, 12.2550F, 6.7073F, 4.8785F},
416 {4868.500F, 12.1912F, 6.6815F, 4.8515F},
417 {4918.000F, 12.1245F, 6.6555F, 4.8245F},
418 {4967.500F, 12.0577F, 6.6285F, 4.7973F},
419 {5017.000F, 11.9895F, 6.6008F, 4.7699F},
420 {5066.500F, 11.9200F, 6.5727F, 4.7424F},
421 {5116.000F, 11.8491F, 6.5439F, 4.7148F},
422 {5165.500F, 11.7766F, 6.5138F, 4.6870F},
423 {5215.000F, 11.7026F, 6.4828F, 4.6591F},
424 {5264.500F, 11.6269F, 6.4510F, 4.6310F},
425 {5314.000F, 11.5495F, 6.4187F, 4.6028F},
426 {5363.500F, 11.4705F, 6.3854F, 4.5744F},
427 {5413.000F, 11.3896F, 6.3512F, 4.5459F},
428 {5462.500F, 11.3068F, 6.3160F, 4.5173F},
429 {5512.000F, 11.2221F, 6.2798F, 4.4885F},
430 {5561.500F, 11.1353F, 6.2426F, 4.4596F},
431 {5611.000F, 11.0558F, 6.2095F, 4.4305F},
432 {5661.000F, 10.9229F, 6.0897F, 4.4010F},
433 {5711.000F, 10.7900F, 5.9600F, 4.3714F}
438 {5711.000F, 10.2000F, 5.6100F, 4.0646F},
439 {5761.000F, 10.0320F, 5.5040F, 4.0028F},
440 {5811.000F, 9.8640F, 5.3980F, 3.9410F},
441 {5861.000F, 9.6960F, 5.2920F, 3.8793F},
442 {5911.000F, 9.5280F, 5.1860F, 3.8175F},
443 {5961.000F, 9.3600F, 5.0800F, 3.7557F}
448 {5961.000F, 9.0300F, 4.8700F, 3.5470F},
449 {6011.000F, 8.8475F, 4.7830F, 3.5167F},
450 {6061.000F, 8.6650F, 4.6960F, 3.4864F},
451 {6111.000F, 8.4825F, 4.6090F, 3.4561F},
452 {6161.000F, 8.3000F, 4.5230F, 3.4258F},
454 {6206.000F, 8.1750F, 4.5090F, 3.3985F},
455 {6251.000F, 8.0500F, 4.5000F, 3.3713F},
456 {6293.500F, 8.0450F, 4.4900F, 3.3455F},
457 {6336.000F, 8.0400F, 4.4800F, 3.3198F}
462 {6336.000F, 6.5000F, 3.8500F, 2.9200F},
463 {6351.000F, 6.5000F, 3.8500F, 2.9200F}
468 {6351.000F, 5.8000F, 3.4600F, 2.7200F},
469 {6371.000F, 5.8000F, 3.4600F, 2.7200F}}};