Aim of the project to transform the data from PES to SPEC.
The aim of this project is to read low-resolution photon spectrometer measurements and predict, with an uncertainty band, a high-resolution invasive
photon spectrometer result, in such a way that one may continue to collect low-resolution data without stopping the beam, but obtaining nevertheless, high-resolution
results.
# Usage
The concept is to collect both results simultaneously during a training phase and use it to learn a model that may be used later, under the same conditions, but without the high-resolution, invasive spectrometer. The idea is that minimum tuning of the parameters of this methods are needed, so that if the data for training is available, no fine-tuning is required.
## Installation
One may install it simply with `pip install pes_to_spec`.
## Usage
The API may be used as follows:
```
from pes_to_spec.model import Model
# this is the main object holding all
# information needed for training and prediction
# the default parameters should be sufficient in most times
model = Model()
# this trains the model
# low_resolution_raw_data is a dictionary with keys "channel_[1-4]_[A-D]" and values set to 2D-shaped
# numpy arrays with shape (number_of_train_IDs, features),
# indicating the low resolution spectra for each input channel
# high_resolution_intensity and high_resolution_photon_energy are estimates from the high-resolution invasive spectrometer
channels = [f"channel_{i}_{l}" for i, l in product(range(1, 5), ["A", "B", "C", "D"])]
low_resolution_raw_data = {ch: run['SA3_XTD10_PES/ADC/1:network', f"digitizers.{ch}.raw.samples"].select_trains(by_id[tids]).ndarray() for ch in channels}
```
## Exploration initial tests
A first draft and explorative code can be seen in the `exploration` directory.
1. inv_train.py -> Train a model on the specific RUN.
1. inv_train.py -> Train a model on the specific RUN.
Thish will save the pca model and fit model in experiments/YOUR_DIR/checkpoints and the data in
Thish will save the pca model and fit model in experiments/YOUR_DIR/checkpoints and the data in
...
@@ -12,4 +98,4 @@ experiments/YOUR_DIR/data.
...
@@ -12,4 +98,4 @@ experiments/YOUR_DIR/data.
3. inv_inference -> Use trained model to do inference on new data point
3. inv_inference -> Use trained model to do inference on new data point
4. data_drift_check.py -> Check data drift between two datasets
4. data_drift_check.py -> Check data drift between two datasets