--- ray/src/cv/iso2klems.pl 2022/03/08 19:50:06 2.2 +++ ray/src/cv/iso2klems.pl 2022/08/12 23:55:00 2.4 @@ -1,5 +1,5 @@ #!/usr/bin/perl -w -# RCSid $Id: iso2klems.pl,v 2.2 2022/03/08 19:50:06 greg Exp $ +# RCSid $Id: iso2klems.pl,v 2.4 2022/08/12 23:55:00 greg Exp $ # # Convert tabulated isotropic direct-hemispherical and direct-direct to Klems XML # @@ -48,13 +48,13 @@ system "cat @ARGV | tabfunc -i @vnm > $funcfile"; die "Invalid input data, requires 5 columns\n" if ( $? ); open (MYFH, ">> $funcfile"); print MYFH "DEG : PI/180;\n"; -print MYFH "and(a,b) : if(a,b,a);\n"; +print MYFH "sq(x) : x*x;\n"; print MYFH "eq(a,b) : min(a-b+1e-5,b-a+1e-5);\n"; print MYFH "rtheta(i) : select(i,5,15,25,35,45,55,65,75,90);\n"; print MYFH "nphis(i) : select(i,1,8,16,20,24,24,24,16,12);\n"; print MYFH "tdeg1(tb) : if(tb-1.5, (rtheta(tb)+rtheta(tb-1))/2, 0);\n"; -print MYFH "omega1(tb) : 2*PI*if(tb-1.5, (cos(rtheta(tb-1)*DEG)-cos(rtheta(tb)*DEG))/nphis(tb),"; -print MYFH "\t(1 - cos(rtheta(1)*DEG)));\n"; +print MYFH "omega1(tb) : PI*if(tb-1.5, (sq(cos(rtheta(tb-1)*DEG))-sq(cos(rtheta(tb)*DEG)))/nphis(tb),"; +print MYFH "\t(1 - sq(cos(rtheta(1)*DEG))));\n"; print MYFH "tbin(b,cnt) : if(nphis(b)-cnt-.5, b, tbin(b+1,cnt-nphis(b)));\n"; print MYFH "tdeg(b) : tdeg1(tbin(1,b-1));\n"; print MYFH "omega(b) : omega1(tbin(1,b-1));\n"; @@ -65,13 +65,13 @@ my $nsamps = $hsamps * 2; if ($windoz) { $cmd = qq{cnt $nsamps } . qq{| rcalc -f $funcfile -w -e "tdeg=180/$nsamps*(\$1+.5);abs(x):if(x,x,-x)" } . - qq{-e "theta=tdeg*DEG;ifact=2*PI*abs(cos(theta))*sin(theta)" } . + qq{-e "theta=tdeg*DEG;ifact=PI*PI*abs(cos(theta))*sin(theta)" } . q{-e "$1=ifact*Tdiff(tdeg);$2=ifact*Rdiff(tdeg)" } . qq{| total -$hsamps -m}; } else { $cmd = qq{cnt $nsamps } . qq{| rcalc -f $funcfile -w -e 'tdeg=180/$nsamps*(\$1+.5);abs(x):if(x,x,-x)' } . - qq{-e 'theta=tdeg*DEG;ifact=2*PI*abs(cos(theta))*sin(theta)' } . + qq{-e 'theta=tdeg*DEG;ifact=PI*PI*abs(cos(theta))*sin(theta)' } . q{-e '$1=ifact*Tdiff(tdeg);$2=ifact*Rdiff(tdeg)' -od } . qq{| total -id2 -$hsamps -m}; } @@ -91,10 +91,10 @@ if ($windoz) { qq{-e "Rd1=if($h2h[1]-.001,Rdiff(tideg)*Rdiff(tsdeg)/$h2h[1],0)" } . qq{-e "Td2=if($h2h[2]-.001,Tdiff(180-tideg)*Tdiff(180-tsdeg)/$h2h[2],0)" } . qq{-e "Rd2=if($h2h[3]-.001,Rdiff(180-tideg)*Rdiff(180-tsdeg)/$h2h[3],0)" } . - qq{-e "\$1=if(Tspec(0),if(diag,Tspec(tideg)/om,Td1*corr),Td1)" } . - qq{-e "\$2=if(Rspec(0),if(diag,Rspec(tideg)/om,Rd1*corr),Rd1)" } . - qq{-e "\$3=if(Tspec(180),if(diag,Tspec(180-tideg)/om,Td2*corr),Td2)" } . - qq{-e "\$4=if(Rspec(180),if(diag,Rspec(180-tideg)/om,Rd2*corr),Rd2)" }; + q{-e "$1=if(Tspec(0),if(diag,Tspec(tideg)/om,Td1*corr),Td1)" } . + q{-e "$2=if(Rspec(0),if(diag,Rspec(tideg)/om,Rd1*corr),Rd1)" } . + q{-e "$3=if(Tspec(180),if(diag,Tspec(180-tideg)/om,Td2*corr),Td2)" } . + q{-e "$4=if(Rspec(180),if(diag,Rspec(180-tideg)/om,Rd2*corr),Rd2)" }; } else { $cmd = qq{cnt 145 145 } . qq{| rcalc -f $funcfile } . @@ -103,10 +103,10 @@ if ($windoz) { qq{-e 'Rd1=if($h2h[1]-.001,Rdiff(tideg)*Rdiff(tsdeg)/$h2h[1],0)' } . qq{-e 'Td2=if($h2h[2]-.001,Tdiff(180-tideg)*Tdiff(180-tsdeg)/$h2h[2],0)' } . qq{-e 'Rd2=if($h2h[3]-.001,Rdiff(180-tideg)*Rdiff(180-tsdeg)/$h2h[3],0)' } . - qq{-e '\$1=if(Tspec(0),if(diag,Tspec(tideg)/om,Td1*corr),Td1)' } . - qq{-e '\$2=if(Rspec(0),if(diag,Rspec(tideg)/om,Rd1*corr),Rd1)' } . - qq{-e '\$3=if(Tspec(180),if(diag,Tspec(180-tideg)/om,Td2*corr),Td2)' } . - qq{-e '\$4=if(Rspec(180),if(diag,Rspec(180-tideg)/om,Rd2*corr),Rd2)' }; + q{-e '$1=if(Tspec(0),if(diag,Tspec(tideg)/om,Td1*corr),Td1)' } . + q{-e '$2=if(Rspec(0),if(diag,Rspec(tideg)/om,Rd1*corr),Rd1)' } . + q{-e '$3=if(Tspec(180),if(diag,Tspec(180-tideg)/om,Td2*corr),Td2)' } . + q{-e '$4=if(Rspec(180),if(diag,Rspec(180-tideg)/om,Rd2*corr),Rd2)' }; } system qq{$cmd | rsplit "-t " $TK1dataf $RK1dataf $TK2dataf $RK2dataf}; die "Error running rcalc or rsplit" if ( $? );