Class: BTAP::Environment::WeatherFile

Inherits:
Object
  • Object
show all
Defined in:
lib/openstudio-standards/weather/Weather.Model.rb

Constant Summary collapse

YEAR =
0
MONTH =
1
DAY =
2
HOUR =
3
MINUTE =
4
DATA_SOURCE =
5
DRY_BULB_TEMPERATURE =
6
DEW_POINT_TEMPERATURE =
7
RELATIVE_HUMIDITY =
8
ATMOSPHERIC_STATION_PRESSURE =
9
EXTRATERRESTRIAL_HORIZONTAL_RADIATION =

not used

10
EXTRATERRESTRIAL_DIRECT_NORMAL_RADIATION =

not used

11
HORIZONTAL_INFRARED_RADIATION_INTENSITY =
12
GLOBAL_HORIZONTAL_RADIATION =

not used

13
DIRECT_NORMAL_RADIATION =
14
DIFFUSE_HORIZONTAL_RADIATION =
15
GLOBAL_HORIZONTAL_ILLUMINANCE =

not used

16
DIRECT_NORMAL_ILLUMINANCE =

not used

17
DIFFUSE_HORIZONTAL_ILLUMINANCE =

not used

18
ZENITH_LUMINANCE =

not used

19
WIND_DIRECTION =
20
WIND_SPEED =
21
TOTAL_SKY_COVER =

not used

22
OPAQUE_SKY_COVER =

not used

23
VISIBILITY =

not used

24
CEILING_HEIGHT =

not used

25
PRESENT_WEATHER_OBSERVATION =
26
PRESENT_WEATHER_CODES =
27
PRECIPITABLE_WATER =

not used

28
AEROSOL_OPTICAL_DEPTH =

not used

29
SNOW_DEPTH =
30
DAYS_SINCE_LAST_SNOWFALL =

not used

31
ALBEDO =

not used

32
LIQUID_PRECIPITATION_DEPTH =
33
LIQUID_PRECIPITATION_QUANTITY =
34

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(weather_file) ⇒ String

This method initializes and returns self.

Parameters:

Author:



392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
# File 'lib/openstudio-standards/weather/Weather.Model.rb', line 392

def initialize(weather_file)
  # First check if the epw file exists at a full path.  If not found there,
  # check for the file in the openstudio-standards/data/weather directory.
  weather_file = weather_file.to_s
  @epw_filepath = nil
  @ddy_filepath = nil
  @stat_filepath = nil
  if File.exist?(weather_file)
    @epw_filepath = weather_file.to_s
    @ddy_filepath = weather_file.sub('epw', 'ddy').to_s
    @stat_filepath = weather_file.sub('epw', 'stat').to_s
  else
    # Run differently depending on whether running from embedded filesystem in OpenStudio CLI or not
    if __dir__[0] == ':' # Running from OpenStudio CLI
      # load weather file from embedded files
      epw_string = load_resource_relative("../../../data/weather/#{weather_file}")
      ddy_string = load_resource_relative("../../../data/weather/#{weather_file.gsub('.epw', '.ddy')}")
      stat_string = load_resource_relative("../../../data/weather/#{weather_file.gsub('.epw', '.stat')}")

      # extract to local weather dir
      weather_dir = File.expand_path(File.join(Dir.pwd, 'extracted_files/weather/'))
      puts "Extracting weather files to #{weather_dir}"
      FileUtils.mkdir_p(weather_dir)
      File.open("#{weather_dir}/#{weather_file}", 'wb') { |f| f << epw_string; f.flush }
      File.open("#{weather_dir}/#{weather_file.gsub('.epw', '.ddy')}", 'wb') { |f| f << ddy_string; f.flush }
      File.open("#{weather_dir}/#{weather_file.gsub('.epw', '.stat')}", 'wb') { |f| f << stat_string; f.flush }
    else # loaded gem from system path
      top_dir = File.expand_path('../../..', File.dirname(__FILE__))
      weather_dir = File.expand_path("#{top_dir}/data/weather")
    end

    @epw_filepath = "#{weather_dir}/#{weather_file}"
    @ddy_filepath = "#{weather_dir}/#{weather_file.sub('epw', 'ddy')}"
    @stat_filepath = "#{weather_dir}/#{weather_file.sub('epw', 'stat')}"
  end

  # Ensure that epw, ddy, and stat file all exist
  raise("Weather file #{@epw_filepath} not found.") unless File.exist?(@epw_filepath) && @epw_filepath.downcase.include?('.epw')
  raise("Weather file ddy #{@ddy_filepath} not found.") unless File.exist?(@ddy_filepath) && @ddy_filepath.downcase.include?('.ddy')
  raise("Weather file stat #{@stat_filepath} not found.") unless File.exist?(@stat_filepath) && @stat_filepath.downcase.include?('.stat')

  # load file objects.
  @epw_file = OpenStudio::EpwFile.new(OpenStudio::Path.new(@epw_filepath))
  if OpenStudio::EnergyPlus.loadAndTranslateIdf(@ddy_filepath).empty?
    raise "Unable to load ddy idf file#{@ddy_filepath}."
  else
    @ddy_file = OpenStudio::EnergyPlus.loadAndTranslateIdf(@ddy_filepath).get
  end
  @stat_file = EnergyPlus::StatFile.new(@stat_filepath)

  # assign variables.

  @latitude = @epw_file.latitude
  @longitude = @epw_file.longitude
  @elevation = @epw_file.elevation
  @city = @epw_file.city
  @state_province_region = @epw_file.stateProvinceRegion
  @country = @epw_file.country
  @hdd18 = @stat_file.hdd18
  @cdd18 = @stat_file.cdd18
  @hdd10 = @stat_file.hdd10
  @cdd10 = @stat_file.cdd10
  @heating_design_info = @stat_file.heating_design_info
  @cooling_design_info  = @stat_file.cooling_design_info
  @extremes_design_info = @stat_file.extremes_design_info
  @monthly_dry_bulb = @stat_file.monthly_dry_bulb
  @mean_dry_bulb = @stat_file.mean_dry_bulb
  @delta_dry_bulb = @stat_file.delta_dry_bulb
  @location_name = "#{@country}-#{@state_province_region}-#{@city}"
  @energy_plus_location_name = "#{@city}_#{@state_province_region}_#{@country}"
  @climate_zone = @stat_file.climate_zone
  @standard = @stat_file.standard
  @summer_wet_months = @stat_file.summer_wet_months
  @winter_dry_months = @stat_file.winter_dry_months
  @autumn_months = @stat_file.autumn_months
  @spring_months = @stat_file.spring_months
  @typical_summer_wet_week = @stat_file.typical_summer_wet_week
  @typical_winter_dry_week = @stat_file.typical_winter_dry_week
  @typical_autumn_week = @stat_file.typical_autumn_week
  @typical_spring_week = @stat_file.typical_spring_week
  @db990 = @heating_design_info[2]
  return self
end

Instance Attribute Details

#autumn_monthsObject

Returns the value of attribute autumn_months.



320
321
322
# File 'lib/openstudio-standards/weather/Weather.Model.rb', line 320

def autumn_months
  @autumn_months
end

#cdd10Object

Returns the value of attribute cdd10.



320
321
322
# File 'lib/openstudio-standards/weather/Weather.Model.rb', line 320

def cdd10
  @cdd10
end

#cdd18Object

Returns the value of attribute cdd18.



320
321
322
# File 'lib/openstudio-standards/weather/Weather.Model.rb', line 320

def cdd18
  @cdd18
end

#cityObject

Returns the value of attribute city.



320
321
322
# File 'lib/openstudio-standards/weather/Weather.Model.rb', line 320

def city
  @city
end

#climate_zoneObject

Returns the value of attribute climate_zone.



320
321
322
# File 'lib/openstudio-standards/weather/Weather.Model.rb', line 320

def climate_zone
  @climate_zone
end

#cooling_design_infoObject

Returns the value of attribute cooling_design_info.



320
321
322
# File 'lib/openstudio-standards/weather/Weather.Model.rb', line 320

def cooling_design_info
  @cooling_design_info
end

#countryObject

Returns the value of attribute country.



320
321
322
# File 'lib/openstudio-standards/weather/Weather.Model.rb', line 320

def country
  @country
end

#db990Object

Returns the value of attribute db990.



320
321
322
# File 'lib/openstudio-standards/weather/Weather.Model.rb', line 320

def db990
  @db990
end

#ddy_filepathObject

Returns the value of attribute ddy_filepath.



320
321
322
# File 'lib/openstudio-standards/weather/Weather.Model.rb', line 320

def ddy_filepath
  @ddy_filepath
end

#delta_dry_bulbObject

Returns the value of attribute delta_dry_bulb.



320
321
322
# File 'lib/openstudio-standards/weather/Weather.Model.rb', line 320

def delta_dry_bulb
  @delta_dry_bulb
end

#elevationObject

Returns the value of attribute elevation.



320
321
322
# File 'lib/openstudio-standards/weather/Weather.Model.rb', line 320

def elevation
  @elevation
end

#energy_plus_location_nameObject

Returns the value of attribute energy_plus_location_name.



320
321
322
# File 'lib/openstudio-standards/weather/Weather.Model.rb', line 320

def energy_plus_location_name
  @energy_plus_location_name
end

#epw_filepathObject

Returns the value of attribute epw_filepath.



320
321
322
# File 'lib/openstudio-standards/weather/Weather.Model.rb', line 320

def epw_filepath
  @epw_filepath
end

#extremes_design_infoObject

Returns the value of attribute extremes_design_info.



320
321
322
# File 'lib/openstudio-standards/weather/Weather.Model.rb', line 320

def extremes_design_info
  @extremes_design_info
end

#hdd10Object

Returns the value of attribute hdd10.



320
321
322
# File 'lib/openstudio-standards/weather/Weather.Model.rb', line 320

def hdd10
  @hdd10
end

#hdd18Object

Returns the value of attribute hdd18.



320
321
322
# File 'lib/openstudio-standards/weather/Weather.Model.rb', line 320

def hdd18
  @hdd18
end

#heating_design_infoObject

Returns the value of attribute heating_design_info.



320
321
322
# File 'lib/openstudio-standards/weather/Weather.Model.rb', line 320

def heating_design_info
  @heating_design_info
end

#latitudeObject

Returns the value of attribute latitude.



320
321
322
# File 'lib/openstudio-standards/weather/Weather.Model.rb', line 320

def latitude
  @latitude
end

#location_nameObject

Returns the value of attribute location_name.



320
321
322
# File 'lib/openstudio-standards/weather/Weather.Model.rb', line 320

def location_name
  @location_name
end

#longitudeObject

Returns the value of attribute longitude.



320
321
322
# File 'lib/openstudio-standards/weather/Weather.Model.rb', line 320

def longitude
  @longitude
end

#monthly_dry_bulbObject

Returns the value of attribute monthly_dry_bulb.



320
321
322
# File 'lib/openstudio-standards/weather/Weather.Model.rb', line 320

def monthly_dry_bulb
  @monthly_dry_bulb
end

#spring_monthsObject

Returns the value of attribute spring_months.



320
321
322
# File 'lib/openstudio-standards/weather/Weather.Model.rb', line 320

def spring_months
  @spring_months
end

#standardObject

Returns the value of attribute standard.



320
321
322
# File 'lib/openstudio-standards/weather/Weather.Model.rb', line 320

def standard
  @standard
end

#stat_filepathObject

Returns the value of attribute stat_filepath.



320
321
322
# File 'lib/openstudio-standards/weather/Weather.Model.rb', line 320

def stat_filepath
  @stat_filepath
end

#state_province_regionObject

Returns the value of attribute state_province_region.



320
321
322
# File 'lib/openstudio-standards/weather/Weather.Model.rb', line 320

def state_province_region
  @state_province_region
end

#summer_wet_monthsObject

Returns the value of attribute summer_wet_months.



320
321
322
# File 'lib/openstudio-standards/weather/Weather.Model.rb', line 320

def summer_wet_months
  @summer_wet_months
end

#typical_autumn_weekObject

Returns the value of attribute typical_autumn_week.



320
321
322
# File 'lib/openstudio-standards/weather/Weather.Model.rb', line 320

def typical_autumn_week
  @typical_autumn_week
end

#typical_spring_weekObject

Returns the value of attribute typical_spring_week.



320
321
322
# File 'lib/openstudio-standards/weather/Weather.Model.rb', line 320

def typical_spring_week
  @typical_spring_week
end

#typical_summer_wet_weekObject

Returns the value of attribute typical_summer_wet_week.



320
321
322
# File 'lib/openstudio-standards/weather/Weather.Model.rb', line 320

def typical_summer_wet_week
  @typical_summer_wet_week
end

#typical_winter_dry_weekObject

Returns the value of attribute typical_winter_dry_week.



320
321
322
# File 'lib/openstudio-standards/weather/Weather.Model.rb', line 320

def typical_winter_dry_week
  @typical_winter_dry_week
end

#winter_dry_monthsObject

Returns the value of attribute winter_dry_months.



320
321
322
# File 'lib/openstudio-standards/weather/Weather.Model.rb', line 320

def winter_dry_months
  @winter_dry_months
end

Instance Method Details

#a169_2006_climate_zoneString

This method returns the Thermal Zone based on cdd10 and hdd18

Returns:

Author:



479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
# File 'lib/openstudio-standards/weather/Weather.Model.rb', line 479

def a169_2006_climate_zone
  cdd10 = self.cdd10.to_f
  hdd18 = self.hdd18.to_f

  if cdd10 > 6000 # Extremely Hot  Humid (0A), Dry (0B)
    return 'ASHRAE 169-2006-0A'

  elsif (cdd10 > 5000) && (cdd10 <= 6000) # Very Hot  Humid (1A), Dry (1B)
    return 'ASHRAE 169-2006-1A'

  elsif (cdd10 > 3500) && (cdd10 <= 5000) # Hot  Humid (2A), Dry (2B)
    return 'ASHRAE 169-2006-2A'

  elsif ((cdd10 > 2500) && (cdd10 < 3500)) && (hdd18 <= 2000) # Warm  Humid (3A), Dry (3B)
    return 'ASHRAE 169-2006-3A' # and 'ASHRAE 169-2006-3B'

  elsif (cdd10 <= 2500) && (hdd18 <= 2000) # Warm  Marine (3C)
    return 'ASHRAE 169-2006-3C'

  elsif ((cdd10 > 1500) && (cdd10 < 3500)) && ((hdd18 > 2000) && (hdd18 <= 3000)) # Mixed  Humid (4A), Dry (4B)
    return 'ASHRAE 169-2006-4A' # and 'ASHRAE 169-2006-4B'

  elsif (cdd10 <= 1500) && ((hdd18 > 2000) && (hdd18 <= 3000)) # Mixed  Marine
    return 'ASHRAE 169-2006-4C'

  elsif ((cdd10 > 1000) && (cdd10 <= 3500)) && ((hdd18 > 3000) && (hdd18 <= 4000)) # Cool Humid (5A), Dry (5B)
    return 'ASHRAE 169-2006-5A' # and 'ASHRAE 169-2006-5B'

  elsif (cdd10 <= 1000) && ((hdd18 > 3000) && (hdd18 <= 4000)) # Cool  Marine (5C)
    return 'ASHRAE 169-2006-5C'

  elsif (hdd18 > 4000) && (hdd18 <= 5000) # Cold  Humid (6A), Dry (6B)
    return 'ASHRAE 169-2006-6A' # and 'ASHRAE 169-2006-6B'

  elsif (hdd18 > 5000) && (hdd18 <= 7000) # Very Cold (7)
    return 'ASHRAE 169-2006-7A'

  elsif hdd18 > 7000 # Subarctic/Arctic (8)
    return 'ASHRAE 169-2006-8A'

  else
    # raise ("invalid cdd10 of #{cdd10} or hdd18 of #{hdd18}")
    return '[INVALID]'
  end
end

#eliminate_all_radiationString

This method will eliminate all radiation from the weather and returns self.

Returns:

Author:



593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
# File 'lib/openstudio-standards/weather/Weather.Model.rb', line 593

def eliminate_all_radiation
  scan if @filearray.nil?
  setcolumntovalue(EXTRATERRESTRIAL_HORIZONTAL_RADIATION, '0') # not used
  setcolumntovalue(EXTRATERRESTRIAL_DIRECT_NORMAL_RADIATION, '0') # not used
  setcolumntovalue(HORIZONTAL_INFRARED_RADIATION_INTENSITY, '315')
  setcolumntovalue(GLOBAL_HORIZONTAL_RADIATION, '0') # not used
  setcolumntovalue(DIRECT_NORMAL_RADIATION, '0')
  setcolumntovalue(DIFFUSE_HORIZONTAL_RADIATION, '0')
  setcolumntovalue(TOTAL_SKY_COVER, '10') # not used
  setcolumntovalue(OPAQUE_SKY_COVER, '10') # not used
  setcolumntovalue(VISIBILITY, '0') # not used
  setcolumntovalue(CEILING_HEIGHT, '0') # not used
  # lux values
  setcolumntovalue(GLOBAL_HORIZONTAL_ILLUMINANCE, '0') # not used
  setcolumntovalue(DIRECT_NORMAL_ILLUMINANCE, '0') # not used
  setcolumntovalue(DIFFUSE_HORIZONTAL_ILLUMINANCE, '0') # not used
  setcolumntovalue(ZENITH_LUMINANCE, '0') # not used
  return self
end

#eliminate_all_radiation_except_solarString

This method will eliminate all radiation except solar and returns self.

Returns:

Author:



627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
# File 'lib/openstudio-standards/weather/Weather.Model.rb', line 627

def eliminate_all_radiation_except_solar
  scan if @filearray.nil?
  setcolumntovalue(EXTRATERRESTRIAL_HORIZONTAL_RADIATION, '0') # not used
  setcolumntovalue(EXTRATERRESTRIAL_DIRECT_NORMAL_RADIATION, '0') # not used
  setcolumntovalue(HORIZONTAL_INFRARED_RADIATION_INTENSITY, '315')
  setcolumntovalue(TOTAL_SKY_COVER, '10') # not used
  setcolumntovalue(OPAQUE_SKY_COVER, '10') # not used
  setcolumntovalue(VISIBILITY, '0') # not used
  setcolumntovalue(CEILING_HEIGHT, '0') # not used
  # lux values
  setcolumntovalue(GLOBAL_HORIZONTAL_ILLUMINANCE, '0') # not used
  setcolumntovalue(DIRECT_NORMAL_ILLUMINANCE, '0') # not used
  setcolumntovalue(DIFFUSE_HORIZONTAL_ILLUMINANCE, '0') # not used
  setcolumntovalue(ZENITH_LUMINANCE, '0') # not used
  return self
end

#eliminate_only_solar_radiationString

This method will eliminate solar radiation and returns self.

Returns:

Author:



616
617
618
619
620
621
622
# File 'lib/openstudio-standards/weather/Weather.Model.rb', line 616

def eliminate_only_solar_radiation
  scan if @filearray.nil?
  setcolumntovalue(GLOBAL_HORIZONTAL_RADIATION, '0') # not used
  setcolumntovalue(DIRECT_NORMAL_RADIATION, '0')
  setcolumntovalue(DIFFUSE_HORIZONTAL_RADIATION, '0')
  return self
end

#eliminate_percipitationString

This method will eliminate percipitation and returns self.

Returns:

Author:



647
648
649
650
651
652
653
654
655
# File 'lib/openstudio-standards/weather/Weather.Model.rb', line 647

def eliminate_percipitation
  scan if @filearray.nil?
  setcolumntovalue(PRESENT_WEATHER_OBSERVATION, '0')
  setcolumntovalue(PRESENT_WEATHER_CODES, '999999999') # no weather. Clear day.
  setcolumntovalue(SNOW_DEPTH, '0')
  setcolumntovalue(LIQUID_PRECIPITATION_DEPTH, '0')
  setcolumntovalue(LIQUID_PRECIPITATION_QUANTITY, '0')
  return self
end

#eliminate_windString

This method eliminates wind and returns self.

Returns:

Author:



660
661
662
663
664
665
# File 'lib/openstudio-standards/weather/Weather.Model.rb', line 660

def eliminate_wind
  scan if @filearray.nil?
  setcolumntovalue(WIND_DIRECTION, '0')
  setcolumntovalue(WIND_SPEED, '0')
  return self
end

#scanObject

This method scans the epw file into memory.



569
570
571
572
573
574
575
576
# File 'lib/openstudio-standards/weather/Weather.Model.rb', line 569

def scan
  @filearray = []
  file = File.new(@epw_filepath, 'r')
  while (line = file.gets)
    @filearray.push(line.split(','))
  end
  file.close
end

#set_constant_dry_and_dewpoint_temperature_humidity_pressure(dbt = '0.0', dpt = '-1.1', hum = '92', press = '98500') ⇒ String

This method sets Constant Dry and Dew Point Temperature Humidity And Pressure and returns self.

Parameters:

  • dbt (Float) (defaults to: '0.0')

    dry bulb temperature

  • dpt (Float) (defaults to: '-1.1')

    dew point temperature

  • hum (Fixnum) (defaults to: '92')

    humidity

  • press (Fixnum) (defaults to: '98500')

    pressure

Returns:

Author:



674
675
676
677
678
679
680
681
# File 'lib/openstudio-standards/weather/Weather.Model.rb', line 674

def set_constant_dry_and_dewpoint_temperature_humidity_pressure(dbt = '0.0', dpt = '-1.1', hum = '92', press = '98500')
  scan if @filearray.nil?
  setcolumntovalue(DRY_BULB_TEMPERATURE, dbt)
  setcolumntovalue(DEW_POINT_TEMPERATURE, dpt)
  setcolumntovalue(RELATIVE_HUMIDITY, hum)
  setcolumntovalue(ATMOSPHERIC_STATION_PRESSURE, press)
  return self
end

#set_weather_file(model, runner = nil) ⇒ String

This method will set the weather file and returns a log string.

Parameters:

  • model (OpenStudio::model::Model)

    A model object

Returns:

Author:



529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
# File 'lib/openstudio-standards/weather/Weather.Model.rb', line 529

def set_weather_file(model, runner = nil)
  BTAP.runner_register('Info', 'BTAP::Environment::WeatherFile::set_weather', runner)
  OpenStudio::Model::WeatherFile.setWeatherFile(model, @epw_file)
  building_name = model.building.get.name
  weather_file_path = model.weatherFile.get.path.get
  BTAP.runner_register('Info', "Set model \"#{building_name}\" to weather file #{weather_file_path}.\n", runner)

  # Add or update site data
  site = model.getSite
  site.setName("#{@epw_file.city}_#{@epw_file.stateProvinceRegion}_#{@epw_file.country}")
  site.setLatitude(@epw_file.latitude)
  site.setLongitude(@epw_file.longitude)
  site.setTimeZone(@epw_file.timeZone)
  site.setElevation(@epw_file.elevation)

  BTAP.runner_register('Info', 'Setting water main temperatures via parsing of STAT file.', runner)
  water_temp = model.getSiteWaterMainsTemperature
  water_temp.setAnnualAverageOutdoorAirTemperature(@stat_file.mean_dry_bulb)
  water_temp.setMaximumDifferenceInMonthlyAverageOutdoorAirTemperatures(@stat_file.delta_dry_bulb)
  BTAP.runner_register('Info', "SiteWaterMainsTemperature.AnnualAverageOutdoorAirTemperature = #{@stat_file.mean_dry_bulb}.", runner)
  BTAP.runner_register('Info', "SiteWaterMainsTemperature.MaximumDifferenceInMonthlyAverageOutdoorAirTemperatures = #{@stat_file.delta_dry_bulb}.", runner)

  # Remove all the Design Day objects that are in the file
  model.getObjectsByType('OS:SizingPeriod:DesignDay'.to_IddObjectType).each(&:remove)

  # Load in the ddy file based on convention that it is in the same directory and has the same basename as the weather
  @ddy_file.getObjectsByType('OS:SizingPeriod:DesignDay'.to_IddObjectType).each do |d|
    # grab only the ones that matter
    ddy_list = /(Htg 99.6. Condns DB)|(Clg .4. Condns WB=>MDB)|(Clg .4% Condns DB=>MWB)/
    if d.name.get =~ ddy_list
      BTAP.runner_register('Info', "Adding design day '#{d.name}'.", runner)
      # add the object to the existing model
      model.addObject(d.clone)
    end
  end
  return true
end

#setcolumntovalue(column, value) ⇒ Object

This method will sets column to a value.

Parameters:

Author:



582
583
584
585
586
587
588
# File 'lib/openstudio-standards/weather/Weather.Model.rb', line 582

def setcolumntovalue(column, value)
  @filearray.each do |line|
    unless line.first =~ /\D(.*)/
      line[column] = value
    end
  end
end

#writetofile(filename) ⇒ Object

This method writes to a file.

Parameters:

Author:



686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
# File 'lib/openstudio-standards/weather/Weather.Model.rb', line 686

def writetofile(filename)
  scan if @filearray.nil?

  begin
    FileUtils.mkdir_p(File.dirname(filename))
    file = File.open(filename, 'w')
    @filearray.each do |line|
      firstvalue = true
      newline = ''
      line.each do |value|
        if firstvalue == true
          firstvalue = false
        else
          newline += ','
        end
        newline += value
      end
      file.puts(newline)
    end
  rescue IOError => e
    # some error occur, dir not writable etc.
  ensure
    file.close unless file.nil?
  end
  # copies original file
  FileUtils.cp(@ddy_filepath, "#{File.dirname(filename)}/#{File.basename(filename, '.epw')}.ddy")
  FileUtils.cp(@stat_filepath, "#{File.dirname(filename)}/#{File.basename(filename, '.epw')}.stat")
end