2021年4月22日 星期四

Plot @ gnuplot

 對於在Linux下工作的人,如果你經常要畫一些二維圖和簡單的三維圖的話,那麼,gnuplot無疑是一個非常好的選擇,不僅圖形漂亮,而且操作簡單。當

然如果需要品質更高的三維圖,請用其他的一些專業繪圖軟體。建議大家學會使用gnuplot。這個小軟體通常都是Redhat
Linux內建的,但內建的版本是3.7的,建議將其升級到4.0,新版本具有很多新功能。最新版本可以到
http://www.gnuplot.info/
下載。
一
些最基本的操作請大家看說明書。這裡總結一下我在使用過程中遇到的一些問題以及解決的辦法,目的是讓那些以前不會的或不熟練的能快速入門,會畫自己想要的
圖,因為原來的說明書很長,較難有針對性地很快找到自己想要的資訊。這裡簡單的總結不可能面面俱到,所以大家不要抱怨我寫的不全,更全面的瞭解還是請看說
明書,網上的資料也多的是。其實這也是我們從網上一點一點搜集和摸索出來的。我相信看完後,應該平時最常見的問題基本上都能在這裡找到答案。如果大家在使
用過程中摸索到了我沒有寫到的技巧和體會,或有其它建議,請大家提告訴我,以不斷完善這篇總結,謝謝。
一、基礎篇:
在linux命令提示字元下運行gnuplot命令啟動,輸入quit或q或exit退出。
1、plot命令
gnuplot> plot sin(x) with line linetype 3 linewidth 2 或
gnuplot> plot sin(x) w l lt 3 lw 2    %用線畫,線的類型(包括顏色與虛線的類型)是3,線的寬度是2,對函數sin(x)作圖
gnuplot> plot sin(x) with point pointtype 3 pointsize 2  或
gnuplot> plot sin(x) w p pt 3 ps 2    %用點畫,點的類型(包括顏色與點的類型)是3,點的大小是2
gnuplot> plot sin(x) title 'f(x)' w lp lt 3 lw 2 pt 3 ps 2    %同時用點和線畫,這裡title ‘f(x)’表示圖例上標'f(x)',如果不用則用預設選項
gnuplot> plot sin(x)    %此時所有選項均用預設值。如果缺某一項則將用預設值
gnuplot> plot ‘a.dat’ u 2:3  w l lt 3 lw 2 %利用資料檔案a.dat中的第二和第三列作圖
順便提一下,如這裡最前面的兩個例子所示,在gnuplot中,如果某兩個詞,按字母先後順序,前面某幾個字母相同,後面的不同,那麼只要寫到第一個不同的字母就可以了。如with,由於沒有其它以w開頭的詞,因此可以用 w 代替,line也可以用 l 代替。
2、同時畫多條曲線
gnuplot> plot sin(x) title ‘sin(x)’ w l lt 1 lw 2, cos(x) title ‘cos(x)’  w l lt 2 lw 2  %兩條曲線是用逗號隔開的。畫多條曲線時,各曲線間均用逗號隔開就可以了。
以上例子中是對函數作圖,如果對資料檔案作圖,將函數名稱換為資料檔案名即可,但要用單引號引起來。
3、關於圖例的位置
預設位置在右上方。
gnuplot> set key left  %放在左邊,有left 和right兩個選項
gnuplot> set key bottom  %放在下邊,只有這一個選項;預設在上邊
gnuplot> set key outside  %放在外邊,但只能在右面的外邊
以上三個選項可以進行組合。如:
gnuplot> set key left bottom  %表示左下邊
還可以直接用座標精確表示圖例的位置,如
gnuplot> set key 0.5,0.6  %將圖例放在0.5,0.6的位置處
4、關於座標軸
gnuplot> set xlabel ‘x’   %x軸標為‘x’
gnuplot> set ylabel ‘y’   %y軸標為’y’
gnuplot> set ylabel ‘DOS’ tc lt 3  %其中的tc lt 3表示’DOS’的顏色用第三種顏色。
gnuplot> set xtics 1.0    %x軸的主刻度的寬度為1.0,同樣可以為y軸定義ytics
gnuplot> set mxtics 3    %x軸上每個主刻度中畫3個分刻度,同樣可以為y軸定義mytics
gnuplot> set border 3 lt 3 lw 2 %設為第三種邊界,顏色類型為3,線寬為2
同樣可以為上邊的x軸(稱為x2)和右邊y(稱為y2)軸進行設定,即x2tics,mx2tics,y2tics,my2tics。
gnuplot> set xtics nomirror
gnuplot> unset x2tics     %以上兩條命令去掉上邊x2軸的刻度
gnuplot> set ytics nomirror
gnuplot> unset y2tics     %以上兩條命令去掉右邊y軸的刻度
5、在圖中插入文字
gnuplot> set label ‘sin(x)’ at 0.5,0.5  %在座標(0.5,0.5)處加入字串’sin(x)’。
在輸出為.ps或.eps檔案時,如果在set term 的語句中加入了enhanced選現,則可以插入上下標、希臘字母和特殊符號。上下標的插入和latex中的方法是一樣的。
6、在圖中添加直線和箭頭
gnuplot> set arrow from 0.0,0.0 to 0.6,0.8    %從(0.0,0.0)到(0.6,0.8)畫一個箭頭
gnuplot> set arrow from 0.0,0.0 to 0.6,0.8 lt 3 lw 2   %這個箭頭顏色類型為3,線寬類型為2
gnuplot> set arrow from 0.0,0.0 to 0.6,0.8 nohead lt 3 lw 2  %利用nohead可以去掉箭頭的頭部,這就是添加直線的方法。
注意,在gnuplot中,對於插入多個的label和arrow等等,系統會預設按先後順序分別對各個label或arrow進行編號,從1開始。如果以後要去掉某個label或arrow,那麼只要用unset命令將相應的去掉即可。如:
gnuplot> unset arrow 2
將去掉第二個箭頭。
7、圖的大小和位置
gnuplot>set size 0.5,0.5  %長寬均為預設寬度的一半,建議用這個取值,尤其是畫成ps或eps圖形的時候
gnuplot>set origin 0.0,0.5   %設定圖的最左下角的那一點在圖形面板中的位置。這裡圖將出現在左上方。
8、畫三維圖
gnuplot>splot ‘檔案名稱’ u 2:4:5  %以第二和第四列作為x和y座標,第五列為z座標。
9.將圖形輸出到檔案
在
gnuplot中,輸出檔案的格式是由terminal來控制的。預設的情況下,都是輸出到螢幕,即終端模式為X11。如果想輸出到檔案,則必須對
terminal進行設定。要瞭解有那些終端類型,可以輸入 set
terminal後斷行符號,所有支援的終端模式(或檔案格式)都列出來了。就我來說,輸出檔案的格式用得最多的是ps和eps檔案。這在運行畫圖命令
plot或splot前必須先運行如下兩條命令:
gnuplot>set term post eps color solid enh
gnuplot>set output ‘a.eps’
其
中第一條命令為設定終端模式,post即為postscript模式,這是輸出到ps或eps檔案必須有的。後面的eps,color,solid以及
enh選項均可以有或沒有,根據你的需要。eps表示輸出為eps檔案,沒有就輸出為ps檔案;color表示輸出圖形為彩色,不用就會儲存為黑白
的;solid表示輸出圖中的所有線都用實線,不用則除了第一條線為實線外,其它的均用不同的虛線;使用enh(enhanced)選項可以在圖中插入上
下標、希臘字母和特殊符號,不用則不能實現這些功能。後面的選項可以根據自己的需要選擇一個或幾個。
第二條命令對output的設定表示要輸出的檔案的名字。但是請注意,運行完這條命令後,還僅僅是定義了輸出檔案的名字,實際上,圖還沒畫到這個檔案裡去。因此運行這兩條命令還只是進行了必須的設定。然後運行如下命令
gnuplot>plot sin(x) w l
或
gnuplot>replot(假如前面已經運行過plot或replot命令的話)
這時,圖形就在上面指定的檔案中了。
要輸出為其它格式,同樣要進行這樣的設定,比如要輸出為jpg格式,則在運行畫圖命令前先運行如下命令:
gnuplot>set term jpeg
gnuplot>set output ‘a.jpg’
如果要由其它模式再返回到輸出到螢幕,則運行如下命令:
gnuplot>set term X11
二、提高篇:

1、如何在同一張圖裡同時畫多個圖

gnuplot>set multiplot   %設定為多圖模式
gnuplot>set origin 0.0,0.5   %設定第一個圖的原點的位置
gnuplot>set size 0.5,0.5  %設定第一個圖的大小
gnuplot>plot “a1.dat”
gnuplot>set origin 0.5,0.5   %設定第二個圖的原點的位置
gnuplot>set size 0.5,0.5   %設定第二個圖的大小
gnuplot>plot “a2.dat”
gnuplot>set origin 0.0,0.0   %設定第三個圖的原點的位置
gnuplot>set size 0.5,0.5  %設定第三個圖的大小
gnuplot>plot “a3.dat”
gnuplot>set origin 0.5,0.0   %設定第四個圖的原點的位置
gnuplot>set size 0.5,0.5  %設定第四個圖的大小
gnuplot>plot “a4.dat”
當然,如果後一個圖中的某個量的設定和前一個的相同,那麼後一個中的這個量的設定可以省略。例如上面對第二、第三和第四個圖的大小的設定。前一個圖中對某個量的設定也會在後一個圖中起作用。如果要取消在後面圖中的作用,必須用如下命令,如取消label,用
gnuplot>unset label
2、作二維圖時,如何使兩邊座標軸的單位長度等長
gnuplot> set size square    %使圖形是方的
gnuplot> set size 0.5,0.5    %使圖形是你要的大小
gnuplot> set xrange[-a:a]
gnuplot> set yrange[-a:a]    %兩座標軸刻度範圍一樣
gnuplot> plot ‘a.dat’
3、如何在同一張圖裡利用左右兩邊的y軸分別畫圖
gnuplot> set xtics nomirror   %去掉上面座標軸x2的刻度
gnuplot> set ytics nomirror   %去掉右邊座標軸y2的刻度
gnuplot> set x2tics       %讓上面座標軸x2刻度自動產生
gnuplot> set y2tics     %讓右邊座標軸y2的刻度自動產生
gnuplot> plot sin(x),cos(x) axes x1y2    %cos(x)用x1y2座標,axes x1y2表示用x1y2座標軸
gnuplot> plot sin(x),cos(x) axes x2y2     %cos(x)用x2y2座標,axes x2y2表示用x2y2座標軸
gnuplot> set x2range[-20:20]   %設定x2座標的範圍
gnuplot> replot
gnuplot> set xrange[-5:5]  %設定x座標的範圍
gnuplot> replot
gnuplot> set xlabel 'x'
gnuplot> set x2label 't'
gnuplot> set ylabel 'y'
gnuplot> set y2label 's'
gnuplot> replot
gnuplot> set title 'The figure'
gnuplot> replot
gnuplot> set x2label 't' textcolor lt 3    %textcolor lt 3或tc lt 3設定座標軸名稱的顏色
4、如何插入希臘字母和特殊符號
一般只能在ps和eps圖中,且必須指定enhanced選項。在X11終端(即顯示器)中無法顯示。
gnuplot> set terminal postscript enhanced然後希臘字母就可以通過{/Symbol a}輸入。例如
gnuplot> set label ‘{/Symbol a}’
各種希臘字母與特殊符號的輸入方法請見安裝包中gnuplot-4.0.0/docs/psdoc目錄下的ps_guide.ps檔案。
另外還可參見:
http://t16web.lanl.gov/Kawano/gnuplot/label-e.html#4.3
5、gnuplot中如何插入Angstrom(埃)這個符號(A上面一個小圓圈)
指令碼中在插入前先加入
gnuplot>set encoding iso_8859_1
這個命令,然後就可以通過“{\305}”加入了。如橫座標要標上“k(1/?)”:
gnuplot>set xlabel 'k(1/{\305})
如果是multiplot模式,則這個命令必須放在
gnuplot>set multiplot
的前面。
如果後面還要插入別的逸出字元,那麼還要在插入字元後加入如下命令:
set encoding default
安裝包中gnuplot-4.0.0/docs/psdoc/ps_guide.ps檔案中的表中的‘E’代表那一列的所有符號都用這個方法輸入。
6、gnuplot畫等高線圖
gnuplot>splot  ‘檔案名稱.dat’  u 1:2:3  w  l   %做三維圖
gnuplot>set dgrid3d 100,100 %設定三維圖表面的網格的數目
gnuplot>replot
gnuplot>set contour    %設定畫等高線
gnuplot>set cntrparam  levels  incremental -0.2,0.01,0.2   %設定等高線的疏密和範圍,資料從   -0.2到0.2中間每隔0.01畫一條線
gnuplot>unset surface   去掉上面的三維圖形
最後用滑鼠拽動圖形,選擇合理的角度即可。或者直接設定(0,0)的視角也可以:
gnuplot>set view 0,0
gnuplot>replot
這裡注意,畫三維圖的資料檔案必須是分塊的,也就是x每變換一個值,y在其變化範圍內變化一周,這樣作為一塊,然後再取一個x值,y再變化一周,作為下一資料區塊,等等。塊與塊之間用一空行格開。
7、如何畫漂亮的pm3d圖
gnuplot> set pm3d                %設定pm3d模式
gnuplot> set isosamples 50,50       %設定網格點
gnuplot> splot x**2+y**2          %畫三維圖
gnuplot> splot x**2+y**2 w pm3d   %畫成pm3d模式,注意比較變化
gnuplot> set view 0,0              %設定視角,(0,0)將投影到底面上去
gnuplot> splot x**2+y**2 w pm3d   %重畫,注意看變化
gnuplot> unset ztics               %把z軸上的數字給去掉
gnuplot> set isosamples 200,200     %使網格變細
gnuplot> replot                   %重畫,注意看變化,主要是過渡更光滑
8、利用指令檔避免重複輸入
有時候對某個資料檔案做好一張圖後,下次可能還要利用這個資料檔案作圖,但某個或某些設定要作些細微變化。這時候,可以把第一次作圖時的命令全部寫到一個檔案裡,如a.plt,下次只要將相應的設定做修改後,用下面的命令就會自動運行檔案所有的命令而最後得到你要的圖:
gnuplot>load ‘a.plt’
作為一個例子,假設檔案名稱為a.plt,裡面的內容為:
set pm3d 
set view 0,0 
unset ztics 
set isosamples 200,200 
splot x**2+y**2 w pm3d
set term post color
set output ‘a.ps’
replot
那麼啟動gnuplot後,只要運行如下命令就可以了:
gnuplot>load ‘a.plt’
如果我們要得到的僅僅是.ps或.eps圖,那也可以在linux命令提示字元下直接運行如下命令:
[zxh@theory zxh]$gnuplot a.plt
9、在gnuplot模式下運行linux命令
在gnuplot提示符下也可以運行linux命令,但必須在相應的命令前面加上 ! 號。例如,假設很多參量都已經設定好了,但需要對某個資料檔案a.dat進行修改後再畫圖,則可以用如下方式
gnuplot>!vi a.dat
通過這種方式,所有的linux命令都可以在gnuplot環境裡運行。
另外,也可以在gnuplot的提示符後輸入shell,暫時性退出gnuplot,進入linux環境,做完要做的事情後,運行exit命令,又回到gnuplot環境下。
gnuplot>shell
[zxh@theory zxh]$vi a.f
[zxh@theory zxh]$f77 a.f
[zxh@theory zxh]$a.out    (假設產生a.dat資料檔案)
[zxh@theory zxh]$exit
gnuplot>plot ‘a.dat’ w l 
                    
                

Plot CCS waveform with analyze_ccs command

Builds earlier than 19.12-294_148:
command: analyze_ccs -verbose -comp_nldm 2 -gui 0

Builds latter than 19.12-294_148:
command: analyze_ccs  -comp_nldm 2 -report_log

### command: gnuplot -p gnuplot.cmd
### load waveform data from files ###

waveform0 = 'slew_0.002825_load_0.000183/waveform_simulation.txt'
waveform1 = 'slew_0.002825_load_0.000183/waveform_CCS.txt'
set multiplot layout 2,1 rowsfirst

### --- sub-figure 1: current

set xlabel 'time'
set ylabel 'current'
set grid
# set xrange [0:2e-10]
set datafile missing "NaN"
plot waveform0 using 1:2 with lp lc 3 pt 4 t "curr-simulation", \
       waveform1 using 1:2 with lp lc 4 pt 5 t "curr-CCS"

### --- sub-figure 2: voltage
set xlabel 'time'
set ylabel 'voltage'
set grid
# set xrange [0:2e-10]
set datafile missing "NaN"
plot waveform0 using 3:4 with lp lc 5 pt 6 t "volt-simulation", \
       waveform1 using 3:4 with lp lc 6 pt 7 t "volt-CCS"
unset multiplot


2021年3月7日 星期日

Fix LBDB-889/LBDB-885

 #! /usr/local/bin/perl 

$dir = "RESULT_DC_LIB_w_normalize_waveform";
mkdir $dir if (!-d $dir); 

open (AA, "ls *.lib |") or die;
while (<AA>){
    chomp;
    push @libs, $_;
}
close AA; 

foreach $lib (@libs){
    chomp ($base_lib = `basename $lib`);
    $out = $dir."/".$base_lib; 

    ($libname = $base_lib) =~ s/\.lib//;
    open (AA, $lib) or die;
    open (BB, ">$out") or die;
    while (<AA>){
        if (/^library \(/){
            print BB "library ($libname) {\n";
        } elsif (/nom_temperature \: (\S+)\;/){
            $p_temp = $1;
            print BB;
        } elsif (/nom_voltage \: (\S+)\;/){
            $p_vol = $1;
            print BB;
        } elsif (/^  cell \((\S+)\)/){
            $p cell = $1;
            if ($p_cell =~ /DCAP/ or $p_cell =~ /ANTENNA/ or $p_cell =~/BHD/ or $p_cel1=~/BOUNDARY/ or $p_cell =~/FILL/ or $p_cell =~/TAPCELL/){
                $arc=1;
                while (<AA>){
                    if (/\{/) { $arc +=1; }
                    if (/\}/) { $arc -=1; }
                    last if ($arc==0);
                    }
                } else {
                        print BB;
                }
        } elsif (/^\s*operating_conditions/) {
                print BB "  library_features (report_delay_calculation);\n";
                print BB $_;
                while (<AA>){
                    if (/^(\s*temperature)/){
                        $attr = $1;
                        print BB "$attr : $p_temp;\n";
                    } elsif (/^(\s*voltage)/){
                        $attr = $1;
                        print BB "$attr : $p_vol;\n";
                    } elsif (/\}/){
                        print BB;
                        last
                    } elsif (/process\s+\:\s+1/){
                        if ($libname=~/ssgnp/){
                            print BB "    process : 1; /* SSGNPGlobalCorner_LocalMC_MOS_MOSCAP */\n";
                        } elsif ($libname=~/ffgnp/){
                            print BB "    process : 1; /* FFGNPGlobalCorner_LocalMC_MOS_MOSCAP */\n";
                        } else {
                            print BB;
                            print "[Warning] Cannot judge process corner by judging library file name ($libname)\n";
                        }
                        } else {
                            print BB;
                        } 
                }
            } elsif (/^\s*cell_footprint/){
            #} elsif (/^\s*area \:/){
                print BB $_;
                if ($p_cell =~ /MB4LVLSRAN2LHCWWRD2BWP360H10P66PDLVT/){
                    print BB "pg_pin (VBB) {\n";
                    print BB "  pg_type : pwell;\n";
                    print BB "  voltage_name : VBB;\n";
                    print BB " physical_connection : device_layer;\n";
                    print BB "}\n";
                    print BB "pg_pin (VDD) {\n";
                    print BB "  pg_type : primary_power;\n";
                    print BB "  voltage_name : VDD;\n";
                    print BB "  related_bias_pin : VPP;\n";
                    print BB "}\n";
                    print BB "pg_pin (VDDO) {\n";
                    print BB "  pg_type : primary_power;\n";
                    print BB "  voltage_name : VDDO;\n";
                    #print BB " related_bias_pin : VPP;\n";
                    print BB "}\n";
                    print BB "pg_pin (VPP) {\n";
                    print BB "  pg_type : nwell;\n";
                    print BB "  voltage_name : VPP;\n";
                    print BB "  physical_connection : device_layer;\n";
                    print BB "}\n";
                    print BB "pg_pin (VSS) {\n";
                    print BB "  pg_type : primary_ground;\n";
                    print BB "  voltage_name : VSS;\n";
                    print BB "  related_bias_pin : VBB;\n";
                    print BB "}\n"; 
                } else {
                    print BB "pg_pin (VBB) {\n";
                    print BB "  pg_type : pwell;\n";
                    print BB "  voltage_name : VBB;\n";
                    print BB "  physical_connection : device_layer;\n";
                    print BB "}\n";
                    print BB "pg_pin (VDD) {\n";
                    print BB "  pg_type : primary_power;\n";
                    print BB "  voltage_name : VDD;\n";
                    print BB "  related_bias_pin : VPP;\n";
                    print BB "}\n";
                    #print BB "pg_pin (VDDI) {\n";
                    #print BB "  pg_type : primary_power;\n";
                    #print BB "  voltage_name : VDDI;\n";
                    #print BB "  related_bias_pin : VPP;\n";
                    #print BB "}\n";
                    print BB "pg_pin (VPP) {\n";
                    print BB "  pg_type : nwell;\n";
                    print BB "  voltage_name : VPP;\n";
                    print BB "  physical_connection : device_layer;\n";
                    print BB "}\n";
                    print BB "pg_pin (VSS) {\n";
                    print BB "  pg_type : primary_ground;\n";
                    print BB "  voltage_name : VSS;\n";
                    print BB "  related_bias_pin : VBB;\n";
                    print BB "}\n";
                }
            } elsif (/^\s*pg_pin/){
                while (<AA>){
                    last if (/\}/);
                }
            } else {
                    print BB;
            } 
        }
        close AA;
        close BB;

}

2021年1月28日 星期四

check non-monotonic in dc_current

 #!/usr/bin/perl
use Term::ANSIColor;
my $input_library = $ARGV[0];

# $index --> 29 dc_current
$dc_current_flag=0; $index=0; $line=0; $increase=0; $decrease=0;

open(LIB,"<input_library");
while(<LIB>){
    $line++;
    if ($dc_current_flag=="4") {
        $original=$_; $increase=0; $decrease=0;
        $_ =~ s/"//g; $_ =~ s/,//g; $_ =~ s/\\//g;
        @aryl=split(" ",$_); $array_size = $#ary1+1;
        for ($i=0; $i<$array_size-1;$i++) {
            if ($aryl[$i] > $aryl[$i+1]) {$increase=1;} # detect increment
            if ($aryl[$i] < $aryl[$i+1]) {$decrease=1;} # detect decrement
        }
        if ($increase=="1" && $decrease=="1") {
            ## Values are non-monotonic when increment and decrement in same line
            print "LINE $line is non-monotonic, the VALUE is \n";
            for ($i=0; $i<$array_size-1; $i++) {
                    if ($ary1[$i] > 
$ary1[$i+1]) {print color("blue")."$ary1[$i] ";} # detect increment
                    if ($ary1[$i] < $ary1[$i+1]) {print color("red")."$ary1[$i] ";} # detect decrement
            }
            print "\n"; print color ('reset');
            #print "$original";
        } 

        ++$index;
        if ($index=="29") {$dc_current_flag=0; $index=0;}
    } 

    if (/dc_current \(/) {$dc_current_flag=1;}
    if ($dc_current_flag>0) { if (/index_1 \(/) {$dc_current_flag=2;}}
    if ($dc_current_flag>0) { if (/index_2 \(/) {$dc_current_flag=3;}}
    if ($dc_current_flag>0) { if (/values \(/) {$dc_current_flag=4;}}
}
close (LIB);

2021年1月26日 星期二

病毒英文


疫苗一詞「vaccine」源自於愛德華·金納所使用的牛痘。「vacca」為拉丁文,意即牛。

 A pandemic (from Greek πᾶν, pan, "all" and δῆμος, demos, "people" the 'crowd') is an epidemic of an infectious disease that has spread across a large region, for instance multiple continents or worldwide, affecting a substantial number of people. 

novel coronavirus (n.) 新冠病毒(武漢肺炎)novel 當名詞為小說,當形容詞為新型的

outbreak (n.) 病毒爆發

droplet infection (n.) 飛沫傳染

quarantine (n.) 檢疫隔離 home isolation (n.) 居家隔離 / hospital quarantine (n.) 住院隔離
The word "quarantine" originates from quarantena, the Venetian language form, meaning "forty days".[15][3] This is due to the 40-day isolation of ships and people practised as a measure of disease prevention related to the plague

stockpile 囤貨
incubation period 潛伏期Incubate 是動詞,指「(細菌或病毒在體內)潛伏」
contract / catch / be infected with 感染、患上
Contract 是動詞「感染、患上」的意思,這是比較正式的用詞,一般也可以用 catch 來表示相同意思,後面直接加上疾病名稱。
precaution 預防、預防措施

mix and match 混打、booster shot 追加劑、疫苗混打(mixing vaccines)

一劑疫苗可以用dose (n),名詞「劑量」即為dosage

immune system 免疫系統、immune response (免疫反應)

2020年12月21日 星期一

Extract CCST and integrate current to Voltage with new formula

 #!/usr/bin/perl 

$FILE_NAME = $ARGV[0];
$i=1; $write_out = 0;
$curly_brackets=0; $write next=0; $start=0; 

open(TEMCCST, ">temp_ccst.txt") || die "Can not open the file : temp.txt \n";
open(SearchFile, "<$FILE_NAME"); 

while(<SearchFile>){
    chop $_;
    if (/voltage/) {
        if (/nom_voltage /) {
            s/;//;
            @rail_voltage=split(":",$_);
            $rail_voltage=$rall_voltage[1];
            print "Rail Voltage is $rall_voltage\n";
            print "95% of Rail Voltage is ".$rall_voltage*0.95."\n";
            }}
    if (/cell \(/) {$start = 1;}
    if($start == "1") {
        if (/output_current/) {$write_out =1;}
    if($write_next == "1") {
        s/"//g: s/\\//g;
        print TEMCCST "$_\n"; $write next=0;}
    if ($write_out == "1") {
        if (/\{/) {$curly_brackets++;}
        if (/\}/) {$curly_brackets--;}
        if (/index_3/) {
            s/index_3 \("//g;
            s/"\);//g;
            print TEMCCST "$_\n";}
        if (/reference_time/) {
            s/ref erence_time//g;
            s/://g;
            s/;//g;
            print TEMCCST "$_\n";}
        if (/index_1/) {
            s/index_1 \("//g;
            s/"\);//g;
            print TEMCCST "$_\n";}
        if (/index_2/) {
            s/index_2 \("//g;
            s/"\);//g;
            print TEMCCST "$_\n";}
        if (/values/) {$write_next = 1;}
        if ($curly_brackets== "0") {$write_out = 0;}
        }
    }
}
close(SearchFile);
close(TEMCCST); 

use List::Util qw/max min/;
$t=0; $rename=0; $starting_v=0;
open(CCST, "<temp_ccst.txt") || die "Can not open the file : temp_ccst.txt \n";
open(TEMFILE, ">gnuplot_ccst.txt") || die "Can not open the file : gnuplot_ccst.txt \n"; 
open(VOLTAGE, "gnuplot_voltage.txt") || die "Can not open the file : gnuplot_voltage.txt \n"; while(<CCST>){
    chop $_;
    $_ =~ s/^\s+|\s+$//g ;          ## remove space
if ($i=="1") {$ref_time=$_;} ## reference_time
if (Si=="2") {$slew=$_;}       ## slew
if (Si=="3") {$load=$_;}       ## load
if (Si=="4") {                          ## time steps
    @aryl=split(",",$_);
    $max_index_3 = max @aryl;
    $min_index_3 = min @aryl;
    push (@accumulated_max_index_3, $max_index_3);
    push (@accumulated_min_index_3, $min_index_3);
    #print "The index_3 size is " ; print scalar @aryl; print "\n";
    #print "The max number of index_3 is $max_index_3 , The min is $min_index_3 \n";
    }
if ($i=="5")                             ## current steps
    @ary2=split(",",$_);
    $max_value = max @ary2;
    $min_value = min @ary2;
    push (@accumulated_max_value, $max_value);
    push (@accumulated_min_value, $min_value);
    #print "The value size is " ; print scalar @ary2; print "\n";
    #print "The max number of value is $max_value , The min is $min_value \n";
    }
    $i++; 
if($i > 5) { 
    $array_size = $#aryl+1;
    for ($j=0; $j<$array_size; $j++) {
        print TEMFILE "$aryl[$j] ";
        print TEMFILE "$ary2[$j]\n";
        }
    for ($j=0; $j<$array_size; $j++) {
        print VOLTAGE "$aryl[$j] ";
            if ($j == "0") {$voltage=$starting_v;}
            if ($j > 0) { 
                $avg_current=$ary2[$j];
                $time_step=$aryl[$j]-$ary1[$j-1];
                $voltage_step=($avg_current*$time_step)/$load;
                $voltage=$v_init+$voltage_step;} 
                $v_init=$voltage;
                print VOLTAGE "$voltage\n";
                }
            $i=1; $rename=1;

## To check if final voltage reached 95% of VDD
    #print "Rail voltage: Srail_voltage Final voltage: $voltage 95% of Rail voltage:
    if (abs($voltage) < ($rail_voltage*0.95)) {print "last voltage point $voltage doesn't reach 95% of VDD at CCST#$t\n";}
        }
if ($rename=="1") {
    close(TEMFILE); close(VOLTAGE);
    rename("gnuplot_ccst.txt",CCST.".$t");
    rename("gnuplot_voltage.txt",VOLTAGE.".$t");
    #print "CCST/VOLTAGE file number is $t \n";
    $t++;
    open(TEMFILE, ">gnuplot_ccst.txt") || die "Can not open the file : gnuplot_ccst.txt \n";
    open(VOLTAGE, ">gnuplot_voltage.txt") || die "Can not open the file : gnuplot_voltage.txt \n";
    $rename=0; 
}}
$accumulated_max_index_3 = max @accumulated_max_index_3;
$accumulated_min_index_3 = min @accumulated_min_index_3;
$accumulated_max_value = max @accumulated_max_value;
$accumulated min value = min @accumulated min value;

print "\n";
print "#######################\n";
print "print out max/min index_3/value \n";
print "#######################\n";
print "The whole max/min index_3 are $accumulated_max_index_3/$accumulated_min_index_3 \n"; print "The whole max/min value are $accumulated_max_value/$accumulated_min_value \n"; 
my $max = max @array;
my $min = min @array;
## Print out size of index_3 and value of CCST
##$array_size = $#aryl+1;
##print "$array_size \n";
##print scalar @aryl;
##print scalar @ary2; 
close(CCST);
close(TEMFILE);
close(VOLTAGE); 

標籤