Commit 8005b5c0 authored by CEVAER's avatar CEVAER
Browse files

Using NRT files of SMAP if FINAL version not found

parent fd95cb15
......@@ -38,7 +38,7 @@ if [ -z "$output_path" ] ; then
exit 1
fi
smap_path=/home/datawork-cersat-public/provider/remss/satellite/l3/smap/smap/wind/v1.0/daily
smap_path=/home/datawork-cersat-public/provider/remss/satellite/l3/smap/smap/wind/v1.0 # includes daily and daily_nrt
smos_path=/home/ref-smoswind-public/data/v2.0/l3/data
if [ -z "$smos" ] && [ -z "$smap" ] ; then
......@@ -59,28 +59,38 @@ fi
shopt -s globstar
if [[ -n $days ]]; then
# Converting the date "$days days ago" to seconds since UNIX-time
sec=$(date --date="$days days ago" +%s)
files_to_process=""
# Keeping only files that are in the requested time interval for SMAP
echo "Fetching files for the last $days days. Generated files will be written in $output_path"
for file in "$inpath"/**/*.nc; do # Whitespace-safe and recursive
if [ "$smap" == "True" ] ; then
secDt=$(echo "$file" | awk -F_ '{print $5"-"$6"-"$7}' | xargs -IDT date -d DT +%s)
elif [ "$smos" == "True" ] ; then
secDt=$(echo "$file" | awk -F_ '{print $5}' | xargs -IDT date -d DT +%s)
fi
if (( $secDt > $sec )); then
files_to_process="$files_to_process"$'\n'"$file"
fi
done
echo "Fetching files for the last $days days. Generated files will be written in $output_path"
else
echo "Updating whole archive in $output_path"
files_to_process=$(find $inpath -name "*.nc")
echo "Updating whole archive in $output_path"
fi
# Converting the date "$days days ago" to seconds since UNIX-time
sec=$(date --date="$days days ago" +%s)
files_to_process=""
# Keeping only files that are in the requested time interval for SMAP
for file in "$inpath"/**/*.nc; do # Whitespace-safe and recursive
if [ "$smap" == "True" ] ; then
# If the current file is an NRT file, checking that the FINAL file does not exist. If it does, skipping the NRT file.
if [[ "$file" == *"daily_nrt"* ]]; then
final_file=${file/daily_nrt/daily}
final_file=${final_file/_NRT/}
final_dir=$(dirname "$final_file")
if [ -d "$final_dir" ] && [ -f "$final_file" ]; then
# Skipping NRT file
echo "skipping NRT $file"
continue
fi
fi
secDt=$(basename "$file" | awk -F_ '{print $5"-"$6"-"$7}' | xargs -IDT date -d DT +%s)
elif [ "$smos" == "True" ] ; then
secDt=$(echo "$file" | awk -F_ '{print $5}' | xargs -IDT date -d DT +%s)
fi
if [[ -z $days ]] || (( $secDt > $sec )); then
files_to_process="$files_to_process"$'\n'"$file"
fi
done
# Removing empty lines
files_to_process=$(echo "$files_to_process" | sed -r '/^\s*$/d')
......
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