Commit 52cee572 authored by Unknown's avatar Unknown
Browse files

Code cleanups

parent 45cab2ca
......@@ -156,7 +156,7 @@ class Optimize(object):
self.solver_type = solver_type
self.solver_options = solver_options
if self.solver_type not in scipy.optimize.__dict__.keys():
warn('Solver %s does not exist!. For additional info see scipy.optimize' % (solver_type))
warn('Solver %s does not exist!. For additional info see scipy.optimize' % solver_type)
sys.exit()
if obj_func['class'] is None:
self.obj_func = obj_func['obj_func']
......
......@@ -129,8 +129,8 @@ def getAuxData(parent_data, auxDataName=None):
auxDataName = parent_data.attrs.keys()
elif type(auxDataName) not in [list, tuple, set]:
auxDataName = [auxDataName] # typically a single string
data_list = list()
try:
data_list = []
file_ref = parent_data.file
for auxName in auxDataName:
ref = parent_data.attrs[auxName]
......@@ -197,14 +197,15 @@ def get_attributes(parent_data, attr_names=None):
attr_names = [attr_names]
att_dict = {}
try:
for attr in attr_names:
for attr in attr_names:
try:
att_dict[attr] = get_attr(parent_data, attr)
except KeyError:
warn('%s is not an attribute of %s'
% (str(attr), parent_data.name))
except:
raise
except KeyError:
warn('%s is not an attribute of %s'
% (str(attr), parent_data.name))
except:
raise
return att_dict
......@@ -410,6 +411,7 @@ def getH5RegRefIndices(ref, h5_main, return_method='slices'):
ref_inds = return_func(start, end)
else:
warn('No method currently exists for converting this type of reference.')
ref_inds = np.empty(0)
else:
raise TypeError('Input ref must be an HDF5 Region Reference')
......@@ -740,11 +742,9 @@ def reshape_to_Ndims(h5_main, h5_pos=None, h5_spec=None, get_labels=False):
ds_labels = np.hstack([pos_labs, spec_labs])
results = (ds_Nd2, True, ds_labels)
return ds_Nd2, True, ds_labels
else:
results = (ds_Nd2, True)
return results
return ds_Nd2, True
def reshape_from_Ndims(ds_Nd, h5_pos=None, h5_spec=None):
......
......@@ -23,14 +23,14 @@ def check_ssh():
return 'SSH_CLIENT' in os.environ or 'SSH_TTY' in os.environ
def uiGetFile(filter='H5 file (*.h5)', caption='Select File'):
def uiGetFile(file_filter='H5 file (*.h5)', caption='Select File'):
"""
Presents a File dialog used for selecting the .mat file
and returns the absolute filepath of the selecte file\n
Parameters
----------
filter : String or list of strings
file_filter : String or list of strings
file extensions to look for
caption : (Optional) String
Title for the file browser window
......@@ -51,7 +51,7 @@ def uiGetFile(filter='H5 file (*.h5)', caption='Select File'):
raise
else:
app = QtWidgets.QApplication([])
path = QtWidgets.QFileDialog.getOpenFileName(caption=caption, filter=filter)[0]
path = QtWidgets.QFileDialog.getOpenFileName(caption=caption, filter=file_filter)[0]
app.closeAllWindows()
app.exit()
del app
......@@ -66,7 +66,7 @@ def uiGetFile(filter='H5 file (*.h5)', caption='Select File'):
raise
else:
app = QtGui.QApplication([])
path = QtGui.QFileDialog.getOpenFileName(caption=caption, filter=filter)
path = QtGui.QFileDialog.getOpenFileName(caption=caption, filter=file_filter)
app.exit()
del app
......
......@@ -21,7 +21,7 @@ class MicroData(object):
"""
def __init__(self, name, parent):
'''
"""
Parameters
----------
name : String
......@@ -29,7 +29,7 @@ class MicroData(object):
parent : String
HDF5 path to the parent of this object. Typically used when
appending to an existing HDF5 file
'''
"""
self.name = name
self.attrs = dict()
self.parent = parent
......@@ -65,18 +65,18 @@ class MicroDataGroup(MicroData):
pass
def addChildren(self, children):
'''
"""
Adds Children to the class to make a tree structure.
Parameters
----------
children : list of MicroData objects
Children can be a mixture of groups and datasets
Returns
-------
None
'''
"""
for child in children:
if isinstance(child, MicroData):
child.parent = self.parent + self.name
......
......@@ -181,8 +181,11 @@ class BEodfRelaxationTranslator(Translator):
ds_wfm_typ = MicroDataset('Bin_Wfm_Type', exec_bin_vec)
# Create Spectroscopic Values and Spectroscopic Values Labels datasets
spec_vals, spec_vals_labs, spec_vals_units = createSpecVals(UDVS_mat, spec_inds, bin_freqs, exec_bin_vec,
parm_dict, UDVS_labs, UDVS_units)
spec_vals, spec_inds, spec_vals_labs, spec_vals_units, spec_vals_names = createSpecVals(UDVS_mat, spec_inds,
bin_freqs,
exec_bin_vec,
parm_dict, UDVS_labs,
UDVS_units)
spec_vals_slices = dict()
for row_ind, row_name in enumerate(spec_vals_labs):
......@@ -359,7 +362,7 @@ class BEodfRelaxationTranslator(Translator):
FFT_full = np.fft.fftshift(np.fft.fft(BE_wave))
bin_FFT = np.conjugate(FFT_full[bin_inds])
return (bin_inds, bin_w, bin_FFT, BE_wave, dc_amp_vec_full)
return bin_inds, bin_w, bin_FFT, BE_wave, dc_amp_vec_full
def _parse_file_path(self, data_filepath):
"""
......@@ -393,7 +396,7 @@ class BEodfRelaxationTranslator(Translator):
path_dict['read_imag'] = imag_path
path_dict['old_mat_parms'] = data_filepath
return (basename, path_dict)
return basename, path_dict
@staticmethod
def __getParmsFromOldMat(file_path):
......@@ -493,7 +496,7 @@ class BEodfRelaxationTranslator(Translator):
elif VS_parms[0] == 2:
# AC mode
parm_dict['VS_mode'] = 'AC modulation mode with time reversal'
parm_dict['VS_amplitude_[V]'] = 0.5 * (VS_final_loop_amp)
parm_dict['VS_amplitude_[V]'] = 0.5 * VS_final_loop_amp
parm_dict[
'VS_offset_[V]'] = 0 # this is not correct. Fix manually when it comes to UDVS generation?
else:
......@@ -620,4 +623,4 @@ class BEodfRelaxationTranslator(Translator):
UD_VS_table[BE_IF_switch == 1, 5] = UD_VS_table[BE_IF_switch == 1, 1]
UD_VS_table[BE_OF_switch == 1, 6] = UD_VS_table[BE_IF_switch == 1, 1]
return (UD_VS_table_label, UD_VS_table_unit, UD_VS_table)
return UD_VS_table_label, UD_VS_table_unit, UD_VS_table
......@@ -299,7 +299,7 @@ def normalizeBEresponse(spectrogram_mat, FFT_BE_wave, harmonic):
# Generate transfer functions
F_AO_spectrogram = np.transpose(np.tile(FFT_BE_wave / scaling_factor, [spectrogram_mat.shape[1], 1]))
# Divide by transfer function
spectrogram_mat = spectrogram_mat / (F_AO_spectrogram)
spectrogram_mat = spectrogram_mat / F_AO_spectrogram
return spectrogram_mat
......@@ -729,7 +729,7 @@ def createSpecVals(udvs_mat, spec_inds, bin_freqs, bin_wfm_type, parm_dict,
Check if more that one unique value
Append column number to iSpec_var if true
"""
if (uvals.size > 1):
if uvals.size > 1:
iSpec_var = np.append(iSpec_var, int(i))
iSpec_var = np.asarray(iSpec_var, np.int)
......@@ -1179,7 +1179,7 @@ BEHistogram Class and Functions
"""
class BEHistogram():
class BEHistogram:
# TODO: Turn into proper class
# TODO: Parallelize Histogram generation
"""
......@@ -1552,7 +1552,7 @@ class BEHistogram():
udvs_bins = np.where(x_hist[1] == udvs_step)[0]
if debug:
print(np.shape(x_hist))
data_mat = h5_main[pix_chunks[ichunk]:pix_chunks[ichunk + 1], (udvs_bins)]
data_mat = h5_main[pix_chunks[ichunk]:pix_chunks[ichunk + 1], udvs_bins]
"""
Get the frequecies that correspond to the current UDVS bins from the total x_hist
......
......@@ -357,7 +357,7 @@ def dm_read_string(f, outdata=None):
put_into_file(f, ">" + str(slen) + "s", outdata)
return header_size
else:
assert(False)
assert False
slen = get_from_file(f, ">L")
raws = get_from_file(f, ">" + str(slen) + "s")
if verbose:
......
......@@ -162,7 +162,7 @@ class GDMTranslator(Translator):
else:
print('File not found for: row {} col {}'.format(row_ind, col_ind))
pos_ind += 1
if (100.0 * (pos_ind) / num_pix) % 10 == 0:
if (100.0 * pos_ind / num_pix) % 10 == 0:
print('completed translating {} %'.format(int(100 * pos_ind / num_pix)))
hdf.close()
......
......@@ -146,7 +146,7 @@ class SporcTranslator(Translator):
else:
print('File for row {} col {} not found'.format(row_ind, col_ind))
pos_ind += 1
if (100.0 * (pos_ind) / num_pix) % 10 == 0:
if (100.0 * pos_ind / num_pix) % 10 == 0:
print('Finished reading {} % of data'.format(int(100 * pos_ind / num_pix)))
hdf.close()
......
......@@ -11,7 +11,7 @@ def apply_select_channel(file_in_h5, img_num, channel_num):
main_h5_handle = h5.File(file_in_h5, 'r+')
image_path = "/Frame_%04i/Channel_%02i" % (img_num, channel_num)
image_path = "%s/Raw_Data" % (image_path)
image_path = "%s/Raw_Data" % image_path
h5_image = main_h5_handle.get(image_path)
img2 = np.empty(h5_image.shape, dtype=h5_image.dtype)
......@@ -34,14 +34,14 @@ def apply_select_channel(file_in_h5, img_num, channel_num):
posi_ind = main_h5_handle[pos_i_ref]
posi_ind = posi_ind[pos_i_reg]
image_path = "/Frame_%04i/Channel_Current/Filter_Step_0000" % (img_num)
image_path = "/Frame_%04i/Channel_Current/Filter_Step_0000" % img_num
try:
main_h5_handle.__delitem__(image_path)
except:
temp = 1
image_path = "%s/Filtered_Image" % (image_path)
image_path = "%s/Filtered_Image" % image_path
main_h5_handle[image_path] = img2
h5_image_new = main_h5_handle.get(image_path)
h5_new_attrs = h5_image_new.attrs
......@@ -59,12 +59,12 @@ def apply_select_channel(file_in_h5, img_num, channel_num):
h5_new_attrs["Parent"] = current_ref
h5_new_attrs["Parent_Region"] = current_reg
image_path = "/Frame_%04i/Channel_Current" % (img_num)
image_path = "/Frame_%04i/Channel_Current" % img_num
path_main = main_h5_handle.get(image_path)
path_attrs = path_main
channel_name = "Channel_%02i" % (channel_num)
channel_name = "Channel_%02i" % channel_num
path_main = main_h5_handle.get(image_path)
path_attrs = path_main.attrs
path_attrs["Origin"] = current_ref
......@@ -80,10 +80,10 @@ def apply_wiener_filter(file_in_h5, img_num, filter_num):
import h5py as h5
main_h5_handle = h5.File(file_in_h5, 'r+')
image_path = "/Frame_%04i/Channel_Current" % (img_num)
image_path = "/Frame_%04i/Channel_Current" % img_num
for x in range(0, filter_num + 1):
image_path = "%s/Filter_Step_%04i" % (image_path, x)
image_path = "%s/Filtered_Image" % (image_path)
image_path = "%s/Filtered_Image" % image_path
h5_image = main_h5_handle.get(image_path)
img2 = np.empty(h5_image.shape, dtype=h5_image.dtype)
......@@ -143,7 +143,7 @@ def apply_wiener_filter(file_in_h5, img_num, filter_num):
img = abs(img)
img = np.real(img)
image_path = "/Frame_%04i/Channel_Current" % (img_num)
image_path = "/Frame_%04i/Channel_Current" % img_num
for x in range(0, filter_num + 2):
image_path = "%s/Filter_Step_%04i" % (image_path, x)
......@@ -152,7 +152,7 @@ def apply_wiener_filter(file_in_h5, img_num, filter_num):
except:
temp = 1
image_path = "%s/Filtered_Image" % (image_path)
image_path = "%s/Filtered_Image" % image_path
main_h5_handle[image_path] = img
h5_image_new = main_h5_handle.get(image_path)
h5_new_attrs = h5_image_new.attrs
......@@ -180,10 +180,10 @@ def apply_gaussian_corr_filter(file_in_h5, img_num, filter_num, gauss_width, gau
import h5py as h5
main_h5_handle = h5.File(file_in_h5, 'r+')
image_path = "/Frame_%04i/Channel_Current" % (img_num)
image_path = "/Frame_%04i/Channel_Current" % img_num
for x in range(0, filter_num + 1):
image_path = "%s/Filter_Step_%04i" % (image_path, x)
image_path = "%s/Filtered_Image" % (image_path)
image_path = "%s/Filtered_Image" % image_path
h5_image = main_h5_handle.get(image_path)
img2 = np.empty(h5_image.shape, dtype=h5_image.dtype)
......@@ -227,7 +227,7 @@ def apply_gaussian_corr_filter(file_in_h5, img_num, filter_num, gauss_width, gau
k2 + y_min:k2 + y_max + 1].reshape([1, gaus.size]))
new_deconv[k1, k2] = temp[0, 1]
image_path = "/Frame_%04i/Channel_Current" % (img_num)
image_path = "/Frame_%04i/Channel_Current" % img_num
for x in range(0, filter_num + 2):
image_path = "%s/Filter_Step_%04i" % (image_path, x)
......@@ -236,7 +236,7 @@ def apply_gaussian_corr_filter(file_in_h5, img_num, filter_num, gauss_width, gau
except:
temp = 1
image_path = "%s/Filtered_Image" % (image_path)
image_path = "%s/Filtered_Image" % image_path
main_h5_handle[image_path] = new_deconv
h5_image_new = main_h5_handle.get(image_path)
h5_new_attrs = h5_image_new.attrs
......@@ -276,9 +276,9 @@ def fun_2d_gaussian(x, y, parm):
ang = np.double(parm[5])
a = ((np.cos(ang) ** 2) / (2 * (x_wid) ** 2)) + ((np.sin(ang) ** 2) / (2 * (y_wid) ** 2))
b = -((np.sin(2 * ang)) / (4 * (x_wid) ** 2)) + ((np.sin(2 * ang)) / (4 * (y_wid) ** 2))
c = ((np.sin(ang) ** 2) / (2 * (x_wid) ** 2)) + ((np.cos(ang) ** 2) / (2 * (y_wid) ** 2))
a = ((np.cos(ang) ** 2) / (2 * x_wid ** 2)) + ((np.sin(ang) ** 2) / (2 * y_wid ** 2))
b = -((np.sin(2 * ang)) / (4 * x_wid ** 2)) + ((np.sin(2 * ang)) / (4 * y_wid ** 2))
c = ((np.sin(ang) ** 2) / (2 * x_wid ** 2)) + ((np.cos(ang) ** 2) / (2 * y_wid ** 2))
gaussian = amp * (
np.exp(-((a * (x - x_cent) ** 2) + (2 * b * (x - x_cent) * (y - y_cent)) + (c * (y - y_cent) ** 2))))
......@@ -291,10 +291,10 @@ def apply_invert_filter(file_in_h5, img_num, filter_num):
import h5py as h5
main_h5_handle = h5.File(file_in_h5, 'r+')
image_path = "/Frame_%04i/Channel_Current" % (img_num)
image_path = "/Frame_%04i/Channel_Current" % img_num
for x in range(0, filter_num + 1):
image_path = "%s/Filter_Step_%04i" % (image_path, x)
image_path = "%s/Filtered_Image" % (image_path)
image_path = "%s/Filtered_Image" % image_path
h5_image = main_h5_handle.get(image_path)
img = np.empty(h5_image.shape, dtype=h5_image.dtype)
......@@ -316,7 +316,7 @@ def apply_invert_filter(file_in_h5, img_num, filter_num):
img = -img
img = img + m_img
image_path = "/Frame_%04i/Channel_Current" % (img_num)
image_path = "/Frame_%04i/Channel_Current" % img_num
for x in range(0, filter_num + 2):
image_path = "%s/Filter_Step_%04i" % (image_path, x)
......@@ -326,7 +326,7 @@ def apply_invert_filter(file_in_h5, img_num, filter_num):
except:
temp = 1
image_path = "%s/Filtered_Image" % (image_path)
image_path = "%s/Filtered_Image" % image_path
main_h5_handle[image_path] = img
h5_image_new = main_h5_handle.get(image_path)
h5_new_attrs = h5_image_new.attrs
......@@ -344,7 +344,7 @@ def apply_invert_filter(file_in_h5, img_num, filter_num):
h5_new_attrs["Parent"] = current_ref
h5_new_attrs["Parent_Region"] = current_reg
main_h5_handle.close
main_h5_handle.close()
return 1
......@@ -353,7 +353,7 @@ def apply_find(file_path_h5, file_name_h5, file_path_png, file_name_png, filter_
import numpy as np
import h5py as h5
image_path = "/Frame_%04i/Filtered_Data/Stack_0000" % (img_num)
image_path = "/Frame_%04i/Filtered_Data/Stack_0000" % img_num
for x in range(0, filter_num + 1):
image_path = "%s/Filter_Step_%04i" % (image_path, x)
......@@ -387,10 +387,10 @@ def apply_binarization_filter(file_in_h5, img_num, filter_num):
import h5py as h5
main_h5_handle = h5.File(file_in_h5, 'r+')
image_path = "/Frame_%04i/Channel_Current" % (img_num)
image_path = "/Frame_%04i/Channel_Current" % img_num
for x in range(0, filter_num + 1):
image_path = "%s/Filter_Step_%04i" % (image_path, x)
image_path = "%s/Filtered_Image" % (image_path)
image_path = "%s/Filtered_Image" % image_path
h5_image = main_h5_handle.get(image_path)
img = np.empty(h5_image.shape, dtype=h5_image.dtype)
......@@ -430,7 +430,7 @@ def apply_binarization_filter(file_in_h5, img_num, filter_num):
time_out[x] = r
time_out_i[x] = x + 1
image_path = "/Frame_%04i/Channel_Current" % (img_num)
image_path = "/Frame_%04i/Channel_Current" % img_num
for x in range(0, filter_num + 2):
image_path = "%s/Filter_Step_%04i" % (image_path, x)
......@@ -439,7 +439,7 @@ def apply_binarization_filter(file_in_h5, img_num, filter_num):
except:
temp = 1
image_path_f = "%s/Filtered_Image" % (image_path)
image_path_f = "%s/Filtered_Image" % image_path
main_h5_handle[image_path_f] = img
h5_image_new = main_h5_handle.get(image_path_f)
h5_new_attrs = h5_image_new.attrs
......@@ -457,19 +457,19 @@ def apply_binarization_filter(file_in_h5, img_num, filter_num):
h5_new_attrs["Parent"] = current_ref
h5_new_attrs["Parent_Region"] = current_reg
image_path_sv = "%s/Spectroscopic_Values" % (image_path)
image_path_sv = "%s/Spectroscopic_Values" % image_path
main_h5_handle[image_path_sv] = time_out
h5_image_new = main_h5_handle.get(image_path_sv)
new_sv_ref = h5_image_new.ref
new_sv_reg = h5_image_new.regionref[0:len(time_out)]
image_path_si = "%s/Spectroscopic_Indices" % (image_path)
image_path_si = "%s/Spectroscopic_Indices" % image_path
main_h5_handle[image_path_si] = time_out_i
h5_image_new = main_h5_handle.get(image_path_si)
new_si_ref = h5_image_new.ref
new_si_reg = h5_image_new.regionref[0:len(time_out)]
image_path_b = "%s/Binary_Matrix" % (image_path)
image_path_b = "%s/Binary_Matrix" % image_path
main_h5_handle[image_path_b] = filter_img
h5_image_new = main_h5_handle.get(image_path_b)
h5_new_attrs = h5_image_new.attrs
......@@ -497,10 +497,10 @@ def apply_binarization_filter_select(file_in_h5, img_num, filter_num, threshold)
import h5py as h5
main_h5_handle = h5.File(file_in_h5, 'r+')
image_path = "/Frame_%04i/Channel_Current" % (img_num)
image_path = "/Frame_%04i/Channel_Current" % img_num
for x in range(0, filter_num + 1):
image_path = "%s/Filter_Step_%04i" % (image_path, x)
image_path = "%s/Filtered_Image" % (image_path)
image_path = "%s/Filtered_Image" % image_path
h5_image = main_h5_handle.get(image_path)
img = np.empty(h5_image.shape, dtype=h5_image.dtype)
......@@ -534,7 +534,7 @@ def apply_binarization_filter_select(file_in_h5, img_num, filter_num, threshold)
temp[img > (i_min + (i_diff * r))] = 1
filter_img = temp[:, 0]
image_path = "/Frame_%04i/Channel_Current" % (img_num)
image_path = "/Frame_%04i/Channel_Current" % img_num
for x in range(0, filter_num + 2):
image_path = "%s/Filter_Step_%04i" % (image_path, x)
......@@ -543,7 +543,7 @@ def apply_binarization_filter_select(file_in_h5, img_num, filter_num, threshold)
except:
temp = 1
image_path = "%s/Filtered_Image" % (image_path)
image_path = "%s/Filtered_Image" % image_path
main_h5_handle[image_path] = filter_img
h5_image_new = main_h5_handle.get(image_path)
h5_new_attrs = h5_image_new.attrs
......@@ -573,10 +573,10 @@ def cluster_into_atomic_columns(file_in_h5, img_num, filter_num, dist_val):
import h5py as h5
main_h5_handle = h5.File(file_in_h5, 'r+')
image_path = "/Frame_%04i/Channel_Current" % (img_num)
image_path = "/Frame_%04i/Channel_Current" % img_num
for ifilt in range(0, filter_num + 1):
image_path = "%s/Filter_Step_%04i" % (image_path, ifilt)
image_path = "%s/Filtered_Image" % (image_path)
image_path = "%s/Filtered_Image" % image_path
h5_image = main_h5_handle.get(image_path)
img2 = np.empty(h5_image.shape, dtype=h5_image.dtype)
......@@ -606,8 +606,8 @@ def cluster_into_atomic_columns(file_in_h5, img_num, filter_num, dist_val):
centers = cluster_2d_oleg_return_geo_center(img, dist_val)
image_path_org = "/Frame_%04i/Channel_Current" % (img_num)
image_path_new = "/Frame_%04i/Channel_Finished" % (img_num)
image_path_org = "/Frame_%04i/Channel_Current" % img_num
image_path_new = "/Frame_%04i/Channel_Finished" % img_num
try:
main_h5_handle.__delitem__(image_path_new)
......@@ -629,8 +629,8 @@ def cluster_into_atomic_columns(file_in_h5, img_num, filter_num, dist_val):
for ifilt in range(0, filter_num + 1):
image_path_org = "%s/Filter_Step_%04i" % (image_path_org, ifilt)
image_path_new = "%s/Filter_Step_%04i" % (image_path_new, ifilt)
image_path_org_temp = "%s/Filtered_Image" % (image_path_org)
image_path_new_temp = "%s/Filtered_Image" % (image_path_new)
image_path_org_temp = "%s/Filtered_Image" % image_path_org
image_path_new_temp = "%s/Filtered_Image" % image_path_new
h5_image_old = main_h5_handle.get(image_path_org_temp)
img_old = np.empty(h5_image_old.shape, dtype=h5_image_old.dtype)
......@@ -654,10 +654,10 @@ def cluster_into_atomic_columns(file_in_h5, img_num, filter_num, dist_val):
h5_new_attrs["Number_Of_Variables"] = number_var
for ivar in range(1, number_var + 1):
var_name = h5_image_old.attrs.get("Variable_%01i_Name" % (ivar))
var_value = h5_image_old.attrs.get("Variable_%01i_Value" % (ivar))
h5_new_attrs["Variable_%01i_Name" % (ivar)] = var_name
h5_new_attrs["Variable_%01i_Value" % (ivar)] = var_value
var_name = h5_image_old.attrs.get("Variable_%01i_Name" % ivar)
var_value = h5_image_old.attrs.get("Variable_%01i_Value" % ivar)
h5_new_attrs["Variable_%01i_Name" % ivar] = var_name
h5_new_attrs["Variable_%01i_Value" % ivar] = var_value
h5_new_attrs["Spectroscopic_Indices"] = sec_i_ref
h5_new_attrs["Spectroscopic_Indices_Region"] = sec_i_reg
......@@ -673,7 +673,7 @@ def cluster_into_atomic_columns(file_in_h5, img_num, filter_num, dist_val):
parrent_ref = h5_image_new.ref
parrent_reg = h5_image_new.regionref[0:len(img_old)]
image_path = "%s/Lattice/Positions" % (image_path_new)
image_path = "%s/Lattice/Positions" % image_path_new
main_h5_handle[image_path] = centers
h5_image_new = main_h5_handle.get(image_path)
h5_new_attrs = h5_image_new.attrs
......@@ -695,12 +695,12 @@ def cluster_2d_oleg(mat_in, dist_val):
to_cluster = np.argwhere(mat_in)
to_cluster = to_cluster.tolist()
while (len(to_cluster) > 0):
while len(to_cluster) > 0:
clust = []
final_clust = []
clust.append(to_cluster[0])
to_cluster.remove(to_cluster[0])
while ((len(clust) > 0) & (len(to_cluster) > 0)):
while (len(clust) > 0) & (len(to_cluster) > 0):
tt[0] = 5000.0 * dist_val
tt[1] = len(to_cluster)
t1 = min(tt)
......@@ -715,8 +715,8 @@ def cluster_2d_oleg(mat_in, dist_val):
final_clust.append(clust[0])
clust.remove(clust[0])
if (len(clust) > 0):
while (len(clust) < 0):
if len(clust) > 0:
while len(clust) < 0:
final_clust.append(clust[0])
clust.remove(clust[0])
......@@ -733,12 +733,12 @@ def cluster_2d_oleg_return_geo_center(mat_in, dist_val):
to_cluster = np.argwhere(mat_in)
to_cluster = to_cluster.tolist()
while (len(to_cluster) > 0):
while len(to_cluster) > 0:
clust = []
final_clust = []
clust.append(to_cluster[0])
to_cluster.remove(to_cluster[0])
while ((len(clust) > 0) & (len(to_cluster) > 0)):
while (len(clust) > 0) & (len(to_cluster) > 0):
tt[0] = 5000.0 * dist_val
tt[1] = len(to_cluster)
t1 = min(tt)
......@@ -753,12 +753,12 @@ def cluster_2d_oleg_return_geo_center(mat_in, dist_val):
final_clust.append(clust[0])
clust.remove(clust[0])
if (len(clust) > 0):
while (len(clust) < 0):
if len(clust) > 0:
while len(clust) < 0:
final_clust.append(clust[0])
clust.remove(clust[0])
if (len(final_clust) > 2):
if len(final_clust) > 2: