本文整理匯總了Python中nexpy.gui.datadialogs.GridParameters.restore_parameters方法的典型用法代碼示例。如果您正苦於以下問題:Python GridParameters.restore_parameters方法的具體用法?Python GridParameters.restore_parameters怎麽用?Python GridParameters.restore_parameters使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類nexpy.gui.datadialogs.GridParameters
的用法示例。
在下文中一共展示了GridParameters.restore_parameters方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: RefineLatticeDialog
# 需要導入模塊: from nexpy.gui.datadialogs import GridParameters [as 別名]
# 或者: from nexpy.gui.datadialogs.GridParameters import restore_parameters [as 別名]
class RefineLatticeDialog(BaseDialog):
def __init__(self, parent=None):
super(RefineLatticeDialog, self).__init__(parent)
self.select_entry(self.choose_entry)
self.refine = NXRefine(self.entry)
self.refine.read_parameters()
self.parameters = GridParameters()
self.parameters.add('symmetry', self.refine.symmetries, 'Symmetry',
None, self.set_symmetry)
self.parameters.add('a', self.refine.a, 'Unit Cell - a (Ang)', True)
self.parameters.add('b', self.refine.b, 'Unit Cell - b (Ang)', True)
self.parameters.add('c', self.refine.c, 'Unit Cell - c (Ang)', True)
self.parameters.add('alpha', self.refine.alpha, 'Unit Cell - alpha (deg)', False)
self.parameters.add('beta', self.refine.beta, 'Unit Cell - beta (deg)', False)
self.parameters.add('gamma', self.refine.gamma, 'Unit Cell - gamma (deg)', False)
self.parameters.add('wavelength', self.refine.wavelength, 'Wavelength (Ang)', False)
self.parameters.add('distance', self.refine.distance, 'Distance (mm)', False)
self.parameters.add('yaw', self.refine.yaw, 'Yaw (deg)', False)
self.parameters.add('pitch', self.refine.pitch, 'Pitch (deg)', False)
self.parameters.add('roll', self.refine.roll, 'Roll (deg)')
self.parameters.add('xc', self.refine.xc, 'Beam Center - x', False)
self.parameters.add('yc', self.refine.yc, 'Beam Center - y', False)
self.parameters.add('phi_start', self.refine.phi_start, 'Phi Start (deg)', False)
self.parameters.add('phi_step', self.refine.phi_step, 'Phi Step (deg)')
self.parameters.add('chi_start', self.refine.chi_start, 'Chi Start (deg)', False)
self.parameters.add('chi_step', self.refine.chi_step, 'Chi Step (deg)')
self.parameters.add('omega_start', self.refine.omega_start, 'Omega Start (deg)', False)
self.parameters.add('omega_step', self.refine.omega_step, 'Omega Step (deg)')
self.parameters.add('polar', self.refine.polar_max,
'Max. Polar Angle (deg)', None, self.set_polar_max)
self.parameters.add('polar_tolerance', self.refine.polar_tolerance, 'Polar Angle Tolerance')
self.parameters.add('peak_tolerance', self.refine.peak_tolerance, 'Peak Angle Tolerance')
self.parameters.add('orientation_matrix', False, 'Orientation Matrix', False)
self.refine_buttons = self.action_buttons(
('Refine Angles', self.refine_angles),
('Refine HKLs', self.refine_hkls),
('Restore', self.restore_parameters),
('Reset', self.reset_parameters))
self.lattice_buttons = self.action_buttons(
('Plot', self.plot_lattice),
('List', self.list_peaks),
('Save', self.write_parameters))
self.set_layout(self.entry_layout, self.parameters.grid(),
self.refine_buttons, self.lattice_buttons,
self.close_buttons())
self.parameters.grid_layout.setVerticalSpacing(1)
self.set_title('Refining Lattice')
self.parameters['symmetry'].value = self.refine.symmetry
self.set_symmetry()
self.peaks_box = None
def choose_entry(self):
self.refine = NXRefine(self.entry)
self.update_parameters()
def update_parameters(self):
self.parameters['a'].value = self.refine.a
self.parameters['b'].value = self.refine.b
self.parameters['c'].value = self.refine.c
self.parameters['alpha'].value = self.refine.alpha
self.parameters['beta'].value = self.refine.beta
self.parameters['gamma'].value = self.refine.gamma
self.parameters['wavelength'].value = self.refine.wavelength
self.parameters['distance'].value = self.refine.distance
self.parameters['yaw'].value = self.refine.yaw
self.parameters['pitch'].value = self.refine.pitch
self.parameters['roll'].value = self.refine.roll
self.parameters['xc'].value = self.refine.xc
self.parameters['yc'].value = self.refine.yc
self.parameters['phi_start'].value = self.refine.phi_start
self.parameters['phi_step'].value = self.refine.phi_step
self.parameters['chi_start'].value = self.refine.chi_start
self.parameters['chi_step'].value = self.refine.chi_step
self.parameters['omega_start'].value = self.refine.omega_start
self.parameters['omega_step'].value = self.refine.omega_step
self.parameters['polar'].value = self.refine.polar_max
self.parameters['polar_tolerance'].value = self.refine.polar_tolerance
try:
self.refine.polar_angles, self.refine.azimuthal_angles = \
self.refine.calculate_angles(self.refine.xp, self.refine.yp)
except Exception:
pass
def transfer_parameters(self):
self.refine.a, self.refine.b, self.refine.c, \
self.refine.alpha, self.refine.beta, self.refine.gamma = \
self.get_lattice_parameters()
self.refine.set_symmetry()
self.refine.wavelength = self.get_wavelength()
#.........這裏部分代碼省略.........
示例2: CalibrateDialog
# 需要導入模塊: from nexpy.gui.datadialogs import GridParameters [as 別名]
# 或者: from nexpy.gui.datadialogs.GridParameters import restore_parameters [as 別名]
class CalibrateDialog(BaseDialog):
def __init__(self, parent=None):
super(CalibrateDialog, self).__init__(parent)
self.plotview = None
self.data = None
self.counts = None
self.points = []
self.pattern_geometry = None
self.cake_geometry = None
self.is_calibrated = False
cstr = str(ALL_CALIBRANTS)
calibrants = sorted(cstr[cstr.index(':')+2:].split(', '))
self.parameters = GridParameters()
self.parameters.add('calibrant', calibrants, 'Calibrant')
self.parameters['calibrant'].value = 'CeO2'
self.parameters.add('wavelength', 0.5, 'Wavelength (Ang)', False)
self.parameters.add('distance', 100.0, 'Detector Distance (mm)', True)
self.parameters.add('xc', 512, 'Beam Center - x', True)
self.parameters.add('yc', 512, 'Beam Center - y', True)
self.parameters.add('yaw', 0.0, 'Yaw (degrees)', True)
self.parameters.add('pitch', 0.0, 'Pitch (degrees)', True)
self.parameters.add('roll', 0.0, 'Roll (degrees)', True)
self.parameters.add('search_size', 10, 'Search Size (pixels)')
rings = ['Ring%s' % i for i in range(1,21)]
self.rings_box = self.select_box(rings)
self.set_layout(self.select_entry(self.choose_entry),
self.action_buttons(('Plot Calibration', self.plot_data)),
self.parameters.grid(header=False),
self.make_layout(
self.action_buttons(('Select Points', self.select)),
self.rings_box),
self.action_buttons(('Calibrate', self.calibrate),
('Plot Cake', self.plot_cake),
('Restore', self.restore_parameters),
('Save', self.save_parameters)),
self.close_buttons(close=True))
self.set_title('Calibrating Powder')
def choose_entry(self):
if 'calibration' not in self.entry['instrument']:
raise NeXusError('Please load calibration data to this entry')
self.update_parameters()
self.plot_data()
def update_parameters(self):
self.parameters['wavelength'].value = self.entry['instrument/monochromator/wavelength']
detector = self.entry['instrument/detector']
self.parameters['distance'].value = detector['distance']
self.parameters['yaw'].value = detector['yaw']
self.parameters['pitch'].value = detector['pitch']
self.parameters['roll'].value = detector['roll']
if 'beam_center_x' in detector:
self.parameters['xc'].value = detector['beam_center_x']
if 'beam_center_y' in detector:
self.parameters['yc'].value = detector['beam_center_y']
self.data = self.entry['instrument/calibration']
self.counts = self.data.nxsignal.nxvalue
@property
def search_size(self):
return int(self.parameters['search_size'].value)
@property
def ring(self):
return int(self.rings_box.currentText()[4:]) - 1
@property
def ring_color(self):
colors = ['r', 'b', 'g', 'c', 'm'] * 4
return colors[self.ring]
def plot_data(self):
if self.plotview is None:
if 'Powder Calibration' in plotviews:
self.plotview = plotviews['Powder Calibration']
else:
self.plotview = NXPlotView('Powder Calibration')
self.plotview.plot(self.data, log=True)
self.plotview.aspect='equal'
self.plotview.ytab.flipped = True
self.clear_peaks()
def on_button_press(self, event):
self.plotview.make_active()
if event.inaxes:
self.xp, self.yp = event.x, event.y
else:
self.xp, self.yp = 0, 0
def on_button_release(self, event):
if event.inaxes:
if abs(event.x - self.xp) > 5 or abs(event.y - self.yp) > 5:
return
x, y = self.plotview.inverse_transform(event.xdata, event.ydata)
for i, point in enumerate(self.points):
circle = point[0]
#.........這裏部分代碼省略.........