Ejemplo n.º 1
0
    def check_accelerator_instance(accel: Lhc) -> None:
        accel.verify_object(
        )  # should have been done anyway, but cannot hurt (jdilly)

        # Creator specific checks
        if accel.model_dir is None:
            raise AcceleratorDefinitionError(
                "The accelerator definition is incomplete: model directory (outputdir option) was not given."
            )

        if accel.modifiers is None or not len(accel.modifiers):
            raise AcceleratorDefinitionError(
                "The accelerator definition is incomplete: no modifiers could be found."
            )

        # hint: if modifiers are given as absolute paths: `path / abs_path` returns `abs_path`  (jdilly)
        inexistent_modifiers = [
            m for m in accel.modifiers if not (accel.model_dir / m).exists()
        ]
        if len(inexistent_modifiers):
            raise AcceleratorDefinitionError(
                "The following modifier files do not exist: "
                f"{', '.join([str(accel.model_dir / modifier) for modifier in inexistent_modifiers])}"
            )
Ejemplo n.º 2
0
 def verify_object(self):
     try:
         self.beam
     except AttributeError:
         raise AcceleratorDefinitionError(
             "The accelerator definition is incomplete, beam "
             "has to be specified (--beam option missing?).")
     if self.modifiers is None:
         raise AcceleratorDefinitionError(
             "The accelerator definition is incomplete, optics "
             "file has not been specified.")
     if self.xing is None:
         raise AcceleratorDefinitionError("Crossing on or off not set.")
     if self.label is None:
         raise AcceleratorDefinitionError("Segment label not set.")
     if self.start is None:
         raise AcceleratorDefinitionError("Segment start not set.")
     if self.end is None:
         raise AcceleratorDefinitionError("Segment end not set.")
Ejemplo n.º 3
0
 def verify_object(self) -> None:
     try:
         self.beam
     except AttributeError:
         raise AcceleratorDefinitionError(
             "The accelerator definition is incomplete, beam "
             "has to be specified (--beam option missing?)."
         )
     if self.modifiers is None or not len(self.modifiers):
         raise AcceleratorDefinitionError(
             "The accelerator definition is incomplete, no modifiers could be found."
         )
     if self.xing is None:
         raise AcceleratorDefinitionError("Crossing on or off not set.")
     if self.label is None:
         raise AcceleratorDefinitionError("Segment label not set.")
     if self.start is None:
         raise AcceleratorDefinitionError("Segment start not set.")
     if self.end is None:
         raise AcceleratorDefinitionError("Segment end not set.")
Ejemplo n.º 4
0
 def beam(self, value) -> None:
     if value not in (1, 2):
         raise AcceleratorDefinitionError("Beam parameter has to be one of (1, 2)")
     self._beam = value
Ejemplo n.º 5
0
 def verify_object(self):
     if self.model_dir is None:  # is the class is used to create full response?
         raise AcceleratorDefinitionError("SuperKEKB doesn't have a model creation, "
                                          "calling it this way is most probably wrong.")
Ejemplo n.º 6
0
 def ring(self, value):
     if value not in RINGS:
         raise AcceleratorDefinitionError("Ring parameter has to be one of ('ler', 'her')")
     self._ring = value
Ejemplo n.º 7
0
 def ring(self):
     if self._ring is None:
         raise AcceleratorDefinitionError("The accelerator definition is incomplete, ring "
                                          "has to be specified (--ring option missing?).")
     return self._ring
Ejemplo n.º 8
0
 def verify_object(self):  # TODO: Maybe more checks?
     if self.model_dir is None:  # is the class is used to create full response?
         raise AcceleratorDefinitionError(
             "PETRA doesn't have a model creation yet, calling it this "
             "way is most probably wrong.")
Ejemplo n.º 9
0
 def ring(self, value):
     if value not in (1, 2, 3, 4):
         raise AcceleratorDefinitionError(
             "Ring parameter has to be one of (1, 2, 3, 4)")
     self._ring = value
Ejemplo n.º 10
0
 def verify_object(self):
     _ = self.ring
     if self.modifiers:
         raise AcceleratorDefinitionError(
             f"Accelerator {self.NAME} cannot handle modifiers,"
             f" yet modifiers were given.")
Ejemplo n.º 11
0
 def beam(self):
     if self._beam is None:
         raise AcceleratorDefinitionError(
             "The accelerator definition is incomplete, beam "
             "has to be specified (--beam option missing?).")
     return self._beam