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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5707 - (show annotations)
Mon Jun 29 03:59:06 2015 UTC (3 years, 8 months ago) by sshaw
File MIME type: text/x-python
File size: 2952 byte(s)
adding copyright headers to files without copyright info, moved header to top of file in some cases where it wasn't
1 ##############################################################################
2 #
3 # Copyright (c) 2009-2015 by The University of Queensland
4 # http://www.uq.edu.au
5 #
6 # Primary Business: Queensland, Australia
7 # Licensed under the Open Software License version 3.0
8 # http://www.opensource.org/licenses/osl-3.0.php
9 #
10 # Development until 2012 by Earth Systems Science Computational Center (ESSCC)
11 # Development 2012-2013 by School of Earth Sciences
12 # Development from 2014 by Centre for Geoscience Computing (GeoComp)
13 #
14 ##############################################################################
15
16 """3D gravity inversion example using ER Mapper data"""
17 from __future__ import division, print_function
18
19 __copyright__="""Copyright (c) 2009-2015 by The University of Queensland
20 http://www.uq.edu.au
21 Primary Business: Queensland, Australia"""
22 __license__="""Licensed under the Open Software License version 3.0
23 http://www.opensource.org/licenses/osl-3.0.php"""
24 __url__="https://launchpad.net/escript-finley"
25
26 # Import required modules
27 from esys.downunder import *
28 from esys.weipa import *
29 from esys.escript import unitsSI as U
30 from esys.escript import saveDataCSV
31
32 # Set parameters
33 DATASET = 'data/GravitySmall.ers'
34 DATA_UNITS = 1e-6 * U.m/(U.sec**2)
35 PAD_X = 0.2
36 PAD_Y = 0.2
37 thickness = 40. * U.km
38 l_air = 6. * U.km
39 n_cells_v = 25
40 MU = 0.1
41 COORDINATES=CartesianReferenceSystem()
42 #COORDINATES=WGS84ReferenceSystem()
43
44 def work():
45 # Setup and run the inversion
46 source=ErMapperData(DataSource.GRAVITY, DATASET, scale_factor=DATA_UNITS, reference_system=COORDINATES)
47 db=DomainBuilder(dim=3, reference_system=COORDINATES)
48 db.addSource(source)
49 db.setVerticalExtents(depth=thickness, air_layer=l_air, num_cells=n_cells_v)
50 db.setFractionalPadding(pad_x=PAD_X, pad_y=PAD_Y)
51 db.fixDensityBelow(depth=thickness)
52
53 inv=GravityInversion()
54 inv.setSolverTolerance(1e-4)
55 inv.setSolverMaxIterations(50)
56 inv.setup(db)
57 inv.getCostFunction().setTradeOffFactorsModels(MU)
58
59 density = inv.run()
60 print("density = %s"%density)
61
62 g, w = db.getGravitySurveys()[0]
63 if saveSilo("result0.silo", density=density, gravity_anomaly=g, gravity_weight=w):
64 print("Results saved in result0.silo")
65 else:
66 print("Failed to save result0.silo. Possibly no Silo support.")
67
68 saveVTK("result0.vtu", density=density, gravity_anomaly=g, gravity_weight=w)
69 print("Results saved in result0.vtu")
70
71 saveDataCSV("result0.csv", density=density, x=density.getFunctionSpace().getX())
72 print("Results saved in result0.csv")
73
74 print("All done. Have a nice day.!")
75
76 try:
77 import pyproj
78 havepyproj=True
79 except ImportError:
80 havepyproj=False
81
82 try:
83 import esys.ripley
84 HAVE_RIPLEY = True
85 except ImportError:
86 HAVE_RIPLEY = False
87
88
89 if havepyproj and HAVE_RIPLEY:
90 work()
91 elif HAVE_RIPLEY:
92 print("This example requires the pyproj package which does not appear to be accessible.")
93 else:
94 print("This example requires the ripley module, which is not available")

  ViewVC Help
Powered by ViewVC 1.1.26