You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have a use case with GTC in which we need to store images in a BP file. It would be nice to add a feature that supports Python variables of class bytes (not the same as bytearrays).
As Python bytes are not natively supported, the current approach requires converting an image represented as a bytes array to a numpy uint8 type and writing it to file. Conversely, to read it back, we need to convert the uint8 array to bytes.
The following pseudocode shows a snippet on how this is currently done.
# Perform matplotlib plotting
# Get a bytes object
b = io.BytesIO()
# Write plot to the bytes buffer and return it
plt.savefig(b, format='png')
# Higher level function receives b and converts it into a numpy array.
# Write the numpy array as a uint8 array
dt = np.dtype(np.uint8)
N = len(b)
data = np.frombuffer(b, dtype=dt, count=N, offset=0)
adios_fh.write(varname, data, [N], [0], [N])
The text was updated successfully, but these errors were encountered:
We have a use case with GTC in which we need to store images in a BP file. It would be nice to add a feature that supports Python variables of
class bytes
(not the same asbytearrays
).As Python
bytes
are not natively supported, the current approach requires converting an image represented as a bytes array to a numpy uint8 type and writing it to file. Conversely, to read it back, we need to convert the uint8 array to bytes.The following pseudocode shows a snippet on how this is currently done.
The text was updated successfully, but these errors were encountered: