def generate_energy_spectrum(self): if self.input_beam is None: return try: if self.input_beam.getOEHistory(oe_number=0)._shadow_source_end.src.FSOURCE_DEPTH == 1: raise Exception("Source has no depth, calcution could be inconsistent") if self.kind_of_calculation == 1: congruence.checkFile(self.user_file) else: congruence.checkStrictlyPositiveNumber(self.factor, "Proportionality factor (k) [to eV/Å]") congruence.checkStrictlyPositiveNumber(self.central_value, "Central Energy/Wavelength Value [eV/Å]") beam_out = self.input_beam.duplicate() if self.kind_of_calculation == 0: for index in range(0, len(beam_out._beam.rays)): if self.units == 0: beam_out._beam.rays[index, 10] = ShadowPhysics.getShadowKFromEnergy(self.central_value + self.factor*beam_out._beam.rays[index, 1]) else: beam_out._beam.rays[index, 10] = ShadowPhysics.getShadowKFromWavelength(self.central_value + self.factor*beam_out._beam.rays[index, 1]) else: self.load_energy_distribution() for index in range(0, len(beam_out._beam.rays)): if self.units == 0: beam_out._beam.rays[index, 10] = ShadowPhysics.getShadowKFromEnergy(self.get_value_from_y(beam_out._beam.rays[index, 1])) else: beam_out._beam.rays[index, 10] = ShadowPhysics.getShadowKFromWavelength(self.get_value_from_y(beam_out._beam.rays[index, 1])) self.send("Beam", beam_out) except Exception as exception: QtGui.QMessageBox.critical(self, "Error", str(exception), QtGui.QMessageBox.Ok)