Skip to content

Commit

Permalink
Address SAM issue 1990 - 5 minute weather data header info
Browse files Browse the repository at this point in the history
  • Loading branch information
sjanzou committed Jan 31, 2025
1 parent 20e6a0b commit 1372f57
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions shared/lib_windfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ static float col_or_nan(const std::string& s)
}
}
else
return std::numeric_limits<float>::quiet_NaN();;
return std::numeric_limits<float>::quiet_NaN();
}

static int locate2(std::string buf, std::vector<std::string> &vstring, char delim)
Expand Down Expand Up @@ -479,7 +479,12 @@ bool windfile::open( const std::string &file )
std::vector<std::string> hdr;
int ncols = locate2(m_buf, hdr, ',');

for (size_t i = 0; (int)i < ncols; i++)
lat = std::numeric_limits<float>::quiet_NaN();
lon = std::numeric_limits<float>::quiet_NaN();
elev = std::numeric_limits<float>::quiet_NaN();

// for (size_t i = 0; (int)i < ncols; i++) SAM issue 1990
for (size_t i = 0; (int)i < ncols && (i+1) < hdr.size(); i++)
{
hdr_item = util::lower_case(trimboth(hdr[i]));

Expand Down Expand Up @@ -509,13 +514,28 @@ bool windfile::open( const std::string &file )
}

}
// elevation needed for hub height comparison
if (isnan(elev)) {
m_errorMsg = "Elevation must be specified in header. Please check resource data.";
return false;
}
// are lat and lon required?
if (isnan(lon)) {
m_errorMsg = "Longitude must be specified in header. Please check resource data.";
return false;
}
if (isnan(lat)) {
m_errorMsg = "Latitude must be specified in header. Please check resource data.";
return false;
}

// time stamps expected to be in local time
// wind data files provide both site timezone and data timezone in header
// if the values are different, we can't determine the time zone of the time stamps
if (tz_data != tz_site)
if (tz_data != tz_site) {
m_errorMsg = util::format("data must be in local time: data time zone %s and site time zone %s are not the same", tz_data.c_str(), tz_site.c_str());

return false;
}
// line 2 data column headings
getline(m_ifs, m_buf);
nhdrs++;
Expand Down

0 comments on commit 1372f57

Please sign in to comment.