FAQ | This is a LIVE service | Changelog

Skip to content
Snippets Groups Projects
Commit 3058a14b authored by L. Bower's avatar L. Bower
Browse files

fix to run Depo script

removing three scripts and putting them into the ews-utils package for storage
parent 0f61d42c
No related branches found
No related tags found
No related merge requests found
#/bin/bash
# A script that runs all of a day's wheat rust forecasts in order
# 1: depo
# 2: env
# 3: epi
# 4: advisory
echo "starting catchup"
config=$1 # /storage/app/EWS_prod/regions/EastAfrica/resources/coordinator/configs/config_EastAfrica_fc_live.json
date=$2 # 20221009
# depo
/storage/app/EWS_prod/code/coordinator/scripts/run_Processor.sh -p Deposition -c $config -s $date --clearup &
# Wait at least a minute so that logfile timestamps do not clash
sleep 70
# env
/storage/app/EWS_prod/code/coordinator/scripts/run_Processor.sh -p Environment -c $config -s $date --clearup &
# wait for depo and env to finish
wait
# epi
/storage/app/EWS_prod/code/coordinator/scripts/run_Processor.sh -p Epidemiology -c $config -s $date --clearup &
# Wait at least a minute so that logfile timestamps do not clash
sleep 70
# advisory
/storage/app/EWS_prod/code/coordinator/scripts/run_Processor.sh -p Advisory -c $config -s $date --clearup &
wait
echo "finished catchup"
source ./run_utils.sh
# get path of this script (to point to files within the same git repo)
proc_path="$(dirname "$(readlink -f "$0")")"
source "${proc_path}"/run_utils.sh
setup_conda_env
# get path of this script (to point to files within the same git repo)
proc_path="$(dirname "$(readlink -f "$0")")"
# run the processor with all arguments
processor=${proc_path}/../coordinator/ProcessorDeposition.py
printf "processor is %s\n\n" "$processor"
python "${processor}" "$@"
python "${proc_path}"/../coordinator/ProcessorDeposition.py "$@"
exit_code=$?
teardown_conda_env
......
#!/bin/bash
set -e
# provide custom python packages so they can be imported
# activate conda environment of python modules so they can be imported
source /storage/app/miniconda3/bin/activate /storage/app/EWS/General/EWS-python/py3EWSepi
python /storage/app/EWS/General/EWS-Coordinator/ENVDataPostProcessor.py "$@"
# deactivate conda environment
source /storage/app/miniconda3/bin/deactivate /storage/app/EWS/General/EWS-python/py3EWSepi
#!bin/bash
#slice_tar_file_to_bounds.sh
echo "CAUTION: Bounds are currently hard-wired"
echo "It can be calculated automatically, but requires both ogrinfo and cdo to be available"
# activate conda env which has cdo
# CAUTION: Does not contain rasterio or geopandas, so ogrinfo is not available
echo "run conda activate conda activate /storage/home/tm689/miniconda3/envs/ewses_env"
tar_file=$1 #/.tar.gz file from Met Office
bounds_file=$2 # shpfile
outputdir=$3
# TODO: Determine lonres and latres in the script
lonres=0.140625 # can be obtained from any nc in tar file
latres=0.09375 # can be obtained from any nc in tar file
# 1) Determine bounds of sub-region
bounds_str=$(ogrinfo -so -al $bounds_file | grep "Extent");
echo "bounds_str: $bounds_str"
coords=($(echo $bounds_str | grep -o -E '[0-9\.]+'));
# bounds of input file
blonmin=${coords[0]};
blatmin=${coords[1]};
blonmax=${coords[2]};
blatmax=${coords[3];}
# we need nc files to go beyond those bounds by at least one datapoint
lonmin=$(bc -l <<< "$blonmin - $lonres");
latmin=$(bc -l <<< "$blatmin - $latres");
lonmax=$(bc -l <<< "$blonmax + $lonres");
latmax=$(bc -l <<< "$blatmax + $latres");
# Hard-wired: Pre-determined for example Ethiopia region
lonmin=38.60
lonmax=40.43
latmin=8.10
latmax=8.86
echo "Bounds are $lonmin, $latmin, $lonmax, $latmax"
# 2) get original netcdf files from input tar file
originaldir=$outputdir/original;
mkdir $originaldir;
tar -zxvf $tar_file -C $originaldir;
# 3) Slice the original netcdf files
# define the output directory
# remove suffix
tar_fn=$(basename $tar_file);
tar_fn_small=${tar_fn%.tar.gz}_small;
outputdir_tar_contents=${outputdir}/${tar_fn_small}/;
mkdir $outputdir_tar_contents;
nc_fns=$(find $originaldir -type f -name "*.nc");
for fn in $nc_fns; do
fn_small=${outputdir_tar_contents}$(basename ${fn%.nc})_small.nc;
echo "cdo command: sellonlatbox,$lonmin,$lonmax,$latmin,$latmax $fn $fn_small";
cdo "sellonlatbox,$lonmin,$lonmax,$latmin,$latmax" $fn $fn_small;
done;
# copy over any other files that need to be retained
fns_to_keep=$(find $originaldir -type f -name "sources.txt");
cp $fns_to_keep $outputdir_tar_contents;
# 4) Make the smaller tar file
out_fn=$tar_fn_small.tar.gz;
cd $outputdir;
tar -zcvf $out_fn ${tar_fn_small}/;
cd -;
echo "created ${out_fn}";
# clean up
rm -rf $originaldir;
rm -rf $outputdir_tar_contents;
echo finished;
exit 0;
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment