def _calibrate_comp(comp, chs, row_names, col_names, mult_keys=('range', 'cal'), flip=False):
 ch_names = [c['ch_name'] for c in chs]
 row_cals = np.zeros(len(row_names))
 col_cals = np.zeros(len(col_names))
 for (names, cals, inv) in zip((row_names, col_names), (row_cals, col_cals), (False, True)):
  for ii in range(len(cals)):
   p = ch_names.count(names[ii])
   if (p != 1):
    raise RuntimeError(('Channel %s does not appear exactly once in data' % names[ii]))
   idx = ch_names.index(names[ii])
   val = (chs[idx][mult_keys[0]] * chs[idx][mult_keys[1]])
   val = (float((1.0 / val)) if inv else float(val))
   val = ((1.0 / val) if flip else val)
   cals[ii] = val
 comp['rowcals'] = row_cals
 comp['colcals'] = col_cals
 comp['data']['data'] = ((row_cals[:, None] * comp['data']['data']) * col_cals[None, :])

def _calibrate_comp ( comp , chs , row_names , col_names , mult_keys = ( 'range' , 'cal' ) , flip = False ) : ch_names = [ c [ 'ch_name' ] for c in chs ] row_cals = np . zeros ( len ( row_names ) ) col_cals = np . zeros ( len ( col_names ) ) for ( names , cals , inv ) in zip ( ( row_names , col_names ) , ( row_cals , col_cals ) , ( False , True ) ) : for ii in range ( len ( cals ) ) : p = ch_names . count ( names [ ii ] ) if ( p != 1 ) : raise RuntimeError ( ( 'Channel %s does not appear exactly once in data' % names [ ii ] ) ) idx = ch_names . index ( names [ ii ] ) val = ( chs [ idx ] [ mult_keys [ 0 ] ] * chs [ idx ] [ mult_keys [ 1 ] ] ) val = ( float ( ( 1.0 / val ) ) if inv else float ( val ) ) val = ( ( 1.0 / val ) if flip else val ) cals [ ii ] = val comp [ 'rowcals' ] = row_cals comp [ 'colcals' ] = col_cals comp [ 'data' ] [ 'data' ] = ( ( row_cals [ : , None ] * comp [ 'data' ] [ 'data' ] ) * col_cals [ None , : ] )
get row and column cals .