def create_fitter(cls, fitter_name=FitterName.MINPACK, additional_data=None): congruence.checkEmptyString(fitter_name, "Fitter Name") if fitter_name == FitterName.MINPACK: return FitterMinpack() else: raise ValueError("Fitter name <" + fitter_name +"> not recognized")
def get_name(self, phase_index=0): try: congruence.checkEmptyString(self.name, "--") return self.name.strip() except: return Phase.get_default_name(phase_index)
def parse_formulas(self, text): self.parameters_dictionary.clear() is_empty = False try: congruence.checkEmptyString(text, "") except: is_empty = True if not is_empty: lines = text.splitlines() for i in range(len(lines)): is_line_empty = False try: congruence.checkEmptyString(lines[i], "") except: is_line_empty = True if not is_line_empty: data = lines[i].strip().split("=") if len(data) != 2: raise ValueError( "Free Output Parameters, malformed line:" + str(i + 1)) name = data[0].strip() expression = data[1].strip() self.set_parameter_expression(name, expression)
def get_name(self, diffraction_pattern_index=0): try: congruence.checkEmptyString(self.name, "--") return self.name.strip() except: return DiffractionPattern.get_default_name( diffraction_pattern_index)
def check_fields(self): self.MILLER_INDEX_H = congruence.checkNumber(self.MILLER_INDEX_H, "Miller index H") self.MILLER_INDEX_K = congruence.checkNumber(self.MILLER_INDEX_K, "Miller index K") self.MILLER_INDEX_L = congruence.checkNumber(self.MILLER_INDEX_L, "Miller index L") self.TEMPER = congruence.checkNumber(self.TEMPER, "Temperature factor") if self.SCAN == 0 or self.SCAN == 3: self.SCANFROM = congruence.checkPositiveNumber( self.SCANFROM, "Min Scan value") self.SCANTO = congruence.checkStrictlyPositiveNumber( self.SCANTO, "Max Scan value") else: self.SCANFROM = congruence.checkNumber(self.SCANFROM, "Min Scan value") self.SCANTO = congruence.checkNumber(self.SCANTO, "Max Scan value") congruence.checkLessThan(self.SCANFROM, self.SCANTO, "Min Scan value", "Max Scan value") self.SCANPOINTS = congruence.checkStrictlyPositiveNumber( self.SCANPOINTS, "Scan points") if self.SCAN < 4: self.ENERGY = congruence.checkStrictlyPositiveNumber( self.ENERGY, "Fix value") else: self.ENERGY = congruence.checkNumber(self.ENERGY, "Fix value") if self.MOSAIC == 0: #perfect self.ASYMMETRY_ANGLE = congruence.checkNumber( self.ASYMMETRY_ANGLE, "Asymmetry angle") self.THICKNESS = congruence.checkStrictlyPositiveNumber( self.THICKNESS, "Crystal thickness") elif self.MOSAIC == 1: #mosaic self.THICKNESS = congruence.checkStrictlyPositiveNumber( self.THICKNESS, "Crystal thickness") self.MOSAIC_FWHM = congruence.checkNumber(self.MOSAIC_FWHM, "Mosaicity") elif self.MOSAIC == 2 or self.MOSAIC == 3: #bent ML/PP self.ASYMMETRY_ANGLE = congruence.checkNumber( self.ASYMMETRY_ANGLE, "Asymmetry angle") self.THICKNESS = congruence.checkStrictlyPositiveNumber( self.THICKNESS, "Crystal thickness") self.RSAG = congruence.checkStrictlyPositiveNumber( self.RSAG, "R Sagittal") self.RMER = congruence.checkStrictlyPositiveNumber( self.RMER, "R meridional") if self.ANISOTROPY == 0: self.POISSON = congruence.checkStrictlyPositiveNumber( self.POISSON, "Poisson Ratio") elif self.ANISOTROPY == 2: congruence.checkEmptyString(self.CUT, "Valong; Vnorm; Vperp") elif self.ANISOTROPY == 3: congruence.checkFile(self.FILECOMPLIANCE)
def check_fields(self): self.DESCRIPTION = congruence.checkEmptyString(self.DESCRIPTION, "Description") if self.SUBSTANCE == 3: self.FRACTION = congruence.checkEmptyString(self.FRACTION, "fraction") if self.GRID != 0: if self.GRIDINPUT == 0: self.GRIDDATA = congruence.checkEmptyString(self.GRIDDATA, "grid points") else: congruence.checkFile(self.GRIDDATA)
def check_fields(self): self.DESCRIPTION = congruence.checkEmptyString(self.DESCRIPTION, "Description") if self.SUBSTANCE == 3: self.FRACTION = congruence.checkEmptyString(self.FRACTION, "fraction") if self.GRID != 0: if self.GRIDINPUT == 0: self.GRIDDATA = congruence.checkEmptyString(self.GRIDDATA, "grid points") else: congruence.checkFile(self.GRIDDATA)
def send_data(self): try: congruence.checkEmptyString(self.file_name, "File Name") congruence.checkFile(self.file_name) native_srw_wavefront = load_hdf5_2_wfr(self.file_name, self.data_path) self.send( "SRWData", SRWData(srw_wavefront=SRWWavefront.decorateSRWWF( native_srw_wavefront))) except Exception as e: QMessageBox.critical(self, "Error", str(e.args[0]), QMessageBox.Ok)
def checkFields(self): self.source_plane_distance = congruence.checkNumber(self.source_plane_distance, "Source plane distance") self.image_plane_distance = congruence.checkNumber(self.image_plane_distance, "Image plane distance") congruence.checkStrictlyPositiveNumber(self.delta_rn, u"\u03B4" + "rn" ) congruence.checkStrictlyPositiveNumber(self.diameter, "Z.P. Diameter") if (self.source_distance_flag == 1): congruence.checkPositiveNumber(self.source_distance, "Source Distance" ) if self.type_of_zp == PHASE_ZP: congruence.checkEmptyString(self.zone_plate_material, "Zone Plate Material") congruence.checkStrictlyPositiveNumber(self.zone_plate_thickness, "Zone Plate Thickness") congruence.checkEmptyString(self.substrate_material, "Substrate Material") congruence.checkStrictlyPositiveNumber(self.substrate_thickness, "Substrate Thickness")
def parse_peak(cls, line, line_index=0, diffraction_pattern_index=0): try: congruence.checkEmptyString(line, "Pseudo-Voigt Peak") except: return None if line.strip().startswith("#"): return None else: parameter_prefix = PseudoVoigtPeak.get_parameters_prefix() + str(diffraction_pattern_index + 1) + "_" + str(line_index+1) + "_" line_id = "(d.p. " + str(diffraction_pattern_index+1) +", line " + str(line_index+1) + ")" psuedo_voigt_peak = PseudoVoigtPeak() data = line.strip().split(",") if len(data) < 4: raise ValueError("Pseudo-Voigt Peak, malformed line: " + str(line_index+1)) try: twotheta_0 = FitParameter.parse_parameter_on_row(data[0], parameter_prefix, "twotheta0") eta = FitParameter.parse_parameter_on_row(data[1], parameter_prefix, "eta") fwhm = FitParameter.parse_parameter_on_row(data[2], parameter_prefix, "fwhm") intensity = FitParameter.parse_parameter_on_row(data[3], parameter_prefix, "intensity") except: raise "Row " + line_id + " is malformed" if not twotheta_0.function: congruence.checkStrictlyPositiveAngle(twotheta_0.value, "2\u03b80 " + line_id) if twotheta_0.boundary.is_free(): twotheta_0.boundary = Boundary(min_value=0.0) if not eta.function: if not 0.0 < eta.value < 1.0: raise ValueError("\u03b7 " + line_id + " must be between 0 and 1") if eta.boundary.is_free(): eta.boundary = Boundary(min_value=0.0, max_value=1.0) if not fwhm.function: congruence.checkStrictlyPositiveNumber(fwhm.value, "fwhm " + line_id) if fwhm.boundary.is_free(): fwhm.boundary = Boundary(min_value=0.0) if not intensity.function: congruence.checkStrictlyPositiveNumber(intensity.value, "intensity " + line_id) if intensity.boundary.is_free(): intensity.boundary = Boundary(min_value=0.0) psuedo_voigt_peak.twotheta_0 = twotheta_0 psuedo_voigt_peak.eta = eta psuedo_voigt_peak.fwhm = fwhm psuedo_voigt_peak.intensity = intensity return psuedo_voigt_peak
def check_fields(self): self.DESCRIPTOR = congruence.checkEmptyString(self.DESCRIPTOR, "formula") if self.MAT_FLAG == 1: self.DENSITY = congruence.checkStrictlyPositiveNumber( self.DENSITY, "density") if self.GRID > 0: self.GRIDSTART = congruence.checkPositiveNumber( self.GRIDSTART, "Starting Energy") if self.GRID == 1: self.GRIDEND = congruence.checkStrictlyPositiveNumber( self.GRIDEND, "Energy to") congruence.checkLessThan(self.GRIDSTART, self.GRIDEND, "Starting Energy", "Energy to") self.GRIDN = congruence.checkStrictlyPositiveNumber( self.GRIDN, "Number of points") if self.CALCULATE >= 7 and self.CALCULATE <= 9: self.ROUGH = congruence.checkPositiveNumber( self.ROUGH, "Roughness") self.THETA1 = congruence.checkPositiveNumber( self.THETA1, "Starting Graz angle") if self.THETAGRID == 1: self.THETA2 = congruence.checkStrictlyPositiveNumber( self.THETA2, "Graz angle to") congruence.checkLessThan(self.THETA1, self.THETA2, "Starting Graz angle", "Graz angle to") self.THETAN = congruence.checkStrictlyPositiveNumber( self.THETAN, "Number of angular points") else: self.THETAGRID = 0
def parse_reflections(self, text, phase_index=0, diffraction_pattern_index=0): try: congruence.checkEmptyString(text, "Reflections") empty = False except: empty = True reflections = [] if not empty: lines = text.splitlines() progressive_str = str(diffraction_pattern_index + 1) + "_" + str(phase_index + 1) + "_" for i in range(len(lines)): congruence.checkEmptyString(lines[i], "Reflections: line " + str(i + 1)) if not lines[i].strip().startswith("#"): data = lines[i].strip().split(",") if len(data) < 4: raise ValueError("Reflections, malformed line: " + str(i + 1)) h = int(data[0].strip()) k = int(data[1].strip()) l = int(data[2].strip()) intensity = FitParameter.parse_parameter_on_row( parameter_string=data[3].strip(), parameter_prefix=Reflection.get_parameters_prefix() + progressive_str, parameter_name="I" + str(h) + str(k) + str(l)) if intensity.boundary.is_free(): intensity.boundary = Boundary(min_value=0.0) reflection = Reflection(h, k, l, intensity=intensity) reflections.append(reflection) self.reflections_of_phases[phase_index] = reflections self.update_reflections(phase_index)
def check_fields(self): self.DESCRIPTOR = congruence.checkEmptyString(self.DESCRIPTOR, "formula") if self.GRID > 0: self.GRIDSTART = congruence.checkPositiveNumber(self.GRIDSTART, "Starting Energy") if self.GRID == 1: self.GRIDEND = congruence.checkStrictlyPositiveNumber(self.GRIDEND, "Energy to") congruence.checkLessThan(self.GRIDSTART, self.GRIDEND, "Starting Energy", "Energy to") self.GRIDN = congruence.checkStrictlyPositiveNumber(self.GRIDN, "Number of points")
def get_phase(self): phase = GSASIIPhase.init_cube(a0=OWGenericWidget.get_fit_parameter_from_widget(self, "a", self.get_parameters_prefix()), symmetry=self.cb_symmetry.currentText(), cif_file=self.cif_file, formula=congruence.checkEmptyString(self.formula, "Chemical Formula"), intensity_scale_factor=OWGenericWidget.get_fit_parameter_from_widget(self, "intensity_scale_factor", self.get_parameters_prefix()), name=self.phase_name, progressive=self.get_parameter_progressive()) return phase
def check_fields_aux(self): if len(self.crl_error_profiles) == 0: raise ValueError("No Thickness error profile specified") if self.crl_material_data == 0: self.crl_material = congruence.checkEmptyString( self.crl_material, "Chemical Formula") else: congruence.checkStrictlyPositiveNumber( self.crl_delta, "Refractive Index (\u03b4)") congruence.checkPositiveNumber(self.crl_scaling_factor, "Thickness Error Scaling Factor")
def parse_peaks(self, text, diffraction_pattern_index=0): try: congruence.checkEmptyString(text, "Reflections") empty = False except: empty = True pseudo_voigt_peaks = [] if not empty: lines = text.splitlines() for line_index in range(len(lines)): pseudo_voigt_peak = PseudoVoigtPeak.parse_peak(line=lines[line_index], line_index=line_index, diffraction_pattern_index=diffraction_pattern_index) if not pseudo_voigt_peak is None: pseudo_voigt_peaks.append(pseudo_voigt_peak) self.pseudo_voigt_peaks = pseudo_voigt_peaks
def check_fields(self): self.DESCRIPTOR = congruence.checkEmptyString(self.DESCRIPTOR, "formula") self.GRIDSTART = congruence.checkPositiveNumber( self.GRIDSTART, "Q from") self.GRIDEND = congruence.checkStrictlyPositiveNumber( self.GRIDEND, "Q to") congruence.checkLessThan(self.GRIDSTART, self.GRIDEND, "Q from", "Q to") self.GRIDN = congruence.checkStrictlyPositiveNumber( self.GRIDN, "Number of q Points")
def check_fields(self): self.DESCRIPTOR = congruence.checkEmptyString(self.DESCRIPTOR, "formula") if self.MAT_FLAG == 1: self.DENSITY = congruence.checkStrictlyPositiveNumber(self.DENSITY, "density") if self.GRID > 0: self.GRIDSTART = congruence.checkPositiveNumber(self.GRIDSTART, "Starting Energy") if self.GRID == 1: self.GRIDEND = congruence.checkStrictlyPositiveNumber(self.GRIDEND, "Energy to") congruence.checkLessThan(self.GRIDSTART, self.GRIDEND, "Starting Energy", "Energy to") self.GRIDN = congruence.checkStrictlyPositiveNumber(self.GRIDN, "Number of points")
def check_fields(self): if self.F12_FLAG == 1: congruence.checkEmptyString(self.SUBSTRATE, "Substrate") congruence.checkEmptyString(self.ODD_MATERIAL, "Odd layer material") congruence.checkEmptyString(self.EVEN_MATERIAL, "Even layer material") if self.SCAN == 0: # ga self.ENERGY = congruence.checkStrictlyPositiveNumber( self.ENERGY, "Photon energy") else: self.THETA = congruence.checkStrictlyPositiveNumber( self.THETA, "Grazing angle") self.SCAN_STEP = congruence.checkStrictlyPositiveNumber( self.SCAN_STEP, "Scanning variable step") self.NPOINTS = congruence.checkStrictlyPositiveNumber( self.NPOINTS, "Number of scanning points") if self.MODE == 0: # periodic layers self.ODD_THICKNESS = congruence.checkStrictlyPositiveNumber( self.ODD_THICKNESS, "Thickness for odd material") self.EVEN_THICKNESS = congruence.checkStrictlyPositiveNumber( self.EVEN_THICKNESS, "Thickness for even material") self.NLAYERS = congruence.checkStrictlyPositiveNumber( self.NLAYERS, "Number of layer pairs") else: congruence.checkFile(self.FILE)
def check_fields(self): self.MILLER_INDEX_H = congruence.checkNumber(self.MILLER_INDEX_H, "Miller index H") self.MILLER_INDEX_K = congruence.checkNumber(self.MILLER_INDEX_K, "Miller index K") self.MILLER_INDEX_L = congruence.checkNumber(self.MILLER_INDEX_L, "Miller index L") self.TEMPER = congruence.checkNumber(self.TEMPER, "Temperature factor") if self.SCAN == 0 or self.SCAN == 3: self.SCANFROM = congruence.checkPositiveNumber(self.SCANFROM, "Min Scan value") self.SCANTO = congruence.checkStrictlyPositiveNumber(self.SCANTO, "Max Scan value") else: self.SCANFROM = congruence.checkNumber(self.SCANFROM, "Min Scan value") self.SCANTO = congruence.checkNumber(self.SCANTO, "Max Scan value") congruence.checkLessThan(self.SCANFROM, self.SCANTO, "Min Scan value", "Max Scan value") self.SCANPOINTS = congruence.checkStrictlyPositiveNumber(self.SCANPOINTS, "Scan points") if self.SCAN < 4: self.ENERGY = congruence.checkStrictlyPositiveNumber(self.ENERGY , "Fix value") else: self.ENERGY = congruence.checkNumber(self.ENERGY , "Fix value") if self.MOSAIC == 0: #perfect self.ASYMMETRY_ANGLE = congruence.checkNumber(self.ASYMMETRY_ANGLE, "Asymmetry angle") self.THICKNESS = congruence.checkStrictlyPositiveNumber(self.THICKNESS, "Crystal thickness") elif self.MOSAIC == 1: #mosaic self.THICKNESS = congruence.checkStrictlyPositiveNumber(self.THICKNESS, "Crystal thickness") self.MOSAIC_FWHM = congruence.checkNumber(self.MOSAIC_FWHM, "Mosaicity") elif self.MOSAIC == 2 or self.MOSAIC == 3: #bent ML/PP self.ASYMMETRY_ANGLE = congruence.checkNumber(self.ASYMMETRY_ANGLE, "Asymmetry angle") self.THICKNESS = congruence.checkStrictlyPositiveNumber(self.THICKNESS, "Crystal thickness") self.RSAG = congruence.checkStrictlyPositiveNumber(self.RSAG, "R Sagittal") self.RMER = congruence.checkStrictlyPositiveNumber(self.RMER, "R meridional") if self.ANISOTROPY == 0: self.POISSON = congruence.checkStrictlyPositiveNumber(self.POISSON, "Poisson Ratio") elif self.ANISOTROPY == 2: congruence.checkEmptyString(self.CUT, "Valong; Vnorm; Vperp") elif self.ANISOTROPY == 3: congruence.checkFile(self.FILECOMPLIANCE)
def check_fields(self): self.MATERIAL_S = congruence.checkEmptyString(self.MATERIAL_S, "Substrate") self.MATERIAL_E = congruence.checkEmptyString(self.MATERIAL_E, "Substrate") self.MATERIAL_O = congruence.checkEmptyString(self.MATERIAL_O, "Substrate") self.ENERGY = congruence.checkStrictlyPositiveNumber( self.ENERGY, "Photon energy") self.THETA = congruence.checkPositiveNumber(self.THETA, "Grazing angle") if self.ENERGY_FLAG == 1: self.ENERGY_END = congruence.checkStrictlyPositiveNumber( self.ENERGY_END, "Photon energy") self.ENERGY_N = congruence.checkStrictlyPositiveNumber( self.ENERGY_N, "Number of energy points") if self.THETA_FLAG == 1: self.THETA_END = congruence.checkStrictlyPositiveNumber( self.THETA_END, "Grazing angle") self.THETA_N = congruence.checkStrictlyPositiveNumber( self.THETA_N, "Number of angle points") self.THICKNESS = congruence.checkStrictlyPositiveNumber( self.THICKNESS, "Bilayer thickness") self.GAMMA = congruence.checkStrictlyPositiveNumber( self.GAMMA, "Bilayer gamma") self.NLAYERS = congruence.checkStrictlyPositiveNumber( self.NLAYERS, "Number of bilayers") # self.ROUGHNESS_O = congruence.checkPositiveNumber( self.ROUGHNESS_O, "Roughness odd material") self.ROUGHNESS_E = congruence.checkPositiveNumber( self.ROUGHNESS_E, "Roughness even material") self.ROUGHNESS_S = congruence.checkPositiveNumber( self.ROUGHNESS_S, "Roughness substrate material")
def check_fields(self): self.DESCRIPTOR = congruence.checkEmptyString(self.DESCRIPTOR, "formula") if self.MAT_FLAG == 1: self.DENSITY = congruence.checkStrictlyPositiveNumber(self.DENSITY, "density") if self.GRID > 0: self.GRIDSTART = congruence.checkPositiveNumber(self.GRIDSTART, "Starting Energy") if self.GRID == 1: self.GRIDEND = congruence.checkStrictlyPositiveNumber(self.GRIDEND, "Energy to") congruence.checkLessThan(self.GRIDSTART, self.GRIDEND, "Starting Energy", "Energy to") self.GRIDN = congruence.checkStrictlyPositiveNumber(self.GRIDN, "Number of points") if self.CALCULATE >= 7 and self.CALCULATE <= 9: self.ROUGH = congruence.checkPositiveNumber(self.ROUGH, "Roughness") self.THETA1 = congruence.checkPositiveNumber(self.THETA1, "Starting Graz angle") if self.THETAGRID == 1: self.THETA2 = congruence.checkStrictlyPositiveNumber(self.THETA2, "Graz angle to") congruence.checkLessThan(self.THETA1, self.THETA2, "Starting Graz angle", "Graz angle to") self.THETAN = congruence.checkStrictlyPositiveNumber(self.THETAN, "Number of angular points") else: self.THETAGRID = 0
def check_fields(self): self.EL1_FOR = congruence.checkEmptyString(self.EL1_FOR, "1st oe formula") if self.EL1_FLAG == 0: # filter self.EL1_THI = congruence.checkStrictlyPositiveNumber(self.EL1_THI, "1st oe filter thickness") self.EL1_HROT = congruence.checkNumber(self.EL1_HROT, "1st oe rotation H") self.EL1_VROT = congruence.checkNumber(self.EL1_VROT, "1st oe rotation V") elif self.EL1_FLAG == 1: # mirror self.EL1_ANG = congruence.checkStrictlyPositiveNumber(self.EL1_ANG, "1st oe mirror angle") self.EL1_ROU = congruence.checkPositiveNumber(self.EL1_ROU, "1st oe mirror roughness") self.EL1_HROT = congruence.checkNumber(self.EL1_HROT, "1st oe rotation H") self.EL1_VROT = congruence.checkNumber(self.EL1_VROT, "1st oe rotation V") self.EL1_HGAP = congruence.checkStrictlyPositiveNumber(self.EL1_HGAP, "1st oe H gap") self.EL1_VGAP = congruence.checkPositiveNumber(self.EL1_VGAP, "1st oe V Gap") elif self.EL1_FLAG == 2: # aperture self.EL1_HGAP = congruence.checkStrictlyPositiveNumber(self.EL1_HGAP, "1st oe H gap") self.EL1_VGAP = congruence.checkPositiveNumber(self.EL1_VGAP, "1st oe V Gap") elif self.EL1_FLAG == 3: # magnifier self.EL1_HMAG = congruence.checkStrictlyPositiveNumber(self.EL1_HMAG, "1st oe H magnification") self.EL1_VMAG = congruence.checkPositiveNumber(self.EL1_VMAG, "1st oe V magnification") elif self.EL1_FLAG == 4: # rotation self.EL1_HROT = congruence.checkNumber(self.EL1_HROT, "1st oe rotation H") self.EL1_VROT = congruence.checkNumber(self.EL1_VROT, "1st oe rotation V")
def check_fields(self): if self.F12_FLAG == 1: congruence.checkEmptyString(self.SUBSTRATE, "Substrate") congruence.checkEmptyString(self.ODD_MATERIAL, "Odd layer material") congruence.checkEmptyString(self.EVEN_MATERIAL, "Even layer material") if self.SCAN == 0: # ga self.ENERGY = congruence.checkStrictlyPositiveNumber(self.ENERGY, "Photon energy") else: self.THETA = congruence.checkStrictlyPositiveNumber(self.THETA, "Grazing angle") self.SCAN_STEP = congruence.checkStrictlyPositiveNumber(self.SCAN_STEP, "Scanning variable step") self.NPOINTS = congruence.checkStrictlyPositiveNumber(self.NPOINTS, "Number of scanning points") if self.MODE == 0: # periodic layers self.ODD_THICKNESS = congruence.checkStrictlyPositiveNumber(self.ODD_THICKNESS, "Thickness for odd material") self.EVEN_THICKNESS = congruence.checkStrictlyPositiveNumber(self.EVEN_THICKNESS, "Thickness for even material") self.NLAYERS = congruence.checkStrictlyPositiveNumber(self.NLAYERS, "Number of layer pairs") else: congruence.checkFile(self.FILE)
def check_fields(self): if self.NELEMENTS >= 1: self.EL1_FOR = congruence.checkEmptyString(self.EL1_FOR, "1st oe formula") if self.EL1_FLAG == 0: # filter self.EL1_THI = congruence.checkStrictlyPositiveNumber(self.EL1_THI, "1st oe filter thickness") elif self.EL1_FLAG == 1: # mirror self.EL1_ANG = congruence.checkStrictlyPositiveNumber(self.EL1_ANG, "1st oe mirror angle") self.EL1_ROU = congruence.checkPositiveNumber(self.EL1_ROU, "1st oe mirror roughness") if not self.EL1_DEN.strip() == "?": self.EL1_DEN = str(congruence.checkStrictlyPositiveNumber(float(congruence.checkNumber(self.EL1_DEN, "1st oe density")), "1st oe density")) if self.NELEMENTS >= 2: self.EL2_FOR = congruence.checkEmptyString(self.EL2_FOR, "2nd oe formula") if self.EL2_FLAG == 0: # filter self.EL2_THI = congruence.checkStrictlyPositiveNumber(self.EL2_THI, "2nd oe filter thickness") elif self.EL2_FLAG == 1: # mirror self.EL2_ANG = congruence.checkStrictlyPositiveNumber(self.EL2_ANG, "2nd oe mirror angle") self.EL2_ROU = congruence.checkPositiveNumber(self.EL2_ROU, "2nd oe mirror roughness") if not self.EL2_DEN.strip() == "?": self.EL2_DEN = str(congruence.checkStrictlyPositiveNumber(float(congruence.checkNumber(self.EL2_DEN, "2nd oe density")), "2nd oe density")) if self.NELEMENTS >= 3: self.EL3_FOR = congruence.checkEmptyString(self.EL3_FOR, "3rd oe formula") if self.EL3_FLAG == 0: # filter self.EL3_THI = congruence.checkStrictlyPositiveNumber(self.EL3_THI, "3rd oe filter thickness") elif self.EL3_FLAG == 1: # mirror self.EL3_ANG = congruence.checkStrictlyPositiveNumber(self.EL3_ANG, "3rd oe mirror angle") self.EL3_ROU = congruence.checkPositiveNumber(self.EL3_ROU, "3rd oe mirror roughness") if not self.EL3_DEN.strip() == "?": self.EL3_DEN = str(congruence.checkStrictlyPositiveNumber(float(congruence.checkNumber(self.EL3_DEN, "3rd oe density")), "3rd oe density")) if self.NELEMENTS >= 4: self.EL4_FOR = congruence.checkEmptyString(self.EL4_FOR, "4th oe formula") if self.EL4_FLAG == 0: # filter self.EL4_THI = congruence.checkStrictlyPositiveNumber(self.EL4_THI, "4th oe filter thickness") elif self.EL4_FLAG == 1: # mirror self.EL4_ANG = congruence.checkStrictlyPositiveNumber(self.EL4_ANG, "4th oe mirror angle") self.EL4_ROU = congruence.checkPositiveNumber(self.EL4_ROU, "4th oe mirror roughness") if not self.EL4_DEN.strip() == "?": self.EL4_DEN = str(congruence.checkStrictlyPositiveNumber(float(congruence.checkNumber(self.EL4_DEN, "4th oe density")), "4th oe density")) if self.NELEMENTS >= 5: self.EL5_FOR = congruence.checkEmptyString(self.EL5_FOR, "5th oe formula") if self.EL5_FLAG == 0: # filter self.EL5_THI = congruence.checkStrictlyPositiveNumber(self.EL5_THI, "5th oe filter thickness") elif self.EL5_FLAG == 1: # mirror self.EL5_ANG = congruence.checkStrictlyPositiveNumber(self.EL5_ANG, "5th oe mirror angle") self.EL5_ROU = congruence.checkPositiveNumber(self.EL5_ROU, "5th oe mirror roughness") if not self.EL5_DEN.strip() == "?": self.EL5_DEN = str(congruence.checkStrictlyPositiveNumber(float(congruence.checkNumber(self.EL5_DEN, "5th oe density")), "5th oe density"))
def check_fields(self): if self.SOURCE == 1: self.ENER_MIN = congruence.checkPositiveNumber(self.ENER_MIN, "Energy from") self.ENER_MAX = congruence.checkStrictlyPositiveNumber(self.ENER_MAX, "Energy to") congruence.checkLessThan(self.ENER_MIN, self.ENER_MAX, "Energy from", "Energy to") self.NPOINTS = congruence.checkStrictlyPositiveNumber(self.ENER_N, "Energy Points") elif self.SOURCE == 2: congruence.checkFile(self.SOURCE_FILE) if self.NELEMENTS >= 1: self.EL1_FOR = congruence.checkEmptyString(self.EL1_FOR, "1st oe formula") if self.EL1_FLAG == 0: # filter self.EL1_THI = congruence.checkStrictlyPositiveNumber(self.EL1_THI, "1st oe filter thickness") elif self.EL1_FLAG == 1: # mirror self.EL1_ANG = congruence.checkStrictlyPositiveNumber(self.EL1_ANG, "1st oe mirror angle") self.EL1_ROU = congruence.checkPositiveNumber(self.EL1_ROU, "1st oe mirror roughness") if not self.EL1_DEN.strip() == "?": self.EL1_DEN = str(congruence.checkStrictlyPositiveNumber(float(congruence.checkNumber(self.EL1_DEN, "1st oe density")), "1st oe density")) if self.NELEMENTS >= 2: self.EL2_FOR = congruence.checkEmptyString(self.EL2_FOR, "2nd oe formula") if self.EL2_FLAG == 0: # filter self.EL2_THI = congruence.checkStrictlyPositiveNumber(self.EL2_THI, "2nd oe filter thickness") elif self.EL2_FLAG == 1: # mirror self.EL2_ANG = congruence.checkStrictlyPositiveNumber(self.EL2_ANG, "2nd oe mirror angle") self.EL2_ROU = congruence.checkPositiveNumber(self.EL2_ROU, "2nd oe mirror roughness") if not self.EL2_DEN.strip() == "?": self.EL2_DEN = str(congruence.checkStrictlyPositiveNumber(float(congruence.checkNumber(self.EL2_DEN, "2nd oe density")), "2nd oe density")) if self.NELEMENTS >= 3: self.EL3_FOR = congruence.checkEmptyString(self.EL3_FOR, "3rd oe formula") if self.EL3_FLAG == 0: # filter self.EL3_THI = congruence.checkStrictlyPositiveNumber(self.EL3_THI, "3rd oe filter thickness") elif self.EL3_FLAG == 1: # mirror self.EL3_ANG = congruence.checkStrictlyPositiveNumber(self.EL3_ANG, "3rd oe mirror angle") self.EL3_ROU = congruence.checkPositiveNumber(self.EL3_ROU, "3rd oe mirror roughness") if not self.EL3_DEN.strip() == "?": self.EL3_DEN = str(congruence.checkStrictlyPositiveNumber(float(congruence.checkNumber(self.EL3_DEN, "3rd oe density")), "3rd oe density")) if self.NELEMENTS >= 4: self.EL4_FOR = congruence.checkEmptyString(self.EL4_FOR, "4th oe formula") if self.EL4_FLAG == 0: # filter self.EL4_THI = congruence.checkStrictlyPositiveNumber(self.EL4_THI, "4th oe filter thickness") elif self.EL4_FLAG == 1: # mirror self.EL4_ANG = congruence.checkStrictlyPositiveNumber(self.EL4_ANG, "4th oe mirror angle") self.EL4_ROU = congruence.checkPositiveNumber(self.EL4_ROU, "4th oe mirror roughness") if not self.EL4_DEN.strip() == "?": self.EL4_DEN = str(congruence.checkStrictlyPositiveNumber(float(congruence.checkNumber(self.EL4_DEN, "4th oe density")), "4th oe density")) if self.NELEMENTS >= 5: self.EL5_FOR = congruence.checkEmptyString(self.EL5_FOR, "5th oe formula") if self.EL5_FLAG == 0: # filter self.EL5_THI = congruence.checkStrictlyPositiveNumber(self.EL5_THI, "5th oe filter thickness") elif self.EL5_FLAG == 1: # mirror self.EL5_ANG = congruence.checkStrictlyPositiveNumber(self.EL5_ANG, "5th oe mirror angle") self.EL5_ROU = congruence.checkPositiveNumber(self.EL5_ROU, "5th oe mirror roughness") if not self.EL5_DEN.strip() == "?": self.EL5_DEN = str(congruence.checkStrictlyPositiveNumber(float(congruence.checkNumber(self.EL5_DEN, "5th oe density")), "5th oe density"))
def check_fields(self): if self.SOURCE == 1: self.ENER_MIN = congruence.checkPositiveNumber(self.ENER_MIN, "Energy from") self.ENER_MAX = congruence.checkStrictlyPositiveNumber(self.ENER_MAX, "Energy to") congruence.checkLessThan(self.ENER_MIN, self.ENER_MAX, "Energy from", "Energy to") self.NPOINTS = congruence.checkStrictlyPositiveNumber(self.ENER_N, "Energy Points") elif self.SOURCE == 2: congruence.checkFile(self.SOURCE_FILE) if self.NELEMENTS >= 1: self.EL1_FOR = congruence.checkEmptyString(self.EL1_FOR, "1st oe formula") if self.EL1_FLAG == 0: # filter self.EL1_THI = congruence.checkStrictlyPositiveNumber(self.EL1_THI, "1st oe filter thickness") elif self.EL1_FLAG == 1: # mirror self.EL1_ANG = congruence.checkStrictlyPositiveNumber(self.EL1_ANG, "1st oe mirror angle") self.EL1_ROU = congruence.checkPositiveNumber(self.EL1_ROU, "1st oe mirror roughness") if not self.EL1_DEN.strip() == "?": self.EL1_DEN = str(congruence.checkStrictlyPositiveNumber(float(congruence.checkNumber(self.EL1_DEN, "1st oe density")), "1st oe density")) if self.NELEMENTS >= 2: self.EL2_FOR = congruence.checkEmptyString(self.EL2_FOR, "2nd oe formula") if self.EL2_FLAG == 0: # filter self.EL2_THI = congruence.checkStrictlyPositiveNumber(self.EL2_THI, "2nd oe filter thickness") elif self.EL2_FLAG == 1: # mirror self.EL2_ANG = congruence.checkStrictlyPositiveNumber(self.EL2_ANG, "2nd oe mirror angle") self.EL2_ROU = congruence.checkPositiveNumber(self.EL2_ROU, "2nd oe mirror roughness") if not self.EL2_DEN.strip() == "?": self.EL2_DEN = str(congruence.checkStrictlyPositiveNumber(float(congruence.checkNumber(self.EL2_DEN, "2nd oe density")), "2nd oe density")) if self.NELEMENTS >= 3: self.EL3_FOR = congruence.checkEmptyString(self.EL3_FOR, "3rd oe formula") if self.EL3_FLAG == 0: # filter self.EL3_THI = congruence.checkStrictlyPositiveNumber(self.EL3_THI, "3rd oe filter thickness") elif self.EL3_FLAG == 1: # mirror self.EL3_ANG = congruence.checkStrictlyPositiveNumber(self.EL3_ANG, "3rd oe mirror angle") self.EL3_ROU = congruence.checkPositiveNumber(self.EL3_ROU, "3rd oe mirror roughness") if not self.EL3_DEN.strip() == "?": self.EL3_DEN = str(congruence.checkStrictlyPositiveNumber(float(congruence.checkNumber(self.EL3_DEN, "3rd oe density")), "3rd oe density")) if self.NELEMENTS >= 4: self.EL4_FOR = congruence.checkEmptyString(self.EL4_FOR, "4th oe formula") if self.EL4_FLAG == 0: # filter self.EL4_THI = congruence.checkStrictlyPositiveNumber(self.EL4_THI, "4th oe filter thickness") elif self.EL4_FLAG == 1: # mirror self.EL4_ANG = congruence.checkStrictlyPositiveNumber(self.EL4_ANG, "4th oe mirror angle") self.EL4_ROU = congruence.checkPositiveNumber(self.EL4_ROU, "4th oe mirror roughness") if not self.EL4_DEN.strip() == "?": self.EL4_DEN = str(congruence.checkStrictlyPositiveNumber(float(congruence.checkNumber(self.EL4_DEN, "4th oe density")), "4th oe density")) if self.NELEMENTS >= 5: self.EL5_FOR = congruence.checkEmptyString(self.EL5_FOR, "5th oe formula") if self.EL5_FLAG == 0: # filter self.EL5_THI = congruence.checkStrictlyPositiveNumber(self.EL5_THI, "5th oe filter thickness") elif self.EL5_FLAG == 1: # mirror self.EL5_ANG = congruence.checkStrictlyPositiveNumber(self.EL5_ANG, "5th oe mirror angle") self.EL5_ROU = congruence.checkPositiveNumber(self.EL5_ROU, "5th oe mirror roughness") if not self.EL5_DEN.strip() == "?": self.EL5_DEN = str(congruence.checkStrictlyPositiveNumber(float(congruence.checkNumber(self.EL5_DEN, "5th oe density")), "5th oe density"))
def check_fields(self): self.DESCRIPTOR = congruence.checkEmptyString(self.DESCRIPTOR, "formula") self.GRIDSTART = congruence.checkPositiveNumber(self.GRIDSTART, "Q from") self.GRIDEND = congruence.checkStrictlyPositiveNumber(self.GRIDEND, "Q to") congruence.checkLessThan(self.GRIDSTART, self.GRIDEND, "Q from", "Q to") self.GRIDN = congruence.checkStrictlyPositiveNumber(self.GRIDN, "Number of q Points")
def check_fields(self): if self.NELEMENTS >= 1: self.EL1_FOR = congruence.checkEmptyString(self.EL1_FOR, "1st oe formula") if self.EL1_FLAG == 0: # filter self.EL1_THI = congruence.checkStrictlyPositiveNumber( self.EL1_THI, "1st oe filter thickness") elif self.EL1_FLAG == 1: # mirror self.EL1_ANG = congruence.checkStrictlyPositiveNumber( self.EL1_ANG, "1st oe mirror angle") self.EL1_ROU = congruence.checkPositiveNumber( self.EL1_ROU, "1st oe mirror roughness") if not self.EL1_DEN.strip() == "?": self.EL1_DEN = str( congruence.checkStrictlyPositiveNumber( float( congruence.checkNumber(self.EL1_DEN, "1st oe density")), "1st oe density")) if self.NELEMENTS >= 2: self.EL2_FOR = congruence.checkEmptyString(self.EL2_FOR, "2nd oe formula") if self.EL2_FLAG == 0: # filter self.EL2_THI = congruence.checkStrictlyPositiveNumber( self.EL2_THI, "2nd oe filter thickness") elif self.EL2_FLAG == 1: # mirror self.EL2_ANG = congruence.checkStrictlyPositiveNumber( self.EL2_ANG, "2nd oe mirror angle") self.EL2_ROU = congruence.checkPositiveNumber( self.EL2_ROU, "2nd oe mirror roughness") if not self.EL2_DEN.strip() == "?": self.EL2_DEN = str( congruence.checkStrictlyPositiveNumber( float( congruence.checkNumber(self.EL2_DEN, "2nd oe density")), "2nd oe density")) if self.NELEMENTS >= 3: self.EL3_FOR = congruence.checkEmptyString(self.EL3_FOR, "3rd oe formula") if self.EL3_FLAG == 0: # filter self.EL3_THI = congruence.checkStrictlyPositiveNumber( self.EL3_THI, "3rd oe filter thickness") elif self.EL3_FLAG == 1: # mirror self.EL3_ANG = congruence.checkStrictlyPositiveNumber( self.EL3_ANG, "3rd oe mirror angle") self.EL3_ROU = congruence.checkPositiveNumber( self.EL3_ROU, "3rd oe mirror roughness") if not self.EL3_DEN.strip() == "?": self.EL3_DEN = str( congruence.checkStrictlyPositiveNumber( float( congruence.checkNumber(self.EL3_DEN, "3rd oe density")), "3rd oe density")) if self.NELEMENTS >= 4: self.EL4_FOR = congruence.checkEmptyString(self.EL4_FOR, "4th oe formula") if self.EL4_FLAG == 0: # filter self.EL4_THI = congruence.checkStrictlyPositiveNumber( self.EL4_THI, "4th oe filter thickness") elif self.EL4_FLAG == 1: # mirror self.EL4_ANG = congruence.checkStrictlyPositiveNumber( self.EL4_ANG, "4th oe mirror angle") self.EL4_ROU = congruence.checkPositiveNumber( self.EL4_ROU, "4th oe mirror roughness") if not self.EL4_DEN.strip() == "?": self.EL4_DEN = str( congruence.checkStrictlyPositiveNumber( float( congruence.checkNumber(self.EL4_DEN, "4th oe density")), "4th oe density")) if self.NELEMENTS >= 5: self.EL5_FOR = congruence.checkEmptyString(self.EL5_FOR, "5th oe formula") if self.EL5_FLAG == 0: # filter self.EL5_THI = congruence.checkStrictlyPositiveNumber( self.EL5_THI, "5th oe filter thickness") elif self.EL5_FLAG == 1: # mirror self.EL5_ANG = congruence.checkStrictlyPositiveNumber( self.EL5_ANG, "5th oe mirror angle") self.EL5_ROU = congruence.checkPositiveNumber( self.EL5_ROU, "5th oe mirror roughness") if not self.EL5_DEN.strip() == "?": self.EL5_DEN = str( congruence.checkStrictlyPositiveNumber( float( congruence.checkNumber(self.EL5_DEN, "5th oe density")), "5th oe density"))