MCPcopy Create free account
hub / github.com/NatLabRockies/OpenStudio / toWthString

Method toWthString

src/utilities/filetypes/EpwFile.cpp:1589–1645  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1587}
1588
1589boost::optional<std::string> EpwDataPoint::toWthString() const {
1590 std::string date = fmt::format("{}/{}", m_month, m_day);
1591 std::string string = date;
1592 std::string hms = fmt::format("{:02d}:{:02d}:00", m_hour, m_minute);
1593 string += '\t' + hms;
1594 boost::optional<double> value = dryBulbTemperature();
1595 if (!value) {
1596 LOG_FREE(Error, "openstudio.EpwFile", "Missing dry bulb temperature on " << date << " at " << hms)
1597 return boost::none;
1598 }
1599 //boost::optional<double> optdrybulb = openstudio::convert(value.get(), "C", "K");
1600 //OS_ASSERT(optdrybulb);
1601 double drybulb = value.get();
1602 string += '\t' + std::to_string(drybulb + 273.15);
1603 value = atmosphericStationPressure();
1604 if (!value) {
1605 LOG_FREE(Error, "openstudio.EpwFile", "Missing atmospheric station pressure on " << date << " at " << hms);
1606 return boost::none;
1607 }
1608 double p = value.get();
1609 string += '\t' + m_atmosphericStationPressure;
1610 if (!windSpeed()) {
1611 LOG_FREE(Error, "openstudio.EpwFile", "Missing wind speed on " << date << " at " << hms);
1612 return boost::none;
1613 }
1614 string += '\t' + m_windSpeed;
1615 if (!windDirection()) {
1616 LOG_FREE(Error, "openstudio.EpwFile", "Missing wind direction on " << date << " at " << hms);
1617 return boost::none;
1618 }
1619 string += '\t' + m_windDirection;
1620 double pw;
1621 value = relativeHumidity();
1622 if (!value) { // Don't have relative humidity - this has not been tested
1623 value = dewPointTemperature();
1624 if (!value) {
1625 LOG_FREE(Error, "openstudio.EpwFile", "Cannot compute humidity ratio on " << date << " at " << hms);
1626 return boost::none;
1627 }
1628 //boost::optional<double> optdewpoint = openstudio::convert(value.get(), "C", "K");
1629 //OS_ASSERT(optdewpoint);
1630 double dewpoint = value.get();
1631 pw = openstudio::psat(dewpoint);
1632 } else { // Have relative humidity
1633 double pws = openstudio::psat(drybulb);
1634 pw = 0.01 * value.get() * pws;
1635 }
1636 double W = 0.621945 * pw / (p - pw);
1637 string += "\t" + std::to_string(W * 1000); // need g/kg
1638 // Pass on solar flux quantities
1639 string += "\t0\t0";
1640 // Pass on Tsky
1641 string += "\t0";
1642 // Pass on snow and rain
1643 string += "\t0\t0";
1644 return boost::optional<std::string>(string);
1645}
1646

Callers 1

translateToWthMethod · 0.80

Calls 2

psatFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected