Guest User

Untitled

a guest
Jul 18th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. import pandas as pd
  2. import numpy as np
  3. import xarray as xr
  4. import geopandas as gpd
  5.  
  6. print(precip_da)
  7.  
  8. Out[]:
  9. <xarray.DataArray 'precip' (time: 13665, latitude: 200, longitude: 220)>
  10. [601260000 values with dtype=float32]
  11. Coordinates:
  12. * longitude (longitude) float32 35.024994 35.074997 35.125 35.175003 ...
  13. * latitude (latitude) float32 5.0249977 5.074997 5.125 5.174999 ...
  14. * time (time) datetime64[ns] 1981-01-01 1981-01-02 1981-01-03 ...
  15. Attributes:
  16. standard_name: convective precipitation rate
  17. long_name: Climate Hazards group InfraRed Precipitation with St...
  18. units: mm/day
  19. time_step: day
  20. geostatial_lat_min: -50.0
  21. geostatial_lat_max: 50.0
  22. geostatial_lon_min: -180.0
  23. geostatial_lon_max: 180.0
  24.  
  25. precip_da.mean(dim="time").plot()
  26.  
  27. awash = gpd.read_file(shp_dir+"/Export_Output.shp")
  28.  
  29. awash
  30. Out[]:
  31. OID_ Name FolderPath SymbolID AltMode Base Clamped Extruded Snippet PopupInfo Shape_Leng Shape_Area geometry
  32. 0 0 Awash_Basin Awash_Basin.kml 0 0 0.0 -1 0 None None 30.180944 9.411263 POLYGON Z ((41.78939511000004 11.5539922500000...
  33.  
  34. awash.plot()
  35.  
  36. ax = awash.plot(alpha=0.2, color='black')
  37. precip_da.mean(dim="time").plot(ax=ax,zorder=-1)
  38.  
  39. masked_precip = precip_da.within(awash)
  40.  
  41. masked_precip = precip_da.loc[precip_da.isin(awash)]
Add Comment
Please, Sign In to add comment