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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4287 - (show annotations)
Thu Mar 7 05:26:44 2013 UTC (6 years, 1 month ago) by caltinay
File MIME type: text/x-python
File size: 3055 byte(s)
Removed simpleGeoMagnetic field function from doco and example source.

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/magnetic joint 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.escript import unitsSI as U
28 from esys.escript import saveDataCSV
29 from esys.weipa import *
30
31 # Set parameters
32 MAGNETIC_DATASET = 'data/MagneticSmall.nc'
33 MAG_UNITS = U.Nano * U.Tesla
34 GRAVITY_DATASET = 'data/GravitySmall.nc'
35 GRAV_UNITS = 1e-6 * U.m/(U.sec**2)
36 # background magnetic field components (B_North, B_East, B_Vertical)
37 B_b = [31232.*U.Nano*U.Tesla, 2201.*U.Nano*U.Tesla, -41405.*U.Nano*U.Tesla]
38 PAD_X = 0.2
39 PAD_Y = 0.2
40 thickness = 40. * U.km
41 l_air = 6. * U.km
42 n_cells_v = 25
43 mu_gravity = 10.
44 mu_magnetic = 0.1
45
46 # Setup and run the inversion
47 grav_source=NetCdfData(NetCdfData.GRAVITY, GRAVITY_DATASET, scale_factor=GRAV_UNITS)
48 mag_source=NetCdfData(NetCdfData.MAGNETIC, MAGNETIC_DATASET, scale_factor=MAG_UNITS)
49 db=DomainBuilder(dim=3)
50 db.addSource(grav_source)
51 db.addSource(mag_source)
52 db.setVerticalExtents(depth=thickness, air_layer=l_air, num_cells=n_cells_v)
53 db.setFractionalPadding(pad_x=PAD_X, pad_y=PAD_Y)
54 db.setBackgroundMagneticFluxDensity(B_b)
55 db.fixDensityBelow(depth=thickness)
56 db.fixSusceptibilityBelow(depth=thickness)
57
58 inv=JointGravityMagneticInversion()
59 inv.setSolverTolerance(1e-4)
60 inv.setSolverMaxIterations(50)
61 inv.setup(db)
62 inv.getCostFunction().setTradeOffFactorsModels([mu_gravity, mu_magnetic])
63 inv.getCostFunction().setTradeOffFactorsRegularization(mu = [1.,1.], mu_c=1.)
64
65 density, susceptibility = inv.run()
66 print("density = %s"%density)
67 print("susceptibility = %s"%susceptibility)
68
69 g, wg = db.getGravitySurveys()[0]
70 B, wB = db.getMagneticSurveys()[0]
71 saveSilo("result_gravmag.silo", density=density, gravity_anomaly=g, gravity_weight=wg, susceptibility=susceptibility, magnetic_anomaly=B, magnetic_weight=wB)
72 print("Results saved in result_gravmag.silo")
73
74 saveVTK("result_gravmag.vtu", density=density, gravity_anomaly=g, gravity_weight=wg, susceptibility=susceptibility, magnetic_anomaly=B, magnetic_weight=wB)
75 print("Results saved in result_gravmag.vtu")
76
77 saveDataCSV("result_gravmag.csv", density=density, susceptibility=susceptibility, x=susceptibility.getFunctionSpace().getX())
78 print("Results saved in result_gravmag.csv")
79
80 print("All done. Have a nice day!")
81

  ViewVC Help
Powered by ViewVC 1.1.26