|
@@ -0,0 +1,50 @@
|
|
1
|
+Miscellaneous notes
|
|
2
|
+
|
|
3
|
+# The database
|
|
4
|
+
|
|
5
|
+Accessed either via the SQL Manager program on the laptop, the `psql` terminal command (via the `psconnect` alias), or with the `psycopg2` (`psycopg2-binary`) python library.
|
|
6
|
+
|
|
7
|
+Have created an experimental table called `public.coup_tall_april` containing data from April 2017 in a "tall" format, using code from Jason:
|
|
8
|
+
|
|
9
|
+```sql
|
|
10
|
+CREATE TABLE public.coup_tall_April AS
|
|
11
|
+SELECT a.icp_id
|
|
12
|
+ , a.read_date
|
|
13
|
+ , c.period
|
|
14
|
+ , sum(c.read_kwh) as kwh_tot
|
|
15
|
+ , sum(case when a.content_code = 'UN' then c.read_kwh else 0 end) as kwh_un
|
|
16
|
+ , sum(case when a.content_code in ('CN','EG') then c.read_kwh else 0 end) as kwh_cn
|
|
17
|
+FROM coup_prd.coupdatamaster a,
|
|
18
|
+ unnest(a.read_array) WITH ORDINALITY c(read_kwh, period)
|
|
19
|
+WHERE a.read_date >= to_date('01/04/2017','dd/mm/yyyy')
|
|
20
|
+ and a.read_date < to_date('01/05/2017','dd/mm/yyyy')
|
|
21
|
+ and a.content_code ~ ('UN|CN|EG')
|
|
22
|
+GROUP BY 1, 2, 3
|
|
23
|
+ORDER BY 1, 2, 3;
|
|
24
|
+```
|
|
25
|
+
|
|
26
|
+This data looks like:
|
|
27
|
+
|
|
28
|
+```sql
|
|
29
|
+SELECT * FROM public.coup_tall_april limit 10;
|
|
30
|
+```
|
|
31
|
+
|
|
32
|
+ icp_id | read_date | period | kwh_tot | kwh_un | kwh_cn
|
|
33
|
+---------+------------+--------+---------+--------+--------
|
|
34
|
+ I000002 | 2017-04-01 | 1 | 0.123 | 0.123 | 0.0
|
|
35
|
+ I000002 | 2017-04-01 | 2 | 0.161 | 0.161 | 0.0
|
|
36
|
+ I000002 | 2017-04-01 | 3 | 0.118 | 0.118 | 0.0
|
|
37
|
+ I000002 | 2017-04-01 | 4 | 0.108 | 0.108 | 0.0
|
|
38
|
+ I000002 | 2017-04-01 | 5 | 0.125 | 0.125 | 0.0
|
|
39
|
+ I000002 | 2017-04-01 | 6 | 0.144 | 0.144 | 0.0
|
|
40
|
+ I000002 | 2017-04-01 | 7 | 0.11 | 0.11 | 0.0
|
|
41
|
+ I000002 | 2017-04-01 | 8 | 0.116 | 0.116 | 0.0
|
|
42
|
+ I000002 | 2017-04-01 | 9 | 0.197 | 0.197 | 0.0
|
|
43
|
+ I000002 | 2017-04-01 | 10 | 0.144 | 0.144 | 0.0
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+* `icp_id` is the ID of the ICP, which may be a home or business. This is a `varchar(10)`, although it appears to only have 7 characters. The ID is not the _real_ ID, but an anonymised value.
|
|
47
|
+* `read_date` is the date, in this case in April 2017.
|
|
48
|
+* `kwh_cn` is the demand in kwh that the company has some level of control over, e.g. by systems that turn off and on water heaters remotely. This ought to be relatively stable, although in many cases this will be 0.
|
|
49
|
+* `kwh_un` is the uncontrolled demand, i.e. the rest.
|
|
50
|
+* `kwh_tot` is the sum of the other kwh measurements for this half-hour
|