Gendaymtx-like output for reflected (only) radiation

Hello,

gendaymtx generates a matrix representing the radiance (in W/m2-sr) for each patch of the sky and each timestep from a weather file.

I would like to generate an equivalent matrix, for a specific point on the ground, that represents only the reflected shortwave radiation for each patch direction and timestep in the weather file. The matrix would have 0 when the direction vector sees the sky and a radiance in W/m2-sr when the direction vector hits a different material. I hope it makes sense.

Thanks!

Are you trying to compute the cosine-weighted integral of reflected contribution at a point for each time step, or do you actually need a map of non-sky regions with a Reinhart or Tregenza subdivision?

Integrating the indirect should be possible using rfluxmtx with a uniform (h=u) sender patch and the -dv- option to make the sky appear black. The receiver would be a sky matching the subdivision out of gendaymtx (which defaults to h=r1). This calculation would yield a vector that when multiplied against the output of gendaymtx would give you a single integrated value per time step.

To get a Reinhart or Tregenza map, you could use rfluxmtx again with the -dv- option and a sender patch with your desired subdivision (e.g., h=r4) to compute a matrix that when multiplied against the output of gendaymtx would yield a matrix with indirect contribution vectors per time step. (The sky receiver would be the same as above.)

I have not tried this, so caveat emptor and all that.

-Greg

P.S. Edited to correct my mix-up of receivers and senders. Also, the sky needs to be modified by “light” rather than “glow” for the -dv- option to work.

Thanks Greg, that helped. To be sure I understand what I am doing, this is a simple example that works for one direction at the time

#geometry.rad
void plastic base_material
0
0
5 0.47 0.403 0.337 0.0 0.0

base_material polygon shading_device
0
0
12
    10 0 0
    10 0 10
    10 10 10
    10 10 0
#receiver.rad
# Combined ground and sky vault
# Start by telling rfluxmtx to generate a single coefficient for the ground:
#@rfluxmtx u=+Y h=u

void glow groundglow
0 0 4 .8 1.1 .8 0
groundglow source ground
0 0 4 0 0 -1 180

# Now, tell rfluxmtx to generate a set of Tregenza sky patches using Y for "north/up":
#@rfluxmtx u=+Y h=r1

void glow sky_glow
0 0 4 1 1 1 0
sky_glow source sky
0 0 4 0 0 1 180

Now I can test a few directions. For example this ray will hit the shading device

oconv geometry.rad > geometry.oct
echo "0 0 6 1 0.1 .1" | rfluxmtx -dv- - receiver.rad -i geometry.oct > coeffs.mtx
#?RADIANCE
oconv -f -i geometry.oct receiver.rad
rcontrib -fo+ -dv- -faa -c 1 -bn 1 -b if(-Dx*0-Dy*0-Dz*1,0,-1) -m groundglow -f reinhartb.cal -p MF=1,rNx=0,rNy=0,rNz=-1,Ux=0,Uy=1,Uz=0,RHS=+1 -bn Nrbins -b rbin -m sky_glow
SOFTWARE= RADIANCE 5.3 official release 2020-09-03 LBNL (5.3.012cb17835)
CAPDATE= 2022:05:07 10:41:04
GMT= 2022:05:07 09:41:04
NCOMP=3
NCOLS=146
FORMAT=ascii

2.397959e-01	2.056123e-01	1.719388e-01	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	2.397959e-03	2.056123e-03	1.719388e-03	2.397959e-03	2.056123e-03	1.719388e-03	0.000000e+00	0.000000e+00	0.000000e+00	7.193877e-03	6.168368e-03	5.158163e-03	7.193877e-03	6.168368e-03	5.158163e-03	4.795918e-03	4.112245e-03	3.438776e-03	9.591836e-03	8.224490e-03	6.877551e-03	4.795918e-03	4.112245e-03	3.438776e-03	7.193877e-03	6.168368e-03	5.158163e-03	7.193877e-03	6.168368e-03	5.158163e-03	2.397959e-03	2.056123e-03	1.719388e-03	2.397959e-03	2.056123e-03	1.719388e-03	0.000000e+00	0.000000e+00	0.000000e+00	2.397959e-03	2.056123e-03	1.719388e-03	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	2.397959e-03	2.056123e-03	1.719388e-03	0.000000e+00	0.000000e+00	0.000000e+00	2.397959e-03	2.056123e-03	1.719388e-03	7.193877e-03	6.168368e-03	5.158163e-03	4.795918e-03	4.112245e-03	3.438776e-03	2.397959e-03	2.056123e-03	1.719388e-03	4.795918e-03	4.112245e-03	3.438776e-03	7.193877e-03	6.168368e-03	5.158163e-03	7.193877e-03	6.168368e-03	5.158163e-03	0.000000e+00	0.000000e+00	0.000000e+00	7.193877e-03	6.168368e-03	5.158163e-03	2.397959e-03	2.056123e-03	1.719388e-03	2.397959e-03	2.056123e-03	1.719388e-03	2.397959e-03	2.056123e-03	1.719388e-03	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	2.397959e-03	2.056123e-03	1.719388e-03	2.397959e-03	2.056123e-03	1.719388e-03	2.397959e-03	2.056123e-03	1.719388e-03	4.795918e-03	4.112245e-03	3.438776e-03	7.193877e-03	6.168368e-03	5.158163e-03	7.193877e-03	6.168368e-03	5.158163e-03	7.193877e-03	6.168368e-03	5.158163e-03	2.397959e-03	2.056123e-03	1.719388e-03	7.193877e-03	6.168368e-03	5.158163e-03	4.795918e-03	4.112245e-03	3.438776e-03	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	2.397959e-03	2.056123e-03	1.719388e-03	2.397959e-03	2.056123e-03	1.719388e-03	4.795918e-03	4.112245e-03	3.438776e-03	2.397959e-03	2.056123e-03	1.719388e-03	0.000000e+00	0.000000e+00	0.000000e+00	7.193877e-03	6.168368e-03	5.158163e-03	2.397959e-03	2.056123e-03	1.719388e-03	4.795918e-03	4.112245e-03	3.438776e-03	2.397959e-03	2.056123e-03	1.719388e-03	2.397959e-03	2.056123e-03	1.719388e-03	2.397959e-03	2.056123e-03	1.719388e-03	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	2.397959e-03	2.056123e-03	1.719388e-03	4.795918e-03	4.112245e-03	3.438776e-03	2.397959e-03	2.056123e-03	1.719388e-03	4.795918e-03	4.112245e-03	3.438776e-03	0.000000e+00	0.000000e+00	0.000000e+00	2.397959e-03	2.056123e-03	1.719388e-03	2.397959e-03	2.056123e-03	1.719388e-03	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	4.795918e-03	4.112245e-03	3.438776e-03	7.193877e-03	6.168368e-03	5.158163e-03	2.397959e-03	2.056123e-03	1.719388e-03	2.397959e-03	2.056123e-03	1.719388e-03	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	0.000000e+00	

rfluxmtx generates a matrix that gives the contributions of the sky patches to the radiance from the direction 1 0.1 .1 as seen from 0 0 6. It is not clear to me why I need -dv-. Is this an rtrace options?

If now I multiply this matrix against the output of gendaymtx

dctimestep coeffs.mtx sky.mtx > out.mtx

I get a matrix [1 x 8760] representing the radiance from the “patch” in the direction above in W/m2-sr.

Is this correct? If it is then I do not understand why if I do

echo "0 0 6 0 0 1" | rfluxmtx -dv- - receiver.rad -i geometry.oct > coeffs.mtx

I get

#?RADIANCE
oconv -f -i geometry.oct receiver.rad
rcontrib -fo+ -dv- -faa -c 1 -bn 1 -b if(-Dx*0-Dy*0-Dz*1,0,-1) -m groundglow -f reinhartb.cal -p MF=1,rNx=0,rNy=0,rNz=-1,Ux=0,Uy=1,Uz=0,RHS=+1 -bn Nrbins -b rbin -m sky_glow
SOFTWARE= RADIANCE 5.3 official release 2020-09-03 LBNL (5.3.012cb17835)
CAPDATE= 2022:05:07 11:00:26
GMT= 2022:05:07 10:00:26
NCOMP=3
NCOLS=146
FORMAT=ascii

All 0.000000e+00 .... 1.000000e+00	1.000000e+00	1.000000e+00	

Shouldn’t I have all zeros because of the -dv- option?

Thanks!

Sorry – I realized last night that I forgot you need to use a “light” material for the sky in order for -dv- to do what we want. I also mixed up “sender” and “receiver” in my previous reply. (I edited it for correctness.) I hope this helps.

I haven’t run through your whole example, but it looks like the sky is repeated twice in your receiver file, which can’t be right.

Thanks Greg.

I have modified receiver.rad to use light instead of glow.

# Combined ground and sky vault
# Start by telling rfluxmtx to generate a single coefficient for the ground:
#@rfluxmtx u=+Y h=u

void glow groundglow
0 0 4 .8 1.1 .8 0
groundglow source ground
0 0 4 0 0 -1 180

# Now, tell rfluxmtx to generate a set of Tregenza sky patches using Y for "north/up":
#@rfluxmtx u=+Y h=r1

void light sky_glow
0 0 3 1 1 1
sky_glow source sky
0 0 4 0 0 1 180

It does change the results. So if I use a ray pointint upward, for example, I have all zeros. However, if I use as input a ray that intersects the shading device

echo "0 0 6 1 0.1 .1" | rfluxmtx -ab 4 -dv- - receiver.rad -i geometry.oct > coeffs.mtx

in coeffs.mtx I can see only the contribution from the ground

2.350000e-01	2.015000e-01	1.685000e-01	.. 0 0 0 0

I am probably missing something, but I am not sure where I am defining the sky twice.

Thanks

My apologies again. I replied too hastily yesterday, and didn’t take the time to go over your example thoroughly. There was no repeat of the sky – I simply misread it.

Regarding -dv-, I realize now that we have a “catch-22” insofar as a light-modified sky works with -dv- but doesn’t work with rcontrib, since it only sends one random ray to it. A glow-modified sky does not work with -dv-, so we’re stuck.

Perhaps you can run the calculation twice using your original glow-based sky, once as normal and once with -ab 0, generating two matrices. If you subtract the -ab 0 matrix from the full calculation using rmtxop, you should end up with a matrix missing the direct sky component, I think.

-Greg

Thanks Greg, no worries.

That seems to work. I get all zeros when the ray patch points to the sky. I just need to verify the numbers

patch="0 0 6 1 0.1 0.1"
echo $patch | rfluxmtx -ab 4 - receiver.rad -i geometry.oct | rcollate -oc 146 -or 1 -w > coeffs_full.mtx
echo $patch | rfluxmtx -ab 0 - receiver.rad -i geometry.oct | rcollate -oc 146 -or 1 -w > coeffs_sky.mtx
rmtxop -s -1 coeffs_sky.mtx + coeffs_full.mtx > coeffs.mtx
dctimestep coeffs.mtx sky.mtx > out.mtx
1 Like

Glad this worked! By the way, the new rcrop utility described in this post can extract any vector from a matrix, and is probably better-suited than your (admittedly clever) use of rcollate.

1 Like