Advertisement
Guest User

Untitled

a guest
Apr 30th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.08 KB | None | 0 0
  1. rom mpl_toolkits.basemap import Basemap as Bm
  2. import matplotlib.pyplot as plt
  3. from pyhdf import SD as hdf
  4.  
  5.  
  6. class Grafica:
  7. def __init__(self,lon1,lon2, lat1, lat2):
  8. if lon2 > lon1:
  9. self.lon1 = lon1
  10. self.lon2 = lon2
  11. else:
  12. self.lon1 = lon2
  13. self.lon2 = lon1
  14. if lat2 > lat1:
  15. self.lat1 = lat1
  16. self.lat2 = lat2
  17. else:
  18. self.lat1 = lat2
  19. self.lat2 = lat1
  20. def plotM(self):
  21. #m = Bm(llcrnrlon=lon[i][0], llcrnrlat=lat[i][-1], urcrnrlon=lon[i][-1], urcrnrlat=lat[i][0], projection='mill')
  22. m = Bm(llcrnrlon=self.lon1, llcrnrlat=self.lat1, urcrnrlon=self.lon2, urcrnrlat=self.lat2, projection='mill')
  23. m.shadedrelief()
  24. plt.savefig('mapa.png',dpi=500)
  25.  
  26. def plot(self,datos):
  27. #m = Bm(llcrnrlon=lon[i][0], llcrnrlat=lat[i][-1], urcrnrlon=lon[i][-1], urcrnrlat=lat[i][0], projection='mill')
  28. m = Bm(llcrnrlon=self.lon1, llcrnrlat=self.lat1, urcrnrlon=self.lon2, urcrnrlat=self.lat2, projection='mill')
  29. m.shadedrelief()
  30. m.imshow(datos[:])
  31. m.colorbar()
  32.  
  33. #plt.show()
  34. plt.savefig('mapaT.png',dpi=500)
  35.  
  36.  
  37.  
  38. if __name__ == '__main__':
  39.  
  40. # fileSD = hdf.SD('/home/dextron/PycharmProjects/incendioHack/datos/MOD11_L2.A2017119.0045.006.NRT.hdf')
  41. fileSD = hdf.SD('datos/MOD11_L2.A2017096.1445.006.2017097093512.hdf')
  42.  
  43. lat = fileSD.select('Latitude')
  44. lon = fileSD.select('Longitude')
  45. emision = fileSD.select('Emis_31')
  46. #emision2 = fileSD.select('Emis_32')
  47. lsData = fileSD.select('LST')
  48. print lsData.attributes()
  49. print lsData.getdatastrs()
  50. print emision.attributes()
  51. print emision.getdatastrs()
  52. print emision.info()
  53.  
  54. latM = min(map(lambda x : min(x), lat[:]))
  55. latX = max(map(lambda x : max(x), lat[:]))
  56. lonM = min(map(lambda x: min(x), lon[:]))
  57. lonX = max(map(lambda x: max(x), lon[:]))
  58.  
  59. #Test grafica
  60. test = Grafica(lonM, lonX, latM, latX)
  61. test.plotM() # mapa coordenadas
  62. test.plot(lsData) # mapa de temperaturas escalado
  63. #test.plot(emision2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement