Class: BTAP::Environment::WeatherFile
- Inherits:
-
Object
- Object
- BTAP::Environment::WeatherFile
- Defined in:
- lib/openstudio-standards/btap/environment.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
-
#cdd10 ⇒ Object
Returns the value of attribute cdd10.
-
#cdd18 ⇒ Object
Returns the value of attribute cdd18.
-
#city ⇒ Object
Returns the value of attribute city.
-
#cooling_design_info ⇒ Object
Returns the value of attribute cooling_design_info.
-
#country ⇒ Object
Returns the value of attribute country.
-
#delta_dry_bulb ⇒ Object
Returns the value of attribute delta_dry_bulb.
-
#elevation ⇒ Object
Returns the value of attribute elevation.
-
#energy_plus_location_name ⇒ Object
Returns the value of attribute energy_plus_location_name.
-
#extremes_design_info ⇒ Object
Returns the value of attribute extremes_design_info.
-
#hdd10 ⇒ Object
Returns the value of attribute hdd10.
-
#hdd18 ⇒ Object
Returns the value of attribute hdd18.
-
#heating_design_info ⇒ Object
Returns the value of attribute heating_design_info.
-
#latitude ⇒ Object
Returns the value of attribute latitude.
-
#location_name ⇒ Object
Returns the value of attribute location_name.
-
#longitude ⇒ Object
Returns the value of attribute longitude.
-
#monthly_dry_bulb ⇒ Object
Returns the value of attribute monthly_dry_bulb.
-
#state_province_region ⇒ Object
Returns the value of attribute state_province_region.
Instance Method Summary collapse
-
#eliminate_all_radiation ⇒ String
This method will eliminate all radiation and returns self.
-
#eliminate_all_radiation_except_solar ⇒ String
This method will eliminate all radiation except solar and returns self.
-
#eliminate_only_solar_radiation ⇒ String
This method will eliminate solar radiation and returns self.
-
#eliminate_percipitation ⇒ String
This method will eliminate percipitation and returns self.
-
#eliminate_wind ⇒ String
This method eliminates wind and returns self.
-
#initialize(weather_file) ⇒ String
constructor
This method initializes and returns self.
-
#scan ⇒ Object
This method scans.
-
#set_weather_file(model, runner = nil) ⇒ String
This method will set the weather file and returns a log string.
-
#setcolumntovalue(column, value) ⇒ Object
This method will sets column to a value.
-
#setConstantDryandDewPointTemperatureHumidityAndPressure(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.
-
#writetofile(filename) ⇒ Object
This method writes to a file.
Constructor Details
#initialize(weather_file) ⇒ String
This method initializes and returns self.
461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 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 |
# File 'lib/openstudio-standards/btap/environment.rb', line 461 def initialize(weather_file) # Define the openstudio-standards weather location top_dir = File.( '../../..',File.dirname(__FILE__)) weather_dir = "#{top_dir}/data/weather" # 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.exists?(weather_file) @epw_filepath = "#{weather_file}" @ddy_filepath = "#{weather_file.sub('epw','ddy')}" @stat_filepath = "#{weather_file.sub('epw','stat')}" elsif File.exists?("#{weather_dir}/#{weather_file}") @epw_filepath = "#{weather_dir}/#{weather_file}" @ddy_filepath = "#{weather_dir}/#{weather_file.sub('epw','ddy')}" @stat_filepath = "#{weather_dir}/#{weather_file.sub('epw','stat')}" else raise("Could not find weather file #{weather_file}. Make sure file path is correct.") end # Ensure that epw, ddy, and stat file all exist raise("Weather file #{@epw_filepath} not found.") unless File.exists?(@epw_filepath) && @epw_filepath.downcase.include?('.epw') raise("Weather file ddy #{@ddy_filepath} not found.") unless File.exists?(@ddy_filepath) && @ddy_filepath.downcase.include?('.ddy') raise("Weather file stat #{@stat_filepath} not found.") unless File.exists?(@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 = 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 @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}" @heating_design_info = @stat_file.heating_design_info @cooling_design_info = @stat_file.cooling_design_info @extremes_design_info = @stat_file.extremes_design_info return self end |
Instance Attribute Details
#cdd10 ⇒ Object
Returns the value of attribute cdd10.
402 403 404 |
# File 'lib/openstudio-standards/btap/environment.rb', line 402 def cdd10 @cdd10 end |
#cdd18 ⇒ Object
Returns the value of attribute cdd18.
402 403 404 |
# File 'lib/openstudio-standards/btap/environment.rb', line 402 def cdd18 @cdd18 end |
#city ⇒ Object
Returns the value of attribute city.
402 403 404 |
# File 'lib/openstudio-standards/btap/environment.rb', line 402 def city @city end |
#cooling_design_info ⇒ Object
Returns the value of attribute cooling_design_info.
418 419 420 |
# File 'lib/openstudio-standards/btap/environment.rb', line 418 def cooling_design_info @cooling_design_info end |
#country ⇒ Object
Returns the value of attribute country.
402 403 404 |
# File 'lib/openstudio-standards/btap/environment.rb', line 402 def country @country end |
#delta_dry_bulb ⇒ Object
Returns the value of attribute delta_dry_bulb.
402 403 404 |
# File 'lib/openstudio-standards/btap/environment.rb', line 402 def delta_dry_bulb @delta_dry_bulb end |
#elevation ⇒ Object
Returns the value of attribute elevation.
402 403 404 |
# File 'lib/openstudio-standards/btap/environment.rb', line 402 def elevation @elevation end |
#energy_plus_location_name ⇒ Object
Returns the value of attribute energy_plus_location_name.
402 403 404 |
# File 'lib/openstudio-standards/btap/environment.rb', line 402 def energy_plus_location_name @energy_plus_location_name end |
#extremes_design_info ⇒ Object
Returns the value of attribute extremes_design_info.
419 420 421 |
# File 'lib/openstudio-standards/btap/environment.rb', line 419 def extremes_design_info @extremes_design_info end |
#hdd10 ⇒ Object
Returns the value of attribute hdd10.
402 403 404 |
# File 'lib/openstudio-standards/btap/environment.rb', line 402 def hdd10 @hdd10 end |
#hdd18 ⇒ Object
Returns the value of attribute hdd18.
402 403 404 |
# File 'lib/openstudio-standards/btap/environment.rb', line 402 def hdd18 @hdd18 end |
#heating_design_info ⇒ Object
Returns the value of attribute heating_design_info.
417 418 419 |
# File 'lib/openstudio-standards/btap/environment.rb', line 417 def heating_design_info @heating_design_info end |
#latitude ⇒ Object
Returns the value of attribute latitude.
402 403 404 |
# File 'lib/openstudio-standards/btap/environment.rb', line 402 def latitude @latitude end |
#location_name ⇒ Object
Returns the value of attribute location_name.
402 403 404 |
# File 'lib/openstudio-standards/btap/environment.rb', line 402 def location_name @location_name end |
#longitude ⇒ Object
Returns the value of attribute longitude.
402 403 404 |
# File 'lib/openstudio-standards/btap/environment.rb', line 402 def longitude @longitude end |
#monthly_dry_bulb ⇒ Object
Returns the value of attribute monthly_dry_bulb.
402 403 404 |
# File 'lib/openstudio-standards/btap/environment.rb', line 402 def monthly_dry_bulb @monthly_dry_bulb end |
#state_province_region ⇒ Object
Returns the value of attribute state_province_region.
402 403 404 |
# File 'lib/openstudio-standards/btap/environment.rb', line 402 def state_province_region @state_province_region end |
Instance Method Details
#eliminate_all_radiation ⇒ String
This method will eliminate all radiation and returns self.
589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 |
# File 'lib/openstudio-standards/btap/environment.rb', line 589 def eliminate_all_radiation() self.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_solar ⇒ String
This method will eliminate all radiation except solar and returns self.
623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 |
# File 'lib/openstudio-standards/btap/environment.rb', line 623 def eliminate_all_radiation_except_solar() self.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_radiation ⇒ String
This method will eliminate solar radiation and returns self.
612 613 614 615 616 617 618 |
# File 'lib/openstudio-standards/btap/environment.rb', line 612 def eliminate_only_solar_radiation() self.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_percipitation ⇒ String
This method will eliminate percipitation and returns self.
643 644 645 646 647 648 649 650 651 |
# File 'lib/openstudio-standards/btap/environment.rb', line 643 def eliminate_percipitation self.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_wind ⇒ String
This method eliminates wind and returns self.
656 657 658 659 660 661 |
# File 'lib/openstudio-standards/btap/environment.rb', line 656 def eliminate_wind self.scan() if @filearray == nil setcolumntovalue(Wind_Direction,"0") setcolumntovalue(Wind_Speed,"0") return self end |
#scan ⇒ Object
This method scans.
565 566 567 568 569 570 571 572 |
# File 'lib/openstudio-standards/btap/environment.rb', line 565 def scan() @filearray = Array.new() file = File.new(@epw_filepath, "r") while (line = file.gets) @filearray.push(line.split(",")) end file.close end |
#set_weather_file(model, runner = nil) ⇒ String
This method will set the weather file and returns a log string.
527 528 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 |
# File 'lib/openstudio-standards/btap/environment.rb', line 527 def set_weather_file(model, runner = nil) BTAP::runner_register("Info", "BTAP::Environment::WeatherFile::set_weather",runner) OpenStudio::Model::WeatherFile::setWeatherFile(model, @epw_file) BTAP::runner_register("Info", "Set model \"#{model.building.get.name}\" to weather file #{model.weatherFile.get.path.get}.\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 { |d| d.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.
578 579 580 581 582 583 584 |
# File 'lib/openstudio-standards/btap/environment.rb', line 578 def setcolumntovalue(column,value) @filearray.each do |line| unless line.first =~ /\D(.*)/ line[column] = value end end end |
#setConstantDryandDewPointTemperatureHumidityAndPressure(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.
670 671 672 673 674 675 676 677 |
# File 'lib/openstudio-standards/btap/environment.rb', line 670 def setConstantDryandDewPointTemperatureHumidityAndPressure(dbt = "0.0",dpt="-1.1",hum="92",press="98500") self.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 |
#writetofile(filename) ⇒ Object
This method writes to a file.
682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 |
# File 'lib/openstudio-standards/btap/environment.rb', line 682 def writetofile(filename) self.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 = newline +"," end newline = 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 |