Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
616 commits
Select commit Hold shift + click to select a range
bf05650
Better work at handling comments
rprospero Apr 4, 2025
85536c5
Refactor text parsing to better handle comments
rprospero Apr 4, 2025
7bf5ed3
More tests of xml
rprospero Apr 4, 2025
2311130
Mark weird units, but continue parsing
rprospero Apr 4, 2025
d026e18
Add last xml test
rprospero Apr 4, 2025
7c2efe7
Fix parsing of BeamSize
rprospero Apr 4, 2025
610cccc
Add micron unit alias
rprospero Apr 8, 2025
7694469
Handle singular unit names in parsing
rprospero Apr 8, 2025
46c95aa
Always print summary in same order
rprospero Apr 8, 2025
187a910
Reinstate summary output when xml loader is used as a main module
rprospero Apr 14, 2025
19e6565
Factor our finding cansas version into its own file
rprospero Apr 14, 2025
a840ac7
More docstrings
rprospero Apr 14, 2025
a1fcbe8
Fix typo in comment
rprospero Apr 14, 2025
0979a8f
Fix type hints
rprospero Apr 14, 2025
f4cf971
Provide default name for unnamed data sets
rprospero Apr 14, 2025
c7e7234
Better default names for SasData entries
rprospero Apr 14, 2025
0ef9be3
Process can have multiple terms, which may be quantites
rprospero Apr 14, 2025
753ab3f
Fix hdf process term parsing
rprospero Apr 14, 2025
9c447b4
Correctly parse process notes
rprospero Apr 14, 2025
88c234f
Add type hint to load_data filename
rprospero Apr 14, 2025
ceaad30
More concise source parsing
rprospero Apr 24, 2025
82dee5c
Whitespace fix
rprospero Apr 24, 2025
1e7d74d
Typehint on load_data
rprospero Apr 24, 2025
d277587
Fix up Source parser
rprospero Apr 24, 2025
5d0d10e
Add raw data to xml metadata
rprospero Apr 15, 2025
de38e18
Add raw handling to reader
rprospero Apr 15, 2025
649ed41
Enable raw data filter
rprospero Apr 15, 2025
fcdf63b
Start testing data filter
rprospero Apr 15, 2025
f062270
Run through code formatter
rprospero Apr 15, 2025
01d9989
Simplify metadata filtering
rprospero Apr 24, 2025
f3f128a
Raise KeyError instead of ValueError
rprospero May 7, 2025
6dcf2b2
Fix up ascii reader tests
rprospero May 8, 2025
c7d7808
Update creation of SasData in trend
rprospero May 8, 2025
7fed0d5
Properly compare named units with unnamed units
rprospero May 8, 2025
bd33387
Enforce loading test reference files in UTF-8
rprospero May 8, 2025
8838814
Skeleton framework for SESANS data
rprospero May 6, 2025
1d90727
Start parsing sesans header
rprospero May 6, 2025
0a90e30
Start parsing SESANS sample metadata
rprospero May 6, 2025
0d143f2
Include SESANS angle metadata
rprospero May 6, 2025
dc74a1c
Multiple SESANS files in reader test
rprospero May 6, 2025
40c4625
Parse actual data from SES files
rprospero May 6, 2025
a41229e
Add Raw SESANS Node Data
rprospero May 7, 2025
52cb377
Update XML test references to include apertures
rprospero May 7, 2025
a3425ea
SESANS metadata as a process, not an aperture
rprospero May 7, 2025
50ea575
Fixup lint
rprospero May 7, 2025
077e7f9
Make changes suggested in PR review
rprospero May 19, 2025
be7959f
Fix simple typos from rebase
rprospero Jun 3, 2025
61fa5f4
Add equality testing for quantities
rprospero Jun 10, 2025
6cd475f
More tests for quantities
rprospero Jun 10, 2025
96ff546
Fix meshmerge calculation
rprospero Jun 17, 2025
0f6e652
Ruff format.
jamescrake-merani Jun 23, 2025
3ac1e3c
This comment was repetitive.
jamescrake-merani Jun 23, 2025
830bec3
Ruff format.
jamescrake-merani Jun 24, 2025
58a6e0d
Function to guess the dataset type.
jamescrake-merani Jun 24, 2025
c75ff6d
Function for loading a file with default params.
jamescrake-merani Jun 24, 2025
a55de01
Ruff format.
jamescrake-merani Jun 24, 2025
2075511
Remove imports ruff is complaining aren't used.
jamescrake-merani Jun 24, 2025
73ef112
Added a test to make sure 2d data gets read right.
jamescrake-merani Jun 24, 2025
936cfcc
Makes sure the dataset type gets guessed.
jamescrake-merani Jun 24, 2025
d8a2487
Use basename for sasdata ascii name.
jamescrake-merani Jun 25, 2025
ea09c43
Be consistent with how basename is called.
jamescrake-merani Jul 4, 2025
e9380d1
Move comment to avoid odd Ruff format.
jamescrake-merani Jul 4, 2025
813318a
Move comment again.
jamescrake-merani Jul 4, 2025
08bf6ca
Fixed test.
jamescrake-merani Jul 4, 2025
cd6b7b1
Created an import metadata function.
jamescrake-merani Jul 7, 2025
53bc299
Remove the old function.
jamescrake-merani Jul 7, 2025
e2e91a1
Use the new import function.
jamescrake-merani Jul 7, 2025
4661998
Remove these imports.
jamescrake-merani Jul 7, 2025
a14e202
Need to use keywords for this dataclass.
jamescrake-merani Jul 7, 2025
923e3ce
Import the mumag data for testing.
jamescrake-merani Jul 7, 2025
fdad3d9
Added a case for mumag data.
jamescrake-merani Jul 7, 2025
1728f0e
Added test for loading ascii data with metadata.
jamescrake-merani Jul 7, 2025
4a868be
Use params filenames not just filenames.
jamescrake-merani Jul 7, 2025
3df6d79
Fixed column parameters.
jamescrake-merani Jul 7, 2025
378811d
Doh. Missing commas on filename list.
jamescrake-merani Jul 7, 2025
77f8b6a
Roll the raw metadata into the metadata object.
jamescrake-merani Jul 7, 2025
e707182
Need to fill in all the parameters.
jamescrake-merani Jul 7, 2025
9c28c3c
Forgot process :P
jamescrake-merani Jul 7, 2025
900d8ae
Consider both of these.
jamescrake-merani Jul 7, 2025
1bcbf4c
Combine both metadata so we go through all of them
jamescrake-merani Jul 7, 2025
cadf4bf
Raw metadata is in lists.
jamescrake-merani Jul 7, 2025
062a6d4
I don't know what these decimals were.
jamescrake-merani Jul 7, 2025
84a0418
Start implementing ModellingRequirements
rprospero Jun 18, 2025
3ce131a
Start testing modelling requirements
rprospero Jun 18, 2025
f1507c5
Start adding better tests for ModellingRequirements
rprospero Jun 18, 2025
1803e9e
Flip order of parameters on compose
rprospero Jun 18, 2025
243e4bb
Don't assume that Sesans includes smear
rprospero Jun 18, 2025
f9eeddd
Enable left composition by null model
rprospero Jun 18, 2025
c7d8f41
support right addition of NullModel
rprospero Jun 18, 2025
ca4c5c5
Allow preprocess and postprocess steps
rprospero Jun 18, 2025
fdcc0ff
Start performing Hankel transform for SESANS
rprospero Jun 18, 2025
6bd829b
Ignore slit smearing before SESANS
rprospero Jun 20, 2025
085b990
Pull sesans metadata from file
rprospero Jun 20, 2025
b33ff7b
Add unit test for Hankel transform
rprospero Jun 20, 2025
6950d8b
Fix units with error calculation
rprospero Jun 20, 2025
c0419e7
χ² squared based test
rprospero Jun 20, 2025
20307d0
Code Review Suggestions
rprospero Jun 20, 2025
ee005dc
Fix up rename in compose
rprospero Jun 20, 2025
8803f16
Fix uncertainty in SESANS parser
rprospero Jul 1, 2025
58697a4
Update SESANS units in unit_kinds
rprospero Jul 14, 2025
3b18035
Applies auto fixes for ruff rule F401
DrPaulSharp Jul 17, 2025
9ca96bf
Applies auto fixes for ruff rule E714
DrPaulSharp Jul 17, 2025
70bdcdd
Applies auto fixes for ruff rule F541
DrPaulSharp Jul 17, 2025
dbb75ff
Test should fail when there's no data.
Jul 18, 2025
5d11d70
Added a get default unit function.
Jul 18, 2025
4dec429
Use the new get default unit function.
Jul 18, 2025
91ede8e
Pass in the unit group as well.
Jul 18, 2025
6a86235
Return value if it isn't None.
Jul 18, 2025
1a7f3fc
Set the dataset type properly.
Jul 18, 2025
66ac703
Expect 2D test to fail.
Jul 18, 2025
87f4ba5
Use Quantity in models
rprospero Jul 14, 2025
79e9896
Don't use a quantity for model post processing
rprospero Jul 14, 2025
75f5855
Basic Pinhole model
rprospero Jul 14, 2025
9ae5aaa
Refactor pinhole tests
rprospero Jul 15, 2025
fef8d48
Fix radius bug in smearing
rprospero Jul 17, 2025
3a9a900
More realisting δq
rprospero Jul 18, 2025
3d4f54d
Combine Smearing and Sesans tests
rprospero Jul 17, 2025
cd3c31e
Define model metadata in constructor
rprospero Jul 18, 2025
a5cc938
Better testing range for pinhole
rprospero Jul 18, 2025
c38ff81
Add slit smearing
rprospero Jul 18, 2025
4793a88
Remove old commented code
rprospero Jul 18, 2025
5d28135
Vectorise slit calculation
rprospero Jul 21, 2025
eace2cb
Check combination of slit models
rprospero Jul 21, 2025
2808a44
Decrease logical depth of linear_extrapolation
rprospero Jul 31, 2025
ac722a9
Decrease logical depth of slit_resolution
rprospero Jul 31, 2025
f796598
Decrease logical depth of geometric_extrapolation
rprospero Jul 31, 2025
bfe005b
Apply PR changes
rprospero Jul 31, 2025
2997aaa
Fixes ruff linting errors (#140)
DrPaulSharp Aug 1, 2025
5173249
Adds Pyupgrade (UP) ruleset and rules SIM118 & SIM300 to ruff linter …
DrPaulSharp Aug 6, 2025
1d0e3f7
Applies fixes for isort (I) ruff ruleset (#146)
DrPaulSharp Aug 7, 2025
ffe95ac
Fixes whitespace errors
DrPaulSharp Aug 6, 2025
755cbe5
Fix hours, days, and years
rprospero Aug 1, 2025
692aa40
Add command for explicitly formatting quantity units
rprospero Aug 1, 2025
a0f33b2
Add test harness for serialisation
rprospero Jun 3, 2025
2b9d9de
Add first real json property
rprospero Aug 1, 2025
9a3aaa5
Export data type
rprospero Aug 1, 2025
daf2f8b
Add mask and model requirements
rprospero Aug 1, 2025
422d448
Start exporting metadata
rprospero Aug 1, 2025
0b9d4d9
Start adding sample details
rprospero Aug 1, 2025
af06e7e
Export process metadata
rprospero Aug 1, 2025
7124535
Export Instrument and Raw metadata
rprospero Aug 1, 2025
6442443
Support exporting Quantities
rprospero Aug 1, 2025
78fc908
Remove unneeded default calls
rprospero Aug 1, 2025
7d4821c
Start writing decoder
rprospero Aug 1, 2025
d55e227
Correctly export sample temperature
rprospero Aug 1, 2025
cc2a7e6
Fix notes nodes type
rprospero Aug 1, 2025
e2377bd
Decode metadata from json
rprospero Aug 1, 2025
aedbb0c
Use proper bytes for numpy serialisation
rprospero Aug 11, 2025
ca33778
Fix historical unit errors
rprospero Aug 1, 2025
39f4cf0
Parse MetaNode
rprospero Aug 1, 2025
27abec4
Use .json extension for JSON files
rprospero Aug 11, 2025
8c80d14
Establish settings for ruff and pycodestyle
rprospero Aug 12, 2025
b740011
Fix formatting
rprospero Aug 12, 2025
e4d2cd8
[pre-commit.ci lite] apply automatic fixes for ruff linting errors
pre-commit-ci-lite[bot] Aug 12, 2025
43bd815
Adds main check to "transforms.py"
DrPaulSharp Aug 13, 2025
41cd481
Start descending
rprospero Aug 12, 2025
1a13a53
Convert tail call recursion to loop
rprospero Aug 13, 2025
4ffadb2
Enumerate keys for access
rprospero Aug 13, 2025
9ecb06d
Descend into dicts
rprospero Aug 13, 2025
462c4f6
Fix access to dict items
rprospero Aug 13, 2025
e9a9872
Fix formatting and doctstrings
rprospero Aug 13, 2025
919b5f5
Enable tag collection
rprospero Aug 13, 2025
0df88fe
Fix PR Comments
rprospero Aug 13, 2025
c0b5693
Formatting fixes
rprospero Aug 14, 2025
80fd66b
Start encoding
rprospero Aug 15, 2025
4c7fa24
Test saving with XML files
rprospero Sep 8, 2025
c56a372
More tests for sample metadata
rprospero Sep 8, 2025
37d4693
Switch to safe asserts
rprospero Sep 8, 2025
994a9f4
Start serialising process
rprospero Sep 9, 2025
6980c36
Start serialising process
rprospero Sep 9, 2025
df8f80f
Write instrument tests
rprospero Sep 9, 2025
7929927
Start testing g5 round trip
rprospero Sep 10, 2025
dd660c1
Fix *most* of the round trip issues
rprospero Sep 10, 2025
e1b06c6
Everything passes if we ignore raw
rprospero Sep 10, 2025
f797c6c
Start trying to serialise raw data
rprospero Sep 10, 2025
da99c9d
Simplify test setup
rprospero Sep 10, 2025
ff03585
[pre-commit.ci lite] apply automatic fixes for ruff linting errors
pre-commit-ci-lite[bot] Sep 12, 2025
0e3abbe
Attach metadata to every entry
rprospero Sep 11, 2025
c9e7351
Add comments to as_h5
rprospero Sep 11, 2025
436eeac
Fix up file handling of test
rprospero Sep 11, 2025
abf8081
[pre-commit.ci lite] apply automatic fixes for ruff linting errors
pre-commit-ci-lite[bot] Sep 12, 2025
1add120
Remove debugging print
rprospero Sep 12, 2025
9adb0d3
Respond to PR suggestions
rprospero Sep 24, 2025
6e73ab3
Adds local pre-commit hook for ruff linting auto fixes
DrPaulSharp Sep 29, 2025
14e5082
Handle bytes type object in units parser
rprospero Sep 24, 2025
39c71da
Fix underline length in metadata export
rprospero Sep 24, 2025
8e399b3
Fix import of actual sasdata
rprospero Sep 24, 2025
a8c623c
Tweak json handling
rprospero Sep 24, 2025
19bae0c
Fix most of HDF file loading
rprospero Sep 24, 2025
42008db
Properly save multidimensional data
rprospero Sep 26, 2025
4c76d06
Fix parsing of exception in test
rprospero Sep 26, 2025
c11c84f
Perform serialisation test on ALL example data
rprospero Sep 26, 2025
d89f39c
Export json
rprospero Sep 26, 2025
4515003
[pre-commit.ci lite] apply automatic fixes for ruff linting errors
pre-commit-ci-lite[bot] Sep 26, 2025
05a0225
Fix json export of data objects
rprospero Sep 26, 2025
79d7a5e
Fixes to json export
rprospero Sep 26, 2025
027ba00
Respond to PR suggestions
rprospero Oct 7, 2025
364f2ae
Use file name as file id
rprospero Oct 7, 2025
a772231
157 refactor design documentation (#158)
lucas-wilkins Oct 21, 2025
1fa1264
Redesign tests (#155)
jamescrake-merani Oct 22, 2025
053a080
Mark dataload test for faster turnaround
rprospero Oct 22, 2025
9d02511
Ruff code formatting
rprospero Oct 22, 2025
408b55c
Fix up HDF Test case
rprospero Oct 22, 2025
d994334
Start moving HDF tests into James test framework
rprospero Oct 22, 2025
d1409c6
Start moving XML into James test framework
rprospero Oct 22, 2025
71b569d
Move round trip testing into main framework
rprospero Oct 22, 2025
000ba98
Move json testing into test framework
rprospero Oct 22, 2025
b0c7f6d
Eliminate old testing detritus
rprospero Oct 22, 2025
ad74dbe
Start on Sesans testing
rprospero Oct 22, 2025
0c912f1
[pre-commit.ci lite] apply automatic fixes for ruff linting errors
pre-commit-ci-lite[bot] Oct 22, 2025
a818e26
Modifies autogen code to match ruff rules
DrPaulSharp Nov 17, 2025
127640d
added rpms and ran to rebuild tables
paulneves77 Nov 17, 2025
1320e7c
ran ruff fixes
paulneves77 Nov 17, 2025
217f2db
added 3D datatype and added Qz generalizations where obvious
paulneves77 Nov 13, 2025
abd83f1
added first attempt at ND binner which can take in I(x,y,z,u,v,...) a…
paulneves77 Nov 13, 2025
5efb3c1
added rebin and sketch of inplied qz for postprocessing
paulneves77 Nov 14, 2025
91f9275
updated rebin, added rpm to units, and working on testing readers
paulneves77 Nov 15, 2025
5bbed22
the ND xubpixel binning appears to be working, and made some updates …
paulneves77 Nov 15, 2025
ba37b66
corrected errors in qz calculator, cleaned up test_hdf5_reader, impro…
paulneves77 Nov 16, 2025
ef75194
corrected errors in qz calculator, cleaned up test_hdf5_reader, impro…
paulneves77 Nov 16, 2025
26e9c72
started cleaning up for pull request
paulneves77 Nov 17, 2025
23f1ff7
fixed temp_hdf5_reader to be slightly more compliant with NXcanSAS st…
paulneves77 Nov 17, 2025
8a6f3a6
fixed apertures and run from none to empty list if missing, and fixed…
paulneves77 Nov 17, 2025
8051242
[pre-commit.ci lite] apply automatic fixes for ruff linting errors
pre-commit-ci-lite[bot] Nov 17, 2025
f6c7d6d
cleaned up code based on Jeff Kryzwon's suggestions and added test ca…
paulneves77 Nov 17, 2025
9417b0a
removed NDrebin from this branch.
paulneves77 Nov 17, 2025
74795e5
implemented minor cleanups to code
paulneves77 Nov 18, 2025
d8d4571
fixed a few bugs and cleaned up more
paulneves77 Nov 18, 2025
9f0ff27
added raw back to metadata
paulneves77 Dec 1, 2025
f12a9b9
fixed some bugs with importing sasdata/test/sasdataloader/data/simple…
paulneves77 Dec 2, 2025
688384e
fixed the collimation cansas_class attribute in the nxcansas_1Dand2D_…
paulneves77 Dec 2, 2025
feebaf2
removed local path references, removed spurious units.py
paulneves77 Dec 3, 2025
82a1607
moved duplicate code in parse_quantity to a call of parse_float, chan…
paulneves77 Dec 3, 2025
6f3b4af
fixed minor error in reference output for nxcansas_1Dand2D_multisasda…
paulneves77 Dec 3, 2025
f4b99e3
brought over NDrebin from refactor_24_3D branch
paulneves77 Nov 16, 2025
7f5421e
updated NDrebin a bunch and also added NDrebin testing
paulneves77 Nov 17, 2025
2ca0062
[pre-commit.ci lite] apply automatic fixes for ruff linting errors
pre-commit-ci-lite[bot] Nov 17, 2025
d2c85f2
added note on using NDrebin for M dimensional integration
paulneves77 Nov 17, 2025
6cc296e
first pass at rebasing NDrebin to a class
paulneves77 Nov 18, 2025
95bea50
second pass at cleaning up NDrebin class
paulneves77 Nov 18, 2025
d754cc7
NDrebin class ready for testing
paulneves77 Nov 18, 2025
2d09754
added unit testing for NDrebin
paulneves77 Nov 18, 2025
fd08cf5
removed temporary testing from NDrebin.py
paulneves77 Nov 18, 2025
318ce5d
cleaned up NDrebin, removed old function, added documentation
paulneves77 Nov 18, 2025
e29c76e
refactor NDRebin._build_limits to pass codescene review. vectorized a…
paulneves77 Dec 1, 2025
48f55bd
fixed bug in _build_limits
paulneves77 Dec 1, 2025
d44ccdb
indented code block, clarified non-vector comment, fixed typo, remove…
paulneves77 Dec 3, 2025
8ea93ee
indented code block, clarified non-vector comment, fixed typo, remove…
paulneves77 Dec 3, 2025
129e43a
Merge pull request #178 from SasView/refactor_24_NDrebin
krzywon Dec 11, 2025
2a1210d
Update date format in refactor roadmap
DrPaulSharp Dec 15, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ default_install_hook_types: [pre-commit, pre-push]

repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.14.1
rev: v0.12.9
hooks:
# Run the linter, applying any available fixes
- id: ruff-check
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ html5lib

# Other stuff
matplotlib
pre-commit
pre-commit
2 changes: 1 addition & 1 deletion sasdata/ascii_reader_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
T = TypeVar('T')

# TODO: There may be a better place for this.
pairings = {'I': 'dI', 'Q': 'dQ', 'Qx': 'dQx', 'Qy': 'dQy'}
pairings = {'I': 'dI', 'Q': 'dQ', 'Qx': 'dQx', 'Qy': 'dQy', 'Qz': 'dQz'}
pairing_error = {value: key for key, value in pairings.items()}
# Allows this to be bidirectional.
bidirectional_pairings = pairings | pairing_error
Expand Down
3 changes: 3 additions & 0 deletions sasdata/checklist.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Things to check once everything is in place:

1) Do any centigrade fields read in incorrectly?
2 changes: 1 addition & 1 deletion sasdata/data_backing.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def summary(self, indent_amount: int = 0, indent: str = " ") -> str:
s += f"{indent*(indent_amount+1)}{shorten_string(str(self.data))}\n"
for key in self.attributes:
value = self.attributes[key]
if isinstance(value, (Group | Dataset)):
if isinstance(value, (Group, Dataset)):
value_string = value.summary(indent_amount+1, indent)
else:
value_string = f"{indent * (indent_amount+1)}{key}: {shorten_string(repr(value))}\n"
Expand Down
18 changes: 9 additions & 9 deletions sasdata/data_util/nxsunit.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
__all__ = ['Converter', 'standardize_units']
T = TypeVar('T')
ConversionType = float | tuple[float, float]
DIMENSIONS = {} # type: Dict[str, Dict[str, ConversionType]]
AMBIGUITIES = {} # type: Dict[str, str]
DIMENSIONS: dict[str, dict[str, ConversionType]] = {}
AMBIGUITIES: dict[str, str] = {}
PREFIX = dict(peta=1e15, tera=1e12, giga=1e9, mega=1e6, kilo=1e3, deci=1e-1, centi=1e-2, milli=1e-3, mili=1e-3,
micro=1e-6, nano=1e-9, pico=1e-12, femto=1e-15)
SHORT_PREFIX = dict(P=1e15, T=1e12, G=1e9, M=1e6, k=1e3, d=1e-1, c=1e-2, m=1e-3, u=1e-6, n=1e-9, p=1e-12, f=1e-15)
Expand Down Expand Up @@ -258,7 +258,7 @@ def _build_all_units():
# APS files may be using 'a.u.' for 'arbitrary units'. Other
# facilities are leaving the units blank, using ??? or not even
# writing the units attributes.
unknown = {} # type: Dict[str, ConversionType]
unknown: dict[str, ConversionType] = {}
unknown.update(
{'None': 1, '???': 1, '': 1, 'A.U.': 1, 'a.u.': 1, 'arbitrary': 1, 'arbitrary units': 1,
'Counts': 1, 'counts': 1, 'Cts': 1, 'cts': 1, 'unitless': 1, 'unknown': 1, 'Unknown': 1, 'Unk': 1}
Expand Down Expand Up @@ -356,15 +356,15 @@ class Converter:
value name.
"""
#: Name of the source units (km, Ang, us, ...)
_units = None # type: List[str]
_units: list[str] = None
#: Type of the source units (distance, time, frequency, ...)
dimension = None # type: List[str]
dimension: list[str] = None
#: Scale converter, mapping unit name to scale factor or (scale, offset)
#: for temperature units.
scalemap = None # type: List[Dict[str, ConversionType]]
scalemap: list[dict[str, ConversionType]] = None
#: Scale base for the source units
scalebase = None # type: float
scaleoffset = None # type: float
scalebase: float = None
scaleoffset: float = None

@property
def units(self) -> str:
Expand All @@ -375,7 +375,7 @@ def units(self, unit: str):
self._units = standardize_units(unit)

def __init__(self, units: str | None = None, dimension: list[str] | None = None):
self.units = units if units is not None else 'a.u.' # type: str
self.units: str = units if units is not None else 'a.u.'

# Lookup dimension if not given
if dimension:
Expand Down
2 changes: 1 addition & 1 deletion sasdata/dataloader/data_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ def is_slit_smeared(self):
:return: True is slit smearing info is present, False otherwise
"""
def _check(v):
return (isinstance(v.__class__ == list | np.ndarray)
return (isinstance(v.__class__, list | np.ndarray)
and len(v) > 0 and min(v) > 0)
return _check(self.dxl) or _check(self.dxw)

Expand Down
1 change: 0 additions & 1 deletion sasdata/dataloader/readers/red2d_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ def get_file_contents(self):

wavelength = None
distance = None
transmission = None

pixel_x = None
pixel_y = None
Expand Down
11 changes: 10 additions & 1 deletion sasdata/dataset_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,21 @@ class DatasetType:
two_dim = DatasetType(
name="2D I vs Q",
required=["Qx", "Qy", "I"],
optional=["dQx", "dQy", "dI", "Qz", "ShadowFactor", "mask"],
optional=["dQx", "dQy", "dQz", "dI", "Qz", "ShadowFactor", "mask"],
expected_orders=[
["Qx", "Qy", "I"],
["Qx", "Qy", "I", "dI"],
["Qx", "Qy", "dQx", "dQy", "I", "dI"]])

three_dim = DatasetType(
name="3D I vs Q",
required=["Qx", "Qy", "Qz", "I"],
optional=["dQx", "dQy", "dQz", "dI", "ShadowFactor", "mask"],
expected_orders=[
["Qx", "Qy", "Qz", "I"],
["Qx", "Qy", "Qz", "I", "dI"],
["Qx", "Qy", "Qz", "dQx", "dQy", "dQz", "I", "dI"]])

sesans = DatasetType(
name="SESANS",
required=["SpinEchoLength", "Depolarisation", "Wavelength"],
Expand Down
11 changes: 11 additions & 0 deletions sasdata/distributions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@


class DistributionModel:


@property
def is_density(self) -> bool:
return False

def standard_deviation(self) -> Quantity:
return NotImplementedError("Variance not implemented yet")
Empty file.
43 changes: 43 additions & 0 deletions sasdata/manual_tests/interpolation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import matplotlib.pyplot as plt
import numpy as np

from sasdata.quantities import units
from sasdata.quantities.plotting import quantity_plot
from sasdata.quantities.quantity import NamedQuantity
from sasdata.transforms.rebinning import InterpolationOptions, calculate_interpolation_matrix_1d


def linear_interpolation_check():

for from_bins in [(-10, 10, 10),
(-10, 10, 1000),
(-15, 5, 10),
(15,5, 10)]:
for to_bins in [
(-15, 0, 10),
(-15, 15, 10),
(0, 20, 100)]:

plt.figure()

x = NamedQuantity("x", np.linspace(*from_bins), units=units.meters)
y = x**2

quantity_plot(x, y)

new_x = NamedQuantity("x_new", np.linspace(*to_bins), units=units.meters)

rebin_mat = calculate_interpolation_matrix_1d(x, new_x, order=InterpolationOptions.LINEAR)

new_y = y @ rebin_mat

quantity_plot(new_x, new_y)

print(new_y.history.summary())

plt.show()




linear_interpolation_check()
2 changes: 1 addition & 1 deletion sasdata/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ class Metadata:
process: list[Process]
sample: Sample | None
instrument: Instrument | None
raw: MetaNode
raw: MetaNode | None

def summary(self):
run_string = str(self.run[0] if len(self.run) == 1 else self.run)
Expand Down
57 changes: 57 additions & 0 deletions sasdata/postprocess.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
"""

Post processing for loaded files

"""

import numpy as np

from sasdata.data import SasData


def fix_mantid_units_error(data: SasData) -> SasData:
pass



def apply_fixes(data: SasData, mantid_unit_error=True):
if mantid_unit_error:
data = fix_mantid_units_error(data)

return data


def deduce_qz(data: SasData):
"""Calculates and appends Qz to SasData if Qx, Qy, and wavelength are all present"""
# if Qz is not already in the dataset, but Qx and Qy are
if 'Qz' not in data._data_contents and 'Qx' in data._data_contents and 'Qy' in data._data_contents:
# we start by making the approximation that qz=0
data._data_contents['Qz'] = 0*data._data_contents['Qx']

# now check if metadata has wavelength information
wavelength = getattr(
getattr(
getattr(
getattr(data, "metadata", None),
"instrument",
None
),
"source",
None
),
"wavelength",
None
)

if wavelength is not None:
# we can deduce the value of qz from qx and qy
# if we have the wavelength
qx = data._data_contents['Qx']
qy = data._data_contents['Qy']

# this is how you convert qx, qy, and wavelength to qz
k0 = 2*np.pi/wavelength
qz = k0-(k0**2-qx**2-qy**2)**(0.5)

data._data_contents['Qz'] = qz

Loading