Skip to content

Commit

Permalink
Merge a6439b6 into 3f10a3f
Browse files Browse the repository at this point in the history
  • Loading branch information
jhellerstedt committed Dec 22, 2017
2 parents 3f10a3f + a6439b6 commit dbe24b9
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions nanonispy/read.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ def start_byte(self):

for line in f:
# Convert from bytes to str
#entry = line.strip().decode()
entry = line.strip().decode('utf-8', 'ignore')

try:
entry = line.strip().decode()
except UnicodeDecodeError:
Expand Down Expand Up @@ -210,6 +213,11 @@ def _load_data(self):

# pixel size in bytes
exp_size_per_pix = num_param + num_sweep*num_chan

## pad griddata if incomplete
if len(griddata) < nx * ny * exp_size_per_pix:
paddiff = nx * ny * exp_size_per_pix - len(griddata)
griddata = np.pad(griddata, (0, paddiff), 'constant')

# reshape from 1d to 3d
griddata_shaped = griddata.reshape((nx, ny, exp_size_per_pix))
Expand Down Expand Up @@ -340,7 +348,8 @@ def _load_data(self):
f.close()

# reshape
scandata_shaped = scandata.reshape(nchanns, ndir, nx, ny)
# scandata_shaped = scandata.reshape(nchanns, ndir, nx, ny)
scandata_shaped = scandata.reshape(nchanns, ndir, ny, nx)

# extract data for each channel
for i, chann in enumerate(channs):
Expand Down Expand Up @@ -401,7 +410,13 @@ def _load_data(self):

column_names = f.readline().strip('\n').split('\t')
f.close()
header_lines = len(self.header) + 4

f = open(self.fname, 'r')
ff = f.readlines()
header_lines = ff.index('[DATA]\n') + 2
f.close()

# header_lines = len(self.header) + 4
specdata = np.genfromtxt(self.fname, delimiter='\t', skip_header=header_lines)

for i, name in enumerate(column_names):
Expand Down

0 comments on commit dbe24b9

Please sign in to comment.