def read_uic1tag(fh, byteorder, dtype, count, plane_count=None):
 assert ((dtype in ('2I', '1I')) and (byteorder == '<'))
 result = {}
 if (dtype == '2I'):
  values = fh.read_array('<u4', (2 * count)).reshape(count, 2)
  result = {'z_distance': (values[:, 0] / values[:, 1])}
 elif plane_count:
  for _ in range(count):
   tagid = struct.unpack('<I', fh.read(4))[0]
   if (tagid in (28, 29, 37, 40, 41)):
    fh.read(4)
    continue
   (name, value) = read_uic_tag(fh, tagid, plane_count, offset=True)
   result[name] = value
 return result

def read_uic1tag ( fh , byteorder , dtype , count , plane_count = None ) : assert ( ( dtype in ( '2I' , '1I' ) ) and ( byteorder == '<' ) ) result = { } if ( dtype == '2I' ) : values = fh . read_array ( '<u4' , ( 2 * count ) ) . reshape ( count , 2 ) result = { 'z_distance' : ( values [ : , 0 ] / values [ : , 1 ] ) } elif plane_count : for _ in range ( count ) : tagid = struct . unpack ( '<I' , fh . read ( 4 ) ) [ 0 ] if ( tagid in ( 28 , 29 , 37 , 40 , 41 ) ) : fh . read ( 4 ) continue ( name , value ) = read_uic_tag ( fh , tagid , plane_count , offset = True ) result [ name ] = value return result
read metamorph stk uic1tag from file and return as dictionary .