-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhtml_future_cron.sh
executable file
·69 lines (58 loc) · 2.55 KB
/
html_future_cron.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/bash
#set -x
#------------------------------------------------------------------------
#
# This file is part of MPPCPRO
#
# Model de Prevision de Presence du Criquet Pelerin en Region Occidentale
#
# Copyright (C) CIRAD - FAO (CLCPRO) 2021 - 2024
#
# Developped by Lucile Marescot, Elodie Fernandez and Cyril Piou
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#------------------------------------------------------------------------
#--------------------------------------------------------
#
# Script to launch creation of html file in cron
#
# Will be launched on last day of previous decade
# ie on a 10, 20 or last day of a month
# Only valid in that case !
#
#--------------------------------------------------------
# Command line arguments (for easy launch in cron)
yyyymmdd=$1
ana_env=~/software/miniforge3/bin/activate
scriptdir=/home/elfernandez/Production/mppcpro
fcstdir=/data/Production/Forecasts/CGLS_VIIRS
dirflag=/data/Production/Flags
roi=/data/Production/StaticData/CLCPRO.RData
# Activate conda environment
source $ana_env webmap
which R
# Check if html already done
html_flag_ok=$dirflag/${yyyymmdd:0:4}/${yyyymmdd:4:2}/html_future_${yyyymmdd}_OK
[[ -e $html_flag_ok ]] && echo "$(date) - Html future already created and available for ${yyyymmdd}" && exit 1
# Check that forecast has run correctly
# Not strictly necessary as we could rely on the R code to fail if necessary input data not available
forecast_flag_ok=$dirflag/${yyyymmdd:0:4}/${yyyymmdd:4:2}/forecast_future_${yyyymmdd}_OK
[[ ! -e $forecast_flag_ok ]] && echo "$(date) - Forecast data not available - Exit" && exit 1
# Launch R code
# need to add for now because of subfunction in R in other file
cd ${scriptdir}
Rscript --vanilla ${scriptdir}/forecasts.R -d "${yyyymmdd:0:4}-${yyyymmdd:4:2}-${yyyymmdd:6:2}" -o ${fcstdir} -f ${fcstdir} -c ${roi}
[[ ! $? -eq 0 ]] && echo "$(date) - Creation of html failed - Exit" && exit 1
echo "Creation of html successful"
touch $html_flag_ok