xdenisx

asi

Aug 22nd, 2014
289
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.71 KB | None | 0 0
  1. #!/bin/python
  2. # -*- coding: utf-8 -*-
  3.  
  4. import Ngl
  5. import Nio
  6. import numpy
  7. import sys
  8. from scipy import array,arange,nan
  9. import os
  10.  
  11. year = "mean"
  12.  
  13. mon1 = "08"
  14. day1 = "14"
  15.  
  16. mon2 = "08"
  17. day2 = "23"
  18.  
  19. h_file = sys.argv[1];
  20.  
  21. dates = os.path.basename(os.path.splitext(h_file)[0])
  22.  
  23. filename = "psfile"
  24.  
  25. ffile1 = Nio.open_file(h_file)
  26. ffile2 = Nio.open_file("~/asi/grid.hdf")
  27.  
  28. concentration_nio  = ffile1.variables["ASI_Ice_Concentration"]
  29. lon_nc = ffile2.variables["Longitudes"]
  30. lat_nc = ffile2.variables["Latitudes"]
  31.  
  32.  
  33. lonn = lon_nc[:]
  34. latt = lat_nc[:]
  35.  
  36. #latt = numpy.zeros((607,895))
  37. #lonn = numpy.zeros((607,895))
  38.  
  39. #for i in range(895):
  40. #    latt[i,:] = lat[:]
  41.    
  42. #for i in range(607):
  43. #    lonn[:,i] = lon[:]
  44.  
  45. rlist            = Ngl.Resources()
  46. rlist.wkColorMap = 'posneg_1'
  47. rlist.wkWidth = 1600
  48. rlist.wkHeight = 1600
  49. wks_type = "png"
  50. wks = Ngl.open_wks(wks_type,"./"+dates[10:18],rlist)
  51.  
  52.  
  53. resources = Ngl.Resources()
  54.  
  55. #resources.sfMissingValueV = float(concentration_nio._FillValue[0])
  56.  
  57. concentration = concentration_nio[:,:]*100.0
  58.  
  59. #Индексы ячеек сетки, где концентрация отсутствующие значения NaN
  60. ggg=numpy.nonzero(numpy.isnan(concentration[:,:])==1)
  61. #Заполнение этих ячеек -128
  62. concentration[ggg]=-128
  63.  
  64. #Missing values
  65. resources.sfMissingValueV = -128
  66. resources.cnMissingValFillColor = "White"
  67. resources.cnMissingValFillPattern = 3
  68. resources.cnMissingValFillScaleF = 0.7
  69. resources.cnMissingValPerimOn = True
  70. resources.cnMissingValPerimColor = "Gray"                      
  71.  
  72. resources.sfXArray        = lonn[:,:]
  73. resources.sfYArray        = latt[:,:]
  74.  
  75. #resources.mpProjection          = "Mercator"
  76.  
  77. #resources.mpDataBaseVersion     = "MediumRes"
  78. #resources.mpLimitMode           = "LatLon"
  79.  
  80. #resources.mpMinLonF             = 95
  81. #resources.mpMaxLonF             = 150
  82.  
  83. #resources.mpMinLatF             = 68
  84. #resources.mpMaxLatF             = 81
  85.  
  86. resources.mpProjection          = "LambertEqualArea"
  87.  
  88. resources.mpDataBaseVersion     = "MediumRes"
  89. resources.mpLimitMode           = 'Corners'
  90.  
  91. resources.mpLeftCornerLatF      = 80. #77.7
  92. resources.mpLeftCornerLonF      = 83 #91
  93.  
  94. resources.mpRightCornerLatF     = 69.5
  95. resources.mpRightCornerLonF     = 142
  96.  
  97. #map rotation
  98. resources.mpCenterLonF           = 125.
  99. resources.mpCenterLatF           = 180.
  100.  
  101. #NSIDC ARCTIC VIEW
  102. #resources.mpProjection          = "Stereographic"
  103. #resources.mpDataBaseVersion     = "MediumRes"
  104. #resources.mpLimitMode           = "Corners"
  105. #resources.mpLeftCornerLatF      = 63.92
  106. #resources.mpLeftCornerLonF      = 260.26
  107. #resources.mpRightCornerLatF     = 60.37
  108. #resources.mpRightCornerLonF     = 85.34
  109.  
  110. #map rotation
  111. #resources.mpCenterLonF           = 315.0
  112. #resources.mpCenterLatF           = 90.0
  113.  
  114. #Grid params
  115.  
  116. #Ubrat' reshetky
  117. #resources.mpGridAndLimbOn      = False
  118. resources.mpGridLineColor = "Black"
  119. #resources.mpCenterLonF = 110.0
  120. resources.mpGridPolarLonSpacingF = 10.0
  121. resources.mpGridLonSpacingF = 10.0
  122. resources.mpGridLatSpacingF = 10.0
  123.  
  124.  
  125.  
  126. resources.mpFillOn                   = True
  127.  
  128. #resources.tmXTOn                = False
  129. #resources.tmXBOn                = False
  130. resources.tmYLOn                = False
  131. resources.tmYROn                = False
  132.  
  133.  
  134. igray = Ngl.new_color(wks,0.7,0.7,0.7)
  135. resources.mpFillColors = [20,-1,igray,-1]
  136.  
  137. resources.cnFillOn             = True
  138. resources.cnFillDrawOrder       = "Predraw"
  139. resources.cnLineLabelsOn        = False
  140. resources.cnRasterSmothingOn = True
  141.  
  142. #CN LINES
  143. resources.cnLinesOn        = False
  144.  
  145. resources.cnFillMode= "RasterFill"
  146. resources.nglSpreadColorStart  = 8
  147. resources.nglSpreadColorEnd      = -2
  148.  
  149. #resources.cnLevelSelectionMode = "ExplicitLevels" # Define own levels.
  150. #resources.cnLevels             = numpy.arange(-0.9,1.,0.1)
  151.  
  152. #resources.cnLevels             = arange(0.,100,10)
  153.  
  154. resources.lbTitleFontHeightF        = 0.020
  155. resources.lbLabelFontHeightF        = 0.008
  156. resources.lbTitleOffsetF            = -0.40
  157.  
  158. resources.lbBoxMinorExtentF         = 0.15
  159. resources.pmLabelBarOrthogonalPosF  = -0.05
  160. resources.lbOrientation             = "Horizontal"
  161.  
  162. resources.cnLineLabelsFontHeightF        = 0.05
  163. #Kolya end
  164.  
  165. resources.lbTitleString             = 'Sea ice conc, res. 6.25km, [%]'
  166. #resources.lbTitleFontHeightF        = 0.018
  167. #resources.lbLabelFontHeightF        = 0.010
  168. #resources.lbTitleOffsetF            = -0.27
  169. #resources.lbBoxMinorExtentF         = 0.15
  170. #resources.pmLabelBarOrthogonalPosF  = -0.01
  171.  
  172. #resources.lbBoxLinesOn = False
  173.  
  174. #resources.lbOrientation             = "Horizontal"
  175.  
  176. resources.tiMainString       = "Laptev sea "+dates[10:14]+"/"+dates[14:16]+"/"+dates[16:18]
  177.  
  178.  
  179. map = Ngl.contour_map(wks,concentration[:,:],resources)
Advertisement
Add Comment
Please, Sign In to add comment