aemo 0.1.8 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 462daf9d1f745619116d0696f71d4e4ada7d5a9e
4
- data.tar.gz: 87d0ae57035a4134252d0be9070b40f7c158f536
3
+ metadata.gz: 339e83560f9d3cbf2dde96d4097b1cdd905b7299
4
+ data.tar.gz: 276afbdd7bc7a07948a54195ee7efe7fd187b940
5
5
  SHA512:
6
- metadata.gz: f5f3601a33f2b69105665b5caa8dcfbfa024c90f75db6d4564357a31f8bf90f5111d6c5b4167b720f0543e18ac61e3c4282377449d449c271707ae8e64a60902
7
- data.tar.gz: 3364c54321a235b3bacf33feebf2992fe79dfc63a30582c211a8f3fef3df1ff68643e88fa188ee6b918752453f87841d59e5f7b0f454f7f2514c648c07ea74a4
6
+ metadata.gz: 710fcb76538f49718313d3b89d9930820dee43dfe70a5c8eebda6d67e41a232234ad43b0edcbdffe95c47fb2403872d9ec4e2ced6ea99c7a068ab4ea2adbb51e
7
+ data.tar.gz: 4fb67cf0b3611f6a7b4f82a1bdadf8824f1189d8ab490b6893675725640ed0ce2d442bb74b9449ce3b5839c318e8e5fd2dc789a3bb26024705f920081a8fdaeb
@@ -3,7 +3,7 @@ $:.push File.expand_path('../lib', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = 'aemo'
6
- s.version = '0.1.8'
6
+ s.version = '0.1.9'
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.date = '2015-02-26'
9
9
  s.summary = 'AEMO Gem'
@@ -87,36 +87,36 @@ module AEMO
87
87
  }
88
88
 
89
89
  METHOD_FLAGS = {
90
- "11" => { type: ["SUB"], installation_type: [1,2,3,4], short_descriptor: "Check", description: "" },
91
- "12" => { type: ["SUB"], installation_type: [1,2,3,4], short_descriptor: "Calculated", description: "" },
92
- "13" => { type: ["SUB"], installation_type: [1,2,3,4], short_descriptor: "SCADA", description: "" },
93
- "14" => { type: ["SUB"], installation_type: [1,2,3,4], short_descriptor: "Like Day", description: "" },
94
- "15" => { type: ["SUB"], installation_type: [1,2,3,4], short_descriptor: "Average Like Day", description: "" },
95
- "16" => { type: ["SUB"], installation_type: [1,2,3,4], short_descriptor: "Agreed", description: "" },
96
- "17" => { type: ["SUB"], installation_type: [1,2,3,4], short_descriptor: "Linear", description: "" },
97
- "18" => { type: ["SUB"], installation_type: [1,2,3,4], short_descriptor: "Alternate", description: "" },
98
- "19" => { type: ["SUB"], installation_type: [1,2,3,4], short_descriptor: "Zero", description: "" },
99
- "51" => { type: ["EST","SUB"], installation_type: 5, short_descriptor: "Previous Year", description: "" },
100
- "52" => { type: ["EST","SUB"], installation_type: 5, short_descriptor: "Previous Read", description: "" },
101
- "53" => { type: ["SUB"], installation_type: 5, short_descriptor: "Revision", description: "" },
102
- "54" => { type: ["SUB"], installation_type: 5, short_descriptor: "Linear", description: "" },
103
- "55" => { type: ["SUB"], installation_type: 5, short_descriptor: "Agreed", description: "" },
104
- "56" => { type: ["EST","SUB"], installation_type: 5, short_descriptor: "Prior to First Read – Agreed", description: "" },
105
- "57" => { type: ["EST","SUB"], installation_type: 5, short_descriptor: "Customer Class", description: "" },
106
- "58" => { type: ["EST","SUB"], installation_type: 5, short_descriptor: "Zero", description: "" },
107
- "61" => { type: ["EST","SUB"], installation_type: 6, short_descriptor: "Previous Year", description: "" },
108
- "62" => { type: ["EST","SUB"], installation_type: 6, short_descriptor: "Previous Read", description: "" },
109
- "63" => { type: ["EST","SUB"], installation_type: 6, short_descriptor: "Customer Class", description: "" },
110
- "64" => { type: ["SUB"], installation_type: 6, short_descriptor: "Agreed", description: "" },
111
- "65" => { type: ["EST"], installation_type: 6, short_descriptor: "ADL", description: "" },
112
- "66" => { type: ["SUB"], installation_type: 6, short_descriptor: "Revision", description: "" },
113
- "67" => { type: ["SUB"], installation_type: 6, short_descriptor: "Customer Read", description: "" },
114
- "68" => { type: ["EST","SUB"], installation_type: 6, short_descriptor: "Zero", description: "" },
115
- "71" => { type: ["SUB"], installation_type: 7, short_descriptor: "Recalculation", description: "" },
116
- "72" => { type: ["SUB"], installation_type: 7, short_descriptor: "Revised Table", description: "" },
117
- "73" => { type: ["SUB"], installation_type: 7, short_descriptor: "Revised Algorithm", description: "" },
118
- "74" => { type: ["SUB"], installation_type: 7, short_descriptor: "Agreed", description: "" },
119
- "75" => { type: ["EST"], installation_type: 7, short_descriptor: "Existing Table", description: "" }
90
+ 11 => { type: ["SUB"], installation_type: [1,2,3,4], short_descriptor: "Check", description: "" },
91
+ 12 => { type: ["SUB"], installation_type: [1,2,3,4], short_descriptor: "Calculated", description: "" },
92
+ 13 => { type: ["SUB"], installation_type: [1,2,3,4], short_descriptor: "SCADA", description: "" },
93
+ 14 => { type: ["SUB"], installation_type: [1,2,3,4], short_descriptor: "Like Day", description: "" },
94
+ 15 => { type: ["SUB"], installation_type: [1,2,3,4], short_descriptor: "Average Like Day", description: "" },
95
+ 16 => { type: ["SUB"], installation_type: [1,2,3,4], short_descriptor: "Agreed", description: "" },
96
+ 17 => { type: ["SUB"], installation_type: [1,2,3,4], short_descriptor: "Linear", description: "" },
97
+ 18 => { type: ["SUB"], installation_type: [1,2,3,4], short_descriptor: "Alternate", description: "" },
98
+ 19 => { type: ["SUB"], installation_type: [1,2,3,4], short_descriptor: "Zero", description: "" },
99
+ 51 => { type: ["EST","SUB"], installation_type: 5, short_descriptor: "Previous Year", description: "" },
100
+ 52 => { type: ["EST","SUB"], installation_type: 5, short_descriptor: "Previous Read", description: "" },
101
+ 53 => { type: ["SUB"], installation_type: 5, short_descriptor: "Revision", description: "" },
102
+ 54 => { type: ["SUB"], installation_type: 5, short_descriptor: "Linear", description: "" },
103
+ 55 => { type: ["SUB"], installation_type: 5, short_descriptor: "Agreed", description: "" },
104
+ 56 => { type: ["EST","SUB"], installation_type: 5, short_descriptor: "Prior to First Read – Agreed", description: "" },
105
+ 57 => { type: ["EST","SUB"], installation_type: 5, short_descriptor: "Customer Class", description: "" },
106
+ 58 => { type: ["EST","SUB"], installation_type: 5, short_descriptor: "Zero", description: "" },
107
+ 61 => { type: ["EST","SUB"], installation_type: 6, short_descriptor: "Previous Year", description: "" },
108
+ 62 => { type: ["EST","SUB"], installation_type: 6, short_descriptor: "Previous Read", description: "" },
109
+ 63 => { type: ["EST","SUB"], installation_type: 6, short_descriptor: "Customer Class", description: "" },
110
+ 64 => { type: ["SUB"], installation_type: 6, short_descriptor: "Agreed", description: "" },
111
+ 65 => { type: ["EST"], installation_type: 6, short_descriptor: "ADL", description: "" },
112
+ 66 => { type: ["SUB"], installation_type: 6, short_descriptor: "Revision", description: "" },
113
+ 67 => { type: ["SUB"], installation_type: 6, short_descriptor: "Customer Read", description: "" },
114
+ 68 => { type: ["EST","SUB"], installation_type: 6, short_descriptor: "Zero", description: "" },
115
+ 71 => { type: ["SUB"], installation_type: 7, short_descriptor: "Recalculation", description: "" },
116
+ 72 => { type: ["SUB"], installation_type: 7, short_descriptor: "Revised Table", description: "" },
117
+ 73 => { type: ["SUB"], installation_type: 7, short_descriptor: "Revised Algorithm", description: "" },
118
+ 74 => { type: ["SUB"], installation_type: 7, short_descriptor: "Agreed", description: "" },
119
+ 75 => { type: ["EST"], installation_type: 7, short_descriptor: "Existing Table", description: "" }
120
120
  }
121
121
 
122
122
  REASON_CODES = {
@@ -220,6 +220,7 @@ module AEMO
220
220
  97 => 'Excluded Data',
221
221
  98 => 'Parity Error',
222
222
  99 => 'Energy Type (Register Changed)'
223
+
223
224
  }
224
225
 
225
226
  DATA_STREAM_SUFFIX = {
@@ -370,7 +371,7 @@ module AEMO
370
371
  raise ArgumentError, 'QualityMethod does not have valid QualityFlag' unless QUALITY_FLAGS.keys.include?(csv[intervals_offset + 0][0])
371
372
  unless %w(A N V).include?(csv[intervals_offset + 0][0])
372
373
  raise ArgumentError, 'QualityMethod does not have valid length' unless csv[intervals_offset + 0].length == 3
373
- raise ArgumentError, 'QualityMethod does not have valid MethodFlag' unless METHOD_FLAGS.keys.include?(csv[intervals_offset + 0][1..2])
374
+ raise ArgumentError, 'QualityMethod does not have valid MethodFlag' unless METHOD_FLAGS.keys.include?(csv[intervals_offset + 0][1..2].to_i)
374
375
  end
375
376
  unless %w(A N E).include?(csv[intervals_offset + 0][0])
376
377
  raise ArgumentError, 'ReasonCode is not valid' unless REASON_CODES.keys.include?(csv[intervals_offset + 1].to_i)
@@ -392,10 +393,10 @@ module AEMO
392
393
  flag ||= { quality_flag: nil, method_flag: nil, reason_code: nil }
393
394
  if csv[intervals_offset + 0].length == 3
394
395
  flag[:quality_flag] = csv[intervals_offset + 0][0]
395
- flag[:method_flag] = csv[intervals_offset + 0][1,2]
396
+ flag[:method_flag] = csv[intervals_offset + 0][1,2].to_i
396
397
  end
397
398
  unless csv[intervals_offset + 1].nil?
398
- flag[:reason_code] = csv[intervals_offset + 1]
399
+ flag[:reason_code] = csv[intervals_offset + 1].to_i
399
400
  end
400
401
  end
401
402
 
@@ -431,31 +432,24 @@ module AEMO
431
432
  interval_start_point = @interval_data.length - number_of_intervals
432
433
 
433
434
  # For each of these
434
- base_interval_event = { datetime: nil, quality_method: csv[3], reason_code: csv[4], reason_description: csv[5] }
435
+ base_interval_event = { datetime: nil, quality_method: csv[3], reason_code: (csv[4].nil? ? nil : csv[4].to_i), reason_description: csv[5] }
435
436
 
436
437
  # Interval Numbers are 1-indexed
437
438
  ((csv[1].to_i)..(csv[2].to_i)).each do |i|
438
439
  interval_event = base_interval_event.dup
439
440
  interval_event[:datetime] = @interval_data[interval_start_point + (i-1)][:datetime]
440
441
  interval_events << interval_event
441
-
442
- method_flag = nil
443
- unless (quality_method = interval_event[:quality_method].match(/(\d+)/)[1]).nil?
444
- method_flag = METHOD_FLAGS[quality_method][:short_descriptor]
445
- end
446
- reason_code = nil
447
- unless (reason_code = interval_event[:reason_code]).nil?
448
- reason_code = REASON_CODES[reason_code.to_i]
442
+ # Create flag details
443
+ flag ||= { quality_flag: nil, method_flag: nil, reason_code: nil }
444
+ unless interval_event[:quality_method].nil?
445
+ flag[:quality_flag] = interval_event[:quality_method][0]
446
+ flag[:method_flag] = interval_event[:quality_method][1,2].to_i
449
447
  end
450
-
451
- case csv[3][0]
452
- when 'E'
453
- @interval_data[interval_start_point + (i-1)][:flag] = ['Estimate',method_flag,reason_code].compact.join(' - ')
454
- when 'F'
455
- @interval_data[interval_start_point + (i-1)][:flag] = nil
456
- when 'S'
457
- @interval_data[interval_start_point + (i-1)][:flag] = ['Substitute',method_flag,reason_code].compact.join(' - ')
448
+ unless interval_event[:reason_code].nil?
449
+ flag[:reason_code] = interval_event[:reason_code]
458
450
  end
451
+ # Update with flag details
452
+ @interval_data[interval_start_point + (i-1)][:flag] = flag
459
453
  end
460
454
  @interval_events += interval_events
461
455
  end
@@ -22,7 +22,7 @@
22
22
  # @author Joel Courtney <euphemize@gmail.com>
23
23
  module AEMO
24
24
  # aemo version
25
- VERSION = '0.1.8'
25
+ VERSION = '0.1.9'
26
26
 
27
27
  # aemo version split amongst different revisions
28
28
  MAJOR_VERSION, MINOR_VERSION, REVISION = VERSION.split('.').map(&:to_i)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aemo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joel Courtney