Skip to content

Iterator

MicPy provides an iterator interface to read fields from MICRESS binary files one at a time. This approach is more memory-efficient than reading all fields at once, especially for large files. You can iterate over fields using a for loop, which yields a Field object for each field in the binary file.

from micpy import bin

for field in bin.File("A001_Delta_Gamma.conc1"):
    print(repr(field))
Field([[[0.9998329 1.        1.        ... 1.        1.        1.       ]]
       [[1.        1.        1.        ... 1.        1.        1.       ]]
       [[1.        1.        1.        ... 1.        1.        1.       ]]
       ...
       [[1.        1.        1.        ... 1.        1.        1.       ]]
       [[1.        1.        1.        ... 1.        1.        1.       ]]
       [[1.        1.        1.        ... 1.        1.        1.       ]]])

Field([[[0.20875162 0.20875515 0.20876558 ... 1.         1.         1.        ]]
       [[0.20871933 0.20872468 0.20874065 ... 1.         1.         1.        ]]
       [[0.20862672 0.20863731 0.2086692  ... 1.         1.         1.        ]]
       ...
       [[1.         1.         1.         ... 1.         1.         1.        ]]
       [[1.         1.         1.         ... 1.         1.         1.        ]]
       [[1.         1.         1.         ... 1.         1.         1.        ]]])

Field([[[0.22053477 0.22053626 0.22054066 ... 1.0000005  1.0000004  1.0000004 ]]
       [[0.22052616 0.22052798 0.22053333 ... 1.0000005  1.0000004  1.0000004 ]]
       [[0.22049846 0.22050114 0.22050914 ... 1.0000005  1.0000004  1.0000004 ]]
       ...
       [[1.         1.         1.         ... 1.         1.         1.        ]]
       [[1.         1.         1.         ... 1.         1.         1.        ]]
       [[1.         1.         1.         ... 1.         1.         1.        ]]])

Reference

micpy.bin.Field

Bases: ndarray

A field.