-
Notifications
You must be signed in to change notification settings - Fork 2
/
do-hist-one.sh
executable file
·36 lines (31 loc) · 1010 Bytes
/
do-hist-one.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
#!/bin/bash
set -e
year=$1
oyear=$(printf "%04d" ${year})
scenario='historical'
export DATA_ROOT=${DATA_ROOT:=/data}
export OUTDIR=${OUTDIR:=/out}
model_dir=/vagrant/models/sam/2018-01-05/
## Generate the four base layers.
for what in sr cs-sr ab cs-ab hpd; do
printf " %-6s :: %s\n" ${what} ${year}
./ipbes-project.py -m ${model_dir} ${what} ${scenario} ${year} > /dev/null
done
## Combine base layers into BII layer.
for what in sr ab; do
if [ "${what}" == "ab" ]; then
v1="Abundance"
v2="Ab"
else
v1="Richness"
v2="SR"
fi
rio clip ${OUTDIR}/luh2/${scenario}-CompSim${v2}-${oyear}.tif \
--like ${OUTDIR}/luh2/${scenario}-${v1}-${oyear}.tif \
--output ${OUTDIR}/luh2/${scenario}-CompSim${v2}-${oyear}.tif
rio calc --co "COMPRESS=lzw" --co "PREDICTOR=2" --masked \
-t float32 "(* (read 1 1) (read 2 1))" \
-o ${OUTDIR}/luh2/${scenario}-BII${v2}-${oyear}.tif \
${OUTDIR}/luh2/${scenario}-${v1}-${oyear}.tif \
${OUTDIR}/luh2/${scenario}-CompSim${v2}-${oyear}.tif
done