| 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 |
|
} |
| 32 |
|
$srcmod = $_; |
| 33 |
|
$lightline = $#skydesc; |
| 34 |
|
} elsif (defined($srcmod) && /^($srcmod)\s+source\s/) { |
| 35 |
< |
@sunval = split(/\s+/, $skydesc[$lightline + 3]); |
| 35 |
> |
@sunval = split(' ', $skydesc[$lightline + 3]); |
| 36 |
|
shift @sunval; |
| 37 |
|
$sunline = $#skydesc; |
| 38 |
|
} elsif (/\sskyfunc\s*$/) { |
| 43 |
|
# Strip out the solar source if present |
| 44 |
|
my @sundir; |
| 45 |
|
if (defined $sunline) { |
| 46 |
< |
@sundir = split(/\s+/, $skydesc[$sunline + 3]); |
| 46 |
> |
@sundir = split(' ', $skydesc[$sunline + 3]); |
| 47 |
|
shift @sundir; |
| 48 |
|
undef @sundir if ($sundir[2] <= 0); |
| 49 |
|
splice(@skydesc, $sunline, 5); |
| 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)); |
| 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"; |
| 94 |
|
if (@sundir) { |
| 95 |
|
my $somega = ($sundir[3]/360)**2 * 3.141592654**3; |
| 96 |
|
my $cmd = "cnt " . ($nbins-1) . |
| 97 |
< |
" | rcalc -e '$rhcal' -e Rbin=recno " . |
| 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' }; |
| 102 |
|
my (@ang, @dom, @ndx); |
| 103 |
|
my $wtot = 0; |
| 104 |
|
for my $i (0..2) { |
| 105 |
< |
($ang[$i], $dom[$i], $ndx[$i]) = split(/\s+/, $bestdir[$i]); |
| 105 |
> |
($ang[$i], $dom[$i], $ndx[$i]) = split(' ', $bestdir[$i]); |
| 106 |
|
$wtot += 1./($ang[$i]+.02); |
| 107 |
|
} |
| 108 |
|
for my $i (0..2) { |
| 109 |
|
my $wt = 1./($ang[$i]+.02)/$wtot * $somega / $dom[$i]; |
| 110 |
< |
my @scolor = split(/\s+/, $tregval[$ndx[$i]]); |
| 110 |
> |
my @scolor = split(' ', $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 |