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

Annotation of /branches/doubleplusgood/doc/examples/inversion/mag_netcdf.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4157 - (hide annotations)
Wed Jan 23 03:52:07 2013 UTC (6 years, 3 months ago) by caltinay
Original Path: trunk/doc/examples/inversion/magnetic_netcdf.py
File MIME type: text/x-python
File size: 2053 byte(s)
added magnetic netcdf example (no data yet).

1 caltinay 4157
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.escript import unitsSI as U
28     from esys.weipa import saveSilo
29    
30     # Set parameters
31     DATASET = 'magnetic_anomaly.nc'
32     latitude = -28.5
33     PAD_X = 0.2
34     PAD_Y = 0.2
35     thickness = 40. * U.km
36     l_air = 6. * U.km
37     n_cells_v = 25
38     mu = 0.1
39    
40     # Setup and run the inversion
41     B_b=simpleGeoMagneticFluxDensity(latitude=latitude)
42     source=NetCdfData(NetCdfData.MAGNETIC, DATASET)
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.setBackgroundMagneticFluxDensity(B_b)
48     db.fixDensityBelow(depth=thickness)
49    
50     inv=MagneticInversion()
51     inv.setSolverTolerance(1e-4)
52     inv.setSolverMaxIterations(50)
53     inv.setup(db)
54     inv.getCostFunction().setTradeOffFactorsModels(mu)
55    
56     print("Starting inversion, please stand by...")
57     susceptibility = inv.run()
58     print("susceptibility = %s"%susceptibility)
59    
60     # Save results
61     B, w = inv.getCostFunction().getForwardModel().getSurvey(0)
62     saveSilo("result_magnetic.silo", susceptibility=susceptibility, magnetic_anomaly=B[2], magnetic_weight=w[2])
63     print("Results saved in result_magnetic.silo. Good bye.")
64    

  ViewVC Help
Powered by ViewVC 1.1.26