Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pandas as pd
- import numpy as np
- import xarray as xr
- import geopandas as gpd
- print(precip_da)
- Out[]:
- <xarray.DataArray 'precip' (time: 13665, latitude: 200, longitude: 220)>
- [601260000 values with dtype=float32]
- Coordinates:
- * longitude (longitude) float32 35.024994 35.074997 35.125 35.175003 ...
- * latitude (latitude) float32 5.0249977 5.074997 5.125 5.174999 ...
- * time (time) datetime64[ns] 1981-01-01 1981-01-02 1981-01-03 ...
- Attributes:
- standard_name: convective precipitation rate
- long_name: Climate Hazards group InfraRed Precipitation with St...
- units: mm/day
- time_step: day
- geostatial_lat_min: -50.0
- geostatial_lat_max: 50.0
- geostatial_lon_min: -180.0
- geostatial_lon_max: 180.0
- precip_da.mean(dim="time").plot()
- awash = gpd.read_file(shp_dir+"/Export_Output.shp")
- awash
- Out[]:
- OID_ Name FolderPath SymbolID AltMode Base Clamped Extruded Snippet PopupInfo Shape_Leng Shape_Area geometry
- 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...
- awash.plot()
- ax = awash.plot(alpha=0.2, color='black')
- precip_da.mean(dim="time").plot(ax=ax,zorder=-1)
- masked_precip = precip_da.within(awash)
- masked_precip = precip_da.loc[precip_da.isin(awash)]
Add Comment
Please, Sign In to add comment