From fcca8c288fafc065b57b6de064d3790ddb2960c2 Mon Sep 17 00:00:00 2001 From: Lorenzo Figini Date: Fri, 16 Nov 2012 17:16:01 +0000 Subject: [PATCH] added bash/gnuplot scripts to visualize J profiles superposition. --- Makefile | 2 +- scripts/gamma-singleray.sh | 10 ++++---- scripts/profJ-comparison.gnu | 27 +++++++++++++++++++++ scripts/profsum.sh | 47 ++++++++++++++++++++++++++++++++++++ 4 files changed, 80 insertions(+), 6 deletions(-) create mode 100755 scripts/profJ-comparison.gnu create mode 100755 scripts/profsum.sh diff --git a/Makefile b/Makefile index d525689..593ee12 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ vpath %.f src FC=gfortran FFLAGS=-O3 -DIRECTIVES = -DREVISION="'$(shell svnversion)'" +DIRECTIVES = -DREVISION="'$(shell svnversion src)'" all: $(EXE) diff --git a/scripts/gamma-singleray.sh b/scripts/gamma-singleray.sh index 4cb1ca3..4c4dfdd 100755 --- a/scripts/gamma-singleray.sh +++ b/scripts/gamma-singleray.sh @@ -1,9 +1,9 @@ #!/bin/bash # set input/working/output folders -in=/Users/lorenzo/ITER/UL-Grant-161/QO-design/scenario1_scan_gamma -work=/Users/lorenzo/ITER/UL-Grant-161/QO-design/scenario1_scan_gamma/tmp -out=/Users/lorenzo/ITER/UL-Grant-161/QO-design/scenario1_scan_gamma/out +in=/Users/lorenzo/ITER/UL-Grant-161/optical-design +work=/Users/lorenzo/Desktop/tmp +out=/Users/lorenzo/ITER/UL-Grant-161/optical-design/out # check if working folder exists, otherwise create it if [[ ! -e $work ]]; then @@ -31,7 +31,7 @@ else fi fi -listfile=$in/v0_22.txt +listfile=$in/v7-121116_AB.txt listbase=`basename ${listfile} .txt` # count number of lines in input file nlines=`wc -l $listfile | awk '{print $1}'` @@ -65,7 +65,7 @@ for (( iline=1; iline<=$nlines+1; iline++ )); do # table from MIRRORS # awkcommand='NR=='$iline' && NF>=6 {print $1, $2, $3, $4, $5, $6}' # table from AM - awkcommand='NR=='$iline' && NF>=6 {print $1, -$2, sqrt($5^2+$6^2), $7, $3, $4}' + awkcommand='NR=='$iline' && NF>=7 {print $1, $2, sqrt($5^2+$6^2), $7, $3, $4}' line=`sed 's/#.*$//' $listfile | awk "$awkcommand"` if (( `echo $line | wc -w`>0 )); then # if valid line extract values diff --git a/scripts/profJ-comparison.gnu b/scripts/profJ-comparison.gnu new file mode 100755 index 0000000..8e91e2d --- /dev/null +++ b/scripts/profJ-comparison.gnu @@ -0,0 +1,27 @@ +#!/usr/local/bin/gnuplot + +set style line 1 lt 1 lw 1 lc rgb "black" pt 6 #mat +set style line 2 lt 1 lw 1 lc rgb "red" pt 1 #v1 +set style line 3 lt 1 lw 1 lc rgb "blue" pt 2 #v2 +set style line 4 lt 1 lw 1 lc rgb "web-green" pt 3 #v3 +set style line 5 lt 3 lw 2 lc rgb "black" pt 6 #mat sum +set style line 6 lt 3 lw 2 lc rgb "red" pt 1 #v1 sum +set style line 7 lt 3 lw 2 lc rgb "blue" pt 2 #v2 sum +set style line 8 lt 3 lw 2 lc rgb "web-green" pt 4 #v3 sum + +set xrange[0.6:0.95] +set yrange[0:*] +set xlabel "{/Symbol r}" +set ylabel "J_{cd} (kA/m^2)" + +set term postscript color dashed dl 2 enhanced font "Helvetica,16" +set output 'profilesJ_USM_v5_v7.ps' +#set term aqua 0 dashed enhanced font "Helvetica,16" +#set output +#test +set key nobox outside right title 'USM' +plot \ + 'f48_t520_scan_v5-121015_AB_1ray.txt' u (int(abs($2))%3==0?$4:1/0):(-$6*1000) w l ls 3 t 'AB v5', \ + 'f48_t520_scan_v7-121116_AB_1ray.txt' u (int(abs($2))%3==0?$4:1/0):(-$6*1000) w l ls 2 t 'AB v7', \ + 'f48sum_USM_t520_scan_v5-121015_AB_1ray.txt' u (int(abs($2))%3==0?$4:1/0):(-$6*1000) w l ls 7 not, \ + 'f48sum_USM_t520_scan_v7-121116_AB_1ray.txt' u (int(abs($2))%3==0?$4:1/0):(-$6*1000) w l ls 6 not diff --git a/scripts/profsum.sh b/scripts/profsum.sh new file mode 100755 index 0000000..1a3a728 --- /dev/null +++ b/scripts/profsum.sh @@ -0,0 +1,47 @@ +#!/bin/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