/[escript]/trunk/doc/examples/inversion/grav_ermapper.py
ViewVC logotype

Annotation of /trunk/doc/examples/inversion/grav_ermapper.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4392 - (hide annotations)
Mon May 6 02:18:33 2013 UTC (6 years, 2 months ago) by caltinay
File MIME type: text/x-python
File size: 2629 byte(s)
More saveSilo checks.

1 caltinay 4267
2     ##############################################################################
3     #
4     # Copyright (c) 2009-2013 by University of Queensland
5     # http://www.uq.edu.au
6     #
7     # Primary Business: Queensland, Australia
8     # Licensed under the Open Software License version 3.0
9     # http://www.opensource.org/licenses/osl-3.0.php
10     #
11     # Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12     # Development since 2012 by School of Earth Sciences
13     #
14     ##############################################################################
15    
16     """3D gravity inversion example using ER Mapper data"""
17    
18     __copyright__="""Copyright (c) 2009-2013 by University of Queensland
19     http://www.uq.edu.au
20     Primary Business: Queensland, Australia"""
21     __license__="""Licensed under the Open Software License version 3.0
22     http://www.opensource.org/licenses/osl-3.0.php"""
23     __url__="https://launchpad.net/escript-finley"
24    
25     # Import required modules
26     from esys.downunder import *
27     from esys.weipa import *
28     from esys.escript import unitsSI as U
29     from esys.escript import saveDataCSV
30    
31     # Set parameters
32     DATASET = 'data/GravitySmall.ers'
33     DATA_UNITS = 1e-6 * U.m/(U.sec**2)
34     PAD_X = 0.2
35     PAD_Y = 0.2
36     thickness = 40. * U.km
37     l_air = 6. * U.km
38     n_cells_v = 25
39     MU = 0.1
40 gross 4374 COORDINATES=CartesianReferenceSystem()
41     #COORDINATES=WGS84ReferenceSystem()
42 caltinay 4267
43 jfenwick 4311 def work():
44     # Setup and run the inversion
45 gross 4373 source=ErMapperData(DataSource.GRAVITY, DATASET, scale_factor=DATA_UNITS, reference_system=COORDINATES)
46     db=DomainBuilder(dim=3, reference_system=COORDINATES)
47 jfenwick 4311 db.addSource(source)
48     db.setVerticalExtents(depth=thickness, air_layer=l_air, num_cells=n_cells_v)
49     db.setFractionalPadding(pad_x=PAD_X, pad_y=PAD_Y)
50     db.fixDensityBelow(depth=thickness)
51 caltinay 4267
52 jfenwick 4311 inv=GravityInversion()
53     inv.setSolverTolerance(1e-4)
54     inv.setSolverMaxIterations(50)
55     inv.setup(db)
56     inv.getCostFunction().setTradeOffFactorsModels(MU)
57 caltinay 4267
58 jfenwick 4311 density = inv.run()
59     print("density = %s"%density)
60 caltinay 4267
61 jfenwick 4311 g, w = db.getGravitySurveys()[0]
62 caltinay 4392 if saveSilo("result0.silo", density=density, gravity_anomaly=g, gravity_weight=w):
63     print("Results saved in result0.silo")
64     else:
65     print("Failed to save result0.silo. Possibly no Silo support.")
66 caltinay 4267
67 jfenwick 4311 saveVTK("result0.vtu", density=density, gravity_anomaly=g, gravity_weight=w)
68     print("Results saved in result0.vtu")
69 caltinay 4267
70 jfenwick 4311 saveDataCSV("result0.csv", density=density, x=density.getFunctionSpace().getX())
71     print("Results saved in result0.csv")
72 caltinay 4267
73 jfenwick 4311 print("All done. Have a nice day.!")
74 caltinay 4267
75 jfenwick 4311 try:
76     import pyproj
77     havepyproj=True
78     except ImportError:
79     havepyproj=False
80    
81     if havepyproj:
82     work()
83     else:
84     print("This example requires the pyproj package which does not appear to be accessible.")

  ViewVC Help
Powered by ViewVC 1.1.26