Ejemplo n.º 1
0
    def checkFields(self):
        congruence.checkPositiveNumber(self.source_plane_distance,
                                       "Distance from Source")
        congruence.checkPositiveNumber(self.image_plane_distance,
                                       "Image Plane Distance")
        congruence.checkStrictlyPositiveNumber(self.input_diameter,
                                               "Input Diameter")
        congruence.checkStrictlyPositiveAngle(self.angular_acceptance,
                                              "Angular Acceptance")
        congruence.checkStrictlyPositiveNumber(self.output_diameter,
                                               "Output Diameter")
        congruence.checkPositiveNumber(self.residual_divergence,
                                       "Residual Output Divergence")
        congruence.checkStrictlyPositiveNumber(self.lens_length,
                                               "Lens Total Length")

        if self.output_diameter <= self.input_diameter:
            raise Exception(
                "Output Diameter should be greater than Input diameter")

        slit_distance = self.get_slits_distance()

        if self.lens_length < slit_distance:
            raise Exception(
                "Lens total Length should be greater than or equal to " +
                str(slit_distance))

        congruence.checkStrictlyPositiveNumber(self.transmittance,
                                               "Lens Transmittance")
Ejemplo n.º 2
0
    def checkFields(self):
        congruence.checkPositiveNumber(self.source_plane_distance, "Distance from Source")
        congruence.checkPositiveNumber(self.image_plane_distance, "Image Plane Distance")
        congruence.checkStrictlyPositiveNumber(self.input_diameter, "Input Diameter")
        congruence.checkStrictlyPositiveAngle(self.angular_acceptance, "Angular Acceptance")
        congruence.checkStrictlyPositiveNumber(self.output_diameter, "Output Diameter")
        congruence.checkStrictlyPositiveNumber(self.inner_diameter, "Central Diameter")
        congruence.checkStrictlyPositiveNumber(self.focal_length, "Focal Length")
        congruence.checkStrictlyPositiveNumber(self.focus_dimension, "Focus Dimension")
        congruence.checkStrictlyPositiveNumber(self.lens_length, "Lens Total Length")

        if self.inner_diameter <= self.input_diameter:
            raise Exception("Central Diameter should be greater than Input diameter")

        if self.inner_diameter <= self.output_diameter:
            raise Exception("Central Diameter should be greater than Output diameter")

        if self.focal_length < self.output_diameter:
            raise Exception("Focal Length should be greater than or equal to Output diameter")

        first_slit_distance = self.get_first_slits_distance()
        second_slit_distance = self.get_second_slits_distance()

        slit_distance = first_slit_distance + second_slit_distance

        if self.lens_length < slit_distance:
            raise Exception("Lens total Length should be greater than or equal to " + str(slit_distance))

        congruence.checkStrictlyPositiveNumber(self.transmittance, "Lens Transmittance")
    def checkFields(self):
        congruence.checkPositiveNumber(self.source_plane_distance, "Distance from Source")
        congruence.checkPositiveNumber(self.image_plane_distance, "Image Plane Distance")
        congruence.checkStrictlyPositiveNumber(self.input_diameter, "Input Diameter")
        congruence.checkStrictlyPositiveAngle(self.angular_acceptance, "Angular Acceptance")
        congruence.checkStrictlyPositiveNumber(self.output_diameter, "Output Diameter")
        congruence.checkStrictlyPositiveNumber(self.inner_diameter, "Central Diameter")
        congruence.checkStrictlyPositiveNumber(self.focal_length, "Focal Length")
        congruence.checkStrictlyPositiveNumber(self.focus_dimension, "Focus Dimension")
        congruence.checkStrictlyPositiveNumber(self.lens_length, "Lens Total Length")

        if self.inner_diameter <= self.input_diameter:
            raise Exception("Central Diameter should be greater than Input diameter")

        if self.inner_diameter <= self.output_diameter:
            raise Exception("Central Diameter should be greater than Output diameter")

        if self.focal_length < self.output_diameter:
            raise Exception("Focal Length should be greater than or equal to Output diameter")

        first_slit_distance = self.get_first_slits_distance()
        second_slit_distance = self.get_second_slits_distance()

        slit_distance = first_slit_distance + second_slit_distance

        if self.lens_length < slit_distance:
            raise Exception("Lens total Length should be greater than or equal to " + str(slit_distance))

        congruence.checkStrictlyPositiveNumber(self.transmittance, "Lens Transmittance")
    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 checkFields(self):
        congruence.checkPositiveNumber(self.source_plane_distance, "Distance from Source")
        congruence.checkPositiveNumber(self.image_plane_distance, "Image Plane Distance")
        congruence.checkStrictlyPositiveNumber(self.input_diameter, "Input Diameter")
        congruence.checkStrictlyPositiveAngle(self.angular_acceptance, "Angular Acceptance")
        congruence.checkStrictlyPositiveNumber(self.output_diameter, "Output Diameter")
        congruence.checkPositiveNumber(self.residual_divergence, "Residual Output Divergence")
        congruence.checkStrictlyPositiveNumber(self.lens_length, "Lens Total Length")

        if self.output_diameter <= self.input_diameter:
            raise Exception("Output Diameter should be greater than Input diameter")

        slit_distance = self.get_slits_distance()

        if self.lens_length < slit_distance:
            raise Exception("Lens total Length should be greater than or equal to " + str(slit_distance))

        congruence.checkStrictlyPositiveNumber(self.transmittance, "Lens Transmittance")
Ejemplo n.º 6
0
    def get_lorentz_polarization(self):
        if self.use_polarization_factor == 1:
            congruence.checkPositiveNumber(self.degree_of_polarization,
                                           "Deg. Pol.")
            congruence.checkLessOrEqualThan(self.degree_of_polarization, 1.0,
                                            "Deg. Pol.", "1.0")

        if self.use_polarization_factor == 1 and self.use_twotheta_mono == 1:
            congruence.checkStrictlyPositiveAngle(self.twotheta_mono,
                                                  "2\u03B8 Monochromator")

        return PolarizationParameters(
            use_lorentz_factor=self.use_lorentz_factor == 1,
            lorentz_formula=self.lorentz_formula,
            use_polarization_factor=self.use_polarization_factor,
            twotheta_mono=None if
            (self.use_polarization_factor == 0
             or self.use_twotheta_mono == 0) else self.twotheta_mono,
            beampath=self.beampath,
            degree_of_polarization=self.degree_of_polarization)
Ejemplo n.º 7
0
 def check_fields(self):
     congruence.checkFile(self.FILE)
     self.LAMBDA = congruence.checkStrictlyPositiveNumber(self.LAMBDA, "Lambda")
     self.U = congruence.checkNumber(self.U, "U")
     self.V = congruence.checkNumber(self.V, "V")
     self.W = congruence.checkNumber(self.W, "W")
     self.X = congruence.checkNumber(self.X, "X")
     self.LS = congruence.checkNumber(self.LS, "LS")
     self.THMIN = congruence.checkPositiveAngle(self.THMIN, "TwoTheta from")
     self.THMAX = congruence.checkPositiveAngle(self.THMAX, "TwoTheta to")
     self.STEP = congruence.checkStrictlyPositiveAngle(self.STEP, "TwoTheta step")
     congruence.checkGreaterThan(self.THMAX, self.THMIN, "TwoTheta to", "TwoTheta from")
Ejemplo n.º 8
0
 def check_fields(self):
     congruence.checkFile(self.FILE)
     self.LAMBDA = congruence.checkStrictlyPositiveNumber(self.LAMBDA, "Lambda")
     self.U = congruence.checkNumber(self.U, "U")
     self.V = congruence.checkNumber(self.V, "V")
     self.W = congruence.checkNumber(self.W, "W")
     self.X = congruence.checkNumber(self.X, "X")
     self.LS = congruence.checkNumber(self.LS, "LS")
     self.THMIN = congruence.checkPositiveAngle(self.THMIN, "TwoTheta from")
     self.THMAX = congruence.checkPositiveAngle(self.THMAX, "TwoTheta to")
     self.STEP = congruence.checkStrictlyPositiveAngle(self.STEP, "TwoTheta step")
     congruence.checkGreaterThan(self.THMAX, self.THMIN, "TwoTheta to", "TwoTheta from")