investigation_set.py 1.94 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
# -*- coding: utf-8 -*-
"""
Spyder Editor

Dies ist eine temporäre Skriptdatei.
"""

import h5py
import numpy as np
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
import cartopy.feature as cfeature
import cartopy.io.shapereader as shpreader
#from shapely.geometry import Point, Polygon
#from geopandas.tools import sjoin


18 19
dType = 'ASWDIR'   #data type
year = '2015'
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56

path = 'D:/WetterdatenPamore/' + year + '/' \
               + year + '_'+ dType + '.h5'

with h5py.File(path, 'r') as f:
   data = f[dType]
   lat = f['latitude']
   lon = f['longitude']
   refPos = (lat[0,0], lon[0,0])
   posRight = (lat[0,100], lon[0,100])
   posDown = (lat[100,0], lon[100,0])
   print (refPos, posRight, posDown)
   #print(min(data))
   #print(max(data))
   #print(data[:15])
   print(data[12,0,0])
   for key in f.keys():
       print(key)
   for att in f.attrs.keys():
       print(att, f.attrs[att])
       
   data_crs = ccrs.PlateCarree()
   fig = plt.figure(figsize=(15,15))
   ax = fig.add_subplot(1, 1, 1, projection=ccrs.EuroPP())
   ax.set_extent([0, 10, 50, 60], crs=ccrs.PlateCarree())
   resolution = '10m'
   #ax.add_feature(cfeature.LAND)
   #ax.add_feature(cfeature.OCEAN)
   ax.add_feature(cfeature.COASTLINE.with_scale(resolution))
   ax.add_feature(cfeature.BORDERS.with_scale(resolution))
   #ax.add_feature(cfeature.LAKES, alpha=0.5)
   #ax.add_feature(cfeature.RIVERS)
   ax.gridlines()
   
   ax.scatter(refPos[1], refPos[0], transform=data_crs, c='black')
   ax.scatter(posRight[1], posRight[0], transform=data_crs, c='red')
   ax.scatter(posDown[1], posDown[0], transform=data_crs, c='blue')
57 58 59 60 61 62
   
   print('Top left - Lat:', lat[0,0], "   Lon:", lon[0,0])
   print('Top Right - Lat:', lat[0,len(lat[0]) - 1], "   Lon:", lon[0,len(lon[0]) - 1])
   print('Bottom left - Lat:', lat[len(lat) - 1,0], "   Lon:", lon[len(lon) - 1,0])
   print('Bottom Right - Lat:', lat[len(lat) - 1,len(lat[0]) - 1], "   Lon:",  lon[len(lon) - 1,len(lon[0]) - 1])
   
63
   plt.show()