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

Contents of /branches/doubleplusgood/doc/examples/inversion/grav_ermapper.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4345 - (show annotations)
Fri Mar 29 07:09:41 2013 UTC (5 years, 11 months ago) by jfenwick
File MIME type: text/x-python
File size: 2408 byte(s)
Spelling fixes
1
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
41 def work():
42 # Setup and run the inversion
43 source=ErMapperData(DataSource.GRAVITY, DATASET, scale_factor=DATA_UNITS)
44 db=DomainBuilder(dim=3)
45 db.addSource(source)
46 db.setVerticalExtents(depth=thickness, air_layer=l_air, num_cells=n_cells_v)
47 db.setFractionalPadding(pad_x=PAD_X, pad_y=PAD_Y)
48 db.fixDensityBelow(depth=thickness)
49
50 inv=GravityInversion()
51 inv.setSolverTolerance(1e-4)
52 inv.setSolverMaxIterations(50)
53 inv.setup(db)
54 inv.getCostFunction().setTradeOffFactorsModels(MU)
55
56 density = inv.run()
57 print("density = %s"%density)
58
59 g, w = db.getGravitySurveys()[0]
60 saveSilo("result0.silo", density=density, gravity_anomaly=g, gravity_weight=w)
61 print("Results saved in result0.silo")
62
63 saveVTK("result0.vtu", density=density, gravity_anomaly=g, gravity_weight=w)
64 print("Results saved in result0.vtu")
65
66 saveDataCSV("result0.csv", density=density, x=density.getFunctionSpace().getX())
67 print("Results saved in result0.csv")
68
69 print("All done. Have a nice day.!")
70
71 try:
72 import pyproj
73 havepyproj=True
74 except ImportError:
75 havepyproj=False
76
77 if havepyproj:
78 work()
79 else:
80 print("This example requires the pyproj package which does not appear to be accessible.")

  ViewVC Help
Powered by ViewVC 1.1.26