| 7 |
|
# |
| 8 |
|
use strict; |
| 9 |
|
my @skycolor = (0.960, 1.004, 1.118); |
| 10 |
+ |
my $mf = 4; |
| 11 |
|
while ($#ARGV >= 0) { |
| 12 |
|
if ("$ARGV[0]" eq "-c") { |
| 13 |
|
@skycolor = @ARGV[1..3]; |
| 14 |
|
shift @ARGV; shift @ARGV; shift @ARGV; |
| 15 |
+ |
} elsif ("$ARGV[0]" eq "-m") { |
| 16 |
+ |
$mf = $ARGV[1]; |
| 17 |
+ |
shift @ARGV; |
| 18 |
|
} |
| 19 |
|
shift @ARGV; |
| 20 |
|
} |
| 52 |
|
my $rhcal = ' |
| 53 |
|
DEGREE : PI/180; |
| 54 |
|
x1 = .5; x2 = .5; |
| 51 |
– |
MF : 2^2; |
| 55 |
|
alpha : 90/(MF*7 + .5); |
| 56 |
|
tnaz(r) : select(r, 30, 30, 24, 24, 18, 12, 6); |
| 57 |
|
rnaz(r) : if(r-(7*MF-.5), 1, MF*tnaz(floor((r+.5)/MF) + 1)); |
| 59 |
|
RowMax : 7*MF + 1; |
| 60 |
|
Rmax : raccum(RowMax); |
| 61 |
|
Rfindrow(r, rem) : if(rem-rnaz(r)-.5, Rfindrow(r+1, rem-rnaz(r)), r); |
| 62 |
< |
Rrow = if(Rbin-(Rmax +.5), RowMax, Rfindrow(0, Rbin)); |
| 62 |
> |
Rrow = if(Rbin-(Rmax-.5), RowMax-1, Rfindrow(0, Rbin)); |
| 63 |
|
Rcol = Rbin - raccum(Rrow) - 1; |
| 64 |
|
Razi_width = 2*PI / rnaz(Rrow); |
| 65 |
|
RAH : alpha*DEGREE; |
| 66 |
|
Razi = if(Rbin-.5, (Rcol + x2 - .5)*Razi_width, 2*PI*x2); |
| 67 |
< |
Ralt = if(Rbin-.5, (Rrow + x1)*RAH, asin(2*x1-1)); |
| 67 |
> |
Ralt = if(Rbin-.5, (Rrow + x1)*RAH, asin(-x1)); |
| 68 |
|
Romega = if(.5-Rbin, 2*PI, if(Rmax-.5-Rbin, |
| 69 |
|
Razi_width*(sin(RAH*(Rrow+1)) - sin(RAH*Rrow)), |
| 70 |
|
2*PI*(1 - cos(RAH/2)) ) ); |
| 73 |
|
Dy = cos(Razi)*cos_ralt; |
| 74 |
|
Dz = sin(Ralt); |
| 75 |
|
'; |
| 76 |
< |
my $nbins = 2306; # This needs to be consistent with MF setting above |
| 76 |
> |
my $nbins = `rcalc -n -e MF:$mf -e \'$rhcal\' -e \'\$1=Rmax+1\'`; |
| 77 |
> |
chomp $nbins; |
| 78 |
|
# Create octree for rtrace |
| 79 |
|
my $octree = "/tmp/gtv$$.oct"; |
| 80 |
|
open OCONV, "| oconv - > $octree"; |
| 83 |
|
print OCONV "skyglow source sky 0 0 4 0 0 1 360\n"; |
| 84 |
|
close OCONV; |
| 85 |
|
# Run rtrace and average output for every 16 samples |
| 86 |
< |
my $tregcommand = "cnt $nbins 16 | rcalc -of -e '$rhcal' " . |
| 86 |
> |
my $tregcommand = "cnt $nbins 16 | rcalc -of -e MF:$mf -e '$rhcal' " . |
| 87 |
|
q{-e 'Rbin=$1;x1=rand(recno*.37-5.3);x2=rand(recno*-1.47+.86)' } . |
| 88 |
|
q{-e '$1=0;$2=0;$3=0;$4=Dx;$5=Dy;$6=Dz' } . |
| 89 |
|
"| rtrace -h -ff -ab 0 -w $octree | total -if3 -16 -m"; |
| 93 |
|
my @bestdir; |
| 94 |
|
if (@sundir) { |
| 95 |
|
my $somega = ($sundir[3]/360)**2 * 3.141592654**3; |
| 96 |
< |
my $cmd = "cnt $nbins | rcalc -e '$rhcal' -e Rbin=recno " . |
| 96 |
> |
my $cmd = "cnt " . ($nbins-1) . |
| 97 |
> |
" | rcalc -e MF:$mf -e '$rhcal' -e Rbin=recno " . |
| 98 |
|
"-e 'dot=Dx*$sundir[0] + Dy*$sundir[1] + Dz*$sundir[2]' " . |
| 99 |
|
"-e 'cond=dot-.866' " . |
| 100 |
|
q{-e '$1=if(1-dot,acos(dot),0);$2=Romega;$3=recno' }; |
| 109 |
|
my $wt = 1./($ang[$i]+.02)/$wtot * $somega / $dom[$i]; |
| 110 |
|
my @scolor = split(/\s+/, $tregval[$ndx[$i]]); |
| 111 |
|
for my $j (0..2) { $scolor[$j] += $wt * $sunval[$j]; } |
| 112 |
< |
$tregval[$ndx[$i]] = "@scolor\n"; |
| 112 |
> |
$tregval[$ndx[$i]] = "$scolor[0]\t$scolor[1]\t$scolor[2]\n"; |
| 113 |
|
} |
| 114 |
|
} |
| 115 |
|
# Output our final vector |