raytraverse.io¶
functions for reading and writing
- raytraverse.io.np2bytes(ar, dtype='<f')[source]¶
format ar as bytestring
- Parameters
ar (np.array) –
dtype (str) – argument to pass to np.dtype()
- Return type
bytes
- raytraverse.io.np2bytefile(ar, outf, dtype='<f', mode='wb')[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()
- 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
- 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
- Return type
imgf
- raytraverse.io.hdr2array(imgf, stdin=None)[source]¶
read np.array from hdr image
- Parameters
imgf (file path of image) –
stdin – passed to Popen (imgf should be “”)
- Returns
ar
- Return type
np.array
- raytraverse.io.hdr2carray(imgf, stdin=None)[source]¶
read np.array from color hdr image
- Parameters
imgf (file path of image) –
stdin – passed to Popen (imgf should be “”)
- 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
- raytraverse.io.load_txt(farray, **kwargs)[source]¶
consistent error handing of np.loadtxt
- Parameters
farray (any) – candidate to load
kwargs – passed to np.loadtxt
- Return type
np.array
- Raises
ValueError: – file exists, but is not loadable
FileNotFoundError: – farray is str, but file does not exist
TypeError: – farray is not str or bytes.