WSL/SLF GitLab Repository

Commit ca016a9e authored by Mathias Bavay's avatar Mathias Bavay
Browse files

The time range output of smet_range now shows the average sampling rate. The...

The time range output of smet_range now shows the average sampling rate. The smet2kml script should now better custom SMET files having a larger than usual header (such as .sno files).
parent 7d3aded9
......@@ -9,7 +9,7 @@ else
INPUT_DIR=$1
fi
ls ${INPUT_DIR}/*.smet | xargs -i head -20 {} | awk '
ls ${INPUT_DIR}/*.smet | xargs -i head -40 {} | awk '
BEGIN {
printf("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n")
printf("<kml xmlns=\"http://www.opengis.net/kml/2.2\">\n")
......
......@@ -28,14 +28,37 @@ if [ "${param}" = "time" ]; then
start=`head -20 ${SMET} | grep -E "^[0-9][0-9][0-9][0-9]" | head -1 | tr -s ' \t' | cut -d' ' -f1`
end=`tail -5 ${SMET} | grep -E "^[0-9][0-9][0-9][0-9]" | tail -1 | tr -s ' \t' | cut -d' ' -f1`
nr_lines=`wc -l ${SMET} | cut -d' ' -f1`
if [ ! -z "${ISO}" ]; then
printf "%04d m\t[ %s - %s ]\t%d lines (%s)\n" "${ALT}" ${start} ${end} ${nr_lines} ${NAME}
fi
if [ ! -z "${JULIAN}" ]; then
start_ISO=`echo ${start} | awk '{printf("%s", strftime("%FT%H:%m", ($1-2440587.5)*24*3600))}'`
end_ISO=`echo ${end} | awk '{printf("%s", strftime("%FT%H:%m", ($1-2440587.5)*24*3600))}'`
printf "%04d m\t[ %s - %s ]\t%d lines (%s)\n" "${ALT}" ${start_ISO} ${end_ISO} ${nr_lines} ${NAME}
fi
echo "${start} ${end} ${nr_lines}" | awk '
function getISO(ts){
return sprintf("%s", strftime("%FT%H:%m", (ts-2440587.5)*24*3600))
}
function getSec(ts){
gsub(/\-|\:|T/," ", ts); split(ts,d," ");
date=sprintf("%04d %02d %02d %02d %02d 00",d[1],d[2],d[3],d[4],d[5]);
return mktime(date)
}
{
if ("'"${ISO}"'" != "") {
ISO_end=$2; ISO_start=$1;
end=getSec($2); start=getSec($1); nr=$3;
}
if ("'"${JULIAN}"'" != "") {
ISO_end=getISO($2); ISO_start=getISO($1);
end=$2*24*3600; start=$1*24*3600; nr=$3
}
period=(end-start)/nr;
if (period<299)
sampling=sprintf("%3.0f s", period)
else if (period<60*60)
sampling=sprintf("%3.0f min", period/60)
else if (period<24*3600)
sampling=sprintf("%3.0f h", period/3600)
else
sampling=sprintf("%3.0f day", period/(3600*24))
printf( "%04d m\t[ %s - %s ]\t~%s\t(%s)\n", "'"${ALT}"'", ISO_start, ISO_end, sampling, "'"${NAME}"'")
}'
done
exit 0
fi
......@@ -53,7 +76,8 @@ for SMET in ${files}; do
awk '
BEGIN {
param="'"${param}"'"
nodata="'"${NODATA}"'"
if (param=="HNW") param="PSUM"
nodata='"${NODATA}"'+0
max=-1e4
min=1e4
f=2
......@@ -78,7 +102,7 @@ for SMET in ${files}; do
next
}
$0 !~ /^[a-zA-Z\[]/ {
val=$(f)
val=$(f)+0
if (val==nodata) next
if (val>max) max = val
if (val<min) min = val
......
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