Nathaniel, the ReadSingle() or ReadDouble() methods of the System.IO
BinaryReader class may do your job. Give those a try. If they don't work,
try ReadBytes() in conjunction with those BitConverter methods you've been
working with. Key, though: you probably want to be using BinaryReader.

-- 
Randolph M. Fritz || rmfri...@gmail.com

On Mon, Apr 16, 2018 at 5:42 PM, Nathaniel Jones <nathaniel...@gmail.com>
wrote:

> Hi all,
>
> I'm trying to read the binary output from dctimestep run with the -od
> argument. The idea is that the binary files appear to be a lot faster to
> save and load than text. However, I'm having a problem reading the binary
> values.
>
> Values less than 512 read in just fine. However, binary values greater
> than 512 are being converted to what look like random values between 31 and
> 32. Upon looking at the binary file, it looks like the first three bytes of
> each double are zero. Of course, I'm not even sure of the endianness of the
> data.
>
> I'm also not sure how to test whether the issue is in my reader or in the
> dctimestep output. Here's my C# code to read the values, in case anyone
> wants to do a deep dive here:
>
> byte[] bytes = System.Text.Encoding.ASCII.GetBytes(buffer, 0, ncols *
> ncomp * sizeof(double));
> for (int j = 0; j < ncols; j++)
> {
>    double r = BitConverter.ToDouble(bytes, j * ncomp * sizeof(double));
>    double g = BitConverter.ToDouble(bytes, (j * ncomp + 1) *
> sizeof(double));
>    double b = BitConverter.ToDouble(bytes, (j * ncomp + 2) *
> sizeof(double));
>    irradiance.Add(Bright(r, g, b), path);
> }
>
> Any help debugging this would be appreciated!
>
> Nathaniel
>
> _______________________________________________
> Radiance-dev mailing list
> Radiance-dev@radiance-online.org
> https://www.radiance-online.org/mailman/listinfo/radiance-dev
>
>
_______________________________________________
Radiance-dev mailing list
Radiance-dev@radiance-online.org
https://www.radiance-online.org/mailman/listinfo/radiance-dev

Reply via email to