88import string
99import warnings
1010from contextlib import contextmanager
11- from enum import Enum
1211
1312from scipy .optimize import leastsq , curve_fit
1413from scipy .stats import t
@@ -667,57 +666,51 @@ def _check_sample_environments(self, d, h5d):
667666 self .is_magnet = False
668667
669668
670- class SpinSet ( object ) :
669+ class SpinSet :
671670 """
672671 Describes a set of spin-channels at a given angle of incidence,
673672 and can process beams with individual reduction options.
674673
675674 Parameters
676675 ----------
677- down_down : str or refnx.reduce.PlatypusNexus
676+ down_down : str or refnx.reduce.PlatypusNexus
678677 Input filename or PlatypusNexus object for the R-- spin
679678 channel.
680- up_up : str or refnx.reduce.PlatypusNexus
679+ up_up : str or refnx.reduce.PlatypusNexus
681680 Input filename or PlatypusNexus object for the R++ spin
682681 channel.
683- down_up : str or refnx.reduce.PlatypusNexus, optional
682+ down_up : str or refnx.reduce.PlatypusNexus, optional
684683 Input filename or PlatypusNexus object for the R-+ spin
685684 channel.
686- up_down : str or refnx.reduce.PlatypusNexus, optional
685+ up_down : str or refnx.reduce.PlatypusNexus, optional
687686 Input filename or PlatypusNexus object for the R+- spin
688687 channel.
689688
690689 Attributes
691690 ----------
692- channels : dict
693- Dictionary of each measured spin channel
694- "dd" : refnx.reduce.PlatypusNexus (R--)
695- "du" : refnx.reduce.PlatypusNexus or None (R-+)
696- "ud" : refnx.reduce.PlatypusNexus or None (R+-)
697- "uu" : refnx.reduce.PlatypusNexus (R++)
698- sc_opts : dict of refnx.reduce.ReductionOptions
691+ channels : dict
692+ Dictionary of each measured spin channel:
693+
694+ - "dd" : :class:`refnx.reduce.PlatypusNexus` (R--)
695+ - "du" : :class:`refnx.reduce.PlatypusNexus` or None (R-+)
696+ - "ud" : :class:`refnx.reduce.PlatypusNexus` or None (R+-)
697+ - "uu" : :class:`refnx.reduce.PlatypusNexus` (R++)
698+
699+ sc_opts : dict of refnx.reduce.ReductionOptions
699700 Reduction options for each spin channel ("dd", "du", "ud", "uu)
700- dd : refnx.reduce.PlatypusNexus
701- R-- spin channel
702- uu : refnx.reduce.PlatypusNexus
703- R++ spin channel
704- du : refnx.reduce.PlatypusNexus or None
705- R-+ spin channel
706- ud : refnx.reduce.PlatypusNexus or None
707- R+- spin channel
708701
709702 Notes
710703 -----
711- Each of the `ReductionOptions` specified in `dd_opts,` etc, is used
704+ Each of the :class: `ReductionOptions` specified in `sc_opts` is used
712705 to specify the options used to reduce each spin channel. The following
713- reduction options must be consistent and identical across all
706+ items in the reduction options must be consistent and identical across all
714707 spin channels so as to maintain the same wavelength axis across
715708 the datasets:
716709
717- lo_wavelength : key in refnx.reduce.ReductionOptions
718- hi_wavelength : key in refnx.reduce.ReductionOptions
719- rebin_percent : key in refnx.reduce.ReductionOptions
720- wavelength_bins : key in refnx.reduce.ReductionOptions
710+ - lo_wavelength : key in refnx.reduce.ReductionOptions
711+ - hi_wavelength : key in refnx.reduce.ReductionOptions
712+ - rebin_percent : key in refnx.reduce.ReductionOptions
713+ - wavelength_bins : key in refnx.reduce.ReductionOptions
721714 """
722715
723716 def __init__ (self , down_down , up_up , down_up = None , up_down = None ):
@@ -784,30 +777,43 @@ def __init__(self, down_down, up_up, down_up=None, up_down=None):
784777
785778 @property
786779 def dd (self ):
780+ """
781+ :class:`refnx.reduce.PlatypusNexus` R-- spin channel
782+ """
787783 return self .channels ["dd" ]
788784
789785 @property
790786 def du (self ):
787+ """
788+ :class:`refnx.reduce.PlatypusNexus` R-+ spin channel
789+ """
791790 return self .channels ["du" ]
792791
793792 @property
794793 def ud (self ):
794+ """
795+ :class:`refnx.reduce.PlatypusNexus` R+- spin channel
796+ """
795797 return self .channels ["ud" ]
796798
797799 @property
798800 def uu (self ):
801+ """
802+ :class:`refnx.reduce.PlatypusNexus` R++ spin channel
803+ """
799804 return self .channels ["uu" ]
800805
801806 @property
802807 def spin_channels (self ):
803808 """
804- Gives a quick indication of what spin channels were measured and
805- are present in this SpinSet.
809+ Gives a quick indication of what spin channels are present in this
810+ ` SpinSet` .
806811
807812 Returns
808813 -------
809- list of refnx.reduce.SpinChannel Enum values or None, depending on
810- if the spin channel was measured.
814+ channels : list
815+ :class:`refnx.reflect.SpinChannel` Enum values or None, depending
816+ on if the spin channel was measured.
811817 """
812818 return [
813819 (
@@ -820,9 +826,9 @@ def spin_channels(self):
820826
821827 def process (self , ** reduction_options ):
822828 """
823- Process beams in SpinSet.
829+ Process beams in ` SpinSet` .
824830
825- If reduction_options is None, the reduction options for each spin
831+ If ` reduction_options` is None, the reduction options for each spin
826832 channel are specified by the dictionary of spin channel reduction
827833 options `SpinSet.sc_opts` which are initialised to the
828834 standard options when constructing the object.
@@ -831,9 +837,8 @@ def process(self, **reduction_options):
831837 you need to ensure that the wavelength bins between each spin channel
832838 remain identical, otherwise a ValueError will be raised.
833839
834- If `reduction_options`
835- is not None, then SpinSet.process() will use these options for all
836- spin channels.
840+ If `reduction_options` is not None, then `SpinSet.process()` will use
841+ these options for all spin channels.
837842
838843 Parameters
839844 ----------
@@ -879,9 +884,9 @@ def process(self, **reduction_options):
879884
880885 def plot_spectra (self , ** kwargs ):
881886 """
882- Plots the processed spectrums for each spin state in the SpinSet
887+ Plots the processed spectra for each spin state in the SpinSet.
883888
884- Requires matplotlib to be installed
889+ Requires matplotlib be installed.
885890 """
886891 import matplotlib .pyplot as plt
887892
@@ -1479,14 +1484,14 @@ def process(self, **reduction_options):
14791484 deviation.
14801485
14811486 - -1
1482- use `manual_beam_find`.
1487+ use `manual_beam_find`.
14831488 - None
1484- use the automatic beam finder, falling back to
1485- `manual_beam_find` if it's provided.
1489+ use the automatic beam finder, falling back to `manual_beam_find`
1490+ if it's provided.
14861491 - (float, float)
1487- specify the peak and peak standard deviation. The peak standard
1488- deviation is used to calculate the width of the foreground
1489- region, unless `lopx_hipx` is specified.
1492+ specify the peak and peak standard deviation.
1493+ The peak standard deviation is used to calculate the width of
1494+ the foreground region, unless `lopx_hipx` is specified.
14901495
14911496 peak_pos_tol : (float, float) or None
14921497 Convergence tolerance for the beam position and width to be
@@ -1556,8 +1561,7 @@ def process(self, **reduction_options):
15561561 - path - path to the data file
15571562 - datafilename - name of the datafile
15581563 - datafile_number - datafile number.
1559- - m_topandtail - the corrected 2D detector image,
1560- (n_spectra, TOF, {X, Y})
1564+ - m_topandtail - the corrected 2D detector image, (n_spectra, TOF, {X, Y})
15611565 - m_topandtail_sd - corresponding standard deviations
15621566 - n_spectra - number of spectra in processed data
15631567 - bm1_counts - beam montor counts, (n_spectra,)
@@ -1566,8 +1570,7 @@ def process(self, **reduction_options):
15661570 - m_beampos - beam_centre for each spectrum, (n_spectra, )
15671571 - m_lambda - wavelengths for each spectrum, (n_spectra, TOF)
15681572 - m_lambda_fwhm - corresponding FWHM of wavelength distribution
1569- - m_lambda_hist - wavelength bins for each spectrum,
1570- (n_spectra, TOF + 1)
1573+ - m_lambda_hist - wavelength bins for each spectrum, (n_spectra, TOF + 1)
15711574 - m_spec_tof - TOF for each wavelength bin, (n_spectra, TOF)
15721575 - mode - the experimental mode, e.g. FOC/MT/POL/POLANAL/SB/DB
15731576 - detector_z - detector height or angle, (n_spectra, )
0 commit comments