本文整理匯總了Python中nexpy.gui.datadialogs.GridParameters類的典型用法代碼示例。如果您正苦於以下問題:Python GridParameters類的具體用法?Python GridParameters怎麽用?Python GridParameters使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了GridParameters類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: MaskDialog
class MaskDialog(BaseDialog):
def __init__(self, parent=None):
super(MaskDialog, self).__init__(parent)
self.select_entry(self.choose_entry)
self.parameters = GridParameters()
self.parameters.add('mask', 'pilatus_mask/entry/mask', 'Mask Path')
self.action_buttons(('Save Mask', self.save_mask))
self.set_layout(self.entry_layout, self.parameters.grid(),
self.action_buttons(('Save Mask', self.save_mask)),
self.close_buttons())
self.set_title('Mask Data')
def save_mask(self):
try:
mask = self.treeview.tree[self.parameters['mask'].value]
if mask.dtype != np.bool:
raise NeXusError('Mask must be a Boolean array')
elif len(mask.shape) == 1:
raise NeXusError('Mask must be at least two-dimensional')
elif len(mask.shape) > 2:
mask = mask[0]
self.entry['instrument/detector/pixel_mask'] = mask
self.entry['instrument/detector/pixel_mask_applied'] = False
except NeXusError as error:
report_error('Applying Mask', error)
示例2: SampleDialog
class SampleDialog(BaseDialog):
def __init__(self, parent=None):
super(SampleDialog, self).__init__(parent)
self.sample = GridParameters()
self.sample.add('sample', 'sample', 'Sample Name')
self.sample.add('label', 'label', 'Sample Label')
self.set_layout(self.directorybox('Choose Experiment Directory',
default=False),
self.sample.grid(header=False),
self.close_buttons(save=True))
self.set_title('New Sample')
def accept(self):
home_directory = self.get_directory()
self.mainwindow.default_directory = home_directory
sample_directory = os.path.join(home_directory,
self.sample['sample'].value,
self.sample['label'].value)
if not os.path.exists(sample_directory):
os.makedirs(sample_directory)
super(SampleDialog, self).accept()
示例3: EnergyDialog
class EnergyDialog(BaseDialog):
def __init__(self, parent=None):
super(EnergyDialog, self).__init__(parent)
layout = QtGui.QVBoxLayout()
self.select_entry()
self.parameters = GridParameters()
self.parameters.add('m1', self.entry['monitor1/distance'],
'Monitor 1 Distance')
self.parameters.add('m2', self.entry['monitor2/distance'],
'Monitor 2 Distance')
self.parameters.add('Ei', self.entry['instrument/monochromator/energy'],
'Incident Energy')
self.parameters.add('mod', self.entry['instrument/source/distance'],
'Moderator Distance')
layout.addLayout(self.entry_layout)
layout.addLayout(self.parameters.grid())
layout.addLayout(self.action_buttons(('Get Ei', self.get_ei)))
layout.addWidget(self.close_buttons(save=True))
self.setLayout(layout)
self.setWindowTitle('Get Incident Energy')
self.m1 = self.entry['monitor1']
self.m2 = self.entry['monitor2']
@property
def m1_distance(self):
return self.parameters['m1'].value - self.moderator_distance
@property
def m2_distance(self):
return self.parameters['m2'].value - self.moderator_distance
@property
def Ei(self):
return self.parameters['Ei'].value
@property
def moderator_distance(self):
return self.parameters['mod'].value
def get_ei(self):
t = 2286.26 * self.m1_distance / np.sqrt(self.Ei)
m1_time = self.m1[t-200.0:t+200.0].moment()
t = 2286.26 * self.m2_distance / np.sqrt(self.Ei)
m2_time = self.m2[t-200.0:t+200.0].moment()
self.parameters['Ei'].value = (2286.26 * (self.m2_distance - self.m1_distance) /
(m2_time - m1_time))**2
def accept(self):
try:
self.parameters['Ei'].save()
except NeXusError as error:
report_error("Getting Incident Energy", error)
super(EnergyDialog, self).accept()
示例4: __init__
def __init__(self, parent=None):
super(FindDialog, self).__init__(parent)
self.select_entry(self.choose_entry)
self.parameters = GridParameters()
self.parameters.add('threshold', '', 'Threshold')
self.parameters.add('first', '', 'First Frame')
self.parameters.add('last', '', 'Last Frame')
find_layout = QtWidgets.QHBoxLayout()
self.find_button = QtWidgets.QPushButton('Find Peaks')
self.find_button.clicked.connect(self.find_peaks)
self.peak_count = QtWidgets.QLabel()
self.peak_count.setVisible(False)
find_layout.addStretch()
find_layout.addWidget(self.find_button)
find_layout.addWidget(self.peak_count)
find_layout.addStretch()
self.set_layout(self.entry_layout,
self.parameters.grid(),
find_layout,
self.progress_layout(save=True))
self.progress_bar.setVisible(False)
self.progress_bar.setValue(0)
self.set_title('Find Peaks')
self.reduce = None
示例5: __init__
def __init__(self, parent=None):
super(LatticeDialog, self).__init__(parent)
self.select_entry(self.choose_entry)
self.refine = NXRefine()
self.parameters = GridParameters()
self.parameters.add('symmetry', self.refine.symmetries, 'Symmetry',
slot=self.set_lattice_parameters)
self.parameters.add('centring', self.refine.centrings, 'Cell Centring')
self.parameters.add('a', self.refine.a, 'Unit Cell - a (Ang)',
slot=self.set_lattice_parameters)
self.parameters.add('b', self.refine.b, 'Unit Cell - b (Ang)',
slot=self.set_lattice_parameters)
self.parameters.add('c', self.refine.c, 'Unit Cell - c (Ang)',
slot=self.set_lattice_parameters)
self.parameters.add('alpha', self.refine.alpha, 'Unit Cell - alpha (deg)',
slot=self.set_lattice_parameters)
self.parameters.add('beta', self.refine.beta, 'Unit Cell - beta (deg)',
slot=self.set_lattice_parameters)
self.parameters.add('gamma', self.refine.gamma, 'Unit Cell - gamma (deg)',
slot=self.set_lattice_parameters)
self.parameters['symmetry'].value = self.refine.symmetry
self.parameters['centring'].value = self.refine.centring
action_buttons = self.action_buttons(('Plot', self.plot_lattice),
('Save', self.write_parameters))
self.set_layout(self.entry_layout, self.parameters.grid(),
action_buttons, self.close_buttons())
self.set_title('Defining Lattice')
示例6: __init__
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
示例7: setup_scans
def setup_scans(self):
self.scan = GridParameters()
self.scan.add('scan', 'scan', 'Scan Label')
self.scan.add('temperature', 300.0, 'Temperature (K)')
self.scan.add('phi_start', -5.0, 'Phi Start (deg)')
self.scan.add('phi_end', 360.0, 'Phi End (deg)')
self.scan.add('phi_step', 0.1, 'Phi Step (deg)')
self.scan.add('frame_rate', 10, 'Frame Rate (Hz)')
for position in range(1, 6):
self.setup_position(position)
示例8: setup_sample
def setup_sample(self):
self.scan_file['entry/sample'] = NXsample()
self.scan_file['entry/sample/name'] = 'sample'
self.scan_file['entry/sample/label'] = 'label'
self.scan_file['entry/sample/temperature'] = NXfield(300.0, dtype=np.float32)
self.scan_file['entry/sample/temperature'].attrs['units'] = 'K'
self.sample = GridParameters()
self.sample.add('sample', self.scan_file['entry/sample/name'], 'Sample Name')
self.sample.add('label', self.scan_file['entry/sample/label'], 'Sample Label')
self.sample.add('scan', 'scan', 'Scan Label')
self.sample.add('temperature', self.scan_file['entry/sample/temperature'], 'Temperature (K)')
示例9: __init__
def __init__(self, parent=None):
super(SampleDialog, self).__init__(parent)
self.sample = GridParameters()
self.sample.add('sample', 'sample', 'Sample Name')
self.sample.add('label', 'label', 'Sample Label')
self.set_layout(self.directorybox('Choose Experiment Directory',
default=False),
self.sample.grid(header=False),
self.close_buttons(save=True))
self.set_title('New Sample')
示例10: __init__
def __init__(self, parent=None):
super(ConvertDialog, self).__init__(parent)
self.select_entry()
self.parameters = GridParameters()
self.parameters.add('Ei', self.entry['instrument/monochromator/energy'],
'Incident Energy')
self.parameters.add('dQ', self.round(np.sqrt(self.Ei/2)/50), 'Q Step')
self.parameters.add('dE', self.round(self.Ei/50), 'Energy Step')
self.set_layout(self.entry_layout,
self.parameters.grid(),
self.action_buttons(('Plot', self.plot_data),
('Save', self.save_data)),
self.close_buttons())
self.setWindowTitle('Converting to (Q,E)')
示例11: __init__
def __init__(self, parent=None):
super(EnergyDialog, self).__init__(parent)
self.select_entry()
self.parameters = GridParameters()
self.parameters.add("m1", self.entry["monitor1/distance"], "Monitor 1 Distance")
self.parameters.add("m2", self.entry["monitor2/distance"], "Monitor 2 Distance")
self.parameters.add("Ei", self.entry["instrument/monochromator/energy"], "Incident Energy")
self.parameters.add("mod", self.entry["instrument/source/distance"], "Moderator Distance")
action_buttons = self.action_buttons(("Get Ei", self.get_ei))
self.set_layout(self.entry_layout, self.parameters.grid(), action_buttons, self.close_buttons(save=True))
self.set_title("Get Incident Energy")
self.m1 = self.entry["monitor1"]
self.m2 = self.entry["monitor2"]
示例12: setup_scans
def setup_scans(self):
if self.scans:
self.scans.delete_grid()
self.scans = GridParameters()
all_files = [self.sample+'_'+d+'.nxs'
for d in os.listdir(self.sample_directory)
if os.path.isdir(os.path.join(self.sample_directory, d))]
filenames = sorted([f for f in all_files
if os.path.exists(os.path.join(self.sample_directory, f))],
key=natural_sort)
for i, f in enumerate(filenames):
scan = 'f%d' % i
self.scans.add(scan, i+1, f, True, self.update_scans)
self.scans[scan].checkbox.stateChanged.connect(self.update_scans)
self.insert_layout(2, self.scans.grid(header=False))
示例13: __init__
def __init__(self, parent=None):
super(Mask3DDialog, self).__init__(parent)
self.select_entry(self.choose_entry)
self.parameters = GridParameters()
self.parameters.add('radius', 200, 'Radius')
self.parameters.add('width', 3, 'Frame Width')
self.set_layout(self.entry_layout,
self.parameters.grid(),
self.action_buttons(('Calculate 3D Mask', self.calculate_mask)),
self.progress_layout(save=True))
self.progress_bar.setVisible(False)
self.progress_bar.setValue(0)
self.set_title('Calculate 3D Mask')
self.reduce = None
示例14: setup_instrument
def setup_instrument(self):
entry = self.scan_file['entry']
entry.instrument = NXinstrument()
entry.instrument.monochromator = NXmonochromator()
entry.instrument.detector = NXdetector()
entry['instrument/monochromator/wavelength'] = NXfield(0.5, dtype=np.float32)
entry['instrument/monochromator/wavelength'].attrs['units'] = 'Angstroms'
entry['instrument/detector/distance'] = NXfield(100.0, dtype=np.float32)
entry['instrument/detector/distance'].attrs['units'] = 'mm'
entry['instrument/detector/pixel_size'] = NXfield(0.172, dtype=np.float32)
entry['instrument/detector/pixel_size'].attrs['units'] = 'mm'
self.instrument = GridParameters()
self.instrument.add('wavelength', entry['instrument/monochromator/wavelength'], 'Wavelength (Ang)')
self.instrument.add('distance', entry['instrument/detector/distance'], 'Detector Distance (mm)')
self.instrument.add('pixel', entry['instrument/detector/pixel_size'], 'Pixel Size (mm)')
self.instrument.add('positions', [0,1,2,3,4], 'Number of Detector Positions', slot=self.set_entries)
self.instrument['positions'].value = '0'
示例15: __init__
def __init__(self, parent=None):
super(CalculateDialog, self).__init__(parent)
self.select_entry(self.choose_entry)
self.refine = NXRefine()
self.parameters = GridParameters()
self.parameters.add('wavelength', self.refine.wavelength, 'Wavelength (Ang)')
self.parameters.add('distance', self.refine.distance, 'Detector Distance (mm)')
self.parameters.add('xc', self.refine.xc, 'Beam Center - x')
self.parameters.add('yc', self.refine.yc, 'Beam Center - y')
self.parameters.add('pixel', self.refine.pixel_size, 'Pixel Size (mm)')
action_buttons = self.action_buttons(('Plot', self.plot_lattice),
('Save', self.write_parameters))
self.set_layout(self.entry_layout, self.parameters.grid(),
action_buttons, self.close_buttons())
self.set_title('Calculate Angles')