The results of a Geometric Image Analysis may be accessed using:
gia = TheSystem.Analyses.New_Analysis(ZOSAPI.Analysis.AnalysisIDM.GeometricImageAnalysis)
gia_setting = gia.GetSettings()
gia.ApplyAndWaitForCompletion()
gia_results = gia.GetResults()
gia.ApplyAndWaitForCompletion()
gia_data = zos.DoubleToNumpy(gia_results.GetDataGrid(0).Values).reshape(-1, gia_setting.NumberOfPixels)
where zos.DoubleToNumpy is tucked into the boilerplate PythonStandaloneApplication class.
def DoubleToNumpy(self, data):
'''Provided by Sandrine Auriol, Zemax'''
if 'numpy' not in sys.modules:
print('You have not imported numpy into this file')
return False
else:
src_hndl = GCHandle.Alloc(data, GCHandleType.Pinned)
try:
src_ptr = src_hndl.AddrOfPinnedObject().ToInt64()
cbuf = (ctypes.c_double * len(data)).from_address(src_ptr)
npData = np.frombuffer(cbuf, dtype=np.float64)
finally:
if src_hndl.IsAllocated: src_hndl.Free()
return npData