Commit 86cfcb16 authored by Purves, Murray's avatar Purves, Murray
Browse files

Removing height as a variable from radixsnd2arl

parent cb5d4971
Pipeline #16720 passed with stages
in 17 minutes and 3 seconds
...@@ -198,11 +198,10 @@ int main(int argc, char **argv) ...@@ -198,11 +198,10 @@ int main(int argc, char **argv)
std::cout << "Reading input csv file: " << inputCsvPath << std::endl; std::cout << "Reading input csv file: " << inputCsvPath << std::endl;
// Header strings to denote fields // Header strings to denote fields
std::string pressureString = "pres", heightString = "zhgt", std::string pressureString = "pres", tempString = "temp", relHumString = "rh",
tempString = "temp", relHumString = "rh", dewPtString = "tdew", dewPtString = "tdew", wDirString = "wdir", wSpdString = "wspd";
wDirString = "wdir", wSpdString = "wspd"; int pressureIndex = -1, tempIndex = -1, relHumIndex = -1, wDirIndex = -1,
int pressureIndex = -1, heightIndex = -1, tempIndex = -1, relHumIndex = -1, wSpdIndex = -1;
wDirIndex = -1, wSpdIndex = -1;
// Open and read the csv // Open and read the csv
CSVFile inputCsv(inputCsvPath); CSVFile inputCsv(inputCsvPath);
...@@ -236,11 +235,6 @@ int main(int argc, char **argv) ...@@ -236,11 +235,6 @@ int main(int argc, char **argv)
std::cout << " Found pressure at index " << entry << std::endl; std::cout << " Found pressure at index " << entry << std::endl;
pressureIndex = entry; pressureIndex = entry;
} }
else if (inputData[1][entry] == heightString)
{
std::cout << " Found height at index " << entry << std::endl;
heightIndex = entry;
}
else if (inputData[1][entry] == tempString) else if (inputData[1][entry] == tempString)
{ {
std::cout << " Found temperature at index " << entry << std::endl; std::cout << " Found temperature at index " << entry << std::endl;
...@@ -263,8 +257,8 @@ int main(int argc, char **argv) ...@@ -263,8 +257,8 @@ int main(int argc, char **argv)
} }
} }
// If we are missing one, we can't continue // If we are missing one, we can't continue
if (pressureIndex == -1 || heightIndex == -1 || tempIndex == -1 || if (pressureIndex == -1 || tempIndex == -1 || relHumIndex == -1 ||
relHumIndex == -1 || wDirIndex == -1 || wSpdIndex == -1) wDirIndex == -1 || wSpdIndex == -1)
{ {
std::cout << "Missing data fields in input!" << std::endl; std::cout << "Missing data fields in input!" << std::endl;
if (pressureIndex == -1) if (pressureIndex == -1)
...@@ -272,10 +266,6 @@ int main(int argc, char **argv) ...@@ -272,10 +266,6 @@ int main(int argc, char **argv)
std::cout << " Missing pressure field (denoted by " << pressureString std::cout << " Missing pressure field (denoted by " << pressureString
<< ")"; << ")";
} }
if (heightIndex == -1)
{
std::cout << " Missing height field (denoted by " << heightString << ")";
}
if (tempIndex == -1) if (tempIndex == -1)
{ {
std::cout << " Missing temperature field (denoted by " << tempString std::cout << " Missing temperature field (denoted by " << tempString
...@@ -301,8 +291,8 @@ int main(int argc, char **argv) ...@@ -301,8 +291,8 @@ int main(int argc, char **argv)
} }
// Read the data // Read the data
std::vector<float> inputPressures, inputHeights, inputTemps, inputRelHums, std::vector<float> inputPressures, inputTemps, inputRelHums, inputWDirs,
inputWDirs, inputWSpds; inputWSpds;
std::cout << "Data fields found - reading data..." << std::endl; std::cout << "Data fields found - reading data..." << std::endl;
float missingValue = -9999.f; float missingValue = -9999.f;
for (int row = 4; row < inputData.size(); ++row) for (int row = 4; row < inputData.size(); ++row)
...@@ -314,8 +304,8 @@ int main(int argc, char **argv) ...@@ -314,8 +304,8 @@ int main(int argc, char **argv)
; ;
} }
bool foundPressure = false, foundHeight = false, foundTemp = false, bool foundPressure = false, foundTemp = false, foundRelHum = false,
foundRelHum = false, foundWDir = false, foundWSpd = false; foundWDir = false, foundWSpd = false;
for (int entry = 0; entry < inputData[row].size(); ++entry) for (int entry = 0; entry < inputData[row].size(); ++entry)
{ {
float thisValue = from_string(inputData[row][entry], missingValue); float thisValue = from_string(inputData[row][entry], missingValue);
...@@ -325,11 +315,6 @@ int main(int argc, char **argv) ...@@ -325,11 +315,6 @@ int main(int argc, char **argv)
foundPressure = true; foundPressure = true;
inputPressures.push_back(thisValue); inputPressures.push_back(thisValue);
} }
else if (entry == heightIndex)
{
foundHeight = true;
inputHeights.push_back(thisValue);
}
else if (entry == tempIndex) else if (entry == tempIndex)
{ {
foundTemp = true; foundTemp = true;
...@@ -358,12 +343,6 @@ int main(int argc, char **argv) ...@@ -358,12 +343,6 @@ int main(int argc, char **argv)
<< std::endl; << std::endl;
inputPressures.push_back(missingValue); inputPressures.push_back(missingValue);
} }
if (!foundHeight)
{
std::cout << " Warning: couldn't find height in row " << row
<< std::endl;
inputHeights.push_back(missingValue);
}
if (!foundTemp) if (!foundTemp)
{ {
std::cout << " Warning: couldn't find temperature in row " << row std::cout << " Warning: couldn't find temperature in row " << row
...@@ -394,8 +373,6 @@ int main(int argc, char **argv) ...@@ -394,8 +373,6 @@ int main(int argc, char **argv)
// Interpolate the data to remove missing values // Interpolate the data to remove missing values
std::cout << "Interpolating values to remove missing data..." << std::endl; std::cout << "Interpolating values to remove missing data..." << std::endl;
std::cout << "Height:" << std::endl;
interpolateValues(inputPressures, inputHeights);
std::cout << "Temperature:" << std::endl; std::cout << "Temperature:" << std::endl;
interpolateValues(inputPressures, inputTemps); interpolateValues(inputPressures, inputTemps);
std::cout << "Relative humidity:" << std::endl; std::cout << "Relative humidity:" << std::endl;
...@@ -472,19 +449,6 @@ int main(int argc, char **argv) ...@@ -472,19 +449,6 @@ int main(int argc, char **argv)
std::cout << "written" << std::endl; std::cout << "written" << std::endl;
} }
// Write height levels
{
thisRecordHeader.kvar = "HGTS";
thisRecordHeader.var1 = inputHeights[level];
std::vector<std::vector<float>> thisData(
numberGridCells,
std::vector<float>(numberGridCells, inputHeights[level]));
std::cout << " height...";
outputStream.write_record_header(thisRecordHeader);
outputStream.write_record(thisRecordHeader, thisIndexHeader, thisData);
std::cout << "written" << std::endl;
}
// Write temperature levels // Write temperature levels
{ {
thisRecordHeader.kvar = "TEMP"; thisRecordHeader.kvar = "TEMP";
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment