ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/cv/iso2klems.pl
(Generate patch)

Comparing ray/src/cv/iso2klems.pl (file contents):
Revision 2.2 by greg, Tue Mar 8 19:50:06 2022 UTC vs.
Revision 2.6 by greg, Thu Oct 6 14:22:44 2022 UTC

# Line 42 | Line 42 | while ($#ARGV >= 0) {
42          }
43          shift @ARGV;
44   }
45 + userror() if ($#ARGV > 0);
46   my $funcfile = "$td/isofuncs.cal";
47   my @vnm = ("Tspec","Tdiff","Rspec","Rdiff");
48 < system "cat @ARGV | tabfunc -i @vnm > $funcfile";
48 > if ($#ARGV == 0) {
49 >        system "tabfunc -i @vnm < \"$ARGV[0]\" > $funcfile";
50 > } else {
51 >        system "tabfunc -i @vnm > $funcfile";
52 > }
53   die "Invalid input data, requires 5 columns\n" if ( $? );
54   open (MYFH, ">> $funcfile");
55   print MYFH "DEG : PI/180;\n";
56 < print MYFH "and(a,b) : if(a,b,a);\n";
56 > print MYFH "sq(x) : x*x;\n";
57   print MYFH "eq(a,b) : min(a-b+1e-5,b-a+1e-5);\n";
58   print MYFH "rtheta(i) : select(i,5,15,25,35,45,55,65,75,90);\n";
59   print MYFH "nphis(i) : select(i,1,8,16,20,24,24,24,16,12);\n";
60   print MYFH "tdeg1(tb) : if(tb-1.5, (rtheta(tb)+rtheta(tb-1))/2, 0);\n";
61 < print MYFH "omega1(tb) : 2*PI*if(tb-1.5, (cos(rtheta(tb-1)*DEG)-cos(rtheta(tb)*DEG))/nphis(tb),";
62 < print MYFH "\t(1 - cos(rtheta(1)*DEG)));\n";
61 > print MYFH "omega1(tb) : PI*if(tb-1.5, (sq(cos(rtheta(tb-1)*DEG))-sq(cos(rtheta(tb)*DEG)))/nphis(tb),";
62 > print MYFH "\t(1 - sq(cos(rtheta(1)*DEG))));\n";
63   print MYFH "tbin(b,cnt) : if(nphis(b)-cnt-.5, b, tbin(b+1,cnt-nphis(b)));\n";
64   print MYFH "tdeg(b) : tdeg1(tbin(1,b-1));\n";
65   print MYFH "omega(b) : omega1(tbin(1,b-1));\n";
# Line 65 | Line 70 | my $nsamps = $hsamps * 2;
70   if ($windoz) {
71          $cmd = qq{cnt $nsamps } .
72                  qq{| rcalc -f $funcfile -w -e "tdeg=180/$nsamps*(\$1+.5);abs(x):if(x,x,-x)" } .
73 <                qq{-e "theta=tdeg*DEG;ifact=2*PI*abs(cos(theta))*sin(theta)" } .
73 >                qq{-e "theta=tdeg*DEG;ifact=PI*PI*abs(cos(theta))*sin(theta)" } .
74                  q{-e "$1=ifact*Tdiff(tdeg);$2=ifact*Rdiff(tdeg)" } .
75                  qq{| total -$hsamps -m};
76   } else {
77          $cmd = qq{cnt $nsamps } .
78                  qq{| rcalc -f $funcfile -w -e 'tdeg=180/$nsamps*(\$1+.5);abs(x):if(x,x,-x)' } .
79 <                qq{-e 'theta=tdeg*DEG;ifact=2*PI*abs(cos(theta))*sin(theta)' } .
79 >                qq{-e 'theta=tdeg*DEG;ifact=PI*PI*abs(cos(theta))*sin(theta)' } .
80                  q{-e '$1=ifact*Tdiff(tdeg);$2=ifact*Rdiff(tdeg)' -od } .
81                  qq{| total -id2 -$hsamps -m};
82   }
# Line 91 | Line 96 | if ($windoz) {
96                  qq{-e "Rd1=if($h2h[1]-.001,Rdiff(tideg)*Rdiff(tsdeg)/$h2h[1],0)" } .
97                  qq{-e "Td2=if($h2h[2]-.001,Tdiff(180-tideg)*Tdiff(180-tsdeg)/$h2h[2],0)" } .
98                  qq{-e "Rd2=if($h2h[3]-.001,Rdiff(180-tideg)*Rdiff(180-tsdeg)/$h2h[3],0)" } .
99 <                qq{-e "\$1=if(Tspec(0),if(diag,Tspec(tideg)/om,Td1*corr),Td1)" } .
100 <                qq{-e "\$2=if(Rspec(0),if(diag,Rspec(tideg)/om,Rd1*corr),Rd1)" } .
101 <                qq{-e "\$3=if(Tspec(180),if(diag,Tspec(180-tideg)/om,Td2*corr),Td2)" } .
102 <                qq{-e "\$4=if(Rspec(180),if(diag,Rspec(180-tideg)/om,Rd2*corr),Rd2)" };
99 >                q{-e "$1=if(Tspec(0),if(diag,Tspec(tideg)/om,Td1*corr),Td1)" } .
100 >                q{-e "$2=if(Rspec(0),if(diag,Rspec(tideg)/om,Rd1*corr),Rd1)" } .
101 >                q{-e "$3=if(Tspec(180),if(diag,Tspec(180-tideg)/om,Td2*corr),Td2)" } .
102 >                q{-e "$4=if(Rspec(180),if(diag,Rspec(180-tideg)/om,Rd2*corr),Rd2)" };
103   } else {
104          $cmd = qq{cnt 145 145 } .
105                  qq{| rcalc -f $funcfile } .
# Line 103 | Line 108 | if ($windoz) {
108                  qq{-e 'Rd1=if($h2h[1]-.001,Rdiff(tideg)*Rdiff(tsdeg)/$h2h[1],0)' } .
109                  qq{-e 'Td2=if($h2h[2]-.001,Tdiff(180-tideg)*Tdiff(180-tsdeg)/$h2h[2],0)' } .
110                  qq{-e 'Rd2=if($h2h[3]-.001,Rdiff(180-tideg)*Rdiff(180-tsdeg)/$h2h[3],0)' } .
111 <                qq{-e '\$1=if(Tspec(0),if(diag,Tspec(tideg)/om,Td1*corr),Td1)' } .
112 <                qq{-e '\$2=if(Rspec(0),if(diag,Rspec(tideg)/om,Rd1*corr),Rd1)' } .
113 <                qq{-e '\$3=if(Tspec(180),if(diag,Tspec(180-tideg)/om,Td2*corr),Td2)' } .
114 <                qq{-e '\$4=if(Rspec(180),if(diag,Rspec(180-tideg)/om,Rd2*corr),Rd2)' };
111 >                q{-e '$1=if(Tspec(0),if(diag,Tspec(tideg)/om,Td1*corr),Td1)' } .
112 >                q{-e '$2=if(Rspec(0),if(diag,Rspec(tideg)/om,Rd1*corr),Rd1)' } .
113 >                q{-e '$3=if(Tspec(180),if(diag,Tspec(180-tideg)/om,Td2*corr),Td2)' } .
114 >                q{-e '$4=if(Rspec(180),if(diag,Rspec(180-tideg)/om,Rd2*corr),Rd2)' };
115   }
116   system qq{$cmd | rsplit "-t " $TK1dataf $RK1dataf $TK2dataf $RK2dataf};
117   die "Error running rcalc or rsplit" if ( $? );

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines