I have some astronomical data file (.ser) that have 8 bit BGR (data order) pixel data. 301 frames take up 7 GB of valuable space. I wish to combine some of the frames say ten (10) consecutive frames, pixel colour by pixel colour and save them in a file. I have found mmap and can use it to inspect the first 178 bytes of header information then come the frames. How do I efficiently perform the file operations. The pixels are stored as a single byte (8 bits) and the new file after combination will have two (2) bytes (16 bits) presumably as unsigned int. How can I efficiently index through the input file. Any help pointing me in the correct direction will be appreciated.
This seems to be ok
with open(file_name,"r+b") as f:
mm = mmap.mmap(f.fileno(),0) p_f = 10 source_frame_array = bytearray(100) mm.seek(0) source_frame_array = mm.read ()
with open(write_file,"r+b") as w:
for n_f in range (0,int(3)): for n_p in range (0, p_f): n_e = 0 for n_e in range (0, 5): n_e = n_e+n_e # the work w.write(n_e.to_bytes(2,"little")) # plant in file