Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduction Plan Screen - Design #25

Merged
merged 16 commits into from
Apr 23, 2024
Merged
2 changes: 2 additions & 0 deletions docs/source/design/instrument.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,5 @@ The Instrument model is described in `Data Dictionary Instrument Configuration <
+String field_name
+String oncat_meta_field
}

The Instrument is created from the InstrumentConfiguration Settings.
16 changes: 10 additions & 6 deletions docs/source/design/oncat_mvp.rst
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,10 @@ following are supported and their interactions afre described in detail in the n
* Run meta data retrieval with and without OnCat connection
* Group run per specific field and display them
* Retrieve grouped run per user's trigger-button
* Plot creation based on the run meta data
* Plot creation based on the run meta data, when user is connected to OnCat

The experiments and runs are retrieved and saved on User-request based on the current instrument and experiment selection.
The experiments and runs are retrieved and saved on User-requested base on the current instrument and experiment selection.
The danger here, would be that if the user, keeps selecting instrument and experiments, the data will be stored in the backed and thus increasing the application's memory usage.

.. _oncat_mvpi:

Expand Down Expand Up @@ -184,7 +185,11 @@ The M-V-P interactions are described and grouped by major functionality:
Presenter->>View: Display experiments


#. Data fetch - Select Experiment: handle_experiment_selection(experiment)
#. Data fetch - Select Experiment: handle_experiment_selection(experiment) (partial flow). See :ref:`handle_experiment_selection <reduction_mvpi>` for the full flow

UserS can retrieve runs either from OnCat or from a directory by reading each file separately. The later
might be memory and/or cpu intensive. We will have to include some TimeoutError exception or similar to avoid having the program hanging.
In that case the runs table will be empty.

.. mermaid::

Expand All @@ -210,9 +215,7 @@ The M-V-P interactions are described and grouped by major functionality:


#. Data fetch - Select Run Range: handle_run_selection(run_range)
User can retrieve runs either from OnCat or from a directory by reading each file separately. The later
might be memory and/or cpu intensive. We will have to include some TimeoutError exception or similar to avoid havig the program hanging.
In that case the plot and runs table will be empty.
The plot is calculated and displayed only when the user is connected to OnCat, else it is left empty.

.. mermaid::

Expand All @@ -222,6 +225,7 @@ The M-V-P interactions are described and grouped by major functionality:
participant Model
Note over View,Model: Handle Run Selection
View->>Presenter: User sets run range
Note left of View: Validate run range
Presenter->>View: Get run range
Presenter->>Model: Send run range
Note right of Model: Calculate plot data
Expand Down
15 changes: 11 additions & 4 deletions docs/source/design/reduction_plan.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ The detailed Instrument model is found here :ref:`Intrument <instrument>`.
+InstrumentModel instrument
+String experiment
+String run_range
+List~Number~ wavelength
+String mask_filepath
+String background_filepath
+String grouping
Expand Down Expand Up @@ -86,8 +87,9 @@ Below is the expected schema for the Reduction Plan saved in a file:
classDiagram
class ReductionPlanFile{
+String Instrument
+List~Number~ Wavelength
+Number Experiment
+String Run_Range
+String RunRange
+String Grouping
+String UBFile
+String VanadiumFile
Expand All @@ -96,10 +98,15 @@ Below is the expected schema for the Reduction Plan saved in a file:
+String MaskFile
+String DetectorCalibration
+String TubeCalibration
+String SolidAngle
}

* If the data fields and values are correct, a new reduction plan object is created and its values are send and displayed to the user.
The datapath of the files are saved in the reduction plan file. The Instrument contains the name of the instrument. When the reduction plan file is loaded in Garnet, the instrument name is used to create the new Instrument (if it does not exist).

* If the data values are missing or invalid, a reduction plan object is not created. The parameters are sent and displayed to the user to fix them. A corresponding error message is displayed to promt the user to edit the parameters and then save the reduction plan.
Reduction pla file validation rules:

* If data keys (fields) are missing, the file is considered corrupted. No parameters are loaded andan error message is sent and displayed to the user.
* If the data fields and values are correct, a new reduction plan object is created and its values are send and displayed to the user.

* If the data values are missing or invalid, a reduction plan object is not created. The parameters are sent and displayed to the user to fix them. A corresponding error message is displayed to promt the user to edit the parameters and then save the reduction plan.

* If data keys (fields) are missing, the file is considered corrupted. No parameters are loaded andan error message is sent and displayed to the user.
61 changes: 44 additions & 17 deletions docs/source/design/reduction_plan_mvp.rst
Original file line number Diff line number Diff line change
Expand Up @@ -303,12 +303,12 @@ To distinsguish between the states: Create and Edit, we check the selected_plan
Additionally, the following functionality related to experimentdat data is accomplished through PyOnCat:
* OnCat connection
* Read the same metadata as OnCat, without connecting, by going through the files of a user-specified folder
* List of Experiments per instrument
* List of Runs per experiment
* Run meta data retrieval per run
* Group run per specific field and display them
* List of Experiments per Selected Instrument(s)
* List of Runs per Selected Experiment(s)
* Run meta data retrieval for every Run of the Selected Experiment(s)
* Group Runs per specific field and display them
* Retrieve grouped run per users trigger-button
* Plot creation based on the run meta data
* Plot creation based on the Runs' meta data

Details are described here :ref:`PyOnCatModelMVP <pyoncat_mvp>`.

Expand Down Expand Up @@ -396,16 +396,6 @@ The M-V-P interactions are described and grouped by functionality:
/<facility>/<instrument>/shared/<ipts>/garnet. The garnet folder needs to be created, if it does not exist.
If the user has not selected an instrument yet, a default option should appear.

The starting paths of the filebrowser dialogs for the following are updated too:

* for calibration section: /<facility>/<instrument>/shared/calibration
* for vanadium section: /<facility>/<instrument>/shared/Vanadium
* for background and mask: /<facility>/<instrument>/shared/background/

The starting paths can be set, when the user click the corresponding button and selects a specific file (same flow as above). No folder creation occurs in this case.

(UBMatrix does not have a starting path.)

#. Load a reduction plan from file: handle_load_reduction_plan(reduction_plan_file)
#. Valid case

Expand Down Expand Up @@ -564,16 +554,53 @@ The M-V-P interactions are described and grouped by functionality:
Note right of Model: Get wavelength data from instrument's configuration
Note right of Model: Get grouping choices from instrument's configuration
Note right of Model: Get calibration detector and tube data from instrument's configuration
Note right of Model: Get/Create starting directory paths for calibation, vanadium, background and mask from instrument's configuration
Note over View,Model: Show data
Model->>Presenter: Return experiments, goniometer, wavelength and calibration data for instrument
Presenter->>Model: Get experiments, goniometer, wavelength and calibration data for instrument
Presenter->>View: Display data for instrument
Note left of View: Show experiments
Note left of View: Show grouping
Note left of View: Update Goniometer table and Wavelength data
Note left of View: Update goniometer table and wavelength data
Note left of View: Display/Hide calibration detector and tube fields
Note left of View: Set starting directory paths for calibation, vanadium, background and mask


The starting directory paths of the filebrowser dialogs for the following are updated:

* for calibration section: /<facility>/<instrument>/shared/calibration
* for vanadium and mask section: /<facility>/<instrument>/shared/Vanadium
* for background: /<facility>/<instrument>/shared/Background/

#. Select Experiment: handle_experiment_selection(experiment). See :ref:`handle_experiment_selection <oncat_mvpi>` .
The starting paths for calibration, vanadium background and mask sections are retrieved from the Instrument Configuration Settings. No folder creation occurs in this case.


#. Select Experiment: handle_experiment_selection(experiment).

.. mermaid::

sequenceDiagram
participant View
participant Presenter
participant Model
Note over View,Model: Handle Experiment Selection
View->>Presenter: User selects experiment
Presenter->>View: Get experiment
Presenter->>Model: Send experiment
Note right of Model: Store experiment
Note right of Model: Generate and Store data source filepath
Model->>Presenter: Return data source filepath
Presenter->>View: Display data source filepath
Note left of View: Create/Set starting directory paths for UB Matrix

Note over View,Model: Update Grouped Runs (update_grouped_runs(use_cached_runs=True))
Presenter->>Model: Get grouped runs for an experiment
Note right of Model: Get runs from OnCat/filepath folder, if they do not exist
Note right of Model: Store run data and group runs by group field
Model->>Presenter: Return grouped runs for an experiment
Presenter->>View: Display grouped runs

The starting path format for UB matrix: /<facility>/<instrument>/IPTS-<experiment>/shared

#. Select Run Range: handle_run_selection(run_range) See :ref:`handle_run_selection <oncat_mvpi>` .

Expand Down
Loading