Glad that worked. You should be OK reading the header as binary data, though. All the programs that write headers use binary mode, so you just get back what was put in. You don't actually want to do line-end conversion for Radiance headers.
Cheers, -Greg > From: Nathaniel Jones <[email protected]> > Date: April 17, 2018 3:02:19 PM PDT > > Randolph's solution worked here. The tricky part was to be reading the file > header as strings and then the binary data from the same stream. I ended up > creating a BinaryReader when a format other than ascii is specified and > initializing it with the BaseStream from my StreamReader so as not to have to > open the same file twice. This requires tracking the current position in the > stream, so it's not completely clean, but still simpler than what I had > before. It's about three times faster than reading the text input. > > Nathaniel > > On Mon, Apr 16, 2018 at 9:48 PM, Randolph M. Fritz <[email protected]> wrote: > 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 || [email protected] > > On Mon, Apr 16, 2018 at 5:42 PM, Nathaniel Jones <[email protected]> > 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 > [email protected] > https://www.radiance-online.org/mailman/listinfo/radiance-dev > > > > _______________________________________________ > Radiance-dev mailing list > [email protected] > https://www.radiance-online.org/mailman/listinfo/radiance-dev > > > _______________________________________________ > Radiance-dev mailing list > [email protected] > https://www.radiance-online.org/mailman/listinfo/radiance-dev
_______________________________________________ Radiance-dev mailing list [email protected] https://www.radiance-online.org/mailman/listinfo/radiance-dev
