WSL/SLF GitLab Repository

Commit 957498bf authored by Mathias Bavay's avatar Mathias Bavay
Browse files

A new script has been created to help select SMET files based on the...

A new script has been created to help select SMET files based on the parameters they contain. A bug has been found in PSUMDistribute when a distribution interval would be followed by a large data gap (it was filling the remaining of the buffer with 0).
parent 29f9b1dc
......@@ -45,9 +45,20 @@ void ProcPSUMDistribute::process(const unsigned int& param, const std::vector<Me
const size_t endIdx = findNextAccumulation(param, ovec, endDate, ii+1);
//the proper end date is not in our vector
if (endIdx==IOUtils::npos || (endIdx==ii && is_soft)) {
if (endIdx==IOUtils::npos) {
fillInterval(param, ovec, ii+1, nr_elems-1, 0.); //fill the rest with 0
ii = nr_elems;
break;
}
if (endIdx==ii) { //no accumulation period found ahead of a large gap
if (!is_soft) {
std::ostringstream ss;
ss << "Redistribution of precipitation before reaccumulation failed: precipitation value required ";
ss << "in the " << startDate.toString(Date::ISO) << " - " << endDate.toString(Date::ISO) << " interval!\n";
throw NoDataException(ss.str(), AT);
}
ovec[endIdx](param) = 0.;
ii++;
continue;
}
......
#!/bin/bash
#return the list of SMET files in the given directory that have the given parameter. Optionaly, it is possible
#to provide a date range to make sure that the said parameter is not "nodata" in the period of interest
function simpleSelect {
files=`find ${INPUT_DIR}/* -maxdepth 0 -type f -name "*.smet"`
for SMET in ${files}; do
NAME=`basename "${SMET}" .smet`
ALT=`head -15 "${SMET}" | grep altitude | tr -s ' \t' | cut -d' ' -f3 | cut -d'.' -f1`
FIELDS=`head -25 "${SMET}" | grep fields | grep "${param}"`
if [ ! -z "${FIELDS}" ]; then
printf "${NAME} \t ${ALT}m\n"
fi
done
}
function rangeSelect {
files=`find ${INPUT_DIR}/* -maxdepth 0 -type f -name "*.smet"`
for SMET in ${files}; do
NAME=`basename "${SMET}" .smet`
awk --re-interval '
/altitude/ {
altitude=$3
}
/fields/ {
found=1
for(i=3; i<=NF; i++) {
if($(i)=="'${param}'") found=i-2
}
next
}
/nodata/ {
nodata=$3
}
/\[DATA\]/ {
if (found==1) exit
next
}
/^[0-9]{4}-[0-9]{2}-[0-9]{2}/ {
if ($1>"'${end}'") exit
if ($1>="'${start}'" && $(found)!=nodata) {
printf("%s \t %d\n", "'${NAME}'", altitude)
exit
}
}
' ${SMET}
done
}
if [ $# -eq 2 ]; then
INPUT_DIR=$1
param=$2
simpleSelect
else if [ $# -eq 4 ]; then
INPUT_DIR=$1
param=$2
start=$3
end=$4
rangeSelect
else
printf "$0\tlist smet files in a given directory that have a given parameter\n"
printf "Usage: $0 {path} {parameter}\n"
printf "or: $0 {path} {parameter} {start_date} {end_date}\n"
exit
fi
fi
Supports Markdown
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