gray/scripts/profsum.sh
Michele Guerini Rocco 8dfb214ea0
scripts: make shebangs more portable
Use env to find the interpreter instead of a hard-coded path.
2021-12-15 02:30:47 +01:00

48 lines
1.9 KiB
Bash
Executable File

#!/usr/bin/env bash
awkcmd='BEGIN {lastu=0; lastl=0}; \
NR<21 {print}; \
NR==21 {sub("beam ","mirr "); print}; \
NR>21 { \
if(NF>=11) { \
mirr=($1<5?"USM":"LSM"); \
jphi[mirr,$2,$3]+=$5; jcd[mirr,$2,$3]+=$6; dpdv[mirr,$2,$3]+=$7; \
iins[mirr,$2,$3]+=$8; pins[mirr,$2,$3]+=$9; pfrac[mirr,$2,$3]+=$10 \
} \
if( lastu==0 && $1==4) {lastu=1}; \
if( lastl==0 && $1==8) {lastl=1}; \
if((lastu==1 && mirr ~ "USM") || lastl==1) { \
if(NF<11) {print} \
else { \
pfrac[mirr,$2,$3]/=4; \
printf("%4s%4d %12.5E %12.5E %12.5E %12.5E %12.5E %12.5E %12.5E %12.5E %12.5E\n", \
mirr, $2, $3, $4, \
jphi[mirr,$2,$3], jcd[mirr,$2,$3], dpdv[mirr,$2,$3], \
iins[mirr,$2,$3], pins[mirr,$2,$3], pfrac[mirr,$2,$3], $11) \
}; \
} \
}'
awk "$awkcmd" f48_t520_scan_v7-121116_AB_1ray.txt > f48sum_USM_t520_scan_v7-121116_AB_1ray.txt
awkcmd='BEGIN {lastu=0; lastl=0}; \
NR<21 {print}; \
NR==21 {sub("beam ","mirr "); print}; \
NR>21 { \
if(NF>=11 && $1!=3 && $1!=8) { \
mirr=($1<6?"USM":"LSM"); \
jphi[mirr,$2,$3]+=$5; jcd[mirr,$2,$3]+=$6; dpdv[mirr,$2,$3]+=$7; \
iins[mirr,$2,$3]+=$8; pins[mirr,$2,$3]+=$9; pfrac[mirr,$2,$3]+=$10 \
} \
if( lastu==0 && $1==5 ) {lastu=1}; \
if( lastl==0 && $1==10) {lastl=1}; \
if((lastu==1 && mirr ~ "USM") || lastl==1) { \
if(NF<11) {print} \
else { \
pfrac[mirr,$2,$3]/=4; \
printf("%4s%4d %12.5E %12.5E %12.5E %12.5E %12.5E %12.5E %12.5E %12.5E %12.5E\n", \
mirr, $2, $3, $4, \
jphi[mirr,$2,$3], jcd[mirr,$2,$3], dpdv[mirr,$2,$3], \
iins[mirr,$2,$3], pins[mirr,$2,$3], pfrac[mirr,$2,$3], $11) \
}; \
} \
}'
#awk "$awkcmd" f48_t520_scan_10beams.txt > f48sum_t520_scan_10beams.txt