/[escript]/trunk/downunder/test/python/inversion_gravmag_3d.py
ViewVC logotype

Contents of /trunk/downunder/test/python/inversion_gravmag_3d.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4213 - (show annotations)
Tue Feb 19 01:16:29 2013 UTC (7 years, 4 months ago) by caltinay
File MIME type: text/x-python
File size: 3485 byte(s)
Some cleanup and more consistent logging.

1
2 ##############################################################################
3 #
4 # Copyright (c) 2003-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 magnetic/gravity joint inversion example using synthetic data"""
17
18 __copyright__="""Copyright (c) 2003-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 os
26 from esys.downunder import *
27 from esys.escript import unitsSI as U
28 from esys.weipa import saveSilo
29
30 try:
31 WORKDIR=os.environ['DOWNUNDER_WORKDIR']
32 except KeyError:
33 WORKDIR='.'
34
35 # interesting parameters:
36 depth_offset = 10. * U.km
37 n_humps_h = 3
38 n_humps_v = 1
39 mu_gravity = 10.
40 mu_magnetic = 0.1
41 n_cells_in_data = 30
42 latitude = -28.5
43 full_knowledge = False
44 spherical = False
45 #
46 DIM = 3
47 n_cells_in_data = max(n_humps_h*7, n_cells_in_data)
48 l_data = 100. * U.km
49 l_pad = 40. * U.km
50 THICKNESS = 20. * U.km
51 l_air = 20. * U.km
52 n_cells_v = max(
53 int((2*l_air+THICKNESS+depth_offset)/l_data*n_cells_in_data + 0.5), 25)
54
55 B_b=simpleGeoMagneticFluxDensity(latitude=latitude)
56
57 grav_data=SyntheticData(DataSource.GRAVITY, n_length=n_humps_h, n_depth=n_humps_v,
58 depth=THICKNESS+depth_offset, depth_offset=depth_offset,
59 DIM=DIM, number_of_elements=n_cells_in_data, length=l_data,
60 data_offset=0, full_knowledge=full_knowledge, spherical=spherical)
61
62 mag_data=SyntheticData(DataSource.MAGNETIC, n_length=n_humps_h, n_depth=n_humps_v,
63 depth=THICKNESS+depth_offset, depth_offset=depth_offset,
64 DIM=DIM, number_of_elements=n_cells_in_data, length=l_data, B_b=B_b,
65 data_offset=0, full_knowledge=full_knowledge, spherical=spherical)
66
67 domainbuilder=DomainBuilder(dim=DIM)
68 domainbuilder.addSource(grav_data)
69 domainbuilder.addSource(mag_data)
70 domainbuilder.setVerticalExtents(depth=l_air+THICKNESS+depth_offset,
71 air_layer=l_air, num_cells=n_cells_v)
72 domainbuilder.setPadding(pad_x=l_pad, pad_y=l_pad)
73 domainbuilder.fixDensityBelow(depth=THICKNESS+depth_offset)
74 domainbuilder.fixSusceptibilityBelow(depth=THICKNESS+depth_offset)
75 domainbuilder.setBackgroundMagneticFluxDensity(B_b)
76
77 inv=JointGravityMagneticInversion()
78 inv.setSolverTolerance(1e-4)
79 inv.setSolverMaxIterations(50)
80 inv.setup(domainbuilder)
81
82 inv.getCostFunction().setTradeOffFactorsModels([mu_gravity, mu_magnetic])
83 inv.getCostFunction().setTradeOffFactorsRegularization(mu = [1.,1.], mu_c=1.)
84
85 rho_new, k_new = inv.run()
86 rho_ref = grav_data.getReferenceProperty()
87 k_ref = mag_data.getReferenceProperty()
88 print("rho_new = %s"%rho_new)
89 print("rho = %s"%rho_ref)
90 print("k_new = %s"%k_new)
91 print("k = %s"%k_ref)
92
93 g, chi = inv.getCostFunction().getForwardModel(inv.DENSITY).getSurvey(0)
94 B, chi = inv.getCostFunction().getForwardModel(inv.SUSCEPTIBILITY).getSurvey(0)
95
96 saveSilo(os.path.join(WORKDIR, 'results_joint_3d'),
97 density=rho_new, density_ref=rho_ref,
98 susceptability=k_new, susceptability_ref=k_ref,
99 g_data=g, B_data=B, chi=chi)
100

  ViewVC Help
Powered by ViewVC 1.1.26