diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index adc0d6f..d0531d7 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -7,7 +7,6 @@ Check all that apply: - [ ] Source added/refactored - [ ] Added unit tests - [ ] Added integration tests -- [ ] Verified that tests requiring the /SNS and /HFIR filesystems pass without fail **References:** - Links to IBM EWM items: @@ -25,19 +24,3 @@ updated, or an explanation is provided as to why release notes are unnecessary - [ ] All the tests are passing - [ ] The documentation is up to date - [ ] code comments added when explaining intent - -### Execution of tests requiring the /SNS and /HFIR filesystems -It is strongly encouraged that the reviewer runs the following tests in their local machine -because these tests are not run by the GitLab CI. It is assumed that the reviewer has the /SNS and /HFIR filesystems -remotely mounted in their machine. - -```bash -cd /path/to/my/local/mr_reduction/repo/ -git fetch origin merge-requests//head:mr -git switch mr -conda activate -pytest -m mount_eqsans ./tests/unit/ ./tests/integration/ -``` -In the above code snippet, substitute `` for the actual merge request number. Also substitute -`` with the name of the conda environment you use for development. It is critical that -you have installed the repo in editable mode with `pip install -e .` or `conda develop .` diff --git a/docs/index.rst b/docs/index.rst index 7b08c73..9f1336e 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -10,7 +10,7 @@ User Guide .. toctree:: :titlesonly: - /user/multiple_samples + /user/multiple_peaks /user/conda_environments /user/reduce /releases diff --git a/docs/releases.rst b/docs/releases.rst index ccc819e..e1f16b4 100644 --- a/docs/releases.rst +++ b/docs/releases.rst @@ -10,7 +10,7 @@ Notes for major and minor releases. Notes for patch releases are referred. **Of interest to the User**: -- PR #9 Add the capability to autoreduce two samples from the same run +- PR #9 Add the capability to autoreduce two peaks from the same run **Of interest to the Developer:** diff --git a/docs/user/media/manual_reduction_two_samples.GIF b/docs/user/media/manual_reduction_two_peaks.GIF similarity index 100% rename from docs/user/media/manual_reduction_two_samples.GIF rename to docs/user/media/manual_reduction_two_peaks.GIF diff --git a/docs/user/media/manual_reduction_two_samples_report.GIF b/docs/user/media/manual_reduction_two_peaks_report.GIF similarity index 100% rename from docs/user/media/manual_reduction_two_samples_report.GIF rename to docs/user/media/manual_reduction_two_peaks_report.GIF diff --git a/docs/user/media/two_samples_stacked.png b/docs/user/media/two_peaks_stacked.png similarity index 100% rename from docs/user/media/two_samples_stacked.png rename to docs/user/media/two_peaks_stacked.png diff --git a/docs/user/multiple_peaks.rst b/docs/user/multiple_peaks.rst new file mode 100644 index 0000000..e27dbfd --- /dev/null +++ b/docs/user/multiple_peaks.rst @@ -0,0 +1,22 @@ +.. multiple_peaks + +Multiple Peaks in a single Run +================================ + +The Magnetism Reflectometer can stack several (usually 2, rarely 3) peaks on top of each other. +The beam is wide enough to cover all the peaks. +To measure reflectivity, the beam is very narrow in the other direction (so it’s like a thin ribbon). +Because we are sensitive to tiny angles, +the reflection from each peak will appear in different sports on the detector. +With one peak, there will be one spot on the detector. +With two, there will be two if (1) the peaks are not exactly parallel +(in which case it will still look like one spot) and +(2) the peaks are parallel enough so that both spots are on the detector +(otherwise one of the spots may be outside the detector surface. + +.. figure:: ./media/two_peaks_stacked.png + :alt: Reflectometry from two peaks stacked. + :align: center + :width: 900 + + Reflectometry from two peaks stacked. diff --git a/docs/user/multiple_samples.rst b/docs/user/multiple_samples.rst deleted file mode 100644 index 2fedc76..0000000 --- a/docs/user/multiple_samples.rst +++ /dev/null @@ -1,22 +0,0 @@ -.. multiple_samples - -Multiple Samples in a single Run -================================ - -The Magnetism Reflectometer can stack several (usually 2, rarely 3) samples on top of each other. -The beam is wide enough to cover all the samples. -To measure reflectivity, the beam is very narrow in the other direction (so it’s like a thin ribbon). -Because we are sensitive to tiny angles, -the reflection from each sample will appear in different sports on the detector. -With one sample, there will be one spot on the detector. -With two, there will be two if (1) the samples are not exactly parallel -(in which case it will still look like one spot) and -(2) the samples are parallel enough so that both spots are on the detector -(otherwise one of the spots may be outside the detector surface. - -.. figure:: ./media/two_samples_stacked.png - :alt: Reflectometry from two samples stacked. - :align: center - :width: 900 - - Reflectometry from two samples stacked. diff --git a/docs/user/reduce.rst b/docs/user/reduce.rst index e019fce..a03f838 100644 --- a/docs/user/reduce.rst +++ b/docs/user/reduce.rst @@ -49,27 +49,27 @@ Notice how the report shows the superposition of reflectivity curves for runs 41 will happen if reduced files for runs 41446 and 41447 are found either in the output directory `/tmp/test_webform` or the canonical output directory for autoreduction of runs corresponding to run 41445 which in this case is `/SNS/REF_M/IPTS-21391/shared/autoreduce/`. Runs 41445, 41446, and 41447 correspond to experiments -taken on the same sample but with a different incidence angle. +taken on the same peak but with a different incidence angle. -The webapp supports reduction of up to three samples for the scenarios when the run contains more than one sample. -In the following screenshot we selected `Sample Count=2`, causing reduction taking into account options -from `Sample #1` and `Sample #2`. +The webapp supports reduction of up to three peaks for the scenarios when the run contains more than one peak. +In the following screenshot we selected `Peak Count=2`, causing reduction taking into account options +from `Peak #1` and `Peak #2`. -.. figure:: ./media/manual_reduction_two_samples.GIF - :alt: Reduction of two samples. +.. figure:: ./media/manual_reduction_two_peaks.GIF + :alt: Reduction of two peaks. :align: center :width: 900 - Reduction of two samples. + Reduction of two peaks. -The below excerpt from the corresponding report show the reflectivity curves for the two samples (41445_1 and 41445_2). +The below excerpt from the corresponding report show the reflectivity curves for the two peaks (41445_1 and 41445_2). -.. figure:: ./media/manual_reduction_two_samples_report.GIF - :alt: Report for two samples. +.. figure:: ./media/manual_reduction_two_peaks_report.GIF + :alt: Report for two peaks. :align: center :width: 700 - Report for two samples. + Report for two peaks. Automated Reduction diff --git a/src/mr_autoreduce/reduce_REF_M.py.template b/src/mr_autoreduce/reduce_REF_M.py.template index 126913b..b80762d 100755 --- a/src/mr_autoreduce/reduce_REF_M.py.template +++ b/src/mr_autoreduce/reduce_REF_M.py.template @@ -45,7 +45,7 @@ def _as_bool(value): def reduction_user_options(): r"""Collects all values defined by the user in https://monitor.sns.gov/reduction/ref_m/""" - # Options common to all samples: + # Options common to all peaks: kwargs_common = dict( plot_2d=_as_bool(${plot_in_2D}), const_q_binning=_as_bool(${use_const_q}), @@ -55,8 +55,8 @@ def reduction_user_options(): publish = False # uploading to livedata server to be done later by `upload_html_report()` ) - # Options for Sample 1 - kwargs_sample_1 = dict( + # Options for Peak 1 + kwargs_peak_1 = dict( use_roi=True, force_peak_roi=_as_bool(${force_peak}), peak_roi=[int(${peak_min}), int(${peak_max})], @@ -67,8 +67,8 @@ def reduction_user_options(): bck_offset=int(${bck_width}) ) - # Options for Sample 2 - kwargs_sample_2 = dict( + # Options for Peak 2 + kwargs_peak_2 = dict( use_roi=True, force_peak_roi=_as_bool(${force_peak_s2}), peak_roi=[int(${peak_min_s2}), int(${peak_max_s2})], @@ -79,8 +79,8 @@ def reduction_user_options(): bck_offset=int(${bck_width_s2}) ) - # Options for Sample 3 - kwargs_sample_3 = dict( + # Options for Peak 3 + kwargs_peak_3 = dict( use_roi=True, force_peak_roi=_as_bool(${force_peak_s3}), peak_roi=[int(${peak_min_s3}), int(${peak_max_s3})], @@ -91,22 +91,22 @@ def reduction_user_options(): bck_offset=int(${bck_width_s3}), ) - # Do we have more than one sample in this run? - sample_count = int(${sample_count}) - ReductionOptions = namedtuple('ReductionOptions', 'common, sample_count, sample1, sample2, sample3') - return ReductionOptions(kwargs_common, sample_count, kwargs_sample_1, kwargs_sample_2, kwargs_sample_3) + # Do we have more than one peak in this run? + peak_count = int(${peak_count}) + ReductionOptions = namedtuple('ReductionOptions', 'common, peak_count, peak1, peak2, peak3') + return ReductionOptions(kwargs_common, peak_count, kwargs_peak_1, kwargs_peak_2, kwargs_peak_3) def reduce_events_file(event_file_path, outdir): event_file = os.path.split(event_file_path)[-1] # file name - reports = list() # autoreduction reports for each sample in the run, in HTML format + reports = list() # autoreduction reports for each peak in the run, in HTML format opts = reduction_user_options() - assert opts.sample_count <= 3, "Sample count must be <= 3" - kwargs_samples = [opts.sample1, opts.sample2, opts.sample3] - sample_numbers = [None, ] if opts.sample_count == 1 else range(1, opts.sample_count + 1) # numbers start at 1, not 0 - for i, sample_number in enumerate(sample_numbers): - d = dict(data_run=event_file, output_dir=outdir, sample_number=sample_number) - kwargs = {**d, **opts.common, **kwargs_samples[i]} # merge all partial dicts + assert opts.peak_count <= 3, "Peak count must be <= 3" + kwargs_peaks = [opts.peak1, opts.peak2, opts.peak3] + peak_numbers = [None, ] if opts.peak_count == 1 else range(1, opts.peak_count + 1) # numbers start at 1, not 0 + for i, peak_number in enumerate(peak_numbers): + d = dict(data_run=event_file, output_dir=outdir, peak_number=peak_number) + kwargs = {**d, **opts.common, **kwargs_peaks[i]} # merge all partial dicts reports.append(ReductionProcess(**kwargs).reduce()) return reports diff --git a/src/mr_autoreduce/templates/reduction_options.html b/src/mr_autoreduce/templates/reduction_options.html index 381b95d..0a84c5e 100644 --- a/src/mr_autoreduce/templates/reduction_options.html +++ b/src/mr_autoreduce/templates/reduction_options.html @@ -26,11 +26,11 @@ padding: 5px; margin-bottom: 10px; } - .samples-container { + .peaks-container { display: flex; justify-content: space-between; } - .sample { + .peak { width: 30%; padding: 10px; box-sizing: border-box; @@ -53,7 +53,7 @@

Output Directory
-

Options for all samples

+

Options for all peaks

-
-
-

Sample #1

+
+
+

Peak #1

-
-

Sample #2

+
+

Peak #2

-
-

Sample #3

+
+

Peak #3