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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4287 - (show annotations)
Thu Mar 7 05:26:44 2013 UTC (6 years, 5 months ago) by caltinay
File MIME type: text/x-python
File size: 2474 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 magnetic 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/MagneticSmall.nc'
33 DATA_UNITS = U.Nano * U.V * U.sec / (U.m**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 # background magnetic field components (B_North, B_East, B_Vertical)
41 B_b = [31232.*U.Nano*U.Tesla, 2201.*U.Nano*U.Tesla, -41405.*U.Nano*U.Tesla]
42
43 # Setup and run the inversion
44 source=NetCdfData(NetCdfData.MAGNETIC, DATASET, scale_factor=DATA_UNITS)
45 db=DomainBuilder(dim=3)
46 db.addSource(source)
47 db.setVerticalExtents(depth=thickness, air_layer=l_air, num_cells=n_cells_v)
48 db.setFractionalPadding(pad_x=PAD_X, pad_y=PAD_Y)
49 db.setBackgroundMagneticFluxDensity(B_b)
50 db.fixSusceptibilityBelow(depth=thickness)
51
52 inv=MagneticInversion()
53 inv.setSolverTolerance(1e-4)
54 inv.setSolverMaxIterations(50)
55 inv.setup(db)
56 inv.getCostFunction().setTradeOffFactorsModels(MU)
57
58 susceptibility = inv.run()
59 print("susceptibility = %s"%susceptibility)
60
61 B, w = db.getMagneticSurveys()[0]
62 saveSilo("result_magnetic.silo", susceptibility=susceptibility, magnetic_anomaly=B, magnetic_weight=w)
63 print("Results saved in result_magnetic.silo")
64
65 saveVTK("result_magnetic.vtu", susceptibility=susceptibility, magnetic_anomaly=B, magnetic_weight=w)
66 print("Results saved in result_magnetic.vtu")
67
68 saveDataCSV("result_magnetic.csv", susceptibility=susceptibility, x=susceptibility.getFunctionSpace().getX())
69 print("Results saved in result_magnetic.csv")
70
71 print("All done. Have a nice day!")
72

  ViewVC Help
Powered by ViewVC 1.1.26