Skip to content

Commit c6fef87

Browse files
authored
Merge pull request refnx#862 from andyfaff/doc
Doc
2 parents 979c8f5 + 9ee3f73 commit c6fef87

File tree

7 files changed

+79
-73
lines changed

7 files changed

+79
-73
lines changed

doc/faq.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ intuitively expect the fitting process to make a bigger effort for the
5858
theoretical model to be close to data points with smaller uncertainty, and a
5959
lesser effort to be close to data points with larger uncertainty. The
6060
experimental uncertainties are stored in the dataset as
61-
:code:`Data1D.y_err`. The uncertainties are
62-
:ref:`loadable from the datafile<What input/output file formats are supported>`.
61+
:code:`Data1D.y_err`. The uncertainties are :ref:`loadable from the data file<io-formats>`.
6362
See also the documentation for :class:`refnx.dataset.Data1D`.
6463

6564
If you fit with :code:`CurveFitter.fit(method='least_squares')`, then you are
@@ -148,8 +147,10 @@ are currently available from PyPI and can be installed as
148147
conda-forge. You can use conda to install most of the refnx dependencies, but
149148
you will need to use `pip` to install pyqt6.
150149

151-
What input/output file formats are supported
152-
--------------------------------------------
150+
.. _io-formats:
151+
152+
What input/output file formats are supported?
153+
---------------------------------------------
153154
`refnx` can read a range of file types. The most common is 2/3/4 column
154155
ASCII data. The first two columns are Q (:math:`A^{-1}`) and R. If present the
155156
third column will be the standard deviation of the reflectivity. If present

doc/refnx.reflect.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ refnx.reflect
66
:undoc-members:
77
:show-inheritance:
88
:special-members:
9-
:exclude-members: __dict__,__weakref__, __repr__, __module__, __init__, __abstractmethods__, __copy__
9+
:exclude-members: __str__,__static_attributes__,__firstlineno__,__annotations__,__dict__,__weakref__, __repr__, __module__, __init__, __abstractmethods__, __copy__

refnx/reduce/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
catalogue,
1111
create_reflect_nexus,
1212
PlatypusNexus,
13+
ReflectNexus,
1314
number_datafile,
1415
basename_datafile,
1516
datafile_number,
1617
accumulate_HDF_files,
1718
Catalogue,
1819
SpatzNexus,
1920
ReductionOptions,
20-
SpinChannel,
2121
SpinSet,
2222
)
2323
from refnx.reduce.batchreduction import BatchReducer

refnx/reduce/platypusnexus.py

Lines changed: 51 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import string
99
import warnings
1010
from contextlib import contextmanager
11-
from enum import Enum
1211

1312
from scipy.optimize import leastsq, curve_fit
1413
from 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, )

refnx/reduce/reduce.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@ def _reduce_single_angle(self, scale=1):
643643

644644

645645
class PolarisationEfficiency:
646-
"""
646+
r"""
647647
Describes the polarisation efficiency of a neutron scattering system
648648
with the option of having a polariser, flipper-1, flipper-2, and
649649
analyser in the system.
@@ -656,14 +656,13 @@ class PolarisationEfficiency:
656656
Parameters
657657
----------
658658
wavelength_axis : numpy.array (T,)
659-
Array of wavelength bin centres to initialise the length
660-
of the (T, 4, 4) efficiency matrices.
661-
662-
config : {"full", "PF"}
663-
Indication of polariser/analyser configuration. If
664-
"full" is used, all polarising and flipping elements are
665-
taken into account. If "PF" is used, only the polariser
666-
and flipper are taken into account.
659+
Array of wavelength bin centres to initialise the length
660+
of the (T, 4, 4) efficiency matrices.
661+
config : {"full", "PF"}
662+
Indication of polariser/analyser configuration. If
663+
"full" is used, all polarising and flipping elements are
664+
taken into account. If "PF" is used, only the polariser
665+
and flipper are taken into account.
667666
"""
668667

669668
def __init__(self, wavelength_axis, config="full"):
@@ -691,7 +690,7 @@ def standard_efficiencies(self, config):
691690
"""
692691
Define PLATYPUS polarisation efficiency matrices as described in
693692
the invited article in Rev. Sci. Instr. 83, 081301 (2012)
694-
`Polarization "Down Under": The polarized time-of-flight neutron
693+
'Polarization "Down Under": The polarized time-of-flight neutron
695694
reflectometer PLATYPUS' (https://doi.org/10.1063/1.4738579).
696695
697696
In this formulation, the relationship between raw spectra
@@ -708,7 +707,7 @@ def standard_efficiencies(self, config):
708707
709708
Parameters
710709
----------
711-
config : {"full", "PF"}
710+
config : {"full", "PF"}
712711
"""
713712
# Define polariser efficiency as function of wavelength.
714713
p1a = 0.993
@@ -834,11 +833,12 @@ class PolarisedReduce:
834833
spin_set_direct : refnx.reduce.SpinSet
835834
Direct beams from PNR experiment
836835
reducers : dict
837-
Dictionary of each measured spin channel
838-
"dd" : refnx.reduce.PlatypusNexus (R--)
839-
"du" : refnx.reduce.PlatypusNexus or None (R-+)
840-
"ud" : refnx.reduce.PlatypusNexus or None (R+-)
841-
"uu" : refnx.reduce.PlatypusNexus (R++)
836+
Dictionary of each measured spin channel
837+
838+
- "dd" : :class:`refnx.reduce.PlatypusNexus` (R--)
839+
- "du" : :class:`refnx.reduce.PlatypusNexus` or None (R-+)
840+
- "ud" : :class:`refnx.reduce.PlatypusNexus` or None (R+-)
841+
- "uu" : :class:`refnx.reduce.PlatypusNexus` (R++)
842842
843843
Examples
844844
--------
@@ -1274,7 +1274,7 @@ def reduce_stitch(
12741274
scale : float, optional
12751275
Scales the data by this value.
12761276
reduction_options : None, dict, or list of dict, optional
1277-
Options passed directly to `refnx.reduce.PlatypusNexus.process`,
1277+
Options passed directly to :meth:`refnx.reduce.ReflectNexus.process`,
12781278
for processing of individual spectra. Look at that method docstring
12791279
for specification of options. If an individual dict then the same
12801280
options are used to process all datasets. A list (or sequence) of

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ def setup_package():
335335
customize_compiler(ccompiler)
336336
ccompiler.verbose = True
337337
extra_preargs = [
338-
"-O2",
338+
"-O3",
339339
]
340340

341341
if sys.platform == "win32":
@@ -348,7 +348,7 @@ def setup_package():
348348
# the CMPLX macro was only standardised in C11
349349
extra_preargs.extend(
350350
[
351-
"-std=c11",
351+
"-std=c17",
352352
]
353353
)
354354
f = ["src/refcalc.c"]

testimonials.bib

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,6 +1219,7 @@ @phdthesis{wang2024macromolecular
12191219
title={Macromolecular avenues for the creation of bio-inspired hierarchically structured surfaces},
12201220
author={Wang, Yu-Min},
12211221
year={2024},
1222+
school={Univerzita Karlova, P{\v{r}}{\'\i}rodov{\v{e}}deck{\'a} fakulta},
12221223
publisher={Univerzita Karlova, P{\v{r}}{\'\i}rodov{\v{e}}deck{\'a} fakulta}
12231224
}
12241225

@@ -1505,6 +1506,7 @@ @article{shen2025enhanced
15051506
title = {Enhanced Antibacterial Properties of Lyotropic Liquid Crystalline Nanoparticles via Curvature Modulation},
15061507
author = {Shen, Hsin-Hui and Lai, XiangFeng and Le Brun, Anton and Ding, Chen-guang and Hsu, Hsien-Yi and Wang, Yajun and Peleg, Anton},
15071508
year = {2025},
1509+
journal = {Nature portfolio preprint},
15081510
doi = {10.21203/rs.3.rs-6551164},
15091511
}
15101512

0 commit comments

Comments
 (0)