def OnClickUpdate(self, e): zwater, sig_water,sig_water_bar, d_water, Scale,specScale, beta, surface_new = param_unfold(self.nb.parameter,self.nb.parameter_usage,\ self.nb.surface, self.nb.MainControlPage.UBW_flag) bulk = self.nb.bulk #shift_bulk(zwater, self.nb.bulk) surface = RB_update(self.nb.rigid_bodies, surface_new, self.nb.parameter, self.allrasd.cell) for Rasd in self.allrasd.list: Rasd.re_FNR ,Rasd.im_FNR = calcFNR(Rasd.Q,sig_water,sig_water_bar,d_water,zwater, self.allrasd.cell, bulk, surface, database,\ self.allrasd.g_inv, self.nb.MainControlPage.UBW_flag) for item in range(len(self.allrasd.list)): self.allrasd.list[item] = RASD_Fourier(self.allrasd, item) self.datacontrol1[item].SetValue( str(round(self.allrasd.list[item].AR, 3))) self.datacontrol2[item].SetValue( str(round(self.allrasd.list[item].PR, 3)))
def OnClickUpdate(self, e): global_parms, surface_new = param_unfold(self.nb.parameter,self.nb.parameter_usage,self.nb.surface,\ self.nb.MainControlPage.UBW_flag, self.nb.MainControlPage.use_lay_el) bulk = self.nb.bulk surface = RB_update(self.nb.rigid_bodies, surface_new, self.nb.parameter, self.allrasd.cell) for Rasd in self.allrasd.list: Rasd.re_FNR ,Rasd.im_FNR = calcFNR(Rasd.Q,global_parms, self.allrasd.cell, bulk, surface, database,\ self.allrasd.g_inv, self.nb.MainControlPage.UBW_flag,\ self.nb.MainControlPage.use_lay_el, str.lower(self.resel)) for item in range(len(self.allrasd.list)): self.allrasd.list[item] = RASD_Fourier(self.allrasd, item) self.datacontrol1[item].SetValue( str(round(self.allrasd.list[item].AR, 3))) self.datacontrol2[item].SetValue( str(round(self.allrasd.list[item].PR, 3)))
def read_RSD(allrasd, bulk_tmp, surface_tmp, parameter, param_usage, rigid_bodies, database, rasddata, use_bulk_water, dirname, parent): """ read in data in RasdList of RasdAna objects for fitting """ if len(allrasd.E) == 0 and len(allrasd.f1) == 0: dlg = wx.MessageDialog(parent, "Please read in f1f2 data first", "", wx.OK | wx.STAY_ON_TOP) if dlg.ShowModal() == wx.OK: dlg.Destroy() return allrasd elif allrasd.E0 == 0: dlg = wx.MessageDialog(parent, "Please specify Edge Energy first", "", wx.OK | wx.STAY_ON_TOP) if dlg.ShowModal() == wx.OK: dlg.Destroy() return allrasd else: zwater, sig_water, sig_water_bar, d_water, Scale, specScale, beta, surface_new = param_unfold( parameter, param_usage, surface_tmp, use_bulk_water) bulk = bulk_tmp #shift_bulk(zwater, bulk_tmp) surface = RB_update(rigid_bodies, surface_new, parameter, allrasd.cell) cell = allrasd.cell g_inv = allrasd.g_inv allrasd.ndata = 0 for dat in rasddata: n = len(dat) if dat[n - 1] == '\n': dat = str.rstrip(dat, '\n') Q = None f = file(dirname + '/' + dat, 'r') data = f.readlines() f.close() Rasd = RasdAna() for i in range(len(data)): if '#' not in data[i]: tmp = str.rsplit(data[i]) if Q == None: Q = Num.array([tmp[1], tmp[2], tmp[3]], float) Rasd.Q = Q Rasd.mod_Q = Num.dot(Num.dot(Q, g_inv), Q)**0.5 Rasd.re_FNR, Rasd.im_FNR = calcFNR( Q, sig_water, sig_water_bar, d_water, zwater, cell, bulk, surface, database, g_inv, use_bulk_water) Rasd.E = Num.append(Rasd.E, int(round(float(tmp[0])))) Rasd.F = Num.append(Rasd.F, float(tmp[4])**2) Rasd.Ferr = Num.append(Rasd.Ferr, float(tmp[5])**2) Rasd.Alpha = Num.append(Rasd.Alpha, float(tmp[6])) Rasd.Beta = Num.append(Rasd.Beta, float(tmp[7])) Rasd.E0 = allrasd.E0 for x in Rasd.E: Rasd.Eorig = Num.append(Rasd.Eorig, x) Rasd.abs_corr = Num.ones((len(Rasd.E)), float) Rasd.ndata = len(Rasd.E) Rasd.file = dat allrasd.ndata = allrasd.ndata + Rasd.ndata i = 0 Rasd.f1 = Num.ndarray((Rasd.ndata), float) Rasd.f2 = Num.ndarray((Rasd.ndata), float) for i in range(Rasd.ndata): j = 0 for j in range(len(allrasd.E)): if Rasd.E[i] == allrasd.E[j]: Rasd.f1[i] = allrasd.f1[j] Rasd.f2[i] = allrasd.f2[j] allrasd.list.append(Rasd) allrasd.dims = len(allrasd.list) return allrasd
def createStructureRenderer(surface,cell,param,param_use,rigid_bodies,atom_styles): global_parms, surface = \ param_unfold(param, param_use, surface, False, False) surface = RB_update(rigid_bodies, surface, param, cell) actors = [] M = calcM(cell) supercell = [] for i in surface: if i[10] > 0: uxy = i[7] * (i[4] * i[5])**0.5 uxz = i[8] * (i[4] * i[6])**0.5 uyz = i[9] * (i[5] * i[6])**0.5 U = Num.array([[i[4],uxy,uxz],\ [uxy,i[5],uyz],\ [uxz,uyz,i[6]]],float) Uinv = Num.linalg.inv(U) supercell.append([i[0],Num.array([i[1],i[2],i[3]]),Uinv]) supercell.append([i[0],Num.array([i[1]+1,i[2],i[3]]),Uinv]) supercell.append([i[0],Num.array([i[1],i[2]+1,i[3]]),Uinv]) supercell.append([i[0],Num.array([i[1]+1,i[2]+1,i[3]]),Uinv]) #create an ellipsoid for every atom in supercell for i in range(len(supercell)): # create source point = supercell[i][1] [point] = aff2euk(M,[point]) Uinv = supercell[i][2] if supercell[i][0] not in atom_styles.keys(): color = [1,1,1] else: color = atom_styles[supercell[i][0]] actor = Ellipsoid(point, color, Uinv) actors.append(actor) # Create cell corner points points = [] for i in [0.,1.]: for j in [0.,1.]: for k in [0.,1.]: points.append([i,j,k]) points = aff2euk(M, points) #create cell edge lines line_id1 = [0,0,0,1,1,2,2,3,4,4,5,6] line_id2 = [1,2,4,3,5,3,6,7,5,6,7,7] for i in range(12): line = vtk.vtkLineSource() line.SetPoint1(points[line_id1[i]]) line.SetPoint2(points[line_id2[i]]) mapper = vtk.vtkPolyDataMapper() mapper.SetInput(line.GetOutput()) actor = vtk.vtkActor() actor.SetMapper(mapper) actor.GetProperty().SetColor(1,1,1) # (R,G,B) actors.append(actor) # create a renderer ren = vtk.vtkRenderer() # assign actors to the renderer for actor in actors: ren.AddActor(actor) ren.SetBackground(0.0,0.0,0.0) ren.GetActiveCamera().ParallelProjectionOn() ren.ResetCamera() ren.GetActiveCamera().Azimuth(180) ren.GetActiveCamera().Elevation(270) ren.ResetCameraClippingRange() return ren
def read_RSD(allrasd, bulk_tmp, surface_tmp, parameter, param_usage, rigid_bodies, database, rasddata, use_bulk_water, use_lay_el, el, dirname, parent): """ read in data in RasdList of RasdAna objects for fitting """ if len(allrasd.E) == 0 and len(allrasd.f1) == 0: dlg = wx.MessageDialog(parent, "Please read in f1f2 data first", "", wx.OK | wx.STAY_ON_TOP) if dlg.ShowModal() == wx.OK: dlg.Destroy() return allrasd elif allrasd.E0 == 0: dlg = wx.MessageDialog(parent, "Please specify Edge Energy first", "", wx.OK | wx.STAY_ON_TOP) if dlg.ShowModal() == wx.OK: dlg.Destroy() return allrasd else: global_parms, surface_new = param_unfold(parameter, param_usage, surface_tmp, use_bulk_water, use_lay_el) bulk = bulk_tmp surface = RB_update(rigid_bodies, surface_new, parameter, allrasd.cell) cell = allrasd.cell g_inv = allrasd.g_inv allrasd.ndata = 0 allrasd.RMS = 0 f1 = interp1d(allrasd.E, allrasd.f1, 'cubic') f2 = interp1d(allrasd.E, allrasd.f2, 'cubic') for dat in rasddata: n = len(dat) if dat[n - 1] == '\n': dat = str.rstrip(dat, '\n') Q = None f = file(dirname + '/' + dat, 'r') data = f.readlines() f.close() Rasd = RasdAna() for i in range(len(data)): if '#' not in data[i]: tmp = str.rsplit(data[i]) if Q == None: Q = Num.array([tmp[1], tmp[2], tmp[3]], float) Rasd.Q = Q Rasd.mod_Q = Num.dot(Num.dot(Q, g_inv), Q)**0.5 Rasd.re_FNR, Rasd.im_FNR = calcFNR( Q, global_parms, cell, bulk, surface, database, g_inv, use_bulk_water, use_lay_el, el) Rasd.E = Num.append(Rasd.E, float(tmp[0])) Rasd.F = Num.append(Rasd.F, float(tmp[4])**2) Rasd.f1 = Num.append(Rasd.f1, f1(Rasd.E[-1])) Rasd.f2 = Num.append(Rasd.f2, f2(Rasd.E[-1])) if float(tmp[5]) == 0: Rasd.Ferr = Num.append(Rasd.Ferr, 1.0) else: Rasd.Ferr = Num.append(Rasd.Ferr, float(tmp[5])**2) Rasd.Alpha = Num.append(Rasd.Alpha, float(tmp[6])) Rasd.Beta = Num.append(Rasd.Beta, float(tmp[7])) Rasd.E0 = allrasd.E0 for x in Rasd.E: Rasd.Eorig = Num.append(Rasd.Eorig, x) Rasd.abs_corr = Num.ones((len(Rasd.E)), float) Rasd.ndata = len(Rasd.E) Rasd.file = dat allrasd.ndata = allrasd.ndata + Rasd.ndata allrasd.list.append(Rasd) allrasd.dims = len(allrasd.list) allrasd.RMS = allrasd.RMS / allrasd.ndata return allrasd