<s> """<STR_LIT>""" <EOL> from os import SEEK_CUR , path as op <EOL> import re <EOL> from struct import unpack <EOL> import numpy as np <EOL> from . constants import KIT <EOL> from . . meas_info import _read_dig_points <EOL> from ... externals . six . moves import cPickle as pickle <EOL> def read_mrk ( fname ) : <EOL> """<STR_LIT>""" <EOL> ext = op . splitext ( fname ) [ - <NUM_LIT:1> ] <EOL> if ext in ( '<STR_LIT>' , '<STR_LIT>' ) : <EOL> with open ( fname , '<STR_LIT:rb>' , buffering = <NUM_LIT:0> ) as fid : <EOL> fid . seek ( KIT . MRK_INFO ) <EOL> mrk_offset = unpack ( '<STR_LIT:i>' , fid . read ( KIT . INT ) ) [ <NUM_LIT:0> ] <EOL> fid . seek ( mrk_offset ) <EOL> fid . seek ( KIT . INT + ( <NUM_LIT:2> * KIT . DOUBLE * <NUM_LIT:4> ** <NUM_LIT:2> ) , SEEK_CUR ) <EOL> mrk_count = unpack ( '<STR_LIT:i>' , fid . read ( KIT . INT ) ) [ <NUM_LIT:0> ] <EOL> pts = [ ] <EOL> for _ in range ( mrk_count ) : <EOL> fid . seek ( KIT . INT * <NUM_LIT:4> + ( KIT . DOUBLE * <NUM_LIT:3> ) , SEEK_CUR ) <EOL> pts . append ( np . fromfile ( fid , dtype = '<STR_LIT:d>' , count = <NUM_LIT:3> ) ) <EOL> mrk_points = np . array ( pts ) <EOL> elif ext == '<STR_LIT>' : <EOL> mrk_points = _read_dig_points ( fname ) <EOL> elif ext == '<STR_LIT>' : <EOL> with open ( fname , '<STR_LIT:rb>' ) as fid : <EOL> food = pickle . load ( fid ) <EOL> try : <EOL> mrk_points = food [ '<STR_LIT>' ] <EOL> except : <EOL> err = ( "<STR_LIT>" % fname ) <EOL> raise ValueError ( err ) <EOL> else : <EOL> err = ( '<STR_LIT>' <EOL> '<STR_LIT>' % ext ) <EOL> raise ValueError ( err ) <EOL> mrk_points = np . asarray ( mrk_points ) <EOL> if mrk_points . shape != ( <NUM_LIT:5> , <NUM_LIT:3> ) : <EOL> err = ( "<STR_LIT>" <EOL> "<STR_LIT:%s>" % ( fname , mrk_points . shape ) ) <EOL> raise ValueError ( err ) <EOL> return mrk_points <EOL> def read_sns ( fname ) : <EOL> """<STR_LIT>""" <EOL> p = re . compile ( r'<STR_LIT>' + <EOL> r'<STR_LIT>' + <EOL> r'<STR_LIT>' ) <EOL> with open ( fname ) as fid : <EOL> locs = np . array ( p . findall ( fid . read ( ) ) , dtype = float ) <EOL> return locs </s>
