Created
December 3, 2022 21:13
-
-
Save schoeller/c67052252e786d51d5882255fc74307f to your computer and use it in GitHub Desktop.
Pull precipitation series in SWMM format from DWD data
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import warnings | |
warnings.filterwarnings("ignore") | |
from wetterdienst.provider.dwd.observation import DwdObservationRequest, \ | |
DwdObservationPeriod, DwdObservationResolution, DwdObservationParameter, DwdObservationDataset | |
# # all | |
# print("All available parameters") | |
# print( | |
# DwdObservationRequest.discover() | |
# ) | |
# # selection | |
# print("Selection of minute data") | |
# print( | |
# DwdObservationRequest.discover( | |
# filter_=DwdObservationResolution.MINUTE_1 | |
# ) | |
# ) | |
# define request filter by WGS84 position | |
request = DwdObservationRequest( | |
parameter=[ | |
DwdObservationParameter.MINUTE_1.PRECIPITATION_HEIGHT | |
], | |
resolution=DwdObservationResolution.MINUTE_1, | |
period=DwdObservationPeriod.HISTORICAL, | |
start_date="2020-01-01", | |
end_date="2020-12-12" | |
).filter_by_rank( | |
49.93121683122822, | |
8.679585503284287, | |
1 | |
) | |
# fetch values for request and drop na-values and zero values | |
station_data = request.values.all().df | |
station_data.dropna(axis=0).head() | |
df = station_data[station_data.value != 0] | |
# save to file | |
station_data.to_csv("prec.dat", sep="\t", columns = ['station_id', 'date', 'value'], date_format = '%Y %m %d %H %M', index=False, header=False) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment