Python Forum
Working with rain time series
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Working with rain time series
#1
I have rain data with 15 minutes interval, like this:

[yyyy mm dd hh mm rain_value]
2017 1 1 0 0 0.2
2017 1 1 0 15 0.4
2017 1 1 0 30 2.1
2017 1 1 0 45 0
2017 1 1 1 0 0
2017 1 1 1 15 1.3
[...]

And I need to accumulate every rain_value along the time serie making rain events.
But when I have 24 hour with no rain (rain_value = 0), I need to write start and end of rain event and start a new sum when starts to rain again, getting something like this:

Start_Event End_event Accumulated_Rain
'2017-1-1 0:0' '2017-1-4 12:45' 36.2
'2017-1-6 4:15' '2017-1-12 19:45' 43.2

What's the easier way to code this on python?

Thanks
Reply
#2
please show names for all fields, year, month, day, ...
Reply
#3
The fields of time series:

year month day hour minute rain_value
2017 1 1 0 0 0.2
2017 1 1 0 15 0.4
2017 1 1 0 30 2.1
2017 1 1 0 45 0
2017 1 1 1 0 0
2017 1 1 1 15 1.3
Reply
#4
I would keep them in a dictionary by day:
rain_data = {
    '2017-01-01': {
        '00:00': 0.2,
        '00:15': 0.4,
        ...
    }
}
This will allow you to calculate mean or what ever you require.
It is also in a format that can be saved and reloaded as a JSON file:

import json

def save_data(rain_data):
    with open('raindata.json', 'w') as jp:
        json.dump(rain_data, jp)

def load_data():
    with open('raindata.json') as jp:
        return json.load(jp)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Date Time Series Help...Please spra8560 2 314 Feb-01-2024, 01:38 PM
Last Post: spra8560
  Print names in x-axis of a time-series values hobbyist 4 1,178 Apr-22-2023, 09:29 PM
Last Post: deanhystad
  Rain sensor output only on change Pete6 3 1,987 May-11-2022, 10:36 PM
Last Post: Pete6
  Time series JasminQuinn 0 1,005 Apr-22-2022, 10:33 PM
Last Post: JasminQuinn
  How to read rainfall time series and insert missing data points MadsM 4 2,125 Jan-06-2022, 10:39 AM
Last Post: amdi40
  Real Time Audio Processing with Python Sound-Device not working Slartybartfast 2 3,883 Mar-14-2021, 07:20 PM
Last Post: Slartybartfast
  Plotting A Time Series With Shaded Recession Bars adamszymanski 1 3,119 Jan-24-2021, 09:08 PM
Last Post: nealc
  Getting the hourly average of a time series dataset Raskou07 10 12,320 Dec-15-2020, 12:51 PM
Last Post: palladium
  Tableau Time Series Prediction using Python Integration tobimarsh43 0 1,888 Jul-24-2020, 10:38 AM
Last Post: tobimarsh43
  Bode plot from time series experiment data discus 4 7,209 Jun-20-2020, 07:46 AM
Last Post: discus

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020