-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprepare_data2.sh
45 lines (40 loc) · 1.47 KB
/
prepare_data2.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
#!/bin/bash
# ================================================================================
# Create anomalies and obtain PCs for all netCDF files in a given folder.
#
# The example script processes all `*.nc` files in the given FILEPATH. The different
# steps of the script are:
#
# 1. Create anomalies for each input file using `get_anom.sh`. The paramaters are
# provided in a file provided by the argument CONFIGFILE.
#
# 2. Make a copy of the EOFs provided as the argument EOFFILE.
#
# 3. Obtain individual PCs by projecting the anomalies onto the EOFs provided by
# the argument EOFFILE.
#
# The resulting anomalies are saved in a subfolder of FILEPATH named `anom`.
# A copy of EOFFILE and the resulting PCs are saved in a subfolder of FILEPATH
# named`anom/prj`.
#
# Usage:
# ./prepare_data2.sh CONFIGFILE EOFFILE FILEPATH
#
# Author: Andreas Groth
# ================================================================================
CONFIGFILE="$1"
EOFFILE="$2"
FILEPATH="$3"
echo "Processing files in '$FILEPATH' ..."
# 1. get anomalies
./get_anom.sh "$CONFIGFILE" "$FILEPATH"/*.nc
# 2. Make copy of EOFFILE
echo "================================================================================"
echo "Copy EOFs"
outpath="$FILEPATH/anom/prj"
mkdir -p "$outpath"
cp -v "$EOFFILE" "$outpath"
echo "--------------------------------------------------------------------------------"
# 3. get PCs
eof_name=$(basename "$EOFFILE")
./get_pcs.sh "$outpath/$eof_name" "$FILEPATH"/anom/anom_*.nc