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

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

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

revision 4209 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.ers'  if len(sys.argv)>1:
24        FILENAME=sys.argv[1]
25    else:
26        FILENAME='data/QLDWest_grav.ers'
27    
28    
29  if FILENAME[-4:]=='.ers': FILENAME=FILENAME[:-4]  if FILENAME[-4:]=='.ers': FILENAME=FILENAME[:-4]
# Line 88  except: Line 92  except:
92  f=open(FILENAME,'r')  f=open(FILENAME,'r')
93    
94  longitude=np.linspace(originX, originX+spacingX*NX, NX, endpoint=True)  longitude=np.linspace(originX, originX+spacingX*NX, NX, endpoint=True)
95  latitude=np.linspace(originY, originY+spacingY*NY, NY, endpoint=True)  latitude=np.linspace(originY, originY-spacingY*NY, NY, endpoint=True)
96  DATA=np.fromfile(FILENAME, dtype=np.float32).reshape(NY, NX)  DATA=np.fromfile(FILENAME, dtype=np.float32).reshape(NY, NX)
97  # flip data in y-direction since ER Mapper stores data bottom up  # flip data in y-direction since ER Mapper stores data bottom up
98  DATA=np.flipud(DATA)  DATA=np.flipud(DATA)
99    
100  x,y=np.meshgrid(longitude, latitude)  x,y=np.meshgrid(longitude, latitude)
101  plt.figure(figsize=(6*(spacingX*NX/(spacingY*NY)), 6), dpi=100)  plt.figure(figsize=(6*(spacingX*NX/(spacingY*NY))+1, 6), dpi=100)
102  plt.pcolor(x, y, DATA)  plt.pcolor(x, y, DATA)
103  locs,_=plt.xticks()  locs,_=plt.xticks()
104  plt.xticks(locs, map(lambda x:"%g"%x, locs))  plt.xticks(locs, map(lambda x:"%g"%x, locs))

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

  ViewVC Help
Powered by ViewVC 1.1.26