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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4267 - (show annotations)
Fri Mar 1 04:50:54 2013 UTC (6 years, 6 months ago) by caltinay
File MIME type: text/x-python
File size: 2186 byte(s)
Updated inversion example scripts, added ER Mapper data, checked results
and corrected some issues. Cookbook does not reflect the changes yet.

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 netCDF 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.nc'
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 # Setup and run the inversion
42 source=NetCdfData(NetCdfData.GRAVITY, DATASET, scale_factor=DATA_UNITS)
43 db=DomainBuilder(dim=3)
44 db.addSource(source)
45 db.setVerticalExtents(depth=thickness, air_layer=l_air, num_cells=n_cells_v)
46 db.setFractionalPadding(pad_x=PAD_X, pad_y=PAD_Y)
47 db.fixDensityBelow(depth=thickness)
48
49 inv=GravityInversion()
50 inv.setSolverTolerance(1e-4)
51 inv.setSolverMaxIterations(50)
52 inv.setup(db)
53 inv.getCostFunction().setTradeOffFactorsModels(MU)
54
55 density = inv.run()
56 print("density = %s"%density)
57
58 g, w = db.getGravitySurveys()[0]
59 saveSilo("result_gravity.silo", density=density, gravity_anomaly=g, gravity_weight=w)
60 print("Results saved in result_gravity.silo")
61
62 saveVTK("result_gravity.vtu", density=density, gravity_anomaly=g, gravity_weight=w)
63 print("Results saved in result_gravity.vtu")
64
65 saveDataCSV("result_gravity.csv", density=density, x=density.getFunctionSpace().getX())
66 print("Results saved in result_gravity.csv")
67
68 print("All done. Have a nice day!")
69

  ViewVC Help
Powered by ViewVC 1.1.26