def check_fields(self): self.ELECTRONENERGY = congruence.checkStrictlyPositiveNumber( self.ELECTRONENERGY, "Electron Energy") if not self.METHOD == 1: self.ELECTRONENERGYSPREAD = congruence.checkPositiveNumber( self.ELECTRONENERGYSPREAD, "Electron Energy Spread") self.ELECTRONCURRENT = congruence.checkStrictlyPositiveNumber( self.ELECTRONCURRENT, "Electron Current") self.ELECTRONBEAMSIZEH = congruence.checkPositiveNumber( self.ELECTRONBEAMSIZEH, "Electron Beam Size H") self.ELECTRONBEAMSIZEV = congruence.checkPositiveNumber( self.ELECTRONBEAMSIZEV, "Electron Beam Size V") self.ELECTRONBEAMDIVERGENCEH = congruence.checkPositiveNumber( self.ELECTRONBEAMDIVERGENCEH, "Electron Beam Divergence H") self.ELECTRONBEAMDIVERGENCEV = congruence.checkPositiveNumber( self.ELECTRONBEAMDIVERGENCEV, "Electron Beam Divergence V") self.PERIODID = congruence.checkStrictlyPositiveNumber( self.PERIODID, "Period ID") self.NPERIODS = congruence.checkStrictlyPositiveNumber( self.NPERIODS, "Number of Periods") self.DISTANCE = congruence.checkPositiveNumber(self.DISTANCE, "Distance to slit") self.GAPH = congruence.checkPositiveNumber(self.GAPH, "Slit gap H") self.GAPV = congruence.checkPositiveNumber(self.GAPV, "Slit gap V") self.KMIN = congruence.checkPositiveNumber(self.KMIN, "K Min") self.KMAX = congruence.checkStrictlyPositiveNumber(self.KMAX, "K Max") congruence.checkLessThan(self.KMIN, self.KMAX, "K Min", "K Max") self.KPOINTS = congruence.checkStrictlyPositiveNumber( self.KPOINTS, "Number of K Points")
def get_range(self, beam_to_plot, var_x): if self.x_range == 0: x_max = 0 x_min = 0 x, good_only = beam_to_plot.getshcol((var_x, 10)) x_to_plot = copy.deepcopy(x) go = numpy.where(good_only == 1) lo = numpy.where(good_only != 1) if self.rays == 0: x_max = numpy.array(x_to_plot[0:], float).max() x_min = numpy.array(x_to_plot[0:], float).min() elif self.rays == 1: x_max = numpy.array(x_to_plot[go], float).max() x_min = numpy.array(x_to_plot[go], float).min() elif self.rays == 2: x_max = numpy.array(x_to_plot[lo], float).max() x_min = numpy.array(x_to_plot[lo], float).min() xrange = [x_min, x_max] else: congruence.checkLessThan(self.x_range_min, self.x_range_max, "X range min", "X range max") factor1 = ShadowPlot.get_factor(var_x, self.workspace_units_to_cm) xrange = [self.x_range_min / factor1, self.x_range_max / factor1] return xrange
def get_ranges(self, beam_to_plot, var_x, var_y): xrange = None yrange = None factor1 = ShadowPlot.get_factor(var_x, self.workspace_units_to_cm) factor2 = ShadowPlot.get_factor(var_y, self.workspace_units_to_cm) if self.x_range == 0 and self.y_range == 0: pass else: if self.x_range == 1: congruence.checkLessThan(self.x_range_min, self.x_range_max, "X range min", "X range max") xrange = [ self.x_range_min / factor1, self.x_range_max / factor1 ] if self.y_range == 1: congruence.checkLessThan(self.y_range_min, self.y_range_max, "Y range min", "Y range max") yrange = [ self.y_range_min / factor2, self.y_range_max / factor2 ] return xrange, yrange
def checkFields(self): self.number_of_rays = congruence.checkPositiveNumber(self.number_of_rays, "Number of rays") self.seed = congruence.checkPositiveNumber(self.seed, "Seed") self.e_min = congruence.checkPositiveNumber(self.e_min, "Minimum energy") self.e_max = congruence.checkPositiveNumber(self.e_max, "Maximum energy") congruence.checkLessThan(self.e_min, self.e_max, "Minimum energy", "Maximum energy") self.max_number_of_rejected_rays = congruence.checkPositiveNumber(self.max_number_of_rejected_rays, "Max Number of Rejected Rays") self.slit_distance = congruence.checkPositiveNumber(self.slit_distance, "Horizontal half-divergence from [+]") self.min_x = congruence.checkNumber(self.min_x, "Min X/Min Xp") self.max_x = congruence.checkNumber(self.max_x, "Max X/Max Xp") self.min_z = congruence.checkNumber(self.min_z, "Min X/Min Xp") self.max_z = congruence.checkNumber(self.max_z, "Max X/Max Xp") self.energy = congruence.checkPositiveNumber(self.energy, "Energy") self.electron_current = congruence.checkPositiveNumber(self.electron_current, "Electron Current") self.sigma_x = congruence.checkPositiveNumber(self.sigma_x, "Sigma x") self.sigma_z = congruence.checkPositiveNumber(self.sigma_z, "Sigma z") self.emittance_x = congruence.checkPositiveNumber(self.emittance_x, "Emittance x") self.emittance_z = congruence.checkPositiveNumber(self.emittance_z, "Emittance z") self.distance_from_waist_x = congruence.checkNumber(self.distance_from_waist_x, "Distance from waist x") self.distance_from_waist_z = congruence.checkNumber(self.distance_from_waist_z, "Distance from waist z") self.number_of_periods = congruence.checkStrictlyPositiveNumber(self.number_of_periods, "Number of periods") self.k_value = congruence.checkStrictlyPositiveNumber(self.k_value, "K value") self.id_period = congruence.checkStrictlyPositiveNumber(self.id_period, "ID period") if self.optimize_source_combo == 1: congruence.checkFile(self.file_with_phase_space_volume) if self.type_combo == 1: congruence.checkUrl(self.file_with_b_vs_y) elif self.type_combo == 2: congruence.checkUrl(self.file_with_harmonics)
def check_fields(self): self.NPERIODS = congruence.checkStrictlyPositiveNumber( self.NPERIODS, "Number of Periods") self.ENERGY = congruence.checkStrictlyPositiveNumber( self.ENERGY, "Beam Energy") self.PHOT_ENERGY_MIN = congruence.checkPositiveNumber( self.PHOT_ENERGY_MIN, "Min Photon Energy") self.PHOT_ENERGY_MAX = congruence.checkStrictlyPositiveNumber( self.PHOT_ENERGY_MAX, "Max Photon Energy") congruence.checkLessThan(self.PHOT_ENERGY_MIN, self.PHOT_ENERGY_MAX, "Min Photon Energy", "Max Photon Energy") self.NPOINTS = congruence.checkStrictlyPositiveNumber( self.NPOINTS, "Number of Energy Points") self.CURRENT = congruence.checkStrictlyPositiveNumber( self.CURRENT, "Electron Beam Current") if self.FIELD == 0: self.ULAMBDA = congruence.checkStrictlyPositiveNumber( self.ULAMBDA, "Wiggler period") self.K = congruence.checkStrictlyPositiveNumber(self.K, "K") self.NTRAJPOINTS = congruence.checkStrictlyPositiveNumber( self.NTRAJPOINTS, "Number of traj points per period") elif self.FIELD == 1: self.ULAMBDA = congruence.checkStrictlyPositiveNumber( self.ULAMBDA, "Wiggler period") self.NTRAJPOINTS = congruence.checkStrictlyPositiveNumber( self.NTRAJPOINTS, "Number of traj points per period") congruence.checkFile(self.FILE) elif self.FIELD == 2: congruence.checkFile(self.FILE)
def check_fields(self): self.ENERGY = congruence.checkStrictlyPositiveNumber( self.ENERGY, "Electron Energy") self.CURRENT = congruence.checkStrictlyPositiveNumber( self.CURRENT, "Current") self.ENERGY_SPREAD = congruence.checkStrictlyPositiveNumber( self.ENERGY_SPREAD, "Energy Spread") self.SIGX = congruence.checkPositiveNumber(self.SIGX, "Sigma X") self.SIGY = congruence.checkPositiveNumber(self.SIGY, "Sigma Y") self.SIGX1 = congruence.checkPositiveNumber(self.SIGX1, "Sigma X'") self.SIGY1 = congruence.checkPositiveNumber(self.SIGY1, "Sigma Y'") self.PERIOD = congruence.checkStrictlyPositiveNumber( self.PERIOD, "Period length") self.NP = congruence.checkStrictlyPositiveNumber( self.NP, "Number of periods") self.EMIN = congruence.checkPositiveNumber(self.EMIN, "E1 minimum energy") self.EMAX = congruence.checkStrictlyPositiveNumber( self.EMAX, "E1 maximum energy") congruence.checkLessThan(self.EMIN, self.EMAX, "E1 minimum energy", "E1 maximum energy") self.N = congruence.checkStrictlyPositiveNumber( self.N, "Number of Energy Points") self.HARMONIC_FROM = congruence.checkStrictlyPositiveNumber( self.HARMONIC_FROM, "Minimum harmonic number") self.HARMONIC_TO = congruence.checkStrictlyPositiveNumber( self.HARMONIC_TO, "Maximum harmonic number") congruence.checkLessThan(self.HARMONIC_FROM, self.HARMONIC_TO, "Minimum harmonic number", "Maximum harmonic number") self.HARMONIC_STEP = congruence.checkStrictlyPositiveNumber( self.HARMONIC_STEP, "Harmonic step size") self.NEKS = congruence.checkPositiveNumber(self.NEKS, "Intrinsic NEKS")
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 checkFields(self): self.number_of_rays = congruence.checkPositiveNumber(self.number_of_rays, "Number of rays") self.seed = congruence.checkPositiveNumber(self.seed, "Seed") self.e_min = congruence.checkPositiveNumber(self.e_min, "Minimum energy") self.e_max = congruence.checkPositiveNumber(self.e_max, "Maximum energy") congruence.checkLessThan(self.e_min, self.e_max, "Minimum energy", "Maximum energy") self.sigma_x = congruence.checkPositiveNumber(self.sigma_x, "Sigma x") self.sigma_z = congruence.checkPositiveNumber(self.sigma_z, "Sigma z") self.emittance_x = congruence.checkPositiveNumber(self.emittance_x, "Emittance x") self.emittance_z = congruence.checkPositiveNumber(self.emittance_z, "Emittance z") self.distance_from_waist_x = congruence.checkPositiveNumber(self.distance_from_waist_x, "Distance from waist x") self.distance_from_waist_z = congruence.checkPositiveNumber(self.distance_from_waist_z, "Distance from waist z") self.energy = congruence.checkPositiveNumber(self.energy, "Energy") self.magnetic_radius = congruence.checkPositiveNumber(self.magnetic_radius, "Magnetic radius") self.horizontal_half_divergence_from = congruence.checkPositiveNumber(self.horizontal_half_divergence_from, "Horizontal half-divergence from [+]") self.horizontal_half_divergence_to = congruence.checkPositiveNumber(self.horizontal_half_divergence_to, "Horizontal half-divergence to [-]") self.max_vertical_half_divergence_from = congruence.checkPositiveNumber(self.max_vertical_half_divergence_from, "Max vertical half-divergence from [+]") self.max_vertical_half_divergence_to = congruence.checkPositiveNumber(self.max_vertical_half_divergence_to, "Max vertical half-divergence to [-]") if self.optimize_source > 0: self.max_number_of_rejected_rays = congruence.checkPositiveNumber(self.max_number_of_rejected_rays, "Max number of rejected rays") congruence.checkFile(self.optimize_file_name)
def checkFields(self): self.number_of_rays = congruence.checkPositiveNumber(self.number_of_rays, "Number of rays") self.seed = congruence.checkPositiveNumber(self.seed, "Seed") self.e_min = congruence.checkPositiveNumber(self.e_min, "Minimum energy") self.e_max = congruence.checkPositiveNumber(self.e_max, "Maximum energy") congruence.checkLessThan(self.e_min, self.e_max, "Minimum energy", "Maximum energy") self.max_number_of_rejected_rays = congruence.checkPositiveNumber(self.max_number_of_rejected_rays, "Max Number of Rejected Rays") self.slit_distance = congruence.checkPositiveNumber(self.slit_distance, "Horizontal half-divergence from [+]") self.min_x = congruence.checkNumber(self.min_x, "Min X/Min Xp") self.max_x = congruence.checkNumber(self.max_x, "Max X/Max Xp") self.min_z = congruence.checkNumber(self.min_z, "Min X/Min Xp") self.max_z = congruence.checkNumber(self.max_z, "Max X/Max Xp") self.energy = congruence.checkPositiveNumber(self.energy, "Energy") self.electron_current = congruence.checkPositiveNumber(self.electron_current, "Electron Current") self.sigma_x = congruence.checkPositiveNumber(self.sigma_x, "Sigma x") self.sigma_z = congruence.checkPositiveNumber(self.sigma_z, "Sigma z") self.emittance_x = congruence.checkPositiveNumber(self.emittance_x, "Emittance x") self.emittance_z = congruence.checkPositiveNumber(self.emittance_z, "Emittance z") self.distance_from_waist_x = congruence.checkNumber(self.distance_from_waist_x, "Distance from waist x") self.distance_from_waist_z = congruence.checkNumber(self.distance_from_waist_z, "Distance from waist z") self.number_of_periods = congruence.checkStrictlyPositiveNumber(self.number_of_periods, "Number of periods") self.k_value = congruence.checkStrictlyPositiveNumber(self.k_value, "K value") self.id_period = congruence.checkStrictlyPositiveNumber(self.id_period, "ID period") if self.optimize_source_combo == 1: congruence.checkFile(self.file_with_phase_space_volume) if self.type_combo == 1: congruence.checkFile(self.file_with_b_vs_y) elif self.type_combo == 2: congruence.checkFile(self.file_with_harmonics)
def check_fields(self): self.ENERGY = congruence.checkStrictlyPositiveNumber( self.ENERGY, "Beam Energy") self.CUR = congruence.checkStrictlyPositiveNumber( self.CUR, "Beam Current") self.PERIOD = congruence.checkStrictlyPositiveNumber( self.PERIOD, "Period") self.N = congruence.checkStrictlyPositiveNumber( self.N, "Number of Periods") self.KX = congruence.checkNumber(self.KX, "Kx") self.KY = congruence.checkNumber(self.KY, "Ky") self.EMIN = congruence.checkPositiveNumber(self.EMIN, "Min Energy") self.EMAX = congruence.checkStrictlyPositiveNumber( self.EMAX, "Max Energy") congruence.checkLessThan(self.EMIN, self.EMAX, "Min Energy", "Max Energy") self.NEE = congruence.checkStrictlyPositiveNumber( self.NEE, "Number of energy steps") self.D = congruence.checkPositiveNumber(self.D, "Distance") self.XPC = congruence.checkNumber(self.XPC, "X-pos") self.YPC = congruence.checkNumber(self.YPC, "Y-pos") self.XPS = congruence.checkNumber(self.XPS, "X slit") self.YPS = congruence.checkNumber(self.YPS, "Y Slit") self.NXP = congruence.checkStrictlyPositiveNumber( self.NXP, "Integration points X") self.NYP = congruence.checkStrictlyPositiveNumber( self.NYP, "Integration points Y")
def get_ranges(self, beam_to_plot, var_x, var_y): xrange = None yrange = None factor1 = ShadowPlot.get_factor(var_x, self.workspace_units_to_cm) factor2 = ShadowPlot.get_factor(var_y, self.workspace_units_to_cm) if self.x_range == 0 and self.y_range == 0: if self.cartesian_axis == 1: x_max = 0 y_max = 0 x_min = 0 y_min = 0 x, y, good_only = beam_to_plot.getshcol((var_x, var_y, 10)) x_to_plot = copy.deepcopy(x) y_to_plot = copy.deepcopy(y) go = numpy.where(good_only == 1) lo = numpy.where(good_only != 1) if self.rays == 0: x_max = numpy.array(x_to_plot[0:], float).max() y_max = numpy.array(y_to_plot[0:], float).max() x_min = numpy.array(x_to_plot[0:], float).min() y_min = numpy.array(y_to_plot[0:], float).min() elif self.rays == 1: x_max = numpy.array(x_to_plot[go], float).max() y_max = numpy.array(y_to_plot[go], float).max() x_min = numpy.array(x_to_plot[go], float).min() y_min = numpy.array(y_to_plot[go], float).min() elif self.rays == 2: x_max = numpy.array(x_to_plot[lo], float).max() y_max = numpy.array(y_to_plot[lo], float).max() x_min = numpy.array(x_to_plot[lo], float).min() y_min = numpy.array(y_to_plot[lo], float).min() xrange = [x_min, x_max] yrange = [y_min, y_max] else: if self.x_range == 1: congruence.checkLessThan(self.x_range_min, self.x_range_max, "X range min", "X range max") xrange = [ self.x_range_min / factor1, self.x_range_max / factor1 ] if self.y_range == 1: congruence.checkLessThan(self.y_range_min, self.y_range_max, "Y range min", "Y range max") yrange = [ self.y_range_min / factor2, self.y_range_max / factor2 ] return xrange, yrange
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.TEMPERATURE = congruence.checkPositiveNumber( self.TEMPERATURE, "Temperature") self.E_MIN = congruence.checkPositiveNumber(self.E_MIN, "Min Energy") self.E_MAX = congruence.checkStrictlyPositiveNumber( self.E_MAX, "Max Energy") congruence.checkLessThan(self.E_MIN, self.E_MAX, "Min Energy", "Max Energy") self.NPOINTS = congruence.checkStrictlyPositiveNumber( self.NPOINTS, "Number of Points")
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 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.HMILLER = congruence.checkNumber(self.HMILLER, "h miller index") self.KMILLER = congruence.checkNumber(self.KMILLER, "k miller index") self.LMILLER = congruence.checkNumber(self.LMILLER, "l miller index") self.TEMPER = congruence.checkNumber(self.TEMPER, "Temperature factor") self.ENERGY = congruence.checkPositiveNumber(self.ENERGY, "Energy from") self.ENERGY_END = congruence.checkStrictlyPositiveNumber(self.ENERGY_END, "Energy to") congruence.checkLessThan(self.ENERGY, self.ENERGY_END, "Energy from", "Energy to") self.NPOINTS = congruence.checkStrictlyPositiveNumber(self.NPOINTS, "Number of 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): self.ENERGY = congruence.checkStrictlyPositiveNumber(self.ENERGY, "Energy") 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.ASYMMETRY_ANGLE = congruence.checkNumber(self.ASYMMETRY_ANGLE, "Asymmetry angle") self.THICKNESS = congruence.checkStrictlyPositiveNumber(self.THICKNESS, "Crystal thickness") self.TEMPERATURE = congruence.checkNumber(self.TEMPERATURE, "Crystal temperature") self.NPOINTS = congruence.checkStrictlyPositiveNumber(self.NPOINTS, "Number of points") if self.SCALE == 1: self.XFROM = congruence.checkNumber(self.XFROM, "Theta min") self.XTO = congruence.checkNumber(self.XTO, "Theta max") congruence.checkLessThan(self.XFROM, self.XTO, "Theta min", "Theta max")
def check_fields(self): self.HMILLER = congruence.checkNumber(self.HMILLER, "h miller index") self.KMILLER = congruence.checkNumber(self.KMILLER, "k miller index") self.LMILLER = congruence.checkNumber(self.LMILLER, "l miller index") self.TEMPER = congruence.checkNumber(self.TEMPER, "Temperature factor") self.ENERGY = congruence.checkPositiveNumber(self.ENERGY, "Energy from") self.ENERGY_END = congruence.checkStrictlyPositiveNumber( self.ENERGY_END, "Energy to") congruence.checkLessThan(self.ENERGY, self.ENERGY_END, "Energy from", "Energy to") self.NPOINTS = congruence.checkStrictlyPositiveNumber( self.NPOINTS, "Number of Points")
def get_range(self, wavefront_to_plot, var_x): if self.x_range == 0: if var_x == 1: # horizontal x_max = wavefront_to_plot.mesh.xFin x_min = wavefront_to_plot.mesh.xStart else: x_max = wavefront_to_plot.mesh.yFin x_min = wavefront_to_plot.mesh.yStart xrange = [x_min * TO_UM, x_max * TO_UM] else: congruence.checkLessThan(self.x_range_min, self.x_range_max, "Range min", "Range max") xrange = [self.x_range_min, self.x_range_max] return xrange
def check_fields(self): self.ELECTRONENERGY = congruence.checkStrictlyPositiveNumber(self.ELECTRONENERGY, "Electron Energy") if not self.METHOD == 1: self.ELECTRONENERGYSPREAD = congruence.checkPositiveNumber(self.ELECTRONENERGYSPREAD, "Electron Energy Spread") self.ELECTRONCURRENT = congruence.checkStrictlyPositiveNumber(self.ELECTRONCURRENT, "Electron Current") self.ELECTRONBEAMSIZEH = congruence.checkPositiveNumber(self.ELECTRONBEAMSIZEH, "Electron Beam Size H") self.ELECTRONBEAMSIZEV = congruence.checkPositiveNumber(self.ELECTRONBEAMSIZEV, "Electron Beam Size V") self.ELECTRONBEAMDIVERGENCEH = congruence.checkPositiveNumber(self.ELECTRONBEAMDIVERGENCEH, "Electron Beam Divergence H") self.ELECTRONBEAMDIVERGENCEV = congruence.checkPositiveNumber(self.ELECTRONBEAMDIVERGENCEV, "Electron Beam Divergence V") self.PERIODID = congruence.checkStrictlyPositiveNumber(self.PERIODID, "Period ID") self.NPERIODS = congruence.checkStrictlyPositiveNumber(self.NPERIODS, "Number of Periods") self.DISTANCE = congruence.checkPositiveNumber(self.DISTANCE, "Distance to slit") self.GAPH = congruence.checkPositiveNumber(self.GAPH, "Slit gap H") self.GAPV = congruence.checkPositiveNumber(self.GAPV, "Slit gap V") self.KMIN = congruence.checkPositiveNumber(self.KMIN, "K Min") self.KMAX = congruence.checkStrictlyPositiveNumber(self.KMAX, "K Max") congruence.checkLessThan(self.KMIN, self.KMAX, "K Min", "K Max") self.KPOINTS = congruence.checkStrictlyPositiveNumber(self.KPOINTS, "Number of K Points")
def get_ranges(self): xrange = None yrange = None factor1 = self.workspace_units_to_mm factor2 = self.workspace_units_to_mm if self.x_range == 1: congruence.checkLessThan(self.x_range_min, self.x_range_max, "X range min", "X range max") xrange = [self.x_range_min / factor1, self.x_range_max / factor1] if self.y_range == 1: congruence.checkLessThan(self.y_range_min, self.y_range_max, "Y range min", "Y range max") yrange = [self.y_range_min / factor2, self.y_range_max / factor2] return xrange, yrange
def check_fields(self): self.ENERGY = congruence.checkStrictlyPositiveNumber(self.ENERGY, "Beam Energy") self.CUR = congruence.checkStrictlyPositiveNumber(self.CUR, "Beam Current") self.PERIOD = congruence.checkStrictlyPositiveNumber(self.PERIOD, "Period") self.N = congruence.checkStrictlyPositiveNumber(self.N, "Number of Periods") self.KX = congruence.checkNumber(self.KX, "Kx") self.KY = congruence.checkNumber(self.KY, "Ky") self.EMIN = congruence.checkPositiveNumber(self.EMIN, "Min Energy") self.EMAX = congruence.checkStrictlyPositiveNumber(self.EMAX, "Max Energy") congruence.checkLessThan(self.EMIN, self.EMAX, "Min Energy", "Max Energy") self.NEE = congruence.checkStrictlyPositiveNumber(self.NEE, "Number of energy steps") self.D = congruence.checkPositiveNumber(self.D, "Distance") self.XPC = congruence.checkNumber(self.XPC, "X-pos") self.YPC = congruence.checkNumber(self.YPC, "Y-pos") self.XPS = congruence.checkNumber(self.XPS, "X slit") self.YPS = congruence.checkNumber(self.YPS, "Y Slit") self.NXP = congruence.checkStrictlyPositiveNumber(self.NXP, "Integration points X") self.NYP = congruence.checkStrictlyPositiveNumber(self.NYP, "Integration points Y")
def check_fields(self): self.ELECTRONENERGY = congruence.checkStrictlyPositiveNumber( self.ELECTRONENERGY, "Electron Energy") if not self.METHOD == 1: self.ELECTRONENERGYSPREAD = congruence.checkPositiveNumber( self.ELECTRONENERGYSPREAD, "Electron Energy Spread") self.ELECTRONCURRENT = congruence.checkStrictlyPositiveNumber( self.ELECTRONCURRENT, "Electron Current") self.ELECTRONBEAMSIZEH = congruence.checkPositiveNumber( self.ELECTRONBEAMSIZEH, "Electron Beam Size H") self.ELECTRONBEAMSIZEV = congruence.checkPositiveNumber( self.ELECTRONBEAMSIZEV, "Electron Beam Size V") self.ELECTRONBEAMDIVERGENCEH = congruence.checkPositiveNumber( self.ELECTRONBEAMDIVERGENCEH, "Electron Beam Divergence H") self.ELECTRONBEAMDIVERGENCEV = congruence.checkPositiveNumber( self.ELECTRONBEAMDIVERGENCEV, "Electron Beam Divergence V") self.PERIODID = congruence.checkStrictlyPositiveNumber( self.PERIODID, "Period ID") self.NPERIODS = congruence.checkStrictlyPositiveNumber( self.NPERIODS, "Number of Periods") self.KV = congruence.checkPositiveNumber(self.KV, "Kv") self.KH = congruence.checkPositiveNumber(self.KH, "Kh") self.KPHASE = congruence.checkNumber(self.KPHASE, "KPHASE") self.DISTANCE = congruence.checkPositiveNumber(self.DISTANCE, "Distance to slit") self.GAPH = congruence.checkPositiveNumber(self.GAPH, "Slit gap H") self.GAPV = congruence.checkPositiveNumber(self.GAPV, "Slit gap V") self.GAPH_CENTER = congruence.checkPositiveNumber( self.GAPH_CENTER, "Slit center H") self.GAPV_CENTER = congruence.checkPositiveNumber( self.GAPV_CENTER, "Slit center V") self.PHOTONENERGYMIN = congruence.checkPositiveNumber( self.PHOTONENERGYMIN, "photon Energy Min") self.PHOTONENERGYMAX = congruence.checkStrictlyPositiveNumber( self.PHOTONENERGYMAX, "photon Energy Max") congruence.checkLessThan(self.PHOTONENERGYMIN, self.PHOTONENERGYMAX, "photon Energy Min", "photon Energy Max") self.PHOTONENERGYPOINTS = congruence.checkStrictlyPositiveNumber( self.PHOTONENERGYPOINTS, "photon Energy Points") if self.METHOD == 1: # URGENT congruence.checkLessThan(self.PHOTONENERGYPOINTS, 4701, "Number of energy points", "4701")
def check_fields(self): self.ENERGY = congruence.checkStrictlyPositiveNumber(self.ENERGY, "Electron Energy") self.CURRENT = congruence.checkStrictlyPositiveNumber(self.CURRENT, "Current") self.ENERGY_SPREAD = congruence.checkStrictlyPositiveNumber(self.ENERGY_SPREAD, "Energy Spread") self.SIGX = congruence.checkPositiveNumber(self.SIGX , "Sigma X") self.SIGY = congruence.checkPositiveNumber(self.SIGY , "Sigma Y") self.SIGX1 = congruence.checkPositiveNumber(self.SIGX1, "Sigma X'") self.SIGY1 = congruence.checkPositiveNumber(self.SIGY1, "Sigma Y'") self.PERIOD = congruence.checkStrictlyPositiveNumber(self.PERIOD, "Period length") self.NP = congruence.checkStrictlyPositiveNumber(self.NP, "Number of periods") self.EMIN = congruence.checkPositiveNumber(self.EMIN, "E1 minimum energy") self.EMAX = congruence.checkStrictlyPositiveNumber(self.EMAX, "E1 maximum energy") congruence.checkLessThan(self.EMIN, self.EMAX, "E1 minimum energy", "E1 maximum energy") self.N = congruence.checkStrictlyPositiveNumber(self.N, "Number of Energy Points") self.HARMONIC_FROM = congruence.checkStrictlyPositiveNumber(self.HARMONIC_FROM, "Minimum harmonic number") self.HARMONIC_TO = congruence.checkStrictlyPositiveNumber(self.HARMONIC_TO, "Maximum harmonic number") congruence.checkLessThan(self.HARMONIC_FROM, self.HARMONIC_TO, "Minimum harmonic number", "Maximum harmonic number") self.HARMONIC_STEP = congruence.checkStrictlyPositiveNumber(self.HARMONIC_STEP, "Harmonic step size") self.NEKS = congruence.checkPositiveNumber(self.NEKS , "Intrinsic NEKS")
def check_fields(self): self.NPERIODS = congruence.checkStrictlyPositiveNumber(self.NPERIODS, "Number of Periods") self.ENERGY = congruence.checkStrictlyPositiveNumber(self.ENERGY, "Beam Energy") self.PHOT_ENERGY_MIN = congruence.checkPositiveNumber(self.PHOT_ENERGY_MIN, "Min Photon Energy") self.PHOT_ENERGY_MAX = congruence.checkStrictlyPositiveNumber(self.PHOT_ENERGY_MAX, "Max Photon Energy") congruence.checkLessThan(self.PHOT_ENERGY_MIN, self.PHOT_ENERGY_MAX, "Min Photon Energy", "Max Photon Energy") self.NPOINTS = congruence.checkStrictlyPositiveNumber(self.NPOINTS, "Number of Energy Points") self.CURRENT = congruence.checkStrictlyPositiveNumber(self.CURRENT, "Electron Beam Current") if self.FIELD == 0: self.ULAMBDA = congruence.checkStrictlyPositiveNumber(self.ULAMBDA, "Wiggler period") self.K = congruence.checkStrictlyPositiveNumber(self.K, "K") self.NTRAJPOINTS = congruence.checkStrictlyPositiveNumber(self.NTRAJPOINTS, "Number of traj points per period") elif self.FIELD == 1: self.ULAMBDA = congruence.checkStrictlyPositiveNumber(self.ULAMBDA, "Wiggler period") self.NTRAJPOINTS = congruence.checkStrictlyPositiveNumber(self.NTRAJPOINTS, "Number of traj points per period") congruence.checkUrl(self.FILE) elif self.FIELD == 2: congruence.checkUrl(self.FILE)
def check_fields(self): self.ELECTRONENERGY = congruence.checkStrictlyPositiveNumber(self.ELECTRONENERGY, "Electron Energy") if not self.METHOD == 1: self.ELECTRONENERGYSPREAD = congruence.checkPositiveNumber(self.ELECTRONENERGYSPREAD, "Electron Energy Spread") self.ELECTRONCURRENT = congruence.checkStrictlyPositiveNumber(self.ELECTRONCURRENT, "Electron Current") self.ELECTRONBEAMSIZEH = congruence.checkPositiveNumber(self.ELECTRONBEAMSIZEH, "Electron Beam Size H") self.ELECTRONBEAMSIZEV = congruence.checkPositiveNumber(self.ELECTRONBEAMSIZEV, "Electron Beam Size V") self.ELECTRONBEAMDIVERGENCEH = congruence.checkPositiveNumber(self.ELECTRONBEAMDIVERGENCEH, "Electron Beam Divergence H") self.ELECTRONBEAMDIVERGENCEV = congruence.checkPositiveNumber(self.ELECTRONBEAMDIVERGENCEV, "Electron Beam Divergence V") self.PERIODID = congruence.checkStrictlyPositiveNumber(self.PERIODID, "Period ID") self.NPERIODS = congruence.checkStrictlyPositiveNumber(self.NPERIODS, "Number of Periods") self.KV = congruence.checkPositiveNumber(self.KV, "Kv") self.DISTANCE = congruence.checkPositiveNumber(self.DISTANCE, "Distance to slit") self.GAPH = congruence.checkPositiveNumber(self.GAPH, "Slit gap H") self.GAPV = congruence.checkPositiveNumber(self.GAPV, "Slit gap V") self.PHOTONENERGYMIN = congruence.checkPositiveNumber(self.PHOTONENERGYMIN, "photon Energy Min") self.PHOTONENERGYMAX = congruence.checkStrictlyPositiveNumber(self.PHOTONENERGYMAX, "photon Energy Max") congruence.checkLessThan(self.PHOTONENERGYMIN, self.PHOTONENERGYMAX, "photon Energy Min", "photon Energy Max") self.PHOTONENERGYPOINTS = congruence.checkStrictlyPositiveNumber(self.PHOTONENERGYPOINTS, "photon Energy Points") if sys.platform == 'linux' and self.METHOD == 2: raise Exception("SRW calculation code not supported under Linux")
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): if self.RB_CHOICE == 0: self.MACHINE_R_M = congruence.checkStrictlyPositiveNumber(self.MACHINE_R_M, "Magnetic Radius") else: self.BFIELD_T = congruence.checkStrictlyPositiveNumber(self.BFIELD_T, "Magnetic Field") self.BEAM_ENERGY_GEV = congruence.checkStrictlyPositiveNumber(self.BEAM_ENERGY_GEV, "Beam Energy") self.CURRENT_A = congruence.checkStrictlyPositiveNumber(self.CURRENT_A, "Beam Current") self.HOR_DIV_MRAD = congruence.checkPositiveNumber(self.HOR_DIV_MRAD, "Horizontal div Theta") self.PHOT_ENERGY_MIN = congruence.checkPositiveNumber(self.PHOT_ENERGY_MIN, "Min Photon Energy") self.PHOT_ENERGY_MAX = congruence.checkStrictlyPositiveNumber(self.PHOT_ENERGY_MAX, "Max Photon Energy") congruence.checkLessThan(self.PHOT_ENERGY_MIN, self.PHOT_ENERGY_MAX, "Min Photon Energy", "Max Photon Energy") self.NPOINTS = congruence.checkStrictlyPositiveNumber(self.NPOINTS, "Number of Energy Points") self.PSI_MRAD_PLOT = congruence.checkNumber(self.PSI_MRAD_PLOT, "Max Psi for angular plots") if self.VER_DIV == 2: self.PSI_MIN = congruence.checkNumber(self.PSI_MIN, "Min Photon Energy") self.PSI_MAX = congruence.checkNumber(self.PSI_MAX, "Max Photon Max") congruence.checkLessThan(self.PSI_MIN, self.PSI_MAX, "Psi Min", "Psi Max") elif self.VER_DIV == 3: self.PSI_MIN = congruence.checkNumber(self.PSI_MIN, "Min Photon Energy")
def check_fields(self): self.ENERGY = congruence.checkStrictlyPositiveNumber( self.ENERGY, "Energy") 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.ASYMMETRY_ANGLE = congruence.checkNumber(self.ASYMMETRY_ANGLE, "Asymmetry angle") self.THICKNESS = congruence.checkStrictlyPositiveNumber( self.THICKNESS, "Crystal thickness") self.TEMPERATURE = congruence.checkNumber(self.TEMPERATURE, "Crystal temperature") self.NPOINTS = congruence.checkStrictlyPositiveNumber( self.NPOINTS, "Number of points") if self.SCALE == 1: self.XFROM = congruence.checkNumber(self.XFROM, "Theta min") self.XTO = congruence.checkNumber(self.XTO, "Theta max") congruence.checkLessThan(self.XFROM, self.XTO, "Theta min", "Theta max")
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.ENERGY = congruence.checkStrictlyPositiveNumber(self.ENERGY, "Electron Energy") self.CURRENT = congruence.checkStrictlyPositiveNumber(self.CURRENT, "Current") self.ENERGY_SPREAD = congruence.checkStrictlyPositiveNumber(self.ENERGY_SPREAD, "Energy Spread") self.SIGX = congruence.checkPositiveNumber(self.SIGX , "Sigma X") self.SIGY = congruence.checkPositiveNumber(self.SIGY , "Sigma Y") self.SIGX1 = congruence.checkPositiveNumber(self.SIGX1, "Sigma X'") self.SIGY1 = congruence.checkPositiveNumber(self.SIGY1, "Sigma Y'") self.PERIOD = congruence.checkStrictlyPositiveNumber(self.PERIOD, "Period length") self.NP = congruence.checkStrictlyPositiveNumber(self.NP, "Number of periods") self.EMIN = congruence.checkPositiveNumber(self.EMIN, "E1 minimum energy") self.EMAX = congruence.checkStrictlyPositiveNumber(self.EMAX, "E1 maximum energy") congruence.checkLessThan(self.EMIN, self.EMAX, "E1 minimum energy", "E1 maximum energy") self.N = congruence.checkStrictlyPositiveNumber(self.N, "Number of Energy Points") self.DISTANCE = congruence.checkPositiveNumber(self.DISTANCE, "Distance to slit") self.XPS = congruence.checkPositiveNumber(self.XPS, "Aperture Width H") self.YPS = congruence.checkPositiveNumber(self.YPS, "Aperture Height V") self.XPC = congruence.checkPositiveNumber(self.XPC, "Aperture Center H") self.YPC = congruence.checkPositiveNumber(self.YPC, "Aperture Center V") self.HARMONIC_FROM = congruence.checkStrictlyPositiveNumber(self.HARMONIC_FROM, "Minimum harmonic number") self.HARMONIC_TO = congruence.checkStrictlyPositiveNumber(self.HARMONIC_TO, "Maximum harmonic number") congruence.checkLessThan(self.HARMONIC_FROM, self.HARMONIC_TO, "Minimum harmonic number", "Maximum harmonic number") self.HARMONIC_STEP = congruence.checkStrictlyPositiveNumber(self.HARMONIC_STEP, "Harmonic step size") self.NEKS = congruence.checkStrictlyPositiveNumber(self.NEKS, "Neks OR % Helicity")
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.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 calculate_total_filter(self): try: congruence.checkStrictlyPositiveNumber(self.energy_from, "Energy From") congruence.checkStrictlyPositiveNumber(self.energy_to, "Energy to") congruence.checkStrictlyPositiveNumber(self.energy_nr, "Nr. of energies") congruence.checkLessThan(self.energy_from, self.energy_to, "Energy From", "Energy to") energies = numpy.linspace(self.energy_from, self.energy_to, self.energy_nr) total_filter = numpy.ones((self.energy_nr, 2)) total_filter[:, 0] = energies self.__add_data_to_total_filter(total_filter, self.ref_1, self.n_ref_1, self.check_ref_1) self.__add_data_to_total_filter(total_filter, self.ref_2, self.n_ref_2, self.check_ref_2) self.__add_data_to_total_filter(total_filter, self.ref_3, self.n_ref_3, self.check_ref_3) self.__add_data_to_total_filter(total_filter, self.dif_1, self.n_dif_1, self.check_dif_1) self.__add_data_to_total_filter(total_filter, self.dif_2, self.n_dif_2, self.check_dif_2) self.__add_data_to_total_filter(total_filter, self.mul_1, self.n_mul_1, self.check_mul_1) self.__add_data_to_total_filter(total_filter, self.mul_2, self.n_mul_2, self.check_mul_2) self.__add_data_to_total_filter(total_filter, self.pow_1, 0, self.check_pow_1, absorbed=self.abs_tran == 0) total_filter[numpy.where(numpy.isnan(total_filter))] = 0.0 if not total_filter[:, 1].sum() == total_filter.shape[0]: self.filter_plot.clear() self.filter_plot.addCurve(total_filter[:, 0], total_filter[:, 1], replace=True, legend="Total Filter") self.filter_plot.setGraphXLabel("Energy [eV]") self.filter_plot.setGraphYLabel("Intensity Factor") self.filter_plot.setGraphTitle("Total Filter") calculated_data = DataExchangeObject("ShadowOui_Thermal", "TOTAL_FILTER") calculated_data.add_content("total_filter", total_filter) self.send("Total Filter", calculated_data) else: raise ValueError("Calculation not possibile: no input data") except Exception as e: QMessageBox.critical(self, "Error", str(e), QMessageBox.Ok) if self.IS_DEVELOP: raise e
def check_fields(self): self.TEMPERATURE = congruence.checkPositiveNumber(self.TEMPERATURE, "Temperature") self.E_MIN = congruence.checkPositiveNumber(self.E_MIN, "Min Energy") self.E_MAX = congruence.checkStrictlyPositiveNumber(self.E_MAX, "Max Energy") congruence.checkLessThan(self.E_MIN, self.E_MAX, "Min Energy", "Max Energy") self.NPOINTS = congruence.checkStrictlyPositiveNumber(self.NPOINTS, "Number of Points")