Skip to content

Commit 9a7d2c2

Browse files
committed
more reorg
1 parent 772daa5 commit 9a7d2c2

File tree

13 files changed

+1097
-28
lines changed

13 files changed

+1097
-28
lines changed

apps/awkies/getrange.x

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/bash
2+
#=====================================================================================
3+
4+
# Given a Nxd matrix of samples, compute dx2 ranges
5+
# Example: getrange.x samples.dat > ranges.dat
6+
7+
shopt -s expand_aliases
8+
alias awk="awk -v OFMT='%.15e'"
9+
10+
if [ $# -lt 1 ]; then
11+
echo "Number of arguments can not be less than 1"
12+
echo "Syntax: $0 <filename> [<cushion_fraction>]"
13+
exit
14+
elif [ $# -gt 2 ]; then
15+
echo "Number of arguments can not be greater than 2"
16+
echo "Syntax: $0 <filename> [<cushion_fraction>]"
17+
exit
18+
elif [ $# -eq 1 ]; then
19+
fr=0.0
20+
elif [ $# -eq 2 ]; then
21+
fr=$2
22+
fi
23+
24+
filename=$1
25+
26+
DIM=`awk 'END{print NF}' $filename`
27+
28+
for (( COL=1; COL<=$DIM ; COL++ )); do
29+
30+
awk 'BEGIN {
31+
valmin=1e+100;
32+
valmax=-1e+100;
33+
line=1;
34+
}
35+
{
36+
if( $(col) < valmin )
37+
{
38+
valmin=$(col);
39+
}
40+
if( $(col) > valmax )
41+
{
42+
valmax=$(col);
43+
}
44+
}
45+
END{
46+
print valmin-fr*(valmax-valmin), valmax+fr*(valmax-valmin)
47+
}' col=$COL $filename
48+
done

apps/awkies/scale.x

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/bash -e
2+
# Scales matrix data to or from a given parameter domain to [-1,1]^d
3+
# scale.x <input> <to or from> <domain> <output>
4+
5+
shopt -s expand_aliases
6+
alias awk="awk -v OFMT='%.15e'"
7+
8+
IN_FILE=$1
9+
TO_FROM=$2
10+
DOM_FILE=$3
11+
OUT_FILE=$4
12+
13+
N=`awk 'END{print NR}' $IN_FILE`
14+
D=`awk 'END{print NR}' $DOM_FILE`
15+
16+
DD=`awk 'END{print NF}' $IN_FILE`
17+
18+
## check that DD=D
19+
20+
echo "" > $OUT_FILE
21+
for (( i=1; i<=$D ; i++ )); do
22+
A=`awk 'NR==i{print $1}' i=$i $DOM_FILE`
23+
B=`awk 'NR==i{print $2}' i=$i $DOM_FILE`
24+
25+
if [ "$TO_FROM" = "from" ]; then
26+
awk '{print -1.+2.*($i-a)/(b-a)}' i=$i a=$A b=$B $IN_FILE > tmp
27+
elif [ "$TO_FROM" = "to" ]; then
28+
awk '{print (a+b)/2.+$i*(b-a)/2.}' i=$i a=$A b=$B $IN_FILE > tmp
29+
else
30+
echo "Second argument has to be 'to' or 'from'"
31+
exit
32+
fi
33+
paste $OUT_FILE tmp > tmpp; mv tmpp $OUT_FILE
34+
35+
done

apps/awkies/transpose.x

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash -e
2+
# Transpose a matrix: assumes all lines have same number
3+
# of fields
4+
5+
# Example: transpose_file.x file_in > file_out
6+
7+
shopt -s expand_aliases
8+
alias awk="awk -v OFMT='%.15e'"
9+
10+
exec awk '
11+
NR == 1 {
12+
n = NF
13+
for (i = 1; i <= NF; i++)
14+
row[i] = $i
15+
next
16+
}
17+
{
18+
if (NF > n)
19+
n = NF
20+
for (i = 1; i <= NF; i++)
21+
row[i] = row[i] " " $i
22+
}
23+
END {
24+
for (i = 1; i <= n; i++)
25+
print row[i]
26+
}' ${1+"$@"}

apps/pc_fit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@
113113
for isam in range(0, nsam, nevery):
114114
f = plt.figure(figsize=(12,4))
115115
plt.plot(xc, y[isam,:], 'bo-', ms=8, label='Model')
116-
plt.plot(xc, ypred[isam,:], 'go-', ms=8, label='PC apprx.')
116+
plt.plot(xc, ypred[isam,:], 'go-', ms=8, label='PC Apprx.')
117117
plt.title(f'Sample #{isam+1}')
118118
plt.xlabel(xlabel)
119119
plt.ylabel(ylabel)

apps/plot_ens.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
args = parser.parse_args()
1818

1919
ydata = np.loadtxt(args.ydata)
20+
if len(ydata.shape)==1:
21+
ydata = ydata[:, np.newaxis]
2022

2123

2224
nsam, nout = ydata.shape

apps/uqpc/model.x

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
3+
INPUT_FILE=$1
4+
OUTPUT_FILE=$2
5+
6+
# Run the black-box model,
7+
# (a) Test function with 3 inputs and 5 outputs
8+
awk '{print exp($1), $3*log($1**2)+$1+($2**2)*(1-exp(-$3**2)), $1+$3**2, $2+$3, $1*$3}' $1 > $2
9+
10+
# (b) Entry-wise exponential, same number of inputs and outputs
11+
#awk '{for (i=1; i<=NF; i++) { printf("%lg ",exp($i)) }; printf("\n")}' $1 > $2
12+
13+
14+
# # (c) A three parameter time-dependent model, i.e. as many outputs as there are time grid points
15+
# # Warning: this will generate a lot of figures after the whole workflow is done.
16+
# NGRID=50
17+
# echo -n"" > $2
18+
# for ((tgrid=1;tgrid<=$NGRID;tgrid++)); do
19+
# awk '{print $3*$1**2+$2*exp((tgr/ngr)*$3)}' tgr=$tgrid ngr=$NGRID $1 > tmp
20+
# paste $2 tmp > tmpp; mv tmpp $2; rm -f tmp
21+
# done
22+
# # Output names are time grid points
23+
# rm -rf outnames.txt
24+
# for ((i=1;i<=$NGRID;i++)); do
25+
# echo "$i" >> outnames.txt
26+
# done

0 commit comments

Comments
 (0)