Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/python
- # -*- coding: utf-8 -*-
- import Ngl
- import Nio
- import numpy
- import sys
- from scipy import array,arange,nan
- import os
- year = "mean"
- mon1 = "08"
- day1 = "14"
- mon2 = "08"
- day2 = "23"
- h_file = sys.argv[1];
- dates = os.path.basename(os.path.splitext(h_file)[0])
- filename = "psfile"
- ffile1 = Nio.open_file(h_file)
- ffile2 = Nio.open_file("~/asi/grid.hdf")
- concentration_nio = ffile1.variables["ASI_Ice_Concentration"]
- lon_nc = ffile2.variables["Longitudes"]
- lat_nc = ffile2.variables["Latitudes"]
- lonn = lon_nc[:]
- latt = lat_nc[:]
- #latt = numpy.zeros((607,895))
- #lonn = numpy.zeros((607,895))
- #for i in range(895):
- # latt[i,:] = lat[:]
- #for i in range(607):
- # lonn[:,i] = lon[:]
- rlist = Ngl.Resources()
- rlist.wkColorMap = 'posneg_1'
- rlist.wkWidth = 1600
- rlist.wkHeight = 1600
- wks_type = "png"
- wks = Ngl.open_wks(wks_type,"./"+dates[10:18],rlist)
- resources = Ngl.Resources()
- #resources.sfMissingValueV = float(concentration_nio._FillValue[0])
- concentration = concentration_nio[:,:]*100.0
- #Индексы ячеек сетки, где концентрация отсутствующие значения NaN
- ggg=numpy.nonzero(numpy.isnan(concentration[:,:])==1)
- #Заполнение этих ячеек -128
- concentration[ggg]=-128
- #Missing values
- resources.sfMissingValueV = -128
- resources.cnMissingValFillColor = "White"
- resources.cnMissingValFillPattern = 3
- resources.cnMissingValFillScaleF = 0.7
- resources.cnMissingValPerimOn = True
- resources.cnMissingValPerimColor = "Gray"
- resources.sfXArray = lonn[:,:]
- resources.sfYArray = latt[:,:]
- #resources.mpProjection = "Mercator"
- #resources.mpDataBaseVersion = "MediumRes"
- #resources.mpLimitMode = "LatLon"
- #resources.mpMinLonF = 95
- #resources.mpMaxLonF = 150
- #resources.mpMinLatF = 68
- #resources.mpMaxLatF = 81
- resources.mpProjection = "LambertEqualArea"
- resources.mpDataBaseVersion = "MediumRes"
- resources.mpLimitMode = 'Corners'
- resources.mpLeftCornerLatF = 80. #77.7
- resources.mpLeftCornerLonF = 83 #91
- resources.mpRightCornerLatF = 69.5
- resources.mpRightCornerLonF = 142
- #map rotation
- resources.mpCenterLonF = 125.
- resources.mpCenterLatF = 180.
- #NSIDC ARCTIC VIEW
- #resources.mpProjection = "Stereographic"
- #resources.mpDataBaseVersion = "MediumRes"
- #resources.mpLimitMode = "Corners"
- #resources.mpLeftCornerLatF = 63.92
- #resources.mpLeftCornerLonF = 260.26
- #resources.mpRightCornerLatF = 60.37
- #resources.mpRightCornerLonF = 85.34
- #map rotation
- #resources.mpCenterLonF = 315.0
- #resources.mpCenterLatF = 90.0
- #Grid params
- #Ubrat' reshetky
- #resources.mpGridAndLimbOn = False
- resources.mpGridLineColor = "Black"
- #resources.mpCenterLonF = 110.0
- resources.mpGridPolarLonSpacingF = 10.0
- resources.mpGridLonSpacingF = 10.0
- resources.mpGridLatSpacingF = 10.0
- resources.mpFillOn = True
- #resources.tmXTOn = False
- #resources.tmXBOn = False
- resources.tmYLOn = False
- resources.tmYROn = False
- igray = Ngl.new_color(wks,0.7,0.7,0.7)
- resources.mpFillColors = [20,-1,igray,-1]
- resources.cnFillOn = True
- resources.cnFillDrawOrder = "Predraw"
- resources.cnLineLabelsOn = False
- resources.cnRasterSmothingOn = True
- #CN LINES
- resources.cnLinesOn = False
- resources.cnFillMode= "RasterFill"
- resources.nglSpreadColorStart = 8
- resources.nglSpreadColorEnd = -2
- #resources.cnLevelSelectionMode = "ExplicitLevels" # Define own levels.
- #resources.cnLevels = numpy.arange(-0.9,1.,0.1)
- #resources.cnLevels = arange(0.,100,10)
- resources.lbTitleFontHeightF = 0.020
- resources.lbLabelFontHeightF = 0.008
- resources.lbTitleOffsetF = -0.40
- resources.lbBoxMinorExtentF = 0.15
- resources.pmLabelBarOrthogonalPosF = -0.05
- resources.lbOrientation = "Horizontal"
- resources.cnLineLabelsFontHeightF = 0.05
- #Kolya end
- resources.lbTitleString = 'Sea ice conc, res. 6.25km, [%]'
- #resources.lbTitleFontHeightF = 0.018
- #resources.lbLabelFontHeightF = 0.010
- #resources.lbTitleOffsetF = -0.27
- #resources.lbBoxMinorExtentF = 0.15
- #resources.pmLabelBarOrthogonalPosF = -0.01
- #resources.lbBoxLinesOn = False
- #resources.lbOrientation = "Horizontal"
- resources.tiMainString = "Laptev sea "+dates[10:14]+"/"+dates[14:16]+"/"+dates[16:18]
- map = Ngl.contour_map(wks,concentration[:,:],resources)
Advertisement
Add Comment
Please, Sign In to add comment