Question-and-Answer Resource for the Building Energy Modeling Community
Get started with the Help page
Ask Your Question

Revision history [back]

Well an EPW file is really just a CSV file, and the fields will be consistent. So you can use the Ruby CSV class to parse the file. There are probably many equally good ways of doing this, but here is what I quickly came up with:

require 'csv'
csv_path = "path/to/epw.epw"

first_depth_temps = []

CSV.foreach(csv_path) do |row|
  if row[0].include? "GROUND TEMPERATURES"
    num_depths = row[1]
    depth_1 = row[2]
    # index 3 thru 5 are for soil conductivity, density and specific heat
    first_depth_temps = row[6..17]
  end
end
# do stuff with temps

Probably a good idea to add some logic to check if there are values first, since not all EPWs have ground temps.

Finally be aware that, as the documentation states: "These should be considered “undisturbed” ground temperatures - temperatures of soil that have not been disturbed by construction. They are not considered appropriate for calculations of building losses."