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.
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.
np2bytefile
(ar, outf, dtype='<f')[source]¶ save vectors to file
- Parameters
ar (np.array) – array to write
outf (str) – file to write to
dtype (str) – argument to pass to np.dtype()
-
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) – image array
imgf (str) – file path to right
header (list) – list of header lines to append to image header
- Returns
- Return type
imgf
-
raytraverse.io.
carray2hdr
(ar, imgf, header=None)[source]¶ write color channel np.array (3, x, y) to hdr image format
- Parameters
ar (np.array) – image array
imgf (str) – file path to right
header (list) – list of header lines to append to image header
- Returns
- Return type
imgf
-
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