[Radiance-general] Falsecolor and script by csh

Thomas Bleicher tbleicher at googlemail.com
Thu Feb 10 06:08:56 PST 2011


Hello.

On Thu, Feb 10, 2011 at 5:07 AM, caria.roberto at tiscali.it <
caria.roberto at tiscali.it> wrote:

When I use falsecolor I get a file with 1K size and the tiff comand
> gives me "bad picture:
>
> falsecolor pics/lum_gensky_sky_$months[$i].$days[$i].$hours[$i].pic -
> m 179 -s 10000 -l cd/m2 -n 10 > pics/lum_gen_sky_$months[$i].$days
> [$i].$hours[$i].fc.pic
>

falsecolor works like a UNIX filter: it expects data at stdin and writes
modified data to stdout. If you want to specify a filename as input you have
to use the '-i' option.

Writing programs like filters allows you to combine the output of one
program to connect directly with the input of the next without intermediate
(potentially large) files.

Another question is about a script and the "if" function; the script
> is showen below:
>

[...]


> set cloud = `cat data_sky/cloud.dat`
> set i = 1
> while ($i < 10)
>     echo cloud cover for index $i is $cloud[$i]
>     set value = `echo $cloud[$1] | cut -d '.' -f 1`
>          if ($value <= 3) then
>               set sky = "+s"
>          else if ($value <= 7 && $value >= 4) then
>               set sky = "+i"
>          else if ($value <= 10 && $value >= 8) then
>               set sky = "-c"

         endif

         echo $sky
>    @ i++
> end
>
> Maybe the if function is not able to read the data values?
>

When you specified your array in the first example the numbers were
interpreted as numbers. When you read from a file they are at first just
strings. The syntax error is raised because CSH recognises the variable as a
string and wants quotes around the left side of the test ( if ( "$value" <=
3 ) ... ). However, that's not your problem. You have to convert the strings
to numbers to compare against another number in the if condition. Here is a
(slightly cleaned up) version. Note the line with the `expr ...` in it.

set cloud = `cat cloud_cover.dat`
set i = 1
while ($i<10)
    echo "cloud cover for index $i is $cloud[$i]"
    set value_s = `echo $cloud[$i] | cut -d '.' -f 1`
    set value = `expr $value_s`

    if ( $value <= 3 ) then
        set sky = "+s"
    else if ( $value <= 7 ) then
        set sky = "+i"
    else
        set sky = "-c"
    endif

    echo "cloud: $cloud[$i]   sky: $sky"
    @ i++
end


PS: If you are new to shell scripting you should consider switching to bash.
It's more popular and doesn't have as many syntax oddities as CSH.

Thomas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.radiance-online.org/pipermail/radiance-general/attachments/20110210/544827d9/attachment.html>


More information about the Radiance-general mailing list