def updateRegister(self, bidi_parameter:BIDI_PARAMETER, value_array:numpy.ndarray) -> bool: # 0. Ensure bitrange is valid assert bidi_parameter.bitrange_array.shape == value_array.shape # 1. Overwrite mentioned registers self.allBits()[bidi_parameter.bitrange_array] = value_array # 2. Prepare addresses and bit list AlteredAdresses = bidi_parameter.bitrange_array / self.WORD_LENGTH UpdatedRegisters = numpy.unique(AlteredAdresses.astype(numpy.int)) # 3. Iterate over updated registers and write to Bidi success = True for address in numpy.nditer(UpdatedRegisters): content = self.registers_Bits[address] bitstring = numpy.array2string(content, separator='')[1:-1] print("Write to " + num2strg(address) + " : " + bitstring) # TODO: Write the stuff success = success and self.HAMMERHEAD.write( address,int(bitstring,2) ) return success
def fill_people_marker(self, marker_id): """Fill a marker of a woman marker_id the number of the human """ marker = Marker() frame = "/robot_" + num2strg(marker_id) marker.id = marker_id marker.header.frame_id = frame + '/base_link' # marker.header.frame_id = '/robot_0/base_link' marker.header.stamp = rospy.Time.now() marker.type = Marker.MESH_RESOURCE if marker_id % 2 == 0: marker.mesh_resource = "package://social_filter/meshes/man2/models/man1.dae" marker.scale.x = 40 marker.scale.y = 35 marker.scale.z = 50 marker.pose.position.y += 0.04 quaternion = tf.transformations.quaternion_from_euler(0, 0, 1.82) else: marker.mesh_resource = "package://social_filter/meshes/female1/models/female1.dae" marker.scale.x = 0.45 marker.scale.y = 0.35 marker.scale.z = 0.5 quaternion = tf.transformations.quaternion_from_euler(0, 0, 1.57) marker.pose.orientation.x = quaternion[0] marker.pose.orientation.y = quaternion[1] marker.pose.orientation.z = quaternion[2] marker.pose.orientation.w = quaternion[3] marker.mesh_use_embedded_materials = True marker.lifetime = rospy.Duration.from_sec(1.0) return marker
def onChangeCheckBox(self): CheckBox = self.parent.sender() regName = str(CheckBox.accessibleName()) self.parent.statusBar().showMessage(regName + ' was changed to ' + num2strg(CheckBox.isChecked())) BIDI_REG = self.getRegOrNone(regName) newContent = int(CheckBox.isChecked()) if BIDI_REG: # print BIDI_REG self.async_updateBIDIReg( BIDI_REG, newContent) return CheckBox,regName,newContent
ax2.set_title("Radon transform\n(Sinogram)") ax2.set_xlabel("Projection angle (deg)") ax2.set_ylabel("Projection position (pixels)") ax2.imshow(sinogram, cmap='gray', extent=(0, 180, 0, sinogram.shape[0]), aspect='auto') fig.tight_layout() """ Reconstruction with Filtered Back Projection """ t0 = time.time() reconstruction_fbp = iradon(sinogram, theta, circle=True) print("Time for execution of FBP: " + num2strg(round(time.time() - t0, 6)) + " s") error = reconstruction_fbp - image print(f"FBP rms reconstruction error: {np.sqrt(np.mean(error**2)):.3g}") fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(8, 4.5), sharex=True, sharey=True) ax1.set_title("Original") ax1.imshow(image, cmap='gray') ax2.set_title( "Reconstruction with Filtered Back Projection. \n Sampling angle = " + num2strg(SAMPLING_ANGLE) + "\xb0 \n Maximum angle =" + num2strg(MAX_ANGLE) + "\xb0")
Microscope_Type = 'widefield' # choose between: 'widefield', 'gaussian', 'bessel', 'SIM', 'STED', 'aberrated' SaveData = False ############################ ############################ # Generate the Amplitude Transfer Function (or Coherent Transfer Function) t0 = time.time() # this is to calculate the execution time H = amplitude_transfer_function(N, Kextent, n) pixel_size = H.dr extent = H.xyz_extent print('Real space sampling = ' + num2strg(pixel_size / n) + ' * wavelength') H.create_ewald_sphere(K) H.set_numerical_aperture(NA, Detection_Mode) pupil, psf_xy0 = H.set_microscope_type(NA, Microscope_Type) ATF = H.values # 3D Amplitude Transfer Function ASF = ifftshift(ifftn(fftshift(ATF))) * N**3 # # 3D Amplitude Spread Function (normalized for the total volume) PSF = np.abs(ASF)**2 # 3D Point Spread Function OTF = fftshift(fftn(ifftshift(PSF))) # 3D Optical Transfer Function print('Elapsed time for calculation: ' + num2strg(time.time() - t0) + 's')
def __init__(self, parent): ''' Constructor ''' super(DPWMControl_Class, self).__init__(parent) BIDI = parent.BIDI CheckBox_ENDPWM = QtWidgets.QCheckBox(CONST.EN_DPWM, parent) # Enable DPWM CheckBox_ENDPWM.setAccessibleName(BIDI.DPWM_EN.name) CheckBox_RSTDPWM = QtWidgets.QCheckBox(CONST.RST_DPWM, parent) # Reset DPWM CheckBox_RSTDPWM.setAccessibleName(BIDI.DPWM_RST.name) Label_DUTY = QtWidgets.QLabel(CONST.DUTY, parent) BitWidth = CONST.DUTY_BITS # Duty Cycle Scale_Dec = 2 DoubleSpinBox_DUTY = QtWidgets.QDoubleSpinBox(parent) DoubleSpinBox_DUTY.setMaximumWidth(80) DoubleSpinBox_DUTY.setDecimals(BitWidth - Scale_Dec) DoubleSpinBox_DUTY.setSingleStep(10.0 ** Scale_Dec * 2.0 ** (-1 * BitWidth)) DoubleSpinBox_DUTY.setRange(0, 10 ** Scale_Dec * (1 - 2 ** (-1 * BitWidth))) DoubleSpinBox_DUTY.setSuffix(' %') DoubleSpinBox_DUTY.setAccessibleName(BIDI.DPWM_DUTY.name) DoubleSpinBox_DUTY.lineEdit().setReadOnly(True) # Deadtime N and P DT_SUFFIX = ' ps' DT_MAXWIDTH = 80 def getDTSpinBox(SingleStep, Bits, name, attr): SpinBox_DT = QtWidgets.QSpinBox(parent) SpinBox_DT.setMaximumWidth(DT_MAXWIDTH) SpinBox_DT.setSingleStep(SingleStep) SpinBox_DT.setRange(SingleStep, 2 ** Bits * SingleStep) SpinBox_DT.setSuffix(DT_SUFFIX) SpinBox_DT.setAccessibleName(attr) SpinBox_DT.lineEdit().setReadOnly(True) return SpinBox_DT SpinBox_DTN = getDTSpinBox(CONST.DT_STEP_N, CONST.DT_BITS_N, CONST.DT_N, 'DPWM_DT_N') SpinBox_DTP = getDTSpinBox(CONST.DT_STEP_P, CONST.DT_BITS_P, CONST.DT_P, 'DPWM_DT_P') Label_DTN = QtWidgets.QLabel(CONST.DT_N + ":", parent) Label_DTP = QtWidgets.QLabel(CONST.DT_P + ":", parent) CheckBox_ENPHASES = QtWidgets.QCheckBox(CONST.EN_ALLPHASES, parent) # Enable all phases CheckBox_ENPHASES.setAccessibleName(CONST.EN_ALLPHASES) # EN_PHASE def getEN_PHASE(name, attrSHIFT, attrEN, phase): CheckBox_ENPHx = QtWidgets.QCheckBox(name, parent) CheckBox_ENPHx.setAccessibleName(attrEN) ComboBox_ENPHx = QtWidgets.QComboBox(parent) values = [] for string in CONST.DEG_STR: values += [string] ComboBox_ENPHx.setAccessibleName(attrSHIFT) ComboBox_ENPHx.addItems(values) CheckBox_ENPHx.toggled.connect(self.onChangeCheckBox) ComboBox_ENPHx.currentIndexChanged.connect(self.onChangeComboBox) return CheckBox_ENPHx, ComboBox_ENPHx start_EN = 1 colPadd = 3 # Grid Layout Positioning GridLayout = QtWidgets.QGridLayout(); GridLayout.addWidget(CheckBox_ENDPWM , 0, 0, 1, 2) GridLayout.addWidget(CheckBox_RSTDPWM, 1, 0, 1, 2) GridLayout.addWidget(Label_DUTY, 2, 0) GridLayout.addWidget(DoubleSpinBox_DUTY, 2, 1) GridLayout.addWidget(Label_DTN, 3, 0) GridLayout.addWidget(Label_DTP, 4, 0) GridLayout.addWidget(SpinBox_DTN, 3, 1) GridLayout.addWidget(SpinBox_DTP, 4, 1) GridLayout.addWidget(CheckBox_ENPHASES, start_EN - 1, 0 + colPadd, 1, 2) self.CheckBox_ENPH = [None] * 4 self.ComboBox_ENPH = [None] * 4 for phase in range(0, 4): name = CONST.PHASE + ' ' + num2strg(phase + 1) attr_SEL = getattr(BIDI, "SEL_" + num2strg(phase)).name attr_EN = getattr(BIDI, "EN_PH_" + num2strg(phase)).name CheckBox_ENPHx, ComboBox_ENPHx = getEN_PHASE(name, attr_SEL, attr_EN,phase) GridLayout.addWidget(CheckBox_ENPHx, start_EN + phase , 0 + colPadd) GridLayout.addWidget(ComboBox_ENPHx, start_EN + phase , 1 + colPadd) self.CheckBox_ENPH[ phase ] = CheckBox_ENPHx self.ComboBox_ENPH[ phase ] = ComboBox_ENPHx # Set bindings for buttons AllButtons = [CheckBox_ENDPWM, CheckBox_RSTDPWM, CheckBox_ENPHASES, DoubleSpinBox_DUTY, SpinBox_DTN, SpinBox_DTP ] for button in AllButtons: if isinstance(button, QtWidgets.QCheckBox): button.clicked.connect(self.onChangeCheckBox) if hasattr(button, 'valueChanged'): button.valueChanged.connect(self.onChangeSpinBox) gb_DPWM = QtWidgets.QGroupBox(CONST.DPWM) gb_DPWM.setLayout(GridLayout) gb_DPWM.setFixedWidth(self.WIDTH) # gb_DPWM.setFixedHeight( self.HEIGHT ) gb_DPWM.setAlignment(QtCore.Qt.AlignHCenter) self.CheckBox_ENPHASES = CheckBox_ENPHASES self.GroupBox = gb_DPWM self.mainLayout = GridLayout
def onChangeSpinBox(self): SpinBox = self.parent.sender() regName = str(SpinBox.accessibleName()) newContent = SpinBox.value() self.parent.statusBar().showMessage(SpinBox.accessibleName() + ' swas changed to ' + num2strg(newContent)) BIDI_REG = self.getRegOrNone(regName) if BIDI_REG: if SpinBox.__class__ == QtWidgets.QDoubleSpinBox: newContent=float(newContent) else: newContent=int(newContent) self.async_updateBIDIReg( BIDI_REG, newContent)
print('The voxel size is', voxel_size,'um') H.create_ewald_sphere(K) H.set_numerical_aperture(NA, Detection_Mode) pupil, psf_xy0 = H.set_microscope_type(NA, Microscope_Type) ATF = H.values # 3D Amplitude Transfer Function ASF = ifftshift(ifftn(fftshift(ATF))) * N**3 # # 3D Amplitude Spread Function (normalized for the total volume) PSF = np.abs(ASF)**2 # 3D Point Spread Function OTF = fftshift(fftn(ifftshift(PSF))) # 3D Optical Transfer Function print('Elapsed time for calculation: ' + num2strg( time.time()-t0) + 's' ) ############################ ##### Show figures plane=round(N/2) epsilon = 1e-9 # to avoid calculating log 0 later ATF_show = np.rot90( ( np.abs(ATF[plane,:,:]) ) ) ASF_show = np.rot90( ( np.abs(ASF[plane,:,:]) ) ) PSF_show = np.rot90( ( np.abs(PSF[plane,:,:]) ) ) OTF_show = np.rot90( 10*np.log10 ( np.abs(OTF[plane,:,:]) + epsilon ) ) # set font size
def roundandconvert(num): return num2strg(round(num, 4))
def onChangeCheckBox(self): sender = self.sender() self.statusBar().showMessage(sender.accessibleName() + ' was changed to ' + num2strg(sender.isChecked()))
def onChangeSpinBox(self): sender = self.sender() self.statusBar().showMessage(sender.accessibleName() + ' was changed to ' + num2strg(sender.value()))