out_curr[:, 2] = tmp_curr.copy() f = open(name_file, 'w') print("WSxM file copyright Nanotec Electronica", file=f) print( "WSxM ASCII XYZ file; obtained from dIdV code by Krejci et al.", file=f) print("X[A] Y[A] Z[A]", file=f) print("", file=f) np.savetxt(f, out_curr) f.close() # print("WSxM files written") if XSF: print("writing XSF files") xsf_head = Bu.At2XSF(geom_plot) if plot_atoms else GU.XSF_HEAD_DEFAULT for vv in range(NoV): if didv_b: name_file = 'didv_' + namez[ vv] + "_tip_" + tip_type + "-" + tip_orb + "_WF_" + str( WorkFunction - Voltages[vv] * WF_decay) + "_eta_" + str(eta) + '.xsf' GU.saveXSF(name_file, didv[vv], lvec, head=xsf_head) if STM_b: name_file = 'STM_' + namez[ vv] + "_tip_" + tip_type + "-" + tip_orb + "_WF_" + str( WorkFunction) + "_WF_decay_" + str(round( WF_decay, 1)) + "_eta_" + str(eta) + '.xsf' GU.saveXSF(name_file, current[vv], lvec, head=xsf_head) print("XSF files written")
def saveData(self): mapType = self.parent.map vv = self.parent.Vindx k = self.parent.Hindx namez = self.parent.plotData['namez'] tip_type = self.parent.plotData['tip_type'] WorkFunction = self.parent.plotData['WorkFunction'] Voltages = self.parent.plotData['Voltages'] WF_decay = self.parent.plotData['WF_decay'] eta = self.parent.myDict['etaValue'] if mapType == 'dIdV': fileName, fext = QFileDialog.getSaveFileName( self, "QFileDialog.getSaveFileName()", 'didv_' + namez[vv] + "_tip_" + tip_type + "-" + "_WF_" + str(WorkFunction - Voltages[vv] * WF_decay) + "_eta_" + str(eta) + '_%03d' % k, "WSxM Files (*.xyz);;XSF Files (*.xsf);;NPY Files (*.npy)") else: fileName, fext = QFileDialog.getSaveFileName( self, "QFileDialog.getSaveFileName()", 'STM_' + namez[vv] + "_tip_" + tip_type + "-" + "_WF_" + str(WorkFunction) + "_WF_decay_" + str(round(WF_decay, 1)) + "_eta_" + str(eta) + '_%03d' % k, "WSxM Files (*.xyz);;XSF Files (*.xsf);;NPY Files (*.npy)") if fileName: if fext == '(*.xsf)': print( "For XSF or NPY outputs or tip_type = relaxed you have to have installed PPAFM in your PPSTM directory " ) import pyPPSTM.GridUtils as GU print("writing XSF files") geom_plot = self.parent.plotData['geom_plot'] lvec = self.parent.plotData['lvec'] xsf_head = Bu.At2XSF( geom_plot) #if plot_atoms else GU.XSF_HEAD_DEFAULT if mapType == 'dIdV': didv = self.parent.plotData['didv'] GU.saveXSF(fileName, didv[vv], lvec, head=xsf_head) elif mapType == 'STM': current = self.parent.plotData['current'] GU.saveXSF(fileName, current[vv], lvec, head=xsf_head) print("XSF files written") elif fext == '(*.npy)': print( "For XSF or NPY outputs or tip_type = relaxed you have to have installed PPAFM in your PPSTM directory " ) import pyPPSTM.GridUtils as GU print("writing npy binary files") lvec = self.parent.plotData['lvec'] if mapType == 'dIdV': didv = self.parent.plotData['didv'] GU.saveNpy(fileName, didv[vv], lvec) #, head=XSF_HEAD_DEFAULT ) elif mapType == 'STM': current = self.parent.plotData['current'] GU.saveNpy(fileName, current[vv], lvec) #, head=XSF_HEAD_DEFAULT ) print("npy files written") else: # default write in WSxM print("writing WSxM files") tip_r0 = self.parent.plotData['tip_r0'] if mapType == 'dIdV': didv = self.parent.plotData['didv'] tmp_curr = didv[vv, k, :, :].flatten() out_curr = np.zeros((len(tmp_curr), 3)) out_curr[:, 0] = tip_r0[k, :, :, 0].flatten() out_curr[:, 1] = tip_r0[k, :, :, 1].flatten() out_curr[:, 2] = tmp_curr.copy() f = open(fileName, 'w') print("WSxM file copyright Nanotec Electronica", file=f) print( "WSxM ASCII XYZ file; obtained from dIdV code by Krejci et al.", file=f) print("X[A] Y[A] Z[A]", file=f) print("", file=f) np.savetxt(f, out_curr) f.close() elif mapType == 'STM': current = self.parent.plotData['current'] tmp_curr = current[vv, k, :, :].flatten() out_curr = np.zeros((len(tmp_curr), 3)) out_curr[:, 0] = tip_r0[k, :, :, 0].flatten() out_curr[:, 1] = tip_r0[k, :, :, 1].flatten() out_curr[:, 2] = tmp_curr.copy() f = open(fileName, 'w') print("WSxM file copyright Nanotec Electronica", file=f) print( "WSxM ASCII XYZ file; obtained from dIdV code by Krejci et al.", file=f) print("X[A] Y[A] Z[A]", file=f) print("", file=f) np.savetxt(f, out_curr) f.close() print("WSxM files written") print("Data saved")