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); 

2020年9月8日 星期二

用英文禮貌回應對方的感謝

 https://buzzorange.com/vidaorange/2019/12/09/16-responses-to-thank-you/

非正式、口語

1. You’re welcome.

這大概是最常聽到、英文學習者使用率最高的一句了,不過我們如果再延伸一點,加上 very 的話,可以用來強調自己是誠心誠意地在回覆對方的感謝,寫成 You are very welcome! 像 Lucy 舉的這個例子:

A: Thank you so much for packing my shopping for me.(謝謝你幫我裝好我買的東西。)

B: Oh, you’re very welcome.(喔,完全不需要客氣。)

Lucy 在影片中有提到,這是很英式的說法,如果你哪天剛好要去英國,不妨試試這樣的說法喔!

2. No problem!

這是比較偏美式的用法,老一輩似乎比較不喜歡這樣的回答方式,要小心。

A: Thanks for the help today.(謝謝你今天的幫忙。)

B: No problem. I enjoyed helping you.(不客氣。我很樂意幫忙。)

3. Thank you.

看到這樣的回應方式,你可能覺得有些奇怪,怎麼在說「謝謝你」?記得,這種回應方式的重點完全在「語氣的強調」,也就是說,如果有人感謝你,但你覺得應該是對方要被感謝才對,你就可以這樣說。

A: Thanks for accepting the invitation.(謝謝你接受我的邀請。)

B: Thank YOU!(我才要謝謝你!)

像這樣就是在強調「我其實才該感謝對方,因為他們大方邀請我。」

4. The pleasure is mine!

這句話如果像這樣完整說,其實會顯得比較正式,但我們可以簡短表示,像 My pleasure!「我的榮幸!」或是 Pleasure!「別客氣!」。

A: Thanks for taking the parcel in for me.(謝謝你幫我把包裹拿進來。)

B: Pleasure!(別客氣!)

5. I know you’d do the same for me!

這是一種相當友善的用法喔,適合用在熟人身上,完整寫出來的話會是 I know you would do the same for me. 例如:

A: I’d like to thank you for looking after my cat so well.(我想謝謝你把我的貓照顧得那麼好。)

B: I know you’d do the same for me.(我知道你也會為了我這麼做。)

意思就是說「我知道如果換成是你,你也會照顧我的貓,我們互相啦。」

6. That’s all right!

這個說法相對隨興,甚至有時候如果語調稍微一變,會顯得你不太在乎,所以「語氣」很重要喔!像是以下這個情境:

Thank you for picking me up from the station.(謝謝你把我從車站接回來。)

如果你很樂意去接人家,語氣可能就會是:That’s all right!(沒什麼啦!)

如果是心不甘情不願去接,又藏不住情緒,可能就會說:That’s all right.(沒什麼。)

7. No worries!

接下來這句也相當隨興,例如:

A: Thanks for letting me know that my car alarm was going off.(謝謝告訴我車子的防盜警報器響了。)

B: No worries. I thought I’d better tell you.(不會。我想說最好跟你說一聲。)

8. Don’t mention it!

這種說法也很英式,而且很自謙,舉個例子:

A: Thank you so much for bringing the dessert.(謝謝你帶甜點來。)

B: Oh! Don’t mention it!(不用謝啦!)

這種意思就像在表達「雖然帶著甜點來可能很麻煩,我們可能也想要聽到你的感謝,但還是會說『不用謝啦!』」。

9. It was the least I could do!

講出這樣的話,可以讓人感到你的真心誠意,是非常誠懇的說法喔,它一樣很英式,例如:

A: Thank you for visiting me in hospital.(謝謝你到醫院探望我。)

B: Oh, it was the least I could do.(喔,這點事根本算不了什麼。)

10. Anytime!

這句也是相當的口語,而且很大方,例如:

A: Thank you for stopping by.(謝謝你順道過來。)

B: Oh, anytime!(噢,不會啦!)

11. Sure!

這個用法非常美式、非常隨興,常常會跟 No problem! 一起用,講成 Sure, no problem!

A: Thank you for thinking of me.(謝謝你想到我。)

B: Sure!(不會!)或是 Sure, no problem!(不會啦。不客氣。)

12. It was nothing!

以這種方式回應感謝可以讓對方感受到,你覺得他們感謝你的事情其實一點都不麻煩。

A: Thank you for picking my kids up from school.(謝謝你們到學校接我小孩下課。)

B: It was nothing. My kids already needed picking up. No extra effort here.(那沒什麼啦。我也需要載我小孩啊。一點都不麻煩的。)

正式、適合商業或是店面經營

13. Much obliged!

這是一種很英式的說法,而且相當老派,它的完整版是:I’m very much obliged to you.「我不勝感激。」

Thank you so much, doctor. I’m very much obliged to you.(醫生,很謝謝你。感激不盡。)

14. You’re most welcome!

一般來說,只有在很正式場合才會這樣來回應對方的感謝,像影片中 Lucy 提到,她的律師是個嚴謹的人,那前幾天他們講完有關法律的事情,在跟她的律師說謝謝的時候,得到的就是這個回應:You’re most welcome!「無須客氣!」

15. We appreciate your business!

如果是商業方面的對象就很適合這種說法,舉個例子:

A: Thank you for sending the sample so promptly.(感謝您如此快速寄送樣品。)

B: We appreciate your business.(我們很感謝貴公司的合作。)

16. I’m happy to help!

最後這句絕對適合在職場使用,哪天在辦公室或上班的地方遇到類似情境,可以試著運用這句到你們的對話中喔!

A: Thank you for helping me carry the coffees to the office.(謝謝你幫我把咖啡拿到辦公室。)

B: Oh, I’m happy to help.(喔,我很樂意幫忙。)

複習完這麼多可以說「不客氣」的用法,也要記得找機會真正運用,才會進步喔!

2020年7月8日 星期三

untar all files

#!/bin/csh
    foreach filename (`ls *.tgz | sed -r "s/\x1B\[[0-9;]*[mK]//g"`)
    tar -zxvf $filename
end

2020年3月31日 星期二

Check LIB-817 in Liberate

#!/usr/bin/perl
# set targeted files
$FILE1 = "sim.sp" ; $FILE2 = "sim.measure" ;
open (SP, "$FILE1"); open (MEAS, "$FILE2");

### Section 1
## glean initial-conditions (pulse results) from sim.measure
my %meas_hash;
while (<MEAS>) {
            chop $_;
            if (/altosinitialcondition/) {
                  @init = split("=",$_);
                  $init[0] =~ s/\s+//;  #remove space
                  $init[1] =~ s/\s+//;
                  #print "$init[0] $init[1]\n"; #print out for checking
                  $meas_hash { $init[0] } = $init[1];  #create hash table for measurement data
                  # another type
                  # %meas_hash = @init;
              }}
## uncomment following 3 lines to out measurement result we got from sim.measure
#foreach $key (keys %meas_hash){
#          print "pulse measured initial value of $key : $meas_hash{$key}\n";
#}
### Section 2
### glean node information from sim.sp
my %node_hash ;
while (<SP>) {
           chop $_;
           if(/AltosInitialCondition/) {
                   @node = split(" ",$_);
                   $node[2] =~ s/\s+//; $node[2] = lc($node[2]);
                   $node[4] =~ s/\s+//; $node[4] =~ s/v\(//; $node[4] =~ s/\)//;
                   #print "$node[2] $node[4]\n"; #print out for checking
                   $node_hash { $node[2] } = $node[4];
} }
close SP;

### Section 3 
### glean inside-view values from sim.sp 
open (SP, "$FILE1"); 
my %inside_view_hash; 
while (<SP>) { 
           chop $_; 
           if (/^.nodeset/ || /^.ic/) { 
                     s/=//; # remove '=' in .ic to align with format of .nodeset 
                     @inside_view = split(" ",$_); 
                     $inside_view[1] =~ s/\s+//; $inside_view[1] =~ s/v\(//; $inside_view[1] =~ s/\)//; 
                     $inside_view[2] =~ s/\s+//; 
                     foreach $key (keys %node_hash){ 
                           if ($inside_view[1] =~ $node_hash{$key}) { 
                                  $inside_view_hash { $inside_view[1] } = $inside_view[2]; 
                                  #print "$key : nodel= $node_hash{$key} of inside-view value is $inside_view[3]\n"; 
                     }} 
}}
## uncomment following 3 lines to print out inside view result we got from sim.sp 
#foreach $key (keys %inside_view_hash){ 
#             print "inside view initial value of $key : $inside_view_hash{$key}\n"; 
#} 
### Section 4 
### print out result 
#print "List inside-view vs pulse results\n"; 
#print " node inside-view pulse\n"; 
#print "***********************************************************************\n"; #foreach $key (keys %node_hash){ 
#              if (!$inside_view_hash{$node_hash{$key}}) { 
#                       if (defined $inside_view_hash{$node_hash{$key}}) { 
#                              print "";} 
#                       else { 
#                              $inside_view_hash{$node_hash{$key}}="9.99999";}} 
#               print "$key $node_hash{$key} "; print "$inside_view_hash{$node_hash{$key}} "; print "$meas_hash{$key}\n"; 
#}
print "List inside-view vs pulse results\n"; 
print " node inside-view pulse\n"; 
print "***********************************************************************\n"; foreach $key (keys %node_hash){ 
               if (!$inside_view_hash{$node_hash{$key}}) { 
                     if (defined $inside_view_hash{$node_hash{$key}}) { 
                                  print "";} 
                     else { 
                                  $inside_view_hash{$node_hashf$keyl}="9.99999";}}
               printf ("%30s %15s ",$key, $node_hash{$key}); printf ("%.5f  ",$inside_view_hash{$node_hash{$key}}); printf ("%.10f \n",$meas_hash{$key}); 
}

Results:

2020年2月16日 星期日

C Shell -- Calculation

This script was written for plot all 8x8 ccst tables.

#!/bin/csh

set i = 1
while ($i < 65)
            cp CCST.$i CCST.print
            cp VOLTAGE.$i VOLTAGE.print
            echo $i
            gunplot print_all_ccst.gp
            @ i = $i + 1
               ^
end


#### print_all_ccst.gp ####
#!/usr/bin/gnuplot

plot "CCST.print" using 1:2 with linespoints title "CCST"
pause mouse "click any mouse button on selected data point"
plot "VOLTAGE.print" using 1:2 with linespoints title "VOLTAGE"
pause mouse "click any mouse button on selected data point"

標籤