raytraverse.io¶
functions for reading and writing
-
class
raytraverse.io.
CaptureStdOut
(b=False, store=True, outf=None)[source]¶ Bases:
object
redirect output streams at system level (including c printf)
- Parameters
b (bool, optional) – read data as bytes
store (bool, optional) – record stdout in a IOStream, value accesible through self.stdout
outf (IOBase, optional) – if not None, must be writable, closed on exit
Notes
with CaptureStdOut() as capture: do stuff capout = capture.stdout
when using with pytest include the -s flag or this class has no effect
-
property
stdout
¶
-
raytraverse.io.
call_sampler
(outf, command, vecs, shape)[source]¶ make subprocess call to sampler given as command, expects rgb value as return for each vec
- Parameters
outf (str) – path to write out to
command (str) – command line with executable and options
vecs (np.array) – vectors to pass as stdin to command
shape (tuple) – shape of expected output
- Returns
lums – of length vectors.shape[0]
- Return type
np.array
-
raytraverse.io.
np2bytes
(ar, dtype='<f')[source]¶ format ar as bytestring
- Parameters
ar (np.array) –
dtype (str) – argument to pass to np.dtype()
- Returns
- Return type
bytes
-
raytraverse.io.
bytes2np
(buf, shape, dtype='<f')[source]¶ read ar from bytestring
- Parameters
buf (bytes, str) –
shape (tuple) – array shape
dtype (str) – argument to pass to np.dtype()
- Returns
- Return type
np.array
-
raytraverse.io.
bytefile2np
(f, shape, dtype='<f')[source]¶ read binary data from f
- Parameters
f (IOBase) – file object to read array from
shape (tuple) – array shape
dtype (str) – argument to pass to np.dtype()
- Returns
necessary for reconstruction
- Return type
ar.shape
-
raytraverse.io.
array2hdr
(ar, imgf, header=None)[source]¶ write 2d np.array (x,y) to hdr image format
- Parameters
ar (np.array) –
imgf (file path to right) –
header (list of header lines to append to image header) –
-
raytraverse.io.
carray2hdr
(ar, imgf, header=None)[source]¶ write color channel np.array (3, x, y) to hdr image format
- Parameters
ar (np.array) –
imgf (file path to right) –
header (list of header lines to append to image header) –
-
raytraverse.io.
hdr2array
(imgf)[source]¶ read np.array from hdr image
- Parameters
imgf (file path of image) –
- Returns
ar
- Return type
np.array
-
raytraverse.io.
rgbe2lum
(rgbe)[source]¶ convert from Radiance hdr rgbe 4-byte data format to floating point luminance.
- Parameters
rgbe (np.array) – r,g,b,e unsigned integers according to: http://radsite.lbl.gov/radiance/refer/filefmts.pdf
- Returns
lum
- Return type
luminance in cd/m^2