xdenisx

Plot NAO

Nov 20th, 2012
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.25 KB | None | 0 0
  1. # -*- coding: UTF-8 -*-
  2.  
  3. import numpy as np
  4. import matplotlib as mpl
  5. import matplotlib.pyplot as plt
  6. from numpy import *
  7. import sys
  8. from scipy.interpolate import spline
  9.  
  10. plt.clf()
  11.  
  12. #I1
  13. ffile = sys.argv[1]
  14. data = genfromtxt(ffile, unpack=True)
  15. frequency   = data[0][:]
  16. i1 = data[1][:]
  17.  
  18. #D
  19. ffile = sys.argv[2]
  20. data = genfromtxt(ffile, unpack=True)
  21. D = data[1][:]
  22.  
  23. X = frequency
  24. Y_01 = i1
  25. Y_02 = D
  26.  
  27. mpl.rcParams['figure.figsize'] = (8.0, 6.0)
  28.  
  29. line_i1,         = plt.plot(X, Y_01, 'r-', label ='Arctic Oscillation')
  30. #line_D           = plt.plot(X, Y_02, 'b-', label = 'Indicator of rotation (D)')
  31.  
  32.  
  33. plt.title(u'Spectral density of Arctic Oscillation (1950-2012)')
  34.  
  35. plt.legend(loc = 'best')
  36.  
  37. ax_01 = plt.axes()
  38. ax_01.grid(color = 'black')
  39. ax_01.set_xlabel(r'$\omega$', size=25)
  40. ax_01.set_ylabel(u'')
  41.  
  42. if max(D)>max(i1):
  43.  maxY = max(D)
  44. else:
  45.  maxY = max(i1)
  46.  
  47. if min(D)<min(i1):
  48.  minY = min(D)
  49. else:
  50.  minY = min(i1)
  51.  
  52.  
  53. plt.axis((min(X)-0.003, max(X), minY, maxY))
  54.  
  55. plt.annotate('~30 years', xy=(3.142221E-04,20.665250), xytext=(0.015,18),
  56.  arrowprops=dict(facecolor='black', shrink=0.05))
  57.            
  58.  
  59.  
  60. plt.savefig('I1_mod.png', dpi=300, format = 'png')
  61.  
  62. #print 'Correlation (magnitude,i1): %2.1f' % (corrcoef(mod, i1)[0,1])
Advertisement
Add Comment
Please, Sign In to add comment