# # Latitude/Longitude arrays are every 5km. Cloud_Mask is every 1km # It is necessary to decimate the Cloud_Mask to match lat/lon # dimcm = cldmsk.shape NY = dimcm[0] # "along" swath [1 km] MX = dimcm[1] # "across" swath [1 km] cm = cldmsk[4::5,4::5] # decimate to match lat2d/lon2d dimsizes del cldmsk # no longer needed # # Extract the desired bits and attach lat/lon arrays # cmfov = 00 [0] cloudy 01 [1] uncertain # 10 [2] probably clear 00 [3] confidently clear # tmp = Ngl.dim_gbits(numpy.ravel(cm),5,2,6,nlat*nlon) cmfov = numpy.reshape(tmp, [nlat,nlon]) del tmp del cm #---Open a PNG file wks_type = "png" wks = Ngl.open_wks(wks_type,"hdf1") #---Create variable to hold list of plot resources. res = Ngl.Resources() colors = ["gray","red","green","white"] res.nglDraw = False # Don't create plot or res.nglFrame = False # advance frame yet.
# # Latitude/Longitude arrays are every 5km. Cloud_Mask is every 1km # It is necessary to decimate the Cloud_Mask to match lat/lon # dimcm = cldmsk.shape NY = dimcm[0] # "along" swath [1 km] MX = dimcm[1] # "across" swath [1 km] cm = cldmsk[4::5,4::5] # decimate to match lat2d/lon2d dimsizes del cldmsk # no longer needed # # Extract the desired bits and attach lat/lon arrays # cmfov = 00 [0] cloudy 01 [1] uncertain # 10 [2] probably clear 00 [3] confidently clear # tmp = Ngl.dim_gbits(numpy.ravel(cm),5,2,6,nlat*nlon) cmfov = numpy.reshape(tmp, [nlat,nlon]) del tmp del cm #---Set the colormap and open a PostScript workstation. colors = ["white","black","gray","red","green","white"] wks_type = "ps" wklist = Ngl.Resources() wklist.wkColorMap = colors wks = Ngl.open_wks(wks_type,"hdf1",wklist) #---Create variable to hold list of plot resources. res = Ngl.Resources() res.nglDraw = False # Don't create plot or
from utils import * # # 1440052 = "0101011111100100110100" # # skip keep skip keep skip keep skip keep # 01010 11 111 10 010 01 101 00 # 3 2 1 0 # b = 1440052 ibit = 5 nbits = 2 nskip = 3 iter = 4 jout = numpy.array([0, 1, 3, 2], 'i') # Correct values j = Ngl.dim_gbits(b, ibit, nbits, nskip, iter) test_values("dim_gbits (int input)", j, jout) # # 1466224640 = "01010111011001001101000000000000" # # skip keep skip keep skip keep skip keep # 01010 11 101 10 010 01 101 00 # 3 2 1 0 # b = 1466224640 jout = numpy.array([3, 2, 1, 0], 'i') # Correct values j = Ngl.dim_gbits(b, ibit, nbits, nskip, iter) test_values("dim_gbits (int input)", j, jout)