orig/vlpic.csh
author Axel Jacobs <axel@jaloxa.eu>
Mon, 14 Apr 2014 22:21:17 +0100
changeset 73 87fa3132a136
parent 0 0aa115157c9c
permissions -rw-r--r--
New IES test file with spaces in file name
axel@0
     1
#!/bin/csh -f
axel@0
     2
# RCSid: $Id: vlpic.csh,v 3.4 2008/08/25 04:50:32 greg Exp $
axel@0
     3
#
axel@0
     4
# Compute falsecolor image of visibility level
axel@0
     5
# using the wacky formulas of Werner Adrian.
axel@0
     6
#
axel@0
     7
set age=40			# default age (years)
axel@0
     8
set tim=.2			# default time (seconds)
axel@0
     9
while ($#argv > 1)
axel@0
    10
	switch ($argv[1])
axel@0
    11
	case -a:
axel@0
    12
		shift argv
axel@0
    13
		set age="$argv[1]"
axel@0
    14
		breaksw
axel@0
    15
	case -t:
axel@0
    16
		shift argv
axel@0
    17
		set tim="$argv[1]"
axel@0
    18
		breaksw
axel@0
    19
	default:
axel@0
    20
		echo bad option "'$argv[1]'"
axel@0
    21
		exit 1
axel@0
    22
	endsw
axel@0
    23
	shift argv
axel@0
    24
end
axel@0
    25
set tc=`mktemp /tmp/vlcal.XXXXXXX`
axel@0
    26
set tp1=`mktemp /tmp/vlpic.XXXXXX`
axel@0
    27
set tp2=`mktemp /tmp/vlr2pic.XXXXXX`
axel@0
    28
set tp4=`mktemp /tmp/vlr4pic.XXXXXX`
axel@0
    29
set tp8=`mktemp /tmp/vlr8pic.XXXXXX`
axel@0
    30
set tf=($tc $tp1 $tp2 $tp4 $tp8)
axel@0
    31
set inpic=$argv[1]
axel@0
    32
onintr quit
axel@0
    33
set pr=(`getinfo -d < $inpic | sed 's/^-Y \([1-9][0-9]*\) +X \([1-9][0-9]*\)$/\2 \1/'`)
axel@0
    34
# ( vwright V < $inpic ; cat ) > $tc << _EOF_
axel@0
    35
cat > $tc << _EOF_
axel@0
    36
{ A : 3438 * sqrt(Vhn/xmax*Vvn/ymax);	{ pixel size (in minutes) } }
axel@0
    37
PI : 3.14159265358979323846;
axel@0
    38
A = 180*60/PI * sqrt(S(1)/PI);
axel@0
    39
sq(x) : x*x;
axel@0
    40
max(a,b) : if(a-b, a, b);
axel@0
    41
Lv : 0;		{ veiling luminance {temporarily zero} }
axel@0
    42
		{ find direction of maximum contrast }
axel@0
    43
xoff(d) = select(d, 1, 1, 0, -1, -1, -1, 0, 1);
axel@0
    44
yoff(d) = select(d, 0, 1, 1, 1, 0, -1, -1, -1);
axel@0
    45
cf(lf, lb) = (lf - lb)/(lb + Lv);
axel@0
    46
contrast(d) = cf(li(1,xoff(d),yoff(d)), li(1,-xoff(d),-yoff(d)));
axel@0
    47
cwin(d1, d2) = if(contrast(d1) - contrast(d2), d1, d2);
axel@0
    48
bestdir(d) = if(d-1.5, cwin(d, bestdir(d-1)), d);
axel@0
    49
maxdir = bestdir(8);
axel@0
    50
Lt = WE*li(1,xoff(maxdir),yoff(maxdir)) + Lv;
axel@0
    51
La = WE*li(1,-xoff(maxdir),-yoff(maxdir)) + Lv;
axel@0
    52
LLa = log10(La);
axel@0
    53
F = if(La-.6, log10(4.1925) + LLa*.1556 + .1684*La^.5867,
axel@0
    54
	if(La-.00418, 10^(-.072 + LLa*(.3372 + LLa*.0866)),
axel@0
    55
		10^(.028 + .173*LLa)));
axel@0
    56
L = if(La-.6, .05946*La^.466,
axel@0
    57
	if(La-.00418, 10^(-1.256 + .319*LLa),
axel@0
    58
		10^(-.891 + LLa*(.5275 + LLa*.0227))));
axel@0
    59
LAt = log10(A) + .523;
axel@0
    60
AA = .36 - .0972*LAt*LAt/(LAt*(LAt - 2.513) + 2.7895);
axel@0
    61
LLat = LLa + 6;
axel@0
    62
AL = .355 - .1217*LLat*LLat/(LLat*(LLat - 10.4) + 52.28);
axel@0
    63
AZ = sqrt(AA*AA + AL*AL)/2.1;
axel@0
    64
DL1 = 2.6*sq(F/A + L);
axel@0
    65
M = if(La-.004, 10^-(10^-(if(La-.1,.125,.075)*sq(LLa+1) + .0245)), 0);
axel@0
    66
TGB = .6*La^-.1488;
axel@0
    67
FCP = 1 - M*A^-TGB/(2.4*(DL1*(AZ+2)/2));
axel@0
    68
DL2 = DL1*(AZ + T)/T;
axel@0
    69
FA = if(Age-64, sq(Age-56.6)/116.3 + 1.43, sq(Age-19)/2160 + .99);
axel@0
    70
DL3 = DL2 * FA;
axel@0
    71
DL4 = if(La-Lt, DL3*FCP, DL3);
axel@0
    72
lo = (Lt - La)/DL4;		{ Output VL }
axel@0
    73
_EOF_
axel@0
    74
pcomb -w -e "Age:$age;T:$tim" -f $tc -o $inpic > $tp1
axel@0
    75
pfilt -1 -x /2 -y /2 $inpic \
axel@0
    76
	| pcomb -w -e "Age:$age;T:$tim" -f $tc -o - \
axel@0
    77
	| pfilt -1 -r 1 -x $pr[1] -y $pr[2] > $tp2
axel@0
    78
pfilt -1 -x /4 -y /4 $inpic \
axel@0
    79
	| pcomb -w -e "Age:$age;T:$tim" -f $tc -o - \
axel@0
    80
	| pfilt -1 -r 1 -x $pr[1] -y $pr[2] > $tp4
axel@0
    81
pfilt -1 -x /8 -y /8 $inpic \
axel@0
    82
	| pcomb -w -e "Age:$age;T:$tim" -f $tc -o - \
axel@0
    83
	| pfilt -1 -r 1 -x $pr[1] -y $pr[2] > $tp8
axel@0
    84
pcomb -e 'max(a,b):if(a-b,a,b)' -e 'lo=max(gi(1),max(gi(2),max(gi(3),gi(4))))' \
axel@0
    85
	$tp1 $tp2 $tp4 $tp8 \
axel@0
    86
	| falsecolor -l VL -s 56 -m 1 -r 'if(v-1/8,1.6*8/7*(v-1/8)-.6,0)' \
axel@0
    87
		-g 'if(v-1/8,if(v-.453125,1.6-1.6*8/7*(v-1/8),8/3*8/7*(v-1/8)),0)' \
axel@0
    88
		-b 'if(v-1/8,1-8/3*8/7*(v-1/8),0)'
axel@0
    89
quit:
axel@0
    90
rm -f $tf