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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 4309 by caltinay, Fri Mar 8 04:42:01 2013 UTC revision 4310 by jfenwick, Tue Mar 12 03:23:26 2013 UTC
# Line 40  MU = 0.1 Line 40  MU = 0.1
40  # background magnetic field components (B_North, B_East, B_Vertical)  # 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]  B_b = [31232.*U.Nano*U.Tesla, 2201.*U.Nano*U.Tesla, -41405.*U.Nano*U.Tesla]
42    
43  # Setup and run the inversion  def work():
44  source=NetCdfData(NetCdfData.MAGNETIC, DATASET, scale_factor=DATA_UNITS)    # Setup and run the inversion
45  db=DomainBuilder(dim=3)    source=NetCdfData(NetCdfData.MAGNETIC, DATASET, scale_factor=DATA_UNITS)
46  db.addSource(source)    db=DomainBuilder(dim=3)
47  db.setVerticalExtents(depth=thickness, air_layer=l_air, num_cells=n_cells_v)    db.addSource(source)
48  db.setFractionalPadding(pad_x=PAD_X, pad_y=PAD_Y)    db.setVerticalExtents(depth=thickness, air_layer=l_air, num_cells=n_cells_v)
49  db.setBackgroundMagneticFluxDensity(B_b)    db.setFractionalPadding(pad_x=PAD_X, pad_y=PAD_Y)
50  db.fixSusceptibilityBelow(depth=thickness)    db.setBackgroundMagneticFluxDensity(B_b)
51      db.fixSusceptibilityBelow(depth=thickness)
52  inv=MagneticInversion()  
53  inv.setSolverTolerance(1e-4)    inv=MagneticInversion()
54  inv.setSolverMaxIterations(50)    inv.setSolverTolerance(1e-4)
55  inv.setup(db)    inv.setSolverMaxIterations(50)
56  inv.getCostFunction().setTradeOffFactorsModels(MU)    inv.setup(db)
57      inv.getCostFunction().setTradeOffFactorsModels(MU)
58  susceptibility = inv.run()  
59  print("susceptibility = %s"%susceptibility)    susceptibility = inv.run()
60      print("susceptibility = %s"%susceptibility)
61  B, w =  db.getMagneticSurveys()[0]  
62  saveSilo("result_magnetic.silo", susceptibility=susceptibility, magnetic_anomaly=B, magnetic_weight=w)    B, w =  db.getMagneticSurveys()[0]
63  print("Results saved in result_magnetic.silo")    saveSilo("result_magnetic.silo", susceptibility=susceptibility, magnetic_anomaly=B, magnetic_weight=w)
64      print("Results saved in result_magnetic.silo")
65  saveVTK("result_magnetic.vtu", susceptibility=susceptibility, magnetic_anomaly=B, magnetic_weight=w)  
66  print("Results saved in result_magnetic.vtu")    saveVTK("result_magnetic.vtu", susceptibility=susceptibility, magnetic_anomaly=B, magnetic_weight=w)
67      print("Results saved in result_magnetic.vtu")
68  saveDataCSV("result_magnetic.csv", susceptibility=susceptibility, x=susceptibility.getFunctionSpace().getX())  
69  print("Results saved in result_magnetic.csv")    saveDataCSV("result_magnetic.csv", susceptibility=susceptibility, x=susceptibility.getFunctionSpace().getX())
70      print("Results saved in result_magnetic.csv")
71  print("All done. Have a nice day!")  
72      print("All done. Have a nice day!")
73    
74    if 'NetCdfData' in dir():
75      work()
76    else:
77      print("This example requires scipy's netcdf support which does not appear to be installed.")
78    

Legend:
Removed from v.4309  
changed lines
  Added in v.4310

  ViewVC Help
Powered by ViewVC 1.1.26