[Radiance-general] calculating percentages of a given value in
a .dat / .ok file
Lars O. Grobe
grobe at gmx.net
Wed Mar 10 17:31:17 PST 2010
Hi,
I am not sure whether Nick wants to find out the fraction of the
required illuminance level each point achieves (that is what Andrew
calculates) or the fraction of (the amount of) points that meet the
criteria. For the second you have three steps involved:
1) filter the input according to you treshold (300lx)
2) count the value meeting the criteria
3) divide by the total number of points and multiply by 100 to get a
percentage
This can be translated like into:
cat test.dat | rcalc -e '$1=1; $2=if($1-299,1,0)' | total | rcalc -e
'$1=100*$2/$1'
The first step, rcalc, takes one column (you can adapt this according to
your input file) and writes out two columns. The first is set to 1 for
any input, the second is set to one for inputs > 2990 and to 0 for
anything below.
The second step, total, sums up the result of the first step. You get
the sums of two columns - two numbers, the first being the amount of
original input values, the second the amount of values that are above 299.
The third step, rcalc again, divides the number of points meeting the
criteria by the total number of values and multiplies this by 100. This
results in the percentage of values meeting the criteria.
There are quicker ways to achieve this, but I wanted a transparent
format that one can explain. Hope this helps, cheers
Lars.
More information about the Radiance-general
mailing list