Last active
October 13, 2015 01:31
-
-
Save selimnairb/fe6a9f204d1e18ee0310 to your computer and use it in GitHub Desktop.
Python/Pandas code for converting an irregular timeseries of tipping bucket rain gage data to hourly rainfall accumulations
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
#!/usr/bin/env python | |
import sys | |
import pandas as pd | |
df = pd.read_csv(sys.argv[1], delimiter='|', index_col=0, parse_dates=True, header=0, | |
names=['timestamp', 'tips_in', 'qual', 'interp', 'remarks']) | |
monthly_precip_in = df.tips_in.resample('H', how='sum') | |
monthly_precip_mm = monthly_precip_in * 25.4 | |
monthly_precip_mm.name = 'precip_mm' | |
monthly_precip_mm.to_csv(sys.argv[2], header=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Input data are of format:
Where Tips (in) is a tip equal to 0.01 inches.
Output data are of format:
Where precip_mm is rainfall accumulation for the hour, in millimeters.
To run: