calculating number of daylight hours

Happy holidays list!

I am trying to calculate the number of daylight-hours falling on a surface from a series of images in a batch file. I have an image created using -ab 0 and want to convert it into an image that shows a value of 1 for areas receiving direct sun or value of 0 for areas that do not.
I feel like pvalue is what I need to do this. I am following this thread with limited success ( When I try to modify for my task, I am having trouble getting the desired result.

pvalue -d -h -H input.pic | rcalc -e '$1=if(179*$1-100,1,0)' gives an expected result of either a 0 or 1 depending on if the value is above or below the desired threshold.
If I then pipe the result back into pvalue I get a "pvalue: read error" and no image:
pvalue -d -h -H input.pic | rcalc -e '$1=if(179*$1-100,1,0)' | pvalue -r -H -h -d -y 693 +x 1200 > output.pic
Do I need to format the input values differently?

I was also able to somewhat successfully use pcomb to strip the original image into a black and white image using the same "if" condition on lo=, but there was no value associated with the pixels.
Ultimately, I would like to take a series of images and pcomb them in order to make a falsecolor display of sunlight hours in a space/on a surface. I realize it may be easier to calculate with rtrace and then display my results that way, but this was my first thought.

Thanks in advance for any assistance. I'm open to any suggestions you might have.

Chris M. Coulter, LC, IES, LEED AP BD+C
Lighting Designer
500 Griswold, Suite 1700
Detroit, MI 48226

Hi Chris!

pvalue –d –h –H input.pic | rcalc –e ‘$1=if(179*$1-100,1,0)’ | pvalue
–r –H –h –d –y 693 +x 1200 > output.pic

I could not dig deeper into the topic now or try it, but my guess is
that (unless something magic is going on) pvalue -r expects pixel values
for more then one channel. You are only passing the first channel ($1 in
the rcalc expression).

If you use only the first channel ("R") in your simulations to record
results of the -ab 0 calculation, you can ignore the other two channels
("B", "G") and zero them in the output:

pvalue –d –h –H input.hdr | rcalc –e ‘$1=if(179*$1-100,1,0); $2=0; $3=0’

pvalue –r –H –h –d –y 693 +x 1200 > output.hdr

Sorry, I could not resist but change the file extensions from pic to hdr
:slight_smile: So while I am not sure whether this solves the problem, it may hint
you to the error.

Cheers, Lars.

1 Like


Thank you for the response. I thought I had tried that in another test (which I had). Just tinkering around and looking at the original data, I realized that I had at some point switched on the -u option of pvalue to list only the unique values. Once I realized that, my full command line works! I'm sure that switching from a pic extension to hdr helped as well :wink:
I also realized that I would need to divide my 1's by 179 again to get back to the desired units in my images.

Thanks for the help! Hopefully I don't make any more mistakes when I wrap this into my script to generate the data.