2023年9月20日 星期三
calculate_sigma
2023年8月24日 星期四
AWK
1. 用","當作分隔,取出某一欄位
cat *.csv | awk -V FS="," '{print $11}'
2. 比較某一欄的值是否大於或小於某個值
使用方法: cat *.txt | awk -f max.awk
BEGIN {
max = 0.005;
min = -0.005;
FS="[,]";
}
{
if (FNR > 1) {
if ($11>max) {
# print NR; -->印出行號
print $0; -->印出該行內容
}
if ($11<min) {
# print NR;
print $0;
}
}
}
END {
printf("max = %f min = %f ", max,min);
}
2023年8月11日 星期五
vimdiff
2023年6月26日 星期一
Check spike current for CCST waveform
#! /usr/local/bin/perl
### input all simulation waveforms then export values which have spike current
### generate a shell script (check_waveform.sh) to plot waveforms in gnuplot for examination
open (AA, "ls analyze_ccs/*/*/*/waveforms/waveform simulation.txt |") or die;
while (<AA>){
chomp;
push @libs, $_;
}
close AA;
$out = "check_waveform.sh";
open (BB,">$out") or die;
foreach $lib (@libs){
open (AA, $lib) or die;
#print "file: $lib ";
$i=0; $previous_current=le-8; $present_current=le-8;
#$dir=`basename $lib`;
$dir=`dirname $lib`;
chomp($dir);
#print "dir path is $dir \n";
while (<AA>){
chomp;
if ($i>"1"){
@current=split(" ",$_);
$present_current=$current[1];}
if ($i=="2"){
$previous_current=$current[1]; $present_current=$current[1];}
$rel_diff=abs($previous_current/$present_current) ;
#print "Rel diff is $rel_diff , previous is $previous_current , present is $present_current \n";
#export waveform values which have large differences (X10000)
if ($rel_diff > 10000 || $rel_diff < 0.0001){
print "file: $lib has spike at line $i, Rel diff is $rel_diff, previous is $previous_current, present is $present_current\n";
$time_axis=$current[0]+le-10;
print BB "sed -i '/set datafile missing/i";
print BB "set xrange [0:$time_axis]";
print BB "gnuplot $dir/gnuplot.cmd\n";
print BB "gnuplot $dir/gnuplot.cmd\n";
}
$previous_current=$present_current ;
$i++;
}
close AA;
}
close BB;
標籤
- 大盤 (6)
- 未分類資料夾 (2)
- 英文 (28)
- 書刊雜誌 (11)
- Perl (25)
- TCL (10)
- Uncategoried (1)
- UNIX Linux (43)