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

Annotation of /trunk/downunder/test/python/inversion_magnetic_3d.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4433 - (hide annotations)
Fri May 31 12:09:58 2013 UTC (6 years, 3 months ago) by gross
File MIME type: text/x-python
File size: 2615 byte(s)
some clarifications on geodetic coordinates. 
order of background magnetic flux density component has been corrected: input is now B_east, B_north, B_vertical.


1 gross 4121
2     ##############################################################################
3     #
4 caltinay 4140 # Copyright (c) 2003-2013 by University of Queensland
5 gross 4121 # 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 caltinay 4140 """3D magnetic inversion example using synthetic data"""
17    
18     __copyright__="""Copyright (c) 2003-2013 by University of Queensland
19 gross 4121 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 caltinay 4140 try:
31     WORKDIR=os.environ['DOWNUNDER_WORKDIR']
32 gross 4121 except KeyError:
33 caltinay 4140 WORKDIR='.'
34 gross 4121
35 caltinay 4140 # interesting parameters:
36     depth_offset = 10. * U.km
37     n_humps_h = 5
38     n_humps_v = 2
39     mu = 0.1
40     n_cells_in_data = 50
41     latitude = -28.5
42     full_knowledge = False
43 gross 4433 B_b = [2201.*U.Nano*U.Tesla, 31232.*U.Nano*U.Tesla, -41405.*U.Nano*U.Tesla]
44 caltinay 4140 #
45     DIM = 3
46     n_cells_in_data = max(n_humps_h*7, n_cells_in_data)
47     l_data = 100. * U.km
48     l_pad = 40. * U.km
49     THICKNESS = 20. * U.km
50     l_air = 20. * U.km
51     n_cells_v = max(
52     int((2*l_air+THICKNESS+depth_offset)/l_data*n_cells_in_data + 0.5), 25)
53 gross 4121
54    
55 caltinay 4140 source=SyntheticData(DataSource.MAGNETIC, n_length=n_humps_h, n_depth=n_humps_v,
56     depth=THICKNESS+depth_offset, depth_offset=depth_offset,
57     DIM=DIM, number_of_elements=n_cells_in_data, length=l_data, B_b=B_b,
58 gross 4373 data_offset=0, full_knowledge=full_knowledge)
59 gross 4121
60 caltinay 4140 domainbuilder=DomainBuilder(dim=DIM)
61 gross 4121 domainbuilder.addSource(source)
62 caltinay 4140 domainbuilder.setVerticalExtents(depth=l_air+THICKNESS+depth_offset,
63     air_layer=l_air, num_cells=n_cells_v)
64 gross 4121 domainbuilder.setBackgroundMagneticFluxDensity(B_b)
65 caltinay 4140 domainbuilder.setPadding(pad_x=l_pad, pad_y=l_pad)
66 gross 4121 domainbuilder.fixSusceptibilityBelow(depth=THICKNESS+depth_offset)
67    
68     inv=MagneticInversion()
69 caltinay 4140 inv.setSolverTolerance(1e-4)
70     inv.setSolverMaxIterations(50)
71 gross 4122 inv.setup(domainbuilder)
72     inv.getCostFunction().setTradeOffFactorsModels(mu)
73 gross 4121
74     k_new=inv.run()
75 caltinay 4140 k_ref=source.getReferenceProperty()
76     print("k_new = %s"%k_new)
77     print("k = %s"%k_ref)
78 gross 4123 B, chi = inv.getCostFunction().getForwardModel().getSurvey(0)
79 caltinay 4140 saveSilo(os.path.join(WORKDIR, 'results_magnetic_3d'), k=k_new, k_ref=k_ref, B=B, chi=chi)
80 gross 4121

  ViewVC Help
Powered by ViewVC 1.1.26