Question-and-Answer Resource for the Building Energy Modeling Community
Get s tarted with the Help page
Ask Your Question
3

script to evaluate glare in multiple images

asked 2016-04-20 12:01:10 -0500

basdav gravatar image

updated 2017-05-04 09:01:32 -0500

hi all

this might be the most basic thing but can anyone help me, I need to know if the following script is right fur applying evalglare to multiple HDR images? if so, please point me the ‘obvious’ mistake..

I have this:

for t in {8..12}; do evalglare -d -vf view/vh1.vf imgs/back_$t.hdr > gout/back_$t.txt; done

Im applying to few images to simplify the test, I checked the route by trying with a single image…but for some reason is not doing the loop, the error says: Can't open imgs/back_8.hdr Can't open imgs/back_9.hdr Can't open imgs/back_10.hdr Can't open imgs/back_11.hdr Can't open imgs/back_12.hdr

I'll appreciate your help

Chantal

edit retag flag offensive close merge delete

Comments

At first glance, it looks like you either have a search path issue, or the HDR images are corrupted. Need more info to be more helpful, though; looks like a csh script but it would be good to know for sure. What's the script really look like? Is there a shebang line? How are you calling the thing?

rpg777 gravatar image rpg777  ( 2016-04-20 14:11:13 -0500 )edit

It's actually bash. seems to me that the path to the image is the problem. Make sure that you are running the script from the directory that contains the imgs directory and that you don't have any cd commands before the loop.

Andyrew gravatar image Andyrew  ( 2016-04-20 19:01:14 -0500 )edit

Also, does your file name have leading zeros? Usually image sequences have leading zeros like this: back_0008.hdr

Andyrew gravatar image Andyrew  ( 2016-04-20 19:04:15 -0500 )edit

HI all, Thank you for your reply (and sorry for the late one from my side)...

The problem was with the preceeding zeroes (thank you for that). I modified the script this way:

for t in {8..12}; do evalglare -d -vf view/vh1.vf imgs/back_*$t.hdr > gout/back_$t.txt; done

Strangely the first 8 images report a nul file (not zero in the results, just the file has zero bytes). But anyway after several testings with further images this doesn't seem to be a serious issue.

basdav gravatar image basdav  ( 2016-04-21 00:21:26 -0500 )edit

Btw... May I ask if there is any way to get the results in a single output-file, without the need of extracting data from original files?

Thank you again for your help!

Ch.

basdav gravatar image basdav  ( 2016-04-21 00:28:42 -0500 )edit

1 Answer

Sort by » oldest newest most voted
3

answered 2016-04-21 12:48:52 -0500

updated 2016-04-21 12:52:57 -0500

I'm going to put the comments in an answer so the question can be resolved.

The problem is leading zeros. imgs/back_0008.hdr isn't the same as imgs/back_8.hdr. So the variable used in the filename needs to have leading zeros. imgs/back_*${t}.hdr works for this example that runs from 8-12, but as soon as you have images up to 18, it will no longer work because both imgs/back_0008.hdr and imgs/back_0018.hdr match imgs/back_*\${t}.hdr when t=8.

for bash 4 you can use:

for t in {0008..0012} ; do

But OSX ships with bash 3. When using bash 3 on OSX i typically use printf to make a variable with leading zeros like this:

for t in {8..12}; do 
    ts=`printf "%04d" ${t}` ;
    evalglare -d -vf view/vh1.vf imgs/back_${ts}.hdr ;
done > gout/back_allresults.txt

Also, moving the redirect outside the loop sends all standard out generated within the loop to the same file.

edit flag offensive delete link more

Comments

just a note, the ` in the below line is a back tick, not a single quote. It won't work with single quote. Back tick is the key with a tilde to the left of the one on most american keyboards.

ts=`printf "%04d" ${t}`
Andyrew gravatar image Andyrew  ( 2016-04-21 12:55:51 -0500 )edit

Thank you so much! I really appreciate this! Best weekend...
Chantal.

basdav gravatar image basdav  ( 2016-04-22 13:58:29 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

 

Question Tools

1 follower

Stats

Asked: 2016-04-20 12:01:10 -0500

Seen: 164 times

Last updated: Apr 21 '16