Rainfall intensity from tipping bucket

In hydrology, he usually works with rainfall data from a tipping bucket. It is recorded every time the bucket is filled, for example, 0.2 mm or 0.5 mm of water.

I would like to import this type of data into R, but could not find a smooth way to do this. I received very good help from the answers to the question of Creating regular 15-minute time series from irregular time series , but I still miss one part of how we usually process the data: smoothing during low-intensity precipitation.

This is a small part of my tipping bucket data in Malmö, Sweden. 0.2 is recorded for every 0.2 mm of precipitation:

Rainfall Depth[millimeter]:Instantaneous Undefined[undefined]:Instantaneous Time M05_Bulltofta_vippning Flag 2014-08-31 04:09:22 0.2 0 2014-08-31 04:12:14 0.2 0 2014-08-31 04:17:49 0.2 0 2014-08-31 04:20:00 0.2 0 2014-08-31 04:22:10 0.2 0 2014-08-31 04:23:31 0.2 0 2014-08-31 04:24:49 0.2 0 2014-08-31 04:25:49 0.2 0 2014-08-31 04:28:14 0.2 0 2014-08-31 04:36:22 0.2 0 2014-08-31 04:41:06 0.2 0 2014-08-31 04:42:58 0.2 0 2014-08-31 04:43:33 0.2 0 2014-08-31 04:45:03 0.2 0 2014-08-31 04:47:47 0.2 0 2014-08-31 04:49:49 0.2 0 2014-08-31 04:51:35 0.2 0 2014-08-31 04:52:58 0.2 0 2014-08-31 04:54:32 0.2 0 2014-08-31 04:55:54 0.2 0 2014-08-31 04:58:36 0.2 0 2014-08-31 05:02:17 0.2 0 2014-08-31 05:06:21 0.2 0 2014-08-31 05:09:56 0.2 0 2014-08-31 05:12:57 0.2 0 2014-08-31 05:14:38 0.2 0 2014-08-31 05:16:13 0.2 0 2014-08-31 05:17:42 0.2 0 2014-08-31 05:19:05 0.2 0 2014-08-31 05:20:38 0.2 0 2014-08-31 05:22:44 0.2 0 2014-08-31 05:24:11 0.2 0 2014-08-31 05:25:41 0.2 0 2014-08-31 05:26:48 0.2 0 2014-08-31 05:27:24 0.2 0 2014-08-31 05:27:59 0.2 0 2014-08-31 05:28:59 0.2 0 2014-08-31 05:29:40 0.2 0 2014-08-31 05:30:09 0.2 0 2014-08-31 05:30:33 0.2 0 2014-08-31 05:31:03 0.2 0 2014-08-31 05:31:38 0.2 0 2014-08-31 05:32:30 0.2 0 2014-08-31 05:33:46 0.2 0 2014-08-31 05:35:10 0.2 0 2014-08-31 05:36:25 0.2 0 2014-08-31 05:38:20 0.2 0 2014-08-31 05:40:38 0.2 0 2014-08-31 05:44:23 0.2 0 2014-08-31 05:44:53 0.2 0 2014-08-31 05:45:19 0.2 0 2014-08-31 05:45:55 0.2 0 2014-08-31 05:46:50 0.2 0 2014-08-31 05:47:30 0.2 0 2014-08-31 05:48:09 0.2 0 2014-08-31 05:48:26 0.2 0 2014-08-31 05:48:38 0.2 0 2014-08-31 05:48:47 0.2 0 2014-08-31 05:48:59 0.2 0 2014-08-31 05:49:15 0.2 0 2014-08-31 05:49:34 0.2 0 2014-08-31 05:50:00 0.2 0 2014-08-31 05:50:31 0.2 0 2014-08-31 05:50:51 0.2 0 2014-08-31 05:51:20 0.2 0 2014-08-31 05:52:00 0.2 0 2014-08-31 05:52:39 0.2 0 2014-08-31 05:53:01 0.2 0 2014-08-31 05:53:29 0.2 0 2014-08-31 05:53:54 0.2 0 2014-08-31 05:54:21 0.2 0 2014-08-31 05:54:43 0.2 0 2014-08-31 05:55:04 0.2 0 2014-08-31 05:55:28 0.2 0 2014-08-31 05:55:49 0.2 0 2014-08-31 05:56:05 0.2 0 2014-08-31 05:56:27 0.2 0 2014-08-31 05:56:52 0.2 0 2014-08-31 05:57:24 0.2 0 2014-08-31 05:57:56 0.2 0 2014-08-31 05:58:34 0.2 0 2014-08-31 05:59:08 0.2 0 2014-08-31 05:59:43 0.2 0 2014-08-31 06:00:11 0.2 0 2014-08-31 06:00:36 0.2 0 2014-08-31 06:00:54 0.2 0 2014-08-31 06:01:14 0.2 0 2014-08-31 06:01:28 0.2 0 2014-08-31 06:01:47 0.2 0 2014-08-31 06:02:03 0.2 0 2014-08-31 06:02:22 0.2 0 2014-08-31 06:02:43 0.2 0 2014-08-31 06:03:09 0.2 0 2014-08-31 06:03:40 0.2 0 2014-08-31 06:04:32 0.2 0 2014-08-31 06:05:26 0.2 0 2014-08-31 06:06:18 0.2 0 2014-08-31 06:07:13 0.2 0 2014-08-31 06:08:23 0.2 0 2014-08-31 06:09:24 0.2 0 2014-08-31 06:10:13 0.2 0 2014-08-31 06:10:46 0.2 0 2014-08-31 06:11:24 0.2 0 2014-08-31 06:11:47 0.2 0 2014-08-31 06:12:08 0.2 0 2014-08-31 06:12:23 0.2 0 2014-08-31 06:12:40 0.2 0 2014-08-31 06:12:55 0.2 0 2014-08-31 06:13:14 0.2 0 2014-08-31 06:13:30 0.2 0 2014-08-31 06:13:49 0.2 0 2014-08-31 06:14:08 0.2 0 2014-08-31 06:14:31 0.2 0 2014-08-31 06:14:51 0.2 0 2014-08-31 06:15:12 0.2 0 2014-08-31 06:15:33 0.2 0 2014-08-31 06:15:50 0.2 0 2014-08-31 06:16:07 0.2 0 2014-08-31 06:16:27 0.2 0 2014-08-31 06:16:43 0.2 0 2014-08-31 06:17:01 0.2 0 2014-08-31 06:17:19 0.2 0 2014-08-31 06:17:36 0.2 0 2014-08-31 06:17:51 0.2 0 2014-08-31 06:18:08 0.2 0 2014-08-31 06:18:25 0.2 0 2014-08-31 06:18:46 0.2 0 2014-08-31 06:19:05 0.2 0 2014-08-31 06:19:25 0.2 0 2014-08-31 06:19:42 0.2 0 2014-08-31 06:20:00 0.2 0 2014-08-31 06:20:12 0.2 0 2014-08-31 06:20:24 0.2 0 2014-08-31 06:20:36 0.2 0 2014-08-31 06:20:56 0.2 0 2014-08-31 06:21:14 0.2 0 2014-08-31 06:21:27 0.2 0 2014-08-31 06:21:37 0.2 0 2014-08-31 06:21:48 0.2 0 2014-08-31 06:22:06 0.2 0 2014-08-31 06:22:16 0.2 0 2014-08-31 06:22:29 0.2 0 2014-08-31 06:22:47 0.2 0 2014-08-31 06:23:09 0.2 0 2014-08-31 06:23:30 0.2 0 2014-08-31 06:23:57 0.2 0 2014-08-31 06:24:21 0.2 0 2014-08-31 06:24:39 0.2 0 2014-08-31 06:24:51 0.2 0 2014-08-31 06:25:03 0.2 0 2014-08-31 06:25:16 0.2 0 2014-08-31 06:25:29 0.2 0 2014-08-31 06:25:39 0.2 0 2014-08-31 06:25:49 0.2 0 2014-08-31 06:25:59 0.2 0 2014-08-31 06:26:13 0.2 0 2014-08-31 06:26:29 0.2 0 2014-08-31 06:26:50 0.2 0 2014-08-31 06:27:13 0.2 0 2014-08-31 06:27:49 0.2 0 2014-08-31 06:28:12 0.2 0 2014-08-31 06:28:42 0.2 0 2014-08-31 06:29:11 0.2 0 2014-08-31 06:29:44 0.2 0 2014-08-31 06:30:14 0.2 0 2014-08-31 06:30:35 0.2 0 2014-08-31 06:30:49 0.2 0 2014-08-31 06:31:06 0.2 0 2014-08-31 06:31:25 0.2 0 2014-08-31 06:31:56 0.2 0 2014-08-31 06:32:45 0.2 0 2014-08-31 06:34:09 0.2 0 2014-08-31 06:34:53 0.2 0 2014-08-31 06:35:27 0.2 0 2014-08-31 06:36:05 0.2 0 2014-08-31 06:36:25 0.2 0 2014-08-31 06:36:39 0.2 0 2014-08-31 06:36:56 0.2 0 2014-08-31 06:37:11 0.2 0 2014-08-31 06:37:24 0.2 0 2014-08-31 06:37:38 0.2 0 2014-08-31 06:37:50 0.2 0 2014-08-31 06:38:00 0.2 0 2014-08-31 06:38:12 0.2 0 2014-08-31 06:38:22 0.2 0 2014-08-31 06:38:32 0.2 0 2014-08-31 06:38:42 0.2 0 2014-08-31 06:38:52 0.2 0 2014-08-31 06:39:02 0.2 0 2014-08-31 06:39:16 0.2 0 2014-08-31 06:39:29 0.2 0 2014-08-31 06:39:42 0.2 0 2014-08-31 06:39:58 0.2 0 2014-08-31 06:40:20 0.2 0 2014-08-31 06:40:48 0.2 0 2014-08-31 06:41:23 0.2 0 2014-08-31 06:42:03 0.2 0 2014-08-31 06:42:42 0.2 0 2014-08-31 06:43:21 0.2 0 2014-08-31 06:43:46 0.2 0 2014-08-31 06:44:14 0.2 0 2014-08-31 06:44:41 0.2 0 2014-08-31 06:45:11 0.2 0 2014-08-31 06:46:01 0.2 0 2014-08-31 06:46:50 0.2 0 2014-08-31 06:47:32 0.2 0 2014-08-31 06:47:56 0.2 0 2014-08-31 06:48:21 0.2 0 2014-08-31 06:48:36 0.2 0 2014-08-31 06:48:51 0.2 0 2014-08-31 06:49:02 0.2 0 2014-08-31 06:49:17 0.2 0 2014-08-31 06:49:37 0.2 0 2014-08-31 06:50:09 0.2 0 2014-08-31 06:50:41 0.2 0 2014-08-31 06:51:24 0.2 0 2014-08-31 06:52:10 0.2 0 2014-08-31 06:52:55 0.2 0 2014-08-31 06:53:34 0.2 0 2014-08-31 06:54:10 0.2 0 2014-08-31 06:54:43 0.2 0 2014-08-31 06:55:34 0.2 0 2014-08-31 06:57:01 0.2 0 2014-08-31 06:58:27 0.2 0 2014-08-31 06:59:10 0.2 0 2014-08-31 07:00:17 0.2 0 2014-08-31 07:01:25 0.2 0 2014-08-31 07:02:19 0.2 0 2014-08-31 07:03:06 0.2 0 2014-08-31 07:04:03 0.2 0 2014-08-31 07:04:48 0.2 0 2014-08-31 07:05:31 0.2 0 2014-08-31 07:06:14 0.2 0 2014-08-31 07:06:58 0.2 0 2014-08-31 07:07:33 0.2 0 2014-08-31 07:08:19 0.2 0 2014-08-31 07:08:58 0.2 0 2014-08-31 07:09:50 0.2 0 2014-08-31 07:10:38 0.2 0 2014-08-31 07:11:34 0.2 0 2014-08-31 07:12:12 0.2 0 2014-08-31 07:13:09 0.2 0 2014-08-31 07:14:16 0.2 0 2014-08-31 07:15:07 0.2 0 2014-08-31 07:15:45 0.2 0 2014-08-31 07:16:21 0.2 0 2014-08-31 07:16:53 0.2 0 2014-08-31 07:17:30 0.2 0 2014-08-31 07:18:33 0.2 0 2014-08-31 07:19:24 0.2 0 2014-08-31 07:20:07 0.2 0 2014-08-31 07:21:06 0.2 0 2014-08-31 07:21:53 0.2 0 2014-08-31 07:22:46 0.2 0 2014-08-31 07:23:45 0.2 0 2014-08-31 07:24:59 0.2 0 2014-08-31 07:25:50 0.2 0 2014-08-31 07:26:41 0.2 0 2014-08-31 07:27:18 0.2 0 2014-08-31 07:27:59 0.2 0 2014-08-31 07:28:29 0.2 0 2014-08-31 07:29:01 0.2 0 2014-08-31 07:29:54 0.2 0 2014-08-31 07:30:51 0.2 0 2014-08-31 07:31:53 0.2 0 2014-08-31 07:32:25 0.2 0 2014-08-31 07:32:53 0.2 0 2014-08-31 07:33:21 0.2 0 2014-08-31 07:33:47 0.2 0 2014-08-31 07:34:08 0.2 0 2014-08-31 07:34:22 0.2 0 2014-08-31 07:34:42 0.2 0 2014-08-31 07:35:07 0.2 0 2014-08-31 07:35:30 0.2 0 2014-08-31 07:35:52 0.2 0 2014-08-31 07:36:18 0.2 0 2014-08-31 07:36:45 0.2 0 2014-08-31 07:37:13 0.2 0 2014-08-31 07:37:32 0.2 0 2014-08-31 07:37:49 0.2 0 2014-08-31 07:38:07 0.2 0 2014-08-31 07:38:28 0.2 0 2014-08-31 07:38:49 0.2 0 2014-08-31 07:39:04 0.2 0 2014-08-31 07:39:14 0.2 0 2014-08-31 07:39:25 0.2 0 2014-08-31 07:39:35 0.2 0 2014-08-31 07:39:45 0.2 0 2014-08-31 07:40:42 0.2 0 2014-08-31 07:40:57 0.2 0 2014-08-31 07:41:36 0.2 0 2014-08-31 07:42:23 0.2 0 2014-08-31 07:42:42 0.2 0 2014-08-31 07:43:16 0.2 0 2014-08-31 07:44:21 0.2 0 2014-08-31 07:45:19 0.2 0 2014-08-31 07:46:02 0.2 0 2014-08-31 07:47:12 0.2 0 2014-08-31 07:47:39 0.2 0 2014-08-31 07:47:58 0.2 0 2014-08-31 07:48:14 0.2 0 2014-08-31 07:48:25 0.2 0 2014-08-31 07:48:36 0.2 0 2014-08-31 07:48:48 0.2 0 2014-08-31 07:49:04 0.2 0 2014-08-31 07:49:18 0.2 0 2014-08-31 07:49:31 0.2 0 2014-08-31 07:49:52 0.2 0 2014-08-31 07:50:28 0.2 0 2014-08-31 07:51:22 0.2 0 2014-08-31 07:52:20 0.2 0 2014-08-31 07:53:13 0.2 0 2014-08-31 07:54:09 0.2 0 2014-08-31 07:55:22 0.2 0 2014-08-31 07:56:25 0.2 0 2014-08-31 07:57:17 0.2 0 2014-08-31 07:57:46 0.2 0 2014-08-31 07:58:06 0.2 0 2014-08-31 07:58:26 0.2 0 2014-08-31 07:58:43 0.2 0 2014-08-31 07:59:02 0.2 0 2014-08-31 07:59:20 0.2 0 2014-08-31 07:59:32 0.2 0 2014-08-31 07:59:48 0.2 0 2014-08-31 08:00:06 0.2 0 2014-08-31 08:00:29 0.2 0 2014-08-31 08:00:50 0.2 0 2014-08-31 08:01:14 0.2 0 2014-08-31 08:01:36 0.2 0 2014-08-31 08:02:01 0.2 0 2014-08-31 08:02:24 0.2 0 2014-08-31 08:02:41 0.2 0 2014-08-31 08:02:53 0.2 0 2014-08-31 08:03:08 0.2 0 2014-08-31 08:03:23 0.2 0 2014-08-31 08:03:37 0.2 0 2014-08-31 08:03:51 0.2 0 2014-08-31 08:04:05 0.2 0 2014-08-31 08:04:22 0.2 0 2014-08-31 08:04:40 0.2 0 2014-08-31 08:05:00 0.2 0 2014-08-31 08:05:26 0.2 0 2014-08-31 08:05:54 0.2 0 2014-08-31 08:06:23 0.2 0 2014-08-31 08:06:49 0.2 0 2014-08-31 08:07:20 0.2 0 2014-08-31 08:07:53 0.2 0 2014-08-31 08:08:32 0.2 0 2014-08-31 08:09:00 0.2 0 2014-08-31 08:09:25 0.2 0 2014-08-31 08:09:46 0.2 0 2014-08-31 08:10:12 0.2 0 2014-08-31 08:10:48 0.2 0 2014-08-31 08:11:27 0.2 0 2014-08-31 08:12:09 0.2 0 2014-08-31 08:13:06 0.2 0 2014-08-31 08:14:07 0.2 0 2014-08-31 08:14:33 0.2 0 2014-08-31 08:15:01 0.2 0 2014-08-31 08:15:23 0.2 0 2014-08-31 08:15:55 0.2 0 2014-08-31 08:16:22 0.2 0 2014-08-31 08:16:49 0.2 0 2014-08-31 08:17:17 0.2 0 2014-08-31 08:17:33 0.2 0 2014-08-31 08:17:48 0.2 0 2014-08-31 08:17:59 0.2 0 2014-08-31 08:18:12 0.2 0 2014-08-31 08:18:23 0.2 0 2014-08-31 08:18:35 0.2 0 2014-08-31 08:18:46 0.2 0 2014-08-31 08:18:59 0.2 0 2014-08-31 08:19:12 0.2 0 2014-08-31 08:19:26 0.2 0 2014-08-31 08:19:43 0.2 0 2014-08-31 08:20:07 0.2 0 2014-08-31 08:20:30 0.2 0 2014-08-31 08:20:50 0.2 0 2014-08-31 08:21:09 0.2 0 2014-08-31 08:21:30 0.2 0 2014-08-31 08:21:49 0.2 0 2014-08-31 08:22:08 0.2 0 2014-08-31 08:22:23 0.2 0 2014-08-31 08:22:38 0.2 0 2014-08-31 08:22:54 0.2 0 2014-08-31 08:23:16 0.2 0 2014-08-31 08:23:36 0.2 0 2014-08-31 08:24:00 0.2 0 2014-08-31 08:24:24 0.2 0 2014-08-31 08:24:46 0.2 0 2014-08-31 08:25:04 0.2 0 2014-08-31 08:25:20 0.2 0 2014-08-31 08:25:37 0.2 0 2014-08-31 08:25:54 0.2 0 2014-08-31 08:26:06 0.2 0 2014-08-31 08:26:15 0.2 0 2014-08-31 08:26:32 0.2 0 2014-08-31 08:26:51 0.2 0 2014-08-31 08:27:03 0.2 0 2014-08-31 08:27:15 0.2 0 2014-08-31 08:27:28 0.2 0 2014-08-31 08:27:42 0.2 0 2014-08-31 08:27:55 0.2 0 2014-08-31 08:28:11 0.2 0 2014-08-31 08:28:25 0.2 0 2014-08-31 08:28:39 0.2 0 2014-08-31 08:28:53 0.2 0 2014-08-31 08:29:08 0.2 0 2014-08-31 08:29:18 0.2 0 2014-08-31 08:29:31 0.2 0 2014-08-31 08:29:47 0.2 0 2014-08-31 08:30:00 0.2 0 2014-08-31 08:30:18 0.2 0 2014-08-31 08:30:32 0.2 0 2014-08-31 08:30:49 0.2 0 2014-08-31 08:31:05 0.2 0 2014-08-31 08:31:22 0.2 0 2014-08-31 08:31:39 0.2 0 2014-08-31 08:31:55 0.2 0 2014-08-31 08:32:09 0.2 0 2014-08-31 08:32:18 0.2 0 2014-08-31 08:32:27 0.2 0 2014-08-31 08:32:36 0.2 0 2014-08-31 08:32:45 0.2 0 2014-08-31 08:33:22 0.2 0 2014-08-31 08:33:39 0.2 0 2014-08-31 08:33:48 0.2 0 2014-08-31 08:34:06 0.2 0 2014-08-31 08:34:27 0.2 0 2014-08-31 08:34:41 0.2 0 2014-08-31 08:35:04 0.2 0 2014-08-31 08:36:58 0.2 0 2014-08-31 08:37:52 0.2 0 2014-08-31 08:38:31 0.2 0 2014-08-31 08:39:05 0.2 0 2014-08-31 08:39:38 0.2 0 2014-08-31 08:40:12 0.2 0 2014-08-31 08:40:38 0.2 0 2014-08-31 08:40:50 0.2 0 2014-08-31 08:41:01 0.2 0 2014-08-31 08:41:28 0.2 0 2014-08-31 08:41:37 0.2 0 2014-08-31 08:41:46 0.2 0 2014-08-31 08:42:04 0.2 0 2014-08-31 08:42:25 0.2 0 2014-08-31 08:42:36 0.2 0 2014-08-31 08:42:50 0.2 0 2014-08-31 08:43:03 0.2 0 2014-08-31 08:43:25 0.2 0 2014-08-31 08:43:47 0.2 0 2014-08-31 08:44:13 0.2 0 2014-08-31 08:44:37 0.2 0 2014-08-31 08:44:54 0.2 0 2014-08-31 08:45:14 0.2 0 2014-08-31 08:45:58 0.2 0 2014-08-31 08:47:25 0.2 0 2014-08-31 08:54:43 0.2 0 2014-08-31 08:56:44 0.2 0 2014-08-31 08:58:20 0.2 0 2014-08-31 08:58:51 0.2 0 2014-08-31 08:59:19 0.2 0 2014-08-31 08:59:54 0.2 0 2014-08-31 09:00:31 0.2 0 2014-08-31 09:01:44 0.2 0 2014-08-31 09:03:41 0.2 0 2014-08-31 09:05:37 0.2 0 2014-08-31 09:06:45 0.2 0 2014-08-31 09:07:35 0.2 0 2014-08-31 09:08:09 0.2 0 2014-08-31 09:08:24 0.2 0 2014-08-31 09:08:39 0.2 0 2014-08-31 09:08:58 0.2 0 2014-08-31 09:09:20 0.2 0 2014-08-31 09:09:42 0.2 0 2014-08-31 09:10:10 0.2 0 2014-08-31 09:10:40 0.2 0 2014-08-31 09:11:05 0.2 0 2014-08-31 09:11:24 0.2 0 2014-08-31 09:11:39 0.2 0 2014-08-31 09:11:56 0.2 0 2014-08-31 09:12:29 0.2 0 2014-08-31 09:13:19 0.2 0 2014-08-31 09:13:57 0.2 0 2014-08-31 09:14:20 0.2 0 2014-08-31 09:14:40 0.2 0 2014-08-31 09:15:04 0.2 0 2014-08-31 09:15:26 0.2 0 2014-08-31 09:15:43 0.2 0 2014-08-31 09:16:01 0.2 0 2014-08-31 09:16:23 0.2 0 2014-08-31 09:16:57 0.2 0 2014-08-31 09:17:25 0.2 0 2014-08-31 09:23:53 0.2 0 2014-08-31 09:24:48 0.2 0 2014-08-31 09:25:29 0.2 0 2014-08-31 09:26:02 0.2 0 2014-08-31 09:26:26 0.2 0 2014-08-31 09:26:48 0.2 0 2014-08-31 09:27:08 0.2 0 2014-08-31 09:27:29 0.2 0 2014-08-31 09:27:53 0.2 0 2014-08-31 09:28:16 0.2 0 2014-08-31 09:28:38 0.2 0 2014-08-31 09:29:02 0.2 0 2014-08-31 09:29:31 0.2 0 2014-08-31 09:29:50 0.2 0 2014-08-31 09:30:10 0.2 0 2014-08-31 09:30:29 0.2 0 2014-08-31 09:30:54 0.2 0 2014-08-31 09:31:16 0.2 0 2014-08-31 09:31:39 0.2 0 2014-08-31 09:34:22 0.2 0 2014-08-31 09:34:51 0.2 0 2014-08-31 09:35:06 0.2 0 2014-08-31 09:35:16 0.2 0 2014-08-31 09:36:08 0.2 0 2014-08-31 09:36:56 0.2 0 2014-08-31 09:37:53 0.2 0 2014-08-31 09:58:37 0.2 0 2014-08-31 10:02:40 0.2 0 2014-08-31 12:16:12 0.2 0 2014-08-31 12:34:54 0.2 0 2014-08-31 13:29:46 0.2 0 2014-08-31 13:52:40 0.2 0 2014-08-31 14:32:00 0.2 0 2014-08-31 14:38:58 0.2 0 2014-08-31 14:42:59 0.2 0 2014-08-31 14:50:12 0.2 0 2014-08-31 15:05:28 0.2 0 2014-08-31 15:25:45 0.2 0 2014-08-31 15:49:25 0.2 0 2014-08-31 16:10:28 0.2 0 2014-08-31 17:26:46 0.2 0 2014-08-31 18:24:37 0.2 0 2014-08-31 18:31:37 0.2 0 2014-08-31 18:39:27 0.2 0 2014-08-31 18:41:31 0.2 0 2014-08-31 18:44:10 0.2 0 2014-08-31 18:48:17 0.2 0 2014-08-31 18:50:58 0.2 0 2014-08-31 18:52:46 0.2 0 2014-08-31 18:55:23 0.2 0 2014-08-31 19:00:23 0.2 0 2014-08-31 19:04:27 0.2 0 2014-08-31 19:07:12 0.2 0 2014-08-31 19:10:45 0.2 0 2014-08-31 19:13:40 0.2 0 2014-08-31 19:19:03 0.2 0 2014-08-31 19:25:23 0.2 0 2014-08-31 19:34:27 0.2 0 2014-08-31 19:44:11 0.2 0 2014-08-31 20:00:15 0.2 0 2014-08-31 20:01:15 0.2 0 2014-08-31 20:01:40 0.2 0 2014-08-31 20:01:53 0.2 0 2014-08-31 20:02:07 0.2 0 2014-08-31 20:02:26 0.2 0 2014-08-31 20:02:58 0.2 0 2014-08-31 20:03:42 0.2 0 2014-08-31 20:04:22 0.2 0 2014-08-31 20:04:58 0.2 0 2014-08-31 20:05:28 0.2 0 2014-08-31 20:06:02 0.2 0 2014-08-31 20:08:01 0.2 0 2014-08-31 20:11:21 0.2 0 2014-08-31 20:13:14 0.2 0 2014-08-31 20:14:53 0.2 0 2014-08-31 20:16:32 0.2 0 2014-08-31 20:18:32 0.2 0 2014-08-31 20:20:26 0.2 0 2014-08-31 20:22:43 0.2 0 2014-08-31 20:26:41 0.2 0 2014-08-31 20:30:14 0.2 0 2014-08-31 20:33:32 0.2 0 2014-08-31 20:36:54 0.2 0 2014-08-31 20:41:37 0.2 0 2014-08-31 20:42:58 0.2 0 2014-08-31 20:43:46 0.2 0 2014-08-31 20:44:35 0.2 0 2014-08-31 20:47:10 0.2 0 2014-08-31 20:56:03 0.2 0 

This is my code:

 library(xts) ## Import data from txt file tip_time <- read.table("../Rainfall/Malmo_regndata/fasta/M01_Turbinen_vippning.txt", header = TRUE, check.names=FALSE, sep = "\t", skip = 1) tip_time$Time <- as.POSIXct(tip_time$Time) # Convert to POSIXct tip_time = xts(tip_time[,-1], order.by=tip_time[,1]) # Convert to xts acc_tip <- cumsum(tip_time[,1]) # Accumulated rainfall (here in mm) ## Make time series with regular time steps step <- 5 days <- 1 n <- days*24*60/step timesteps <- ISOdatetime(2014,08,31,0,0,0) + seq(0:(n-1))*step*60 # Make timesteps ts <- xts(rep(NA,n), order.by=timesteps) # Make xts with timesteps and NA ## Merge data into time series with regular time steps ts_tip <- merge(ts, na.locf(merge(ts, acc_tip)[,2]), join="inner")[,2] # Merge acc_tip with ts ts_tip[is.na(ts_tip)] <- 0 # Make 0 of NA ## Calculate intesities from accumulated rainfall intensity <- diff(ts_tip, lag = 1) # Calculate intensities (here in mm/5 min) intensity[is.na(intensity)] <- 0 # Make 0 of NA plot(intensity, main="rainfall intensity [mm/5 min]") 

Between 10 a.m. and 6 p.m. precipitation was mainly lower than 0.2 mm. This means that we need to smooth out the time series. Every 0.2 mm of precipitation should be evenly distributed between the time steps before that, if there is one or more time steps without a tip, since we assume that the rain fell evenly at these time steps. How can this be achieved in R? I am grateful if anyone has a good idea on how to solve this problem.

This is a small example from the Afløbsteknik textbook by Winther et al. (2011, Polyteknisk forlag, Lyngby). It shows the desired result (tip_corrected). Please note that the first recorded recall remains unchanged, and smoothing occurs during rain. There is no drop in precipitation. It can be assumed that there should be 2 hours between the two precipitation events in order to make them separate precipitation.

 tip<-c(1,rep(0,9),2,1,2,0,0,1,rep(0,14),1) tip_corrected<-c(1,rep(0.1,9),1.1,1,2,0.333,0.333,0.333,rep(0.0667,15)) windows() plot(tip, pch = 1) points(tip_corrected, pch = 4) legend(23,2, legend = c("tip", "tip_corrected"), pch = c(1,4)) 
+4
source share
3 answers

If I understand what you are trying to do, instead of performing a merge for ts_tip , you can use the approx function with the appropriate rules to linearly interpolate the total rainfall at regular intervals. rule=1:2 leaves NA in the row before the first draft and fills the values ​​of recent acc_tip last value of acc_tip , as shown below. The rest of your code is still there.

  ## Merge data into time series with regular time steps # ts_tip <- merge(ts, na.locf(merge(ts, acc_tip)[,2]), join="inner")[,2] # Merge acc_tip with ts # ts_tip[is.na(ts_tip)] <- 0 # Make 0 of NA # # interpolation of cumulative rainfall at equi-spaced times using approx function ts_tip <- xts(approx(index(acc_tip), acc_tip, rule=1:2, xout=index(ts))$y, order.by=index(ts)) ts_tip[is.na(ts_tip)] <- 0 # changes NA at start of series to 0's 
+1
source

This is probably not the most elegant way, and I would be glad to see the best solutions, but the following should work:

 library(xts) library(plyr) ## Import data from txt file ## I copied your data dump to dat.txt and added "Date" as first column name. (I import 4 columns and merge "Date" and "Time" afterwards.) tip_time <- read.table("dat.txt", header = TRUE, sep = " ", stringsAsFactors = FALSE) tip_time$Time <- paste(tip_time$Date, tip_time$Time) tip_time[,"Date"] <- NULL tip_time$Time <- as.POSIXct(tip_time$Time) # Convert to POSIXct colnames(tip_time) <- c("Time", "bucket", "Flag") ## Make "time series" with regular time steps. regularSteps <- data.frame( Time = seq(from = trunc(tip_time[1, 1], "day"), to = trunc(tail(tip_time[, 1], n = 1), "day") + 60*60*24 - 1, by = 1)) tip_regular <- merge(regularSteps, tip_time, by = "Time", all = TRUE) tip_regular[is.na(tip_regular)] <- 0 ## To aggregate, create groups of 5 minutes. tip_regular$group <- floor(as.numeric(tip_regular$Time) / (5*60)) res <- ddply(.data = tip_regular, .variables = "group", .fun = function(x) { return(data.frame(Time = tail(x$Time, n = 1), buckets = sum(x$bucket))) })[, -1] # To check the result afterwards: res$original <- res$buckets # Smoothing: bucketsize <- 0.2 while(any(res$buckets == 0)) { # Do the following as long as there are empty buckets (or until all empty buckets are at the end of the data set.) # These 3 lines could probably be simplified: firstEmpty <- which(res$buckets == 0)[1] allFull <- which(res$buckets != 0) firstFullAfterEmpty <- allFull[allFull > firstEmpty][1] if(is.na(firstFullAfterEmpty)) break # Take one bucket out, this bucket will be redistributed: res[firstFullAfterEmpty, "buckets"] <- res[firstFullAfterEmpty, "buckets"] - bucketsize toFill <- firstFullAfterEmpty - firstEmpty + 1 # # Number of buckets to fill res[firstEmpty:firstFullAfterEmpty, "buckets"] <- bucketsize / toFill # equally redistribute the water } tip_ts <- xts(x = res$buckets, order.by = res$Time) plot(tip_ts, main="rainfall intensity [mm/5 min]") 

enter image description here

0
source

I use the presented small example tutorial, where tip has the source data and tip_corrected desired data (up to 3 decimal places).

First, find the storm runs

 r<-rle(as.numeric(tip>0)) 

Allocation for running zeros

 ind<-r$values==0 r$values[ind]<-1/(1+r$length[ind]) r$values[!ind]<-0 tip2<-tip+inverse.rle(r) 

Location on tips for borrowing from

 idx<-cumsum(r$lengths)[which(ind)]+1 tip2[idx] <- tip2[idx]-1+tip2[idx-1] 

Test

 all.equal(round(tip2,3),round(tip_corrected,3)) #> TRUE 

You need to handle the extreme cases of the first or last record as 0, which would be convenient for your purposes. It would also be advisable to have a cutoff for the length of the zero runs in order to distribute, since it will not wait all the time.

0
source

All Articles