urbanopt-cli 0.8.0 → 0.8.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -37,11 +37,13 @@ require 'openstudio/load_flexibility_measures'
37
37
 
38
38
  require 'json'
39
39
  require 'rexml/document'
40
+ require 'logger'
40
41
 
41
42
  module URBANopt
42
43
  module Scenario
43
44
  class BaselineMapper < SimulationMapperBase
44
45
  # class level variables
46
+ @@logger = Logger.new($stdout)
45
47
  @@instance_lock = Mutex.new
46
48
  @@osw = nil
47
49
  @@geometry = nil
@@ -383,222 +385,215 @@ module URBANopt
383
385
  end
384
386
 
385
387
  # epw_state to subregions mapping methods
386
- #REK: Maybe we can move these method to the geojson gem
388
+ # REK: Maybe we can move these method to the geojson gem
387
389
  def get_future_emissions_region(feature)
388
390
  # Options are: AZNMc, CAMXc, ERCTc, FRCCc, MROEc, MROWc, NEWEc, NWPPc, NYSTc, RFCEc, RFCMc, RFCWc, RMPAc, SPNOc, SPSOc, SRMVc, SRMWc, SRSOc, SRTVc, and SRVCc
389
391
  # egrid subregions can map directly to zipcodes but not to states. Some state might include multiple egrid subregions. the default mapper prioritize the egrid subregion that is most common in the state (covers the biggest number of zipcodes)
390
- future_emissions_mapping_hash =
391
- {'FL': 'FRCCc', #['FRCCc', 'SRSOc']
392
- 'MS': 'SRMVc', #['SRMVc', 'SRTVc']
393
- 'NE': 'MROWc', #['MROWc', 'RMPAc']
394
- 'OR': 'NWPPc',
395
- 'CA': 'CAMXc', #['CAMXc', 'NWPPc']
396
- 'VA': 'SRVCc', #['SRVCc', 'RFCWc', 'RFCEc'],
397
- 'AR': 'SRMVc', #['SRMVc', 'SPSOc']
398
- 'TX': 'ERCTc', #['ERCTc', 'SRMVc', 'SPSOc', 'AZNMc']
399
- 'OH': 'RFCWc',
400
- 'UT': 'NWPPc',
401
- 'MT': 'NWPPc', #['NWPPc', 'MROWc']
402
- 'TN': 'SRTVc',
403
- 'ID': 'NWPPc',
404
- 'WI': 'MROEc', #['RFCWc', 'MROEc', 'MROWc']
405
- 'WV': 'RFCWc',
406
- 'NC': 'SRVCc',
407
- 'LA': 'SRMVc',
408
- 'IL': 'SRMWc', #['RFCWc', 'SRMWc']
409
- 'OK': 'SPSOc',
410
- 'IA': 'MROWc',
411
- 'WA': 'NWPPc',
412
- 'SD': 'MROWc', #['MROWc', 'RMPAc']
413
- 'MN': 'MROWc',
414
- 'KY': 'SRTVc', #['SRTVc', 'RFCWc']
415
- 'MI': 'RFCMc', #['RFCMc', 'MROEc']
416
- 'KS': 'SPNOc',
417
- 'NJ': 'RFCEc',
418
- 'NY': 'NYSTc',
419
- 'IN': 'RFCWc',
420
- 'VT': 'NEWEc',
421
- 'NM': 'AZNMc', #['AZNMc', 'SPSOc']
422
- 'WY': 'RMPAc', #['RMPAc', 'NWPPc']
423
- 'GA': 'SRSOc',
424
- 'MO': 'SRMWc', #['SRMWc', 'SPNOc']
425
- 'DC': 'RFCEc',
426
- 'SC': 'SRVCc',
427
- 'PA': 'RFCEc', #['RFCEc', 'RFCWc']
428
- 'CO': 'RMPAc',
429
- 'AZ': 'AZNMc',
430
- 'ME': 'NEWEc',
431
- 'AL': 'SRSOc',
432
- 'MD': 'RFCEc', #['RFCEc', 'RFCWc']
433
- 'NH': 'NEWEc',
434
- 'MA': 'NEWEc',
435
- 'ND': 'MROWc',
436
- 'NV': 'NWPPc', #['NWPPc', 'AZNMc']
437
- 'CT': 'NEWEc',
438
- 'DE': 'RFCEc',
439
- 'RI': 'NEWEc'}
440
-
441
- #get the state from weather file
392
+ future_emissions_mapping_hash =
393
+ { 'FL': 'FRCCc', # ['FRCCc', 'SRSOc']
394
+ 'MS': 'SRMVc', # ['SRMVc', 'SRTVc']
395
+ 'NE': 'MROWc', # ['MROWc', 'RMPAc']
396
+ 'OR': 'NWPPc',
397
+ 'CA': 'CAMXc', # ['CAMXc', 'NWPPc']
398
+ 'VA': 'SRVCc', # ['SRVCc', 'RFCWc', 'RFCEc'],
399
+ 'AR': 'SRMVc', # ['SRMVc', 'SPSOc']
400
+ 'TX': 'ERCTc', # ['ERCTc', 'SRMVc', 'SPSOc', 'AZNMc']
401
+ 'OH': 'RFCWc',
402
+ 'UT': 'NWPPc',
403
+ 'MT': 'NWPPc', # ['NWPPc', 'MROWc']
404
+ 'TN': 'SRTVc',
405
+ 'ID': 'NWPPc',
406
+ 'WI': 'MROEc', # ['RFCWc', 'MROEc', 'MROWc']
407
+ 'WV': 'RFCWc',
408
+ 'NC': 'SRVCc',
409
+ 'LA': 'SRMVc',
410
+ 'IL': 'SRMWc', # ['RFCWc', 'SRMWc']
411
+ 'OK': 'SPSOc',
412
+ 'IA': 'MROWc',
413
+ 'WA': 'NWPPc',
414
+ 'SD': 'MROWc', # ['MROWc', 'RMPAc']
415
+ 'MN': 'MROWc',
416
+ 'KY': 'SRTVc', # ['SRTVc', 'RFCWc']
417
+ 'MI': 'RFCMc', # ['RFCMc', 'MROEc']
418
+ 'KS': 'SPNOc',
419
+ 'NJ': 'RFCEc',
420
+ 'NY': 'NYSTc',
421
+ 'IN': 'RFCWc',
422
+ 'VT': 'NEWEc',
423
+ 'NM': 'AZNMc', # ['AZNMc', 'SPSOc']
424
+ 'WY': 'RMPAc', # ['RMPAc', 'NWPPc']
425
+ 'GA': 'SRSOc',
426
+ 'MO': 'SRMWc', # ['SRMWc', 'SPNOc']
427
+ 'DC': 'RFCEc',
428
+ 'SC': 'SRVCc',
429
+ 'PA': 'RFCEc', # ['RFCEc', 'RFCWc']
430
+ 'CO': 'RMPAc',
431
+ 'AZ': 'AZNMc',
432
+ 'ME': 'NEWEc',
433
+ 'AL': 'SRSOc',
434
+ 'MD': 'RFCEc', # ['RFCEc', 'RFCWc']
435
+ 'NH': 'NEWEc',
436
+ 'MA': 'NEWEc',
437
+ 'ND': 'MROWc',
438
+ 'NV': 'NWPPc', # ['NWPPc', 'AZNMc']
439
+ 'CT': 'NEWEc',
440
+ 'DE': 'RFCEc',
441
+ 'RI': 'NEWEc' }
442
+
443
+ # get the state from weather file
442
444
  state = feature.weather_filename.split('_', -1)[1]
443
-
444
- #find region input based on the state
445
+
446
+ # find region input based on the state
445
447
  region = future_emissions_mapping_hash[state.to_sym]
446
448
 
447
- puts "emissions_future_subregion for #{state} is assigned to: #{region}"
448
- puts "You can overwrite this assigned input by specifiying the emissions_future_subregion input in the FeatureFile"
449
+ @@logger.warn("emissions_future_subregion for #{state} is assigned to: #{region}. Note: Not all states have a 1 to 1 mapping with a subregion. Some states('ND','IN', 'MN', 'SD', 'IA', 'WV', 'OH', 'NE' ) include 2 subregions.
450
+ The default mapper maps to the subregion that includes the most zipcodes in the corresponding state. You can overwrite this assigned input by specifiying the emissions_future_subregion input in the FeatureFile.")
449
451
 
450
452
  return region
451
-
452
453
  end
453
454
 
454
455
  def get_hourly_historical_emissions_region(feature)
455
-
456
456
  # Options are: California, Carolinas, Central, Florida, Mid-Atlantic, Midwest, New England, New York, Northwest, Rocky Mountains, Southeast, Southwest, Tennessee, and Texas
457
- # There is no "correct" mapping of eGrid to AVERT regions as they are both large geographical areas that partially overlap.
458
- # Mapping is done using mapping tools from eGrid and AVERT (ZipCode for eGrid and fraction of state for AVERT).
457
+ # There is no "correct" mapping of eGrid to AVERT regions as they are both large geographical areas that partially overlap.
458
+ # Mapping is done using mapping tools from eGrid and AVERT (ZipCode for eGrid and fraction of state for AVERT).
459
459
  # Mapped based on the maps of each set of regions:
460
- hourly_historical_mapping_hash =
461
- {'FL': 'Florida',
462
- 'MS': 'Midwest',
463
- 'NE': 'Midwest',#MRWO could be Midwest / Central
464
- 'OR': 'Northwest',
465
- 'CA': 'California',
466
- 'VA': 'Carolinas',
467
- 'AR': 'Midwest',
468
- 'TX': 'Texas',
469
- 'OH': 'Midwest',#RFCW could be Midwest / Mid Atlantic
470
- 'UT': 'Northwest',
471
- 'MT': 'Northwest',
472
- 'TN': 'Tennessee',
473
- 'ID': 'Northwest',
474
- 'WI': 'Midwest',
475
- 'WV': 'Midwest', #RFCW could be Midwest / Mid Atlantic
476
- 'NC': 'Carolinas',
477
- 'LA': 'Midwest',
478
- 'IL': 'Midwest',
479
- 'OK': 'Central',
480
- 'IA': 'Midwest', #MRWO could be Midwest / Central
481
- 'WA': 'Northwest',
482
- 'SD': 'Midwest',#MRWO could be Midwest / Central
483
- 'MN': 'Midwest',#MRWO could be Midwest / Central
484
- 'KY': 'Tennessee',
485
- 'MI': 'Midwest',
486
- 'KS': 'Central',
487
- 'NJ': 'Mid-Atlantic',
488
- 'NY': 'New York',
489
- 'IN': 'Midwest', #RFCW could be Midwest / Mid Atlantic
490
- 'VT': 'New England',
491
- 'NM': 'Southwest',
492
- 'WY': 'Rocky Mountains',
493
- 'GA': 'SRSO',
494
- 'MO': 'Midwest',
495
- 'DC': 'Mid-Atlantic',
496
- 'SC': 'Carolinas',
497
- 'PA': 'Mid-Atlantic',
498
- 'CO': 'Rocky Mountains',
499
- 'AZ': 'Southwest',
500
- 'ME': 'New England',
501
- 'AL': 'Southeast',
502
- 'MD': 'Mid-Atlantic',
503
- 'NH': 'New England',
504
- 'MA': 'New England',
505
- 'ND': 'Midwest',#MRWO could be Midwest / Central
506
- 'NV': 'Northwest',
507
- 'CT': 'New England',
508
- 'DE': 'Mid-Atlantic',
509
- 'RI': 'New England'}
510
-
511
- #get the state from weather file
460
+ hourly_historical_mapping_hash =
461
+ { 'FL': 'Florida',
462
+ 'MS': 'Midwest',
463
+ 'NE': 'Midwest', # MRWO could be Midwest / Central
464
+ 'OR': 'Northwest',
465
+ 'CA': 'California',
466
+ 'VA': 'Carolinas',
467
+ 'AR': 'Midwest',
468
+ 'TX': 'Texas',
469
+ 'OH': 'Midwest', # RFCW could be Midwest / Mid Atlantic
470
+ 'UT': 'Northwest',
471
+ 'MT': 'Northwest',
472
+ 'TN': 'Tennessee',
473
+ 'ID': 'Northwest',
474
+ 'WI': 'Midwest',
475
+ 'WV': 'Midwest', # RFCW could be Midwest / Mid Atlantic
476
+ 'NC': 'Carolinas',
477
+ 'LA': 'Midwest',
478
+ 'IL': 'Midwest',
479
+ 'OK': 'Central',
480
+ 'IA': 'Midwest', # MRWO could be Midwest / Central
481
+ 'WA': 'Northwest',
482
+ 'SD': 'Midwest', # MRWO could be Midwest / Central
483
+ 'MN': 'Midwest', # MRWO could be Midwest / Central
484
+ 'KY': 'Tennessee',
485
+ 'MI': 'Midwest',
486
+ 'KS': 'Central',
487
+ 'NJ': 'Mid-Atlantic',
488
+ 'NY': 'New York',
489
+ 'IN': 'Midwest', # RFCW could be Midwest / Mid Atlantic
490
+ 'VT': 'New England',
491
+ 'NM': 'Southwest',
492
+ 'WY': 'Rocky Mountains',
493
+ 'GA': 'SRSO',
494
+ 'MO': 'Midwest',
495
+ 'DC': 'Mid-Atlantic',
496
+ 'SC': 'Carolinas',
497
+ 'PA': 'Mid-Atlantic',
498
+ 'CO': 'Rocky Mountains',
499
+ 'AZ': 'Southwest',
500
+ 'ME': 'New England',
501
+ 'AL': 'Southeast',
502
+ 'MD': 'Mid-Atlantic',
503
+ 'NH': 'New England',
504
+ 'MA': 'New England',
505
+ 'ND': 'Midwest', # MRWO could be Midwest / Central
506
+ 'NV': 'Northwest',
507
+ 'CT': 'New England',
508
+ 'DE': 'Mid-Atlantic',
509
+ 'RI': 'New England' }
510
+
511
+ # get the state from weather file
512
512
  state = feature.weather_filename.split('_', -1)[1]
513
513
 
514
- #find region input based on the state
515
- region = hourly_historical_mapping_hash[state.to_sym]
516
- puts "emissions_hourly_historical_subregion for #{state} is assigned to: #{region}"
517
- puts "You can overwrite this assigned input by specifiying the emissions_hourly_historical_subregion input in the FeatureFile"
518
-
519
- return region
514
+ # find region input based on the state
515
+ region = hourly_historical_mapping_hash[state.to_sym]
516
+ @@logger.warn("emissions_hourly_historical_subregion for #{state} is assigned to: #{region}. Note: Not all states have a 1 to 1 mapping with a subregion. Some states('ND','IN', 'MN', 'SD', 'IA', 'WV', 'OH', 'NE' ) include 2 subregions.
517
+ The default mapper maps to the subregion that includes the most zipcodes in the corresponding state. You can overwrite this assigned input by specifiying the emissions_hourly_historical_subregion input in the FeatureFile.")
520
518
 
519
+ return region
521
520
  end
522
521
 
523
-
524
522
  def get_annual_historical_emissions_region(feature)
525
-
526
523
  # Options are: AKGD, AKMS, AZNM, CAMX, ERCT, FRCC, HIMS, HIOA, MROE, MROW, NEWE, NWPP, NYCW, NYLI, NYUP, RFCE, RFCM, RFCW, RMPA, SPNO, SPSO, SRMV, SRMW, SRSO, SRTV, and SRVC
527
524
  # egrid subregions can map directly to zipcodes but not to states. Some state might include multiple egrid subregions. the default mapper prioritize the egrid subregion that is most common in the state (covers the biggest number of zipcodes)
528
- annual_historical_mapping_hash =
529
- {'FL': 'FRCC',
530
- 'MS': 'SRMV',
531
- 'NE': 'MROW',
532
- 'OR': 'NWPP',
533
- 'CA': 'CAMX',
534
- 'VA': 'SRVC',
535
- 'AR': 'SRMV',
536
- 'TX': 'ERCT',
537
- 'OH': 'RFCW',
538
- 'UT': 'NWPP',
539
- 'MT': 'NWPP',
540
- 'TN': 'SRTV',
541
- 'ID': 'NWPP',
542
- 'WI': 'MROE',
543
- 'WV': 'RFCW',
544
- 'NC': 'SRVC',
545
- 'LA': 'SRMV',
546
- 'IL': 'SRMW',
547
- 'OK': 'SPSO',
548
- 'IA': 'MROW',
549
- 'WA': 'NWPP',
550
- 'SD': 'MROW',
551
- 'MN': 'MROW',
552
- 'KY': 'SRTV',
553
- 'MI': 'RFCM',
554
- 'KS': 'SPNO',
555
- 'NJ': 'RFCE',
556
- 'NY': 'NYCW',
557
- 'IN': 'RFCW',
558
- 'VT': 'NEWE',
559
- 'NM': 'AZNM',
560
- 'WY': 'RMPA',
561
- 'GA': 'SRSO',
562
- 'MO': 'SRMW',
563
- 'DC': 'RFCE',
564
- 'SC': 'SRVC',
565
- 'PA': 'RFCE',
566
- 'CO': 'RMPA',
567
- 'AZ': 'AZNM',
568
- 'ME': 'NEWE',
569
- 'AL': 'SRSO',
570
- 'MD': 'RFCE',
571
- 'NH': 'NEWE',
572
- 'MA': 'NEWE',
573
- 'ND': 'MROW',
574
- 'NV': 'NWPP',
575
- 'CT': 'NEWE',
576
- 'DE': 'RFCE',
577
- 'RI': 'NEWE'}
578
- #get the state from weather file
525
+ annual_historical_mapping_hash =
526
+ { 'FL': 'FRCC',
527
+ 'MS': 'SRMV',
528
+ 'NE': 'MROW',
529
+ 'OR': 'NWPP',
530
+ 'CA': 'CAMX',
531
+ 'VA': 'SRVC',
532
+ 'AR': 'SRMV',
533
+ 'TX': 'ERCT',
534
+ 'OH': 'RFCW',
535
+ 'UT': 'NWPP',
536
+ 'MT': 'NWPP',
537
+ 'TN': 'SRTV',
538
+ 'ID': 'NWPP',
539
+ 'WI': 'MROE',
540
+ 'WV': 'RFCW',
541
+ 'NC': 'SRVC',
542
+ 'LA': 'SRMV',
543
+ 'IL': 'SRMW',
544
+ 'OK': 'SPSO',
545
+ 'IA': 'MROW',
546
+ 'WA': 'NWPP',
547
+ 'SD': 'MROW',
548
+ 'MN': 'MROW',
549
+ 'KY': 'SRTV',
550
+ 'MI': 'RFCM',
551
+ 'KS': 'SPNO',
552
+ 'NJ': 'RFCE',
553
+ 'NY': 'NYCW',
554
+ 'IN': 'RFCW',
555
+ 'VT': 'NEWE',
556
+ 'NM': 'AZNM',
557
+ 'WY': 'RMPA',
558
+ 'GA': 'SRSO',
559
+ 'MO': 'SRMW',
560
+ 'DC': 'RFCE',
561
+ 'SC': 'SRVC',
562
+ 'PA': 'RFCE',
563
+ 'CO': 'RMPA',
564
+ 'AZ': 'AZNM',
565
+ 'ME': 'NEWE',
566
+ 'AL': 'SRSO',
567
+ 'MD': 'RFCE',
568
+ 'NH': 'NEWE',
569
+ 'MA': 'NEWE',
570
+ 'ND': 'MROW',
571
+ 'NV': 'NWPP',
572
+ 'CT': 'NEWE',
573
+ 'DE': 'RFCE',
574
+ 'RI': 'NEWE' }
575
+ # get the state from weather file
579
576
  state = feature.weather_filename.split('_', -1)[1]
580
-
581
- #finf region input based on the state
577
+
578
+ # finf region input based on the state
582
579
  region = annual_historical_mapping_hash[state.to_sym]
583
580
 
584
- puts "emissions_annual_historical_subregion for #{state} is assigned to: #{region}"
585
- puts "You can overwrite this assigned input by specifiying the emissions_annual_historical_subregion input in the FeatureFile"
586
-
581
+ @@logger.warn("electricity_emissions_annual_historical_subregion for #{state} is assigned to: #{region}. Note: Not all states have a 1 to 1 mapping with a subregion. Some states('ND','IN', 'MN', 'SD', 'IA', 'WV', 'OH', 'NE' ) include 2 subregions.
582
+ The default mapper maps to the subregion that includes the most zipcodes in the corresponding state. You can overwrite this assigned input by specifiying the electricity_emissions_annual_historical_subregion input in the FeatureFile.")
583
+
587
584
  return region
585
+ end
588
586
 
589
- end
590
-
591
- def is_defined(feature, method_name, raise_error=true)
592
- begin
593
- if feature.method_missing(method_name)
594
- return true
595
- end
596
- rescue NoMethodError
597
- if raise_error
598
- raise "*** ERROR *** #{method_name} is not set on this feature"
599
- end
600
- return false
587
+ def is_defined(feature, method_name, raise_error = true)
588
+ if feature.method_missing(method_name)
589
+ return true
601
590
  end
591
+ rescue NoMethodError
592
+ if raise_error
593
+ raise "*** ERROR *** #{method_name} is not set on this feature"
594
+ end
595
+
596
+ return false
602
597
  end
603
598
 
604
599
  def create_osw(scenario, features, feature_names)
@@ -641,8 +636,8 @@ module URBANopt
641
636
  # Check for required residential fields
642
637
  is_defined(feature, :number_of_stories_above_ground)
643
638
  is_defined(feature, :foundation_type)
644
-
645
- if not is_defined(feature, :hpxml_directory, false)
639
+
640
+ if !is_defined(feature, :hpxml_directory, false)
646
641
  # check additional fields when HPXML dir is not given
647
642
  is_defined(feature, :attic_type)
648
643
  is_defined(feature, :number_of_bedrooms)
@@ -782,7 +777,7 @@ module URBANopt
782
777
 
783
778
  args[:geometry_unit_num_occupants] = 'auto'
784
779
  begin
785
- args[:geometry_unit_num_occupants] = "#{feature.number_of_occupants / args[:geometry_building_num_units]}"
780
+ args[:geometry_unit_num_occupants] = (feature.number_of_occupants / args[:geometry_building_num_units]).to_s
786
781
  rescue StandardError
787
782
  end
788
783
 
@@ -1018,11 +1013,10 @@ module URBANopt
1018
1013
  elsif commercial_building_types.include? building_type
1019
1014
  # set_run_period
1020
1015
  OpenStudio::Extension.set_measure_argument(osw, 'set_run_period', '__SKIP__', false)
1021
-
1022
1016
  # can enable reporting (commercial building types only for now)
1023
- #OpenStudio::Extension.set_measure_argument(osw, 'openstudio_results', '__SKIP__', false)
1024
- #OpenStudio::Extension.set_measure_argument(osw, 'envelope_and_internal_load_breakdown', '__SKIP__', false)
1025
- #OpenStudio::Extension.set_measure_argument(osw, 'generic_qaqc', '__SKIP__', false)
1017
+ # OpenStudio::Extension.set_measure_argument(osw, 'openstudio_results', '__SKIP__', false)
1018
+ # OpenStudio::Extension.set_measure_argument(osw, 'envelope_and_internal_load_breakdown', '__SKIP__', false)
1019
+ # OpenStudio::Extension.set_measure_argument(osw, 'generic_qaqc', '__SKIP__', false)
1026
1020
 
1027
1021
  begin
1028
1022
  timesteps_per_hour = feature.timesteps_per_hour
@@ -1353,111 +1347,144 @@ module URBANopt
1353
1347
  else
1354
1348
  raise "Building type #{building_type} not currently supported."
1355
1349
  end
1350
+
1356
1351
  end
1357
-
1358
- ####### Emissions Adition
1352
+
1353
+ ######## Emissions Adition from add_ems_emissions_reporting
1359
1354
  if feature_type == 'Building'
1360
1355
 
1356
+ # emissions options
1357
+ future_regions = ['AZNMc', 'CAMXc', 'ERCTc', 'FRCCc', 'MROEc', 'MROWc', 'NEWEc', 'NWPPc', 'NYSTc', 'RFCEc', 'RFCMc', 'RFCWc', 'RMPAc', 'SPNOc', 'SPSOc', 'SRMVc', 'SRMWc', 'SRSOc', 'SRTVc', 'SRVCc']
1358
+ hourly_historical_regions = ['California', 'Carolinas', 'Central', 'Florida', 'Mid-Atlantic', 'Midwest', 'New England', 'New York', 'Northwest', 'Rocky Mountains', 'Southeast', 'Southwest', 'Tennessee', 'Texas']
1359
+ annual_historical_regions = ['AKGD', 'AKMS', 'AZNM', 'CAMX', 'ERCT', 'FRCC', 'HIMS', 'HIOA', 'MROE', 'MROW', 'NEWE', 'NWPP', 'NYCW', 'NYLI', 'NYUP', 'RFCE', 'RFCM', 'RFCW', 'RMPA', 'SPNO', 'SPSO', 'SRMV', 'SRMW', 'SRSO', 'SRTV', 'SRVC']
1360
+ annual_historical_years = ['2007', '2009', '2010', '2012', '2014', '2016', '2018', '2019']
1361
+ future_years = ['2020', '2022', '2024', '2026', '2028', '2030', '2032', '2034', '2036', '2038', '2040', '2042', '2044', '2046', '2048', '2050']
1362
+ hourly_historical_years = ['2019']
1363
+
1361
1364
  # add Emissions
1362
1365
  emissions = nil
1363
1366
 
1364
1367
  begin
1365
1368
  emissions = feature.emissions
1366
- rescue
1369
+ rescue StandardError
1367
1370
  end
1368
-
1371
+
1369
1372
  if emissions != true
1370
- puts "Emissions is not activated for this feature. Please set emissions to true in the the Feature properties in the GeoJSON file to add emissions results."
1373
+ @@logger.info('Emissions is not activated for this feature. Please set emissions to true in the the Feature properties in the GeoJSON file to add emissions results.')
1371
1374
 
1372
1375
  elsif emissions == true
1373
-
1374
- #activate emissions measure
1376
+
1377
+ # activate emissions measure
1375
1378
  OpenStudio::Extension.set_measure_argument(osw, 'add_ems_emissions_reporting', '__SKIP__', false)
1376
1379
 
1377
- #get emissions inputs if they are available or get them from the mapping methods if the are not
1380
+ # get emissions inputs if they are available or get them from the mapping methods if the are not
1378
1381
  begin
1379
- emissions_future_subregion = feature.emissions_future_subregion
1380
- rescue
1381
- puts "\nemission_future_subregion is not assigned for feature #{feature_id}. Defining subregion based on the State...."
1382
- emissions_future_subregion = get_future_emissions_region(feature)
1382
+ electricity_emissions_future_subregion = feature.electricity_emissions_future_subregion
1383
+ rescue StandardError
1384
+ @@logger.info("\nelectricity_emission_future_subregion is not assigned for feature #{feature_id}. Defining subregion based on the State....")
1385
+ electricity_emissions_future_subregion = get_future_emissions_region(feature)
1383
1386
  end
1384
1387
 
1385
1388
  begin
1386
- emissions_hourly_historical_subregion = feature.emissions_hourly_historical_subregion
1387
- rescue
1388
- puts "\nemissions_hourly_historical_subregion is not assigned for feature #{feature_id}. Defining subregion based on the State...."
1389
- emissions_hourly_historical_subregion = get_hourly_historical_emissions_region(feature)
1389
+ electricity_emissions_hourly_historical_subregion = feature.electricity_emissions_hourly_historical_subregion
1390
+ rescue StandardError
1391
+ @@logger.info("\nelectricity_emissions_hourly_historical_subregion is not assigned for feature #{feature_id}. Defining subregion based on the State....")
1392
+ electricity_emissions_hourly_historical_subregion = get_hourly_historical_emissions_region(feature)
1390
1393
  end
1391
1394
 
1392
1395
  begin
1393
- emissions_annual_historical_subregion = feature.emissions_annual_historical_subregion
1394
- rescue
1395
- puts "\nemissions_annual_historical_subregion is not assigned for feature #{feature_id}. Defining subregion based on the State...."
1396
- emissions_annual_historical_subregion = get_annual_historical_emissions_region(feature)
1396
+ electricity_emissions_annual_historical_subregion = feature.electricity_emissions_annual_historical_subregion
1397
+ rescue StandardError
1398
+ @@logger.info("\nelectricity_emissions_annual_historical_subregion is not assigned for feature #{feature_id}. Defining subregion based on the State....")
1399
+ electricity_emissions_annual_historical_subregion = get_annual_historical_emissions_region(feature)
1397
1400
  end
1398
1401
 
1399
1402
  begin
1400
- emissions_future_year = feature.emissions_future_year
1401
- rescue
1402
- puts "emissions_future_year should be assigned !"
1403
+ electricity_emissions_future_year = feature.electricity_emissions_future_year
1404
+ rescue StandardError
1405
+ @@logger.info("\nelectricity_emissions_future_year was not assigned by the user. The assigned default value is 2030")
1406
+ electricity_emissions_future_year = '2030'
1403
1407
  end
1404
1408
 
1405
1409
  begin
1406
- emissions_hourly_historical_year = feature.emissions_hourly_historical_year
1407
- rescue
1408
- puts "emissions_hourly_historical_year should be assigned !"
1410
+ electricity_emissions_hourly_historical_year = feature.electricity_emissions_hourly_historical_year
1411
+ rescue StandardError
1412
+ @@logger.info("\nelectricity_emissions_hourly_historical_year was not assigned by the user. The assigned default value is 2019")
1413
+ electricity_emissions_hourly_historical_year = '2019'
1409
1414
  end
1410
1415
 
1411
1416
  begin
1412
- emissions_annual_historical_year = feature.emissions_annual_historical_year
1413
- rescue
1414
- puts "emissions_annual_historical_year should be assigned !"
1417
+ electricity_emissions_annual_historical_year = feature.electricity_emissions_annual_historical_year
1418
+ rescue StandardError
1419
+ @@logger.info("\nelectricity_emissions_annual_historical_year was not assigned by the user. The assigned default value is 2019")
1420
+ electricity_emissions_annual_historical_year = '2019'
1415
1421
  end
1416
1422
 
1417
- puts "\n building #{feature_id} emission inputs summarry:
1418
- emissions_future_subregion = #{emissions_future_subregion};
1419
- emissions_hourly_historical_subregion = #{emissions_hourly_historical_subregion};
1420
- emissions_annual_historical_subregion = #{emissions_annual_historical_subregion};
1421
- emissions_future_year = #{emissions_future_year};
1422
- emissions_hourly_historical_year = #{emissions_hourly_historical_year};
1423
- emissions_annual_historical_year = #{emissions_annual_historical_year} \n "
1423
+ # puts "\n building #{feature_id} emission inputs summarry:
1424
+ # electricity_emissions_future_subregion = #{electricity_emissions_future_subregion};
1425
+ # electricity_emissions_hourly_historical_subregion = #{electricity_emissions_hourly_historical_subregion};
1426
+ # electricity_emissions_annual_historical_subregion = #{electricity_emissions_annual_historical_subregion};
1427
+ # electricity_emissions_future_year = #{electricity_emissions_future_year};
1428
+ # electricity_emissions_hourly_historical_year = #{electricity_emissions_hourly_historical_year};
1429
+ # electricity_emissions_annual_historical_year = #{electricity_emissions_annual_historical_year}\n "
1424
1430
 
1425
1431
  ## Assign the OS measure arguments
1426
1432
  begin
1427
-
1428
- #emissions_future_subregion
1429
- if !emissions_future_subregion.nil? && !emissions_future_subregion.empty?
1430
- OpenStudio::Extension.set_measure_argument(osw, 'add_ems_emissions_reporting', 'future_subregion', emissions_future_subregion)
1433
+ # emissions_future_subregion
1434
+ if !electricity_emissions_future_subregion.nil? && !electricity_emissions_future_subregion.empty?
1435
+ if future_regions.include? electricity_emissions_future_subregion
1436
+ OpenStudio::Extension.set_measure_argument(osw, 'add_ems_emissions_reporting', 'future_subregion', electricity_emissions_future_subregion)
1437
+ else
1438
+ @@logger.error(" '#{electricity_emissions_future_subregion}' is not valid option for electricity_emissions_future_subregion. Please choose an input from #{future_regions}")
1439
+ end
1431
1440
  end
1432
1441
 
1433
- #hourly_historical_subregion
1434
- if !emissions_hourly_historical_subregion.nil? && !emissions_hourly_historical_subregion.empty?
1435
- OpenStudio::Extension.set_measure_argument(osw, 'add_ems_emissions_reporting', 'hourly_historical_subregion', emissions_hourly_historical_subregion)
1442
+ # hourly_historical_subregion
1443
+ if !electricity_emissions_hourly_historical_subregion.nil? && !electricity_emissions_hourly_historical_subregion.empty?
1444
+ if hourly_historical_regions.include? electricity_emissions_hourly_historical_subregion
1445
+ OpenStudio::Extension.set_measure_argument(osw, 'add_ems_emissions_reporting', 'hourly_historical_subregion', electricity_emissions_hourly_historical_subregion)
1446
+ else
1447
+ @@logger.error(" '#{electricity_emissions_hourly_historical_subregion}' is not valid option for electricity_emissions_hourly_historical_subregion. Please choose an input from #{hourly_historical_regions}")
1448
+ end
1436
1449
  end
1437
1450
 
1438
- #annual_historical_subregion
1439
- if !emissions_annual_historical_subregion.nil? && !emissions_annual_historical_subregion.empty?
1440
- OpenStudio::Extension.set_measure_argument(osw, 'add_ems_emissions_reporting', 'annual_historical_subregion', emissions_annual_historical_subregion)
1451
+ # annual_historical_subregion
1452
+ if !electricity_emissions_annual_historical_subregion.nil? && !electricity_emissions_annual_historical_subregion.empty?
1453
+ if annual_historical_regions.include? electricity_emissions_annual_historical_subregion
1454
+ OpenStudio::Extension.set_measure_argument(osw, 'add_ems_emissions_reporting', 'annual_historical_subregion', electricity_emissions_annual_historical_subregion)
1455
+ else
1456
+ @@logger.error(" '#{electricity_emissions_annual_historical_subregion}' is not valid option for electricity_emissions_annual_historical_subregion. Please choose an input from #{annual_historical_regions}")
1457
+ end
1441
1458
  end
1442
1459
 
1443
- #future_year
1444
- if !emissions_future_year.nil? && !emissions_future_year.empty?
1445
- OpenStudio::Extension.set_measure_argument(osw, 'add_ems_emissions_reporting', 'future_year', emissions_future_year)
1460
+ # future_year
1461
+ if !electricity_emissions_future_year.nil? && !electricity_emissions_future_year.empty?
1462
+
1463
+ if future_years.include? electricity_emissions_future_year
1464
+ OpenStudio::Extension.set_measure_argument(osw, 'add_ems_emissions_reporting', 'future_year', electricity_emissions_future_year)
1465
+ else
1466
+ @@logger.error(" '#{electricity_emissions_future_year}' is not valid option for electricity_emissions_future_year. Please choose an input from #{future_years}")
1467
+ end
1446
1468
  end
1447
1469
 
1448
- #hourly_historical_year
1449
- if !emissions_hourly_historical_year.nil? && !emissions_hourly_historical_year.empty?
1450
- OpenStudio::Extension.set_measure_argument(osw, 'add_ems_emissions_reporting', 'hourly_historical_year', emissions_hourly_historical_year)
1451
- else
1452
-
1470
+ # hourly_historical_year
1471
+ if !electricity_emissions_hourly_historical_year.nil? && !electricity_emissions_hourly_historical_year.empty?
1472
+ if hourly_historical_years.include? electricity_emissions_hourly_historical_year
1473
+ OpenStudio::Extension.set_measure_argument(osw, 'add_ems_emissions_reporting', 'hourly_historical_year', electricity_emissions_hourly_historical_year)
1474
+ else
1475
+ @@logger.error(" '#{electricity_emissions_hourly_historical_year}' is not valid option for electricity_emissions_hourly_historical_year. Please choose an input from #{hourly_historical_years}")
1476
+ end
1453
1477
  end
1454
-
1455
- #annual_historical_year'
1456
- if !emissions_annual_historical_year.nil? && !emissions_annual_historical_year.empty?
1457
- OpenStudio::Extension.set_measure_argument(osw, 'add_ems_emissions_reporting', 'annual_historical_year', emissions_annual_historical_year)
1458
- end
1459
1478
 
1460
- rescue
1479
+ # annual_historical_year
1480
+ if !electricity_emissions_annual_historical_year.nil? && !electricity_emissions_annual_historical_year.empty?
1481
+ if annual_historical_years.include? electricity_emissions_annual_historical_year
1482
+ OpenStudio::Extension.set_measure_argument(osw, 'add_ems_emissions_reporting', 'annual_historical_year', electricity_emissions_annual_historical_year)
1483
+ else
1484
+ @@logger.error("'#{electricity_emissions_annual_historical_year}' is not valid option for electricity_emissions_annual_historical_year. Please choose an input from #{annual_historical_years}")
1485
+ end
1486
+ end
1487
+ rescue StandardError
1461
1488
  end
1462
1489
 
1463
1490
  end