NatLabRockies / NatLabRockies/OpenStudio

revamp EpwDataPoint to use double attributes where appropriate

Open
#3,701 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

component - Utilities Other Developer Issue
Dominant language
C++
Stars
646
Forks
237
Avg merge
3d 11h
Merged PRs (30d)
10

Description

There's a lot of back and forth conversions unnecessarily happening because the attributes are std::string but it should be double (or boost::optional<double> rather). We should limit the number of times we do std::stod conversions. Relates #3700 .

eg

hpp

  std::string m_extraterrestrialDirectNormalRadiation; //units Wh/m2, missing 9999., minimum 0

cpp

  boost::optional<double> EpwDataPoint::extraterrestrialDirectNormalRadiation() const
  {
    if(m_extraterrestrialDirectNormalRadiation == "9999") {
      return boost::none;
    }
    return boost::optional<double>(std::stod(m_extraterrestrialDirectNormalRadiation));
  }

  bool EpwDataPoint::setExtraterrestrialDirectNormalRadiation(double value)
  {
    if(0 > value || value == 9999) {
      m_extraterrestrialDirectNormalRadiation = "9999";
      return false;
    }
    m_extraterrestrialDirectNormalRadiation = std::to_string(value);
    return true;
  }

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the EpwDataPoint declarations in the hpp file and their definitions in the cpp file. Identify numeric attributes still stored as std::string, then trace their accessors and setters to determine where double or boost::optional storage can remove repeated conversions. Done means the applicable attributes use numeric storage while preserving missing-value and validation behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
data
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.