-
Notifications
You must be signed in to change notification settings - Fork 4
Refactor 24 trend #198
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
Open
gonzalezma
wants to merge
478
commits into
refactor_24
Choose a base branch
from
refactor_24_trend
base: refactor_24
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Refactor 24 trend #198
Changes from all commits
Commits
Show all changes
478 commits
Select commit
Hold shift + click to select a range
a2681d5
Add type hint to load_data filename
rprospero a35c570
More concise source parsing
rprospero afefd33
Whitespace fix
rprospero 5e95370
Typehint on load_data
rprospero 2fb0009
Fix up Source parser
rprospero 0f12742
Add raw data to xml metadata
rprospero e6940aa
Add raw handling to reader
rprospero 12208ab
Enable raw data filter
rprospero 6cd7508
Start testing data filter
rprospero 16bf1cb
Run through code formatter
rprospero 60179cf
Simplify metadata filtering
rprospero 68a252d
Raise KeyError instead of ValueError
rprospero 2ceaaca
Fix up ascii reader tests
rprospero 0ca3cbf
Update creation of SasData in trend
rprospero 5646166
Properly compare named units with unnamed units
rprospero 95a4eac
Enforce loading test reference files in UTF-8
rprospero 48d43aa
Skeleton framework for SESANS data
rprospero 0f05e1d
Start parsing sesans header
rprospero 8994584
Start parsing SESANS sample metadata
rprospero 53b3575
Include SESANS angle metadata
rprospero e97f2b7
Multiple SESANS files in reader test
rprospero b12c568
Parse actual data from SES files
rprospero ab39c74
Add Raw SESANS Node Data
rprospero c2dd80c
Update XML test references to include apertures
rprospero b549108
SESANS metadata as a process, not an aperture
rprospero 86ca70e
Fixup lint
rprospero 2dd54f8
Make changes suggested in PR review
rprospero f2a61f0
Fix simple typos from rebase
rprospero 54b1bbf
Add equality testing for quantities
rprospero d34f96e
More tests for quantities
rprospero 0a66df1
Fix meshmerge calculation
rprospero 9316ec4
Ruff format.
jamescrake-merani 6c8fbf1
This comment was repetitive.
jamescrake-merani 41a7236
Ruff format.
jamescrake-merani 1f0e1f1
Function to guess the dataset type.
jamescrake-merani e504e25
Function for loading a file with default params.
jamescrake-merani 60ea98e
Ruff format.
jamescrake-merani 1e4d118
Remove imports ruff is complaining aren't used.
jamescrake-merani 51c98a4
Added a test to make sure 2d data gets read right.
jamescrake-merani 7db953c
Makes sure the dataset type gets guessed.
jamescrake-merani 5ab1711
Use basename for sasdata ascii name.
jamescrake-merani b65a24e
Be consistent with how basename is called.
jamescrake-merani 98e8582
Move comment to avoid odd Ruff format.
jamescrake-merani 4fcfa8c
Move comment again.
jamescrake-merani af6e809
Fixed test.
jamescrake-merani 952c177
Created an import metadata function.
jamescrake-merani bcea74b
Remove the old function.
jamescrake-merani 75d631b
Use the new import function.
jamescrake-merani 8cd101a
Remove these imports.
jamescrake-merani bf9b510
Need to use keywords for this dataclass.
jamescrake-merani bafab62
Import the mumag data for testing.
jamescrake-merani ba4b3d3
Added a case for mumag data.
jamescrake-merani c761be0
Added test for loading ascii data with metadata.
jamescrake-merani f714892
Use params filenames not just filenames.
jamescrake-merani 11b51f8
Fixed column parameters.
jamescrake-merani f8aed8d
Doh. Missing commas on filename list.
jamescrake-merani d404ab6
Roll the raw metadata into the metadata object.
jamescrake-merani 11b5c69
Need to fill in all the parameters.
jamescrake-merani 11d3380
Forgot process :P
jamescrake-merani 36e024f
Consider both of these.
jamescrake-merani 3ad7b53
Combine both metadata so we go through all of them
jamescrake-merani 627b259
Raw metadata is in lists.
jamescrake-merani ecb5d67
I don't know what these decimals were.
jamescrake-merani ea45f06
Start implementing ModellingRequirements
rprospero 87794be
Start testing modelling requirements
rprospero 042208c
Start adding better tests for ModellingRequirements
rprospero 3005405
Flip order of parameters on compose
rprospero 82e967b
Don't assume that Sesans includes smear
rprospero b45d9e2
Enable left composition by null model
rprospero 02418f9
support right addition of NullModel
rprospero e86a0d5
Allow preprocess and postprocess steps
rprospero 380fe2f
Start performing Hankel transform for SESANS
rprospero b00eca5
Ignore slit smearing before SESANS
rprospero fdb0285
Pull sesans metadata from file
rprospero ec5957c
Add unit test for Hankel transform
rprospero a708231
Fix units with error calculation
rprospero e4338f5
χ² squared based test
rprospero 43abb7a
Code Review Suggestions
rprospero cc2df3a
Fix up rename in compose
rprospero a21b162
Fix uncertainty in SESANS parser
rprospero c991570
Update SESANS units in unit_kinds
rprospero b3b9bed
Applies auto fixes for ruff rule F401
DrPaulSharp ff4d127
Applies auto fixes for ruff rule E714
DrPaulSharp 970fc96
Applies auto fixes for ruff rule F541
DrPaulSharp 5d79b1f
Test should fail when there's no data.
e3c5026
Added a get default unit function.
8e6f9c6
Use the new get default unit function.
0ded3d1
Pass in the unit group as well.
b2b7a96
Return value if it isn't None.
99826cb
Set the dataset type properly.
63d2bbf
Expect 2D test to fail.
7c96b71
Use Quantity in models
rprospero 438c2e0
Don't use a quantity for model post processing
rprospero 70dcd59
Basic Pinhole model
rprospero 8237477
Refactor pinhole tests
rprospero dff0655
Fix radius bug in smearing
rprospero 0ddfe0e
More realisting δq
rprospero fc75b71
Combine Smearing and Sesans tests
rprospero df66338
Define model metadata in constructor
rprospero dab367c
Better testing range for pinhole
rprospero fc8f154
Add slit smearing
rprospero 7d70145
Remove old commented code
rprospero bb0a40a
Vectorise slit calculation
rprospero dd41247
Check combination of slit models
rprospero fd0d940
Decrease logical depth of linear_extrapolation
rprospero d72dcb7
Decrease logical depth of slit_resolution
rprospero 76dbdf5
Decrease logical depth of geometric_extrapolation
rprospero 7d165bf
Apply PR changes
rprospero c736ce2
Fixes ruff linting errors (#140)
DrPaulSharp eed22fe
Adds Pyupgrade (UP) ruleset and rules SIM118 & SIM300 to ruff linter …
DrPaulSharp 0c8eb9c
Applies fixes for isort (I) ruff ruleset (#146)
DrPaulSharp 618f004
Fixes whitespace errors
DrPaulSharp ffd0ed8
Fix hours, days, and years
rprospero 056170e
Add command for explicitly formatting quantity units
rprospero 55e3415
Add test harness for serialisation
rprospero 59b0362
Add first real json property
rprospero 19392f1
Export data type
rprospero b9fb5e9
Add mask and model requirements
rprospero 44bd2ed
Start exporting metadata
rprospero 501f7a8
Start adding sample details
rprospero 84932ff
Export process metadata
rprospero c876739
Export Instrument and Raw metadata
rprospero c3d2eac
Support exporting Quantities
rprospero 1647cca
Remove unneeded default calls
rprospero d3cae13
Start writing decoder
rprospero 6192b4d
Correctly export sample temperature
rprospero 25f8c0c
Fix notes nodes type
rprospero 5374bd9
Decode metadata from json
rprospero 93769cf
Use proper bytes for numpy serialisation
rprospero 8c7ba6b
Fix historical unit errors
rprospero cbb151c
Parse MetaNode
rprospero 368f5f2
Use .json extension for JSON files
rprospero 0f55766
Establish settings for ruff and pycodestyle
rprospero 277d44b
Fix formatting
rprospero 6f3dcca
[pre-commit.ci lite] apply automatic fixes for ruff linting errors
pre-commit-ci-lite[bot] b999324
Adds main check to "transforms.py"
DrPaulSharp 62ea352
Start descending
rprospero 0c3a389
Convert tail call recursion to loop
rprospero e10fef9
Enumerate keys for access
rprospero 2aa2f67
Descend into dicts
rprospero c349205
Fix access to dict items
rprospero 03898fa
Fix formatting and doctstrings
rprospero a31ca00
Enable tag collection
rprospero be27524
Fix PR Comments
rprospero a90f011
Formatting fixes
rprospero 3df0431
Start encoding
rprospero b92d16a
Test saving with XML files
rprospero 19142f4
More tests for sample metadata
rprospero a677e90
Switch to safe asserts
rprospero c403286
Start serialising process
rprospero 4219a9a
Start serialising process
rprospero 196a24c
Write instrument tests
rprospero 8c147ce
Start testing g5 round trip
rprospero 68f3adb
Fix *most* of the round trip issues
rprospero a3c861f
Everything passes if we ignore raw
rprospero 2872822
Start trying to serialise raw data
rprospero 93de06e
Simplify test setup
rprospero e4cca06
[pre-commit.ci lite] apply automatic fixes for ruff linting errors
pre-commit-ci-lite[bot] d8886af
Attach metadata to every entry
rprospero f92a6d7
Add comments to as_h5
rprospero 5d3cba0
Fix up file handling of test
rprospero 6808c7b
[pre-commit.ci lite] apply automatic fixes for ruff linting errors
pre-commit-ci-lite[bot] 9aaa56d
Remove debugging print
rprospero d7d6cbc
Respond to PR suggestions
rprospero 18c2e9a
Adds local pre-commit hook for ruff linting auto fixes
DrPaulSharp acb0f7d
Handle bytes type object in units parser
rprospero 246b90d
Fix underline length in metadata export
rprospero deb5a8b
Fix import of actual sasdata
rprospero 5d9548c
Tweak json handling
rprospero a3b2a64
Fix most of HDF file loading
rprospero b95e0b7
Properly save multidimensional data
rprospero 523c274
Fix parsing of exception in test
rprospero dd56062
Perform serialisation test on ALL example data
rprospero dbb7ea7
Export json
rprospero cde7581
[pre-commit.ci lite] apply automatic fixes for ruff linting errors
pre-commit-ci-lite[bot] d351970
Fix json export of data objects
rprospero 271cba9
Fixes to json export
rprospero 07fcda4
Respond to PR suggestions
rprospero c999f32
Use file name as file id
rprospero 1102de8
157 refactor design documentation (#158)
lucas-wilkins e1ee6ba
Redesign tests (#155)
jamescrake-merani 091027e
Mark dataload test for faster turnaround
rprospero 77dea8f
Ruff code formatting
rprospero 1eeb65a
Fix up HDF Test case
rprospero cb6593e
Start moving HDF tests into James test framework
rprospero 606930e
Start moving XML into James test framework
rprospero d61d194
Move round trip testing into main framework
rprospero 7130b81
Move json testing into test framework
rprospero 01b48e8
Eliminate old testing detritus
rprospero e822fe3
Start on Sesans testing
rprospero bd46c0d
[pre-commit.ci lite] apply automatic fixes for ruff linting errors
pre-commit-ci-lite[bot] 92f9a9b
Modifies autogen code to match ruff rules
DrPaulSharp e6174e5
added rpms and ran to rebuild tables
paulneves77 2351221
ran ruff fixes
paulneves77 99cc369
added 3D datatype and added Qz generalizations where obvious
paulneves77 7eb65e3
added first attempt at ND binner which can take in I(x,y,z,u,v,...) a…
paulneves77 b9c023e
added rebin and sketch of inplied qz for postprocessing
paulneves77 511abf0
updated rebin, added rpm to units, and working on testing readers
paulneves77 fd518d3
the ND xubpixel binning appears to be working, and made some updates …
paulneves77 c1db42f
corrected errors in qz calculator, cleaned up test_hdf5_reader, impro…
paulneves77 d54650f
corrected errors in qz calculator, cleaned up test_hdf5_reader, impro…
paulneves77 0385e46
started cleaning up for pull request
paulneves77 95da6bb
fixed temp_hdf5_reader to be slightly more compliant with NXcanSAS st…
paulneves77 c0cfb69
fixed apertures and run from none to empty list if missing, and fixed…
paulneves77 c906902
[pre-commit.ci lite] apply automatic fixes for ruff linting errors
pre-commit-ci-lite[bot] 58a03da
cleaned up code based on Jeff Kryzwon's suggestions and added test ca…
paulneves77 6125859
removed NDrebin from this branch.
paulneves77 fb4db3d
implemented minor cleanups to code
paulneves77 c95a60d
fixed a few bugs and cleaned up more
paulneves77 7ae3a53
added raw back to metadata
paulneves77 b866a8d
fixed some bugs with importing sasdata/test/sasdataloader/data/simple…
paulneves77 b4a0fac
fixed the collimation cansas_class attribute in the nxcansas_1Dand2D_…
paulneves77 a3da0d3
removed local path references, removed spurious units.py
paulneves77 0b196ae
moved duplicate code in parse_quantity to a call of parse_float, chan…
paulneves77 d36dcca
fixed minor error in reference output for nxcansas_1Dand2D_multisasda…
paulneves77 0eef81a
brought over NDrebin from refactor_24_3D branch
paulneves77 49e4281
updated NDrebin a bunch and also added NDrebin testing
paulneves77 7277eeb
[pre-commit.ci lite] apply automatic fixes for ruff linting errors
pre-commit-ci-lite[bot] 4b654c1
added note on using NDrebin for M dimensional integration
paulneves77 82b0be9
first pass at rebasing NDrebin to a class
paulneves77 fbc45ba
second pass at cleaning up NDrebin class
paulneves77 fe6acd3
NDrebin class ready for testing
paulneves77 42b1c76
added unit testing for NDrebin
paulneves77 9aaf1ad
removed temporary testing from NDrebin.py
paulneves77 e7a17d7
cleaned up NDrebin, removed old function, added documentation
paulneves77 4adb6db
refactor NDRebin._build_limits to pass codescene review. vectorized a…
paulneves77 b5bc80a
fixed bug in _build_limits
paulneves77 03fc3c1
indented code block, clarified non-vector comment, fixed typo, remove…
paulneves77 b973c9d
indented code block, clarified non-vector comment, fixed typo, remove…
paulneves77 b062df6
Update date format in refactor roadmap
DrPaulSharp ffdbc5d
Basic test harness for names
rprospero 16f0c05
Base 62 encode the hash for shorter names
rprospero 2f6cb0a
Name info in unique id for NamedQuantity
rprospero b74b925
Ruff formatting
rprospero bd1b97a
Properly attach run title and number to quantity information
rprospero 05bb481
Make the name a part of all quantities
rprospero 506ecae
Ensure that xml imports also include a proper name unique id
rprospero c4af257
Ensure ASCII reader generates unique_id for data quantities
rprospero f26144c
Refactor our id_header
rprospero efe74cb
[pre-commit.ci lite] apply automatic fixes for ruff linting errors
pre-commit-ci-lite[bot] 03f88eb
Minor formatting fixes
rprospero 6a79a45
Remove debugging print statements
rprospero 30678b4
Refactor operations (#184)
DrPaulSharp 2813fca
Update refactor roadmap
DrPaulSharp 15acac0
Adds trig and exp operations (#186)
DrPaulSharp d2bd866
Fix typos. One-sigma FWHM Gaussian is confusing, as the Gaussian widt…
gonzalezma 4322834
Fix get_metadatum_from_path function as _raw_metadata and .children.g…
gonzalezma 20c9131
Fix method to_string() to handle correctly Quantity objects
gonzalezma 6112d6a
Refactor Trend to allow more than one axis and manual axis creation. …
gonzalezma 967085a
[pre-commit.ci lite] apply automatic fixes for ruff linting errors
pre-commit-ci-lite[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,4 +16,4 @@ html5lib | |
|
|
||
| # Other stuff | ||
| matplotlib | ||
| pre-commit | ||
| pre-commit | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -458,14 +458,19 @@ def to_string(self, header=""): | |
| ) | ||
| else: | ||
| attributes = "" | ||
| if self.contents: | ||
| if type(self.contents) is str: | ||
| match self.contents: | ||
| case str(): | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The string, Quantity and ndarray cases are exactly the same as the default case. Maybe just remove all but the default? |
||
| children = f"\n{header} {self.contents}" | ||
| else: | ||
| case list() | tuple(): | ||
| children = "".join([n.to_string(header + " ") for n in self.contents]) | ||
| else: | ||
| children = "" | ||
|
|
||
| case Quantity(): | ||
| children = f"\n{header} {self.contents}" | ||
| case ndarray(): | ||
| children = f"\n{header} {self.contents}" | ||
| case None: | ||
| children = "" | ||
| case _: | ||
| children = f"\n{header} {self.contents}" | ||
| return f"\n{header}{self.name}:{attributes}{children}" | ||
|
|
||
| def filter(self, name: str) -> list[ndarray | Quantity | str]: | ||
|
|
@@ -538,7 +543,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) | ||
|
|
@@ -567,6 +572,14 @@ def from_json(obj): | |
| raw=MetaNode.from_json(obj["raw"]), | ||
| ) | ||
|
|
||
| @property | ||
| def id_header(self): | ||
| """Generate a header for used in the unique_id for datasets""" | ||
| title = "" | ||
| if self.title is not None: | ||
| title = self.title | ||
| return f"{title}:{",".join(self.run)}" | ||
|
|
||
| def as_h5(self, f: h5py.Group): | ||
| """Export data onto an HDF5 group""" | ||
| for idx, run in enumerate(self.run): | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
|
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.