Falsecolor and script by csh

Hi all,
I created a pic file with this comand:

rpict -w- view.vf -x 1600 -y 1600 -ab 5 -ad 4096 -as 4096 -ar 256 -
aa 0.2-t 60 oct/gensky_sky_$months[$i].$days[$i].$hours[$i].oct >
pics/lum_gensky_sky_$months[$i].$days[$i].$hours[$i].pic

and everything is fine (I can see the pic and the value are correct)

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

#ra_tiff -z pics/lum_gen_sky_$months[$i].$days[$i].$hours[$i].fc.pic
tiffs/lum_gensky_sky_$months[$i].$days[$i].$hours[$i].fc.tiff

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

foreach cloud (5 10 3 4 8 9 7 1 0 6 5)

      if ($cloud <= 3) then
               set sky = "+s"
                       else if ($cloud <= 7 && $cloud >= 4) then
               set sky = "+i"
                        else if ($cloud <= 10 && $cloud >= 8) then
              set sky = "-c"
       endif

      echo $sky
  
end

It works fine, but if I use a data values, by a text file (data
values put by one column), I get sintax error:

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?

Thanks a lot

Roberto

Supera i limiti: raddoppia la velocità da 10 a 20 Mega! Risparmia con Tutto Incluso: telefono + adsl 20 mega a soli 29,95 € al mese per due anni!SCONTO DI 240 EURO!http://abbonati.tiscali.it/telefono-adsl/prodotti/tc/tuttoincluso/?WT.mc_id=01fw

Hi Roberto!

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

You can pass the image data to be used as value input by falsecolor using

"falsecolor -i filename.hdr > output.hdr"

or by sending to to stdin, e.g.

"cat filename.hdr | falsecolor > output.hdr"

So just add a "-i" in front of the input filename in your script.

Besides that, I would recommend not to use the outdated pic-extension, but the officially registred hdr-extension. But that is a side-not.

echo cloud cover for index $i is $cloud[$i]

Does this work up to here?

Maybe the if function is not able to read the data values?

I have to admit that I do not like bash when working on strings and arrays too much. I usually switch to perl whenever I need to process strings, even if it is just splitting a record.

Cheers, Lars.

Hello.

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

···

On Thu, Feb 10, 2011 at 5:07 AM, [email protected] < [email protected]> wrote: