ESBO-ETC/docs/source/developer/extending.rst

58 lines
3.9 KiB
ReStructuredText
Raw Normal View History

2020-07-07 15:57:27 +02:00
ESBO-ETC can be easily extended by adding new targets, new optical components or a new detector component.
In the following, only the minimal required changes in the source code are described.
2020-10-29 10:11:59 +01:00
Of course, the documentation must be edited as well if new components are added and corresponding build tests should be defined.
Before any changes can be committed to the repository, the developer must ensure that all build tests pass.
The build tests can be started by running
2020-07-07 15:57:27 +02:00
2020-10-29 10:11:59 +01:00
.. code-block:: bash
:linenos:
venv/bin/python3 -m unittest discover tests
in the console in the project's root directory.
2020-07-07 14:56:47 +02:00
Adding Targets
--------------
2020-07-07 15:57:27 +02:00
Adding a new target type to ESBO-ETC is the easiest extension.
In the first place, the new target component must be defined in a new file *classes*-folder.
Thereby, the new component must subclass ``ATarget`` in order to be decoratable by other optical components.
The class must provide a constructor which accepts all attributes of the configuration tag as parameters and initializes the superclass passing the emitted radiation as parameter.
Additionally, the class must implement the method ``checkConfig()`` in order to check the configuration.
In case of an configuration error, the method must return the corresponding error message.
2020-09-10 15:42:52 +02:00
Optionally, the factory method ``create()`` of the class ``TargetFactory`` has to be modified, if the constructor of the new component requires more parameters than the configuration tag attributes.
2020-07-07 14:56:47 +02:00
Adding Optical Components
-------------------------
Extending ESBO-ETC by a new optical component consists of two tasks.
First of all, the new optical component class has to be implemented in a separate file in the *classes*-folder.
The new class must inherit from the abstract class ``AOpticalComponent`` or, in case of an optical component with thermal emission, from the abstract class ``AHotOpticalComponent`` and implement all abstract methods.
In case of a cold optical component, the new class must implement the method ``checkConfig()`` and call the constructor of the super class.
In case of a hot optical component, the new class must implement the method ``checkConfig()`` as well as the method ``propagate()`` and call the constructor of the super class.
The method ``checkConfig()`` is used for checking the XML-configuration file and accepts as parameter the corresponding part of the configuration as ``Entry``-object.
In case of an configuration error, the method must return the corresponding error message.
The method ``propagate()`` is used to model the propagation of incoming radiation through the optical component.
Therefore, this method receives as parameter the incoming radiation as ``SpectralQty``-object and must return the manipulated radiation as ``SpectralQty``-object.
2020-09-10 15:42:52 +02:00
The optional second task consists of modifying the factory method ``create()`` of the class ``OpticalComponentFactory`` in order to properly initialize the new optical component from the configuration.
2020-09-12 11:51:49 +02:00
This is only necessary if the new optical component needs additional parameters besides the attributes of the corresponding configuration tag.
2020-07-07 14:56:47 +02:00
Adding Detector Components
--------------------------
2020-07-07 15:57:27 +02:00
In order to add a new detector component, two tasks must be completed.
The new detector component must be implemented in a designated file in the *classes*-folder, subclassing ``ASensor``.
Thereby, the new class must implement the three methods ``calcSNR()``, ``calcExpTime()`` and ``calcSensitivity()``.
All three methods obtain the incoming background and signal radiation as well as the obstruction factor as parameters apart from some specific parameters and must return the corresponding calculated value.
Additionally, all three methods must be able to calculate multiple SNRs, exposure times or sensitivities at once if an array of specific parameters is provided.
2020-09-12 11:51:49 +02:00
Besides the implementation of the detector, the factory method ``create()`` of the class ``SensorFactory`` can be modified.