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

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

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

revision 4227 by caltinay, Mon Feb 18 06:00:56 2013 UTC revision 4228 by caltinay, Wed Feb 20 03:34:07 2013 UTC
# Line 16  Line 16 
16    
17  from matplotlib import pyplot as plt  from matplotlib import pyplot as plt
18  import numpy as np  import numpy as np
19    import sys
20  from scipy.io import netcdf_file  from scipy.io import netcdf_file
21    
22  # input filename  # input filename
23  FILENAME='data/QLDWest_grav.nc'  if len(sys.argv)>1:
24        FILENAME=sys.argv[1]
25    else:
26        FILENAME='data/QLDWest_grav.nc'
27    
28  f=netcdf_file(FILENAME, 'r')  f=netcdf_file(FILENAME, 'r')
29  NY=f.dimensions["latitude"]  NY=f.dimensions["latitude"]
# Line 35  x_label=longitude.long_name Line 39  x_label=longitude.long_name
39  x_units=longitude.units  x_units=longitude.units
40  longitude=longitude[:]  longitude=longitude[:]
41    
42  DATA=f.variables["onshore_and_offshore_gravity_anomaly_geodetic"]  DATA=f.variables["onshore_only_Bouguer_geodetic"]
43  data_label=DATA.long_name  data_label=DATA.long_name
44  UNITS=DATA.units  UNITS=DATA.units
45  DATA=DATA[:]  DATA=DATA[:]
# Line 50  ll=2*latitude[-1]-latitude[-2] Line 54  ll=2*latitude[-1]-latitude[-2]
54  latitude=np.resize(latitude, len(latitude)+1)  latitude=np.resize(latitude, len(latitude)+1)
55  latitude[-1]=ll  latitude[-1]=ll
56    
57    lx=longitude[-1]-longitude[0]
58    ly=latitude[-1]-latitude[0]
59  x,y=np.meshgrid(longitude, latitude)  x,y=np.meshgrid(longitude, latitude)
60    plt.figure(figsize=(6*lx/ly+1, 6), dpi=100)
61  plt.pcolor(x, y, DATA)  plt.pcolor(x, y, DATA)
62  locs,_=plt.xticks()  locs,_=plt.xticks()
63  plt.xticks(locs, map(lambda x:"%g"%x, locs))  plt.xticks(locs, map(lambda x:"%g"%x, locs))

Legend:
Removed from v.4227  
changed lines
  Added in v.4228

  ViewVC Help
Powered by ViewVC 1.1.26