Jul-13-2017, 10:49 PM
(This post was last modified: Jul-13-2017, 10:49 PM by shaynehansen.)
Getting the error:
return self._RDMS_data[0:, channel_index]
IndexError: index 840 is out of bounds for axis 1 with size 840
The class RDMSDictionary is where the data is read in, and class Pdfs is where I am trying to access and get the IndexError.
Any help is greatly appreciated!
return self._RDMS_data[0:, channel_index]
IndexError: index 840 is out of bounds for axis 1 with size 840
The class RDMSDictionary is where the data is read in, and class Pdfs is where I am trying to access and get the IndexError.
Any help is greatly appreciated!
class RDMSDictionary(collections.abc.Mapping): def __init__(self, RDMS1, RDMS2, RDMS3, RDMS4, RDMS5, RDMS6, RDMS7, channel_file): RDMS_data = self._RDMSfile_data(RDMS1, RDMS2, RDMS3, RDMS4, RDMS5, RDMS6, RDMS7) RDMS_channel = self._RDMS_channels(channel_file) self._RDMS_data = RDMS_data self._RDMS_channel = RDMS_channel def _RDMSfile_data(self, file1, file2, file3, file4, file5, file6, file7): data1 = np.loadtxt(file1, delimiter = '\t', skiprows = 1) data1 = np.delete(data1, [0], axis = 1) data2 = np.loadtxt(file2, delimiter = '\t', skiprows = 1) data2 = np.delete(data2, [0], axis = 1) data3 = np.loadtxt(file3, delimiter = '\t', skiprows = 1) data3 = np.delete(data3, [0], axis = 1) data4 = np.loadtxt(file4, delimiter = '\t', skiprows = 1) data4 = np.delete(data4, [0], axis = 1) data5 = np.loadtxt(file5, delimiter = '\t', skiprows = 1) data5 = np.delete(data5, [0], axis = 1) data6 = np.loadtxt(file6, delimiter = '\t', skiprows = 1) data6 = np.delete(data6, [0], axis = 1) data7 = np.loadtxt(file7, delimiter = '\t', skiprows = 1) data7 = np.delete(data7, [0], axis = 1) RDMS_data_array = np.concatenate((data1, data2, data3, data4, data5, data6, data7), axis = 1) return RDMS_data_array def _RDMS_channels(self, channel_filename): with open(channel_filename, 'r') as cfile: self._RDMS_channel = [] for line in cfile: tokens = line.strip().split('\t') self._RDMS_channel.append(tokens[0]) return self._RDMS_channel def __getitem__(self, channel): if channel in self._RDMS_channel: channel_index = self._RDMS_channel.index(channel) return self._RDMS_data[0:, channel_index] else: raise KeyError("Channel entered is not in list of channels") def __len__(self): return len(self._RDMS_channel) def __iter__(self): return (x for x in self._RDMS_channel)
class Pdfs: def __init__(self, RDMS_pdf_name): RDMS_pdf = self._RDMS_pdf(RDMS_pdf_name) self._RDMS_pdf = RDMS_pdf def _RDMS_pdf(self, pdf_name): with PdfPages(pdf_name) as pdf: current_channel = iter(RDMSdict) n = dictionary._sample_size(key_filename) * dictionary._revolutions(etim_filename) for x in range(len(RDMSdict._RDMS_channels(RDMSchannels))): current = next(current_channel) plt.plot(range(0,n), RDMSdict[current], ':', linewidth = 0.25) pdf.savefig() plt.close()
RDMSfile1 = "R33P10_RDMS_Time1.txt" RDMSfile2 = "R33P10_RDMS_Time2.txt" RDMSfile3 = "R33P10_RDMS_Time3.txt" RDMSfile4 = "R33P10_RDMS_Time4.txt" RDMSfile5 = "R33P10_RDMS_Time5.txt" RDMSfile6 = "R33P10_RDMS_Time6.txt" RDMSfile7 = "R33P10_RDMS_Time7.txt" RDMSchannels = "R33P10_RDMS_channels.txt" RDMSdict = RDMSDictionary(RDMSfile1, RDMSfile2, RDMSfile3, RDMSfile4, RDMSfile5, RDMSfile6, RDMSfile7, RDMSchannels) pdf_name_RDMSfile = 'Data Comparison RDMS Files.pdf' create_pdfs= Pdfs(pdf_name_RDMSfile)