def export_cube(filename, data, data_view): """ export the entire cube to an excel file in the original file's folder. format is xdata, spectrum etc. """ display_ev = copy.copy(data_view.display_ev) no_ext_filename, ext = os.path.splitext(filename) out_filename = no_ext_filename + '.csv' rows, columns, slices = np.shape(data.ycube[...]) spectra_count = 0 for i in np.arange(rows): for j in np.arange(columns): xdata = analysis.xdata_calc2(data.xdata, data.xdata_info['data_type'], display_ev) ydata = analysis.ydata_calc2(data.ycube[i, j, :], data.xdata, data.xdata_info['data_type'], display_ev) if spectra_count == 0: out = np.c_[xdata, ydata] spectra_count = 1 else: out = np.c_[out, xdata, ydata] print np.shape(out) np.savetxt(str(out_filename), out, delimiter=",", fmt="%10.5f")
def convert_ev_cube_process(self, hdf5_file, wavelength_xdata, dimension1, dimension2): """ makes an ev cube from wavelength cube and puts it into original file """ locker = QtCore.QMutexLocker(self.convert_mutex) ev_xdata = 1240/wavelength_xdata ev_step = ev_xdata[1]-ev_xdata[0] rebinned_ev_xdata = np.arange(start=ev_xdata[0], stop=ev_xdata[-1], step=ev_step) ev_list_size, = np.shape(rebinned_ev_xdata) ev_cube = hdf5_file.create_dataset('Experiments/__unnamed__/ev_data', (dimension1, dimension2, ev_list_size)) hdf5_file.create_dataset('Experiments/__unnamed__/ev_xdata', data=rebinned_ev_xdata) for i in np.arange(dimension1): for j in np.arange(dimension2): if self.stop_convert: return ydata = hdf5_file["Experiments/__unnamed__/data"][i,j,:] ev_ydata = analysis.ydata_calc2(input_ydata=ydata, input_xdata=wavelength_xdata, dtype='wavelength', display_ev=True) rebinned_ev_ydata = self.rebin_ev_ydata(ev_ydata,ev_xdata, rebinned_ev_xdata) ev_cube[i,j,:] = rebinned_ev_ydata current_spectrum = i*dimension2 + j self.update_progress(current_spectrum) self.progress_window.close()
def export_cube(filename, data, data_view): """ export the entire cube to an excel file in the original file's folder. format is xdata, spectrum etc. """ display_ev = copy.copy(data_view.display_ev) no_ext_filename, ext = os.path.splitext(filename) out_filename = no_ext_filename + '.csv' rows, columns, slices = np.shape(data.ycube[...]) spectra_count = 0 for i in np.arange(rows): for j in np.arange(columns): xdata = analysis.xdata_calc2(data.xdata, data.xdata_info['data_type'], display_ev) ydata = analysis.ydata_calc2(data.ycube[i,j,:], data.xdata, data.xdata_info['data_type'], display_ev) if spectra_count == 0: out = np.c_[xdata, ydata] spectra_count = 1 else: out = np.c_[out, xdata, ydata] print np.shape(out) np.savetxt(str(out_filename), out, delimiter=",", fmt="%10.5f")
def fit_cube_process(self): locker = QtCore.QMutexLocker(self.spectrum_holder.cube_mutex) self.spectrum_holder.notify_cube_fitting() self.spectrum_viewer.textbox_spectrum_box.setReadOnly(True) (rows,columns,slices) = np.shape(self.data.ycube[...]) #self.progress_bar = self.fit_cube_progress_bar(rows*columns) value = 0 self.stop_fit = False row_count=0 for i in np.arange(rows): column_count = 0 for j in np.arange(columns): peak_holder = DataHolder() ydata = analysis.ydata_calc2(input_ydata=self.data.ycube[i,j,:], input_xdata = self.data.xdata, dtype=self.data.xdata_info['data_type'], display_ev = self.display_ev) ydata = np.float64(ydata) peak_holder.load_from_mf1_cube(self.xdata[:], ydata, j, i) spectrum = peak_holder.get_spectrum(0) if row_count == 0: self.fit_from_spectrum_holder(spectrum) row_count = 1 column_count = 1 elif column_count == 0: index = i*(columns-1) self.fit_from_cube_peaks(spectrum, index) column_count = 1 else: index = -1 self.fit_from_cube_peaks(spectrum, index) peak_list = [] for peak in spectrum.peaks.peak_list: peak_list.append(peak.get_spec()) self.spectrum_holder.cube_peaks.append(peak_list) norm_int_res = self.get_normalized_integrated_residuals(spectrum) self.spectrum_holder.cube_residuals.append(norm_int_res) if self.stop_fit is True: return value += 1 self.update_progress(value) self.progress_window.close() self.spectrum_holder.notify_cube_fitted() self.spectrum_viewer.textbox_spectrum_box.setReadOnly(False) self.spectrum_viewer.label_cube_fitted.setText("Cube Box Loaded")