Skip to content
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

Add Data and Function Background types #276

Merged
merged 30 commits into from
Nov 27, 2024

Conversation

DrPaulSharp
Copy link
Collaborator

@DrPaulSharp DrPaulSharp commented Oct 23, 2024

This enables data and function background types. In the compiled code, we construct a background array over the same range of q points that is used for the simulation, which replaces backgroundParams in the output.

Constant backgrounds are now a constant array made in constructBackground.

Data backgrounds are defined in the data block of the project and appended to the contrast data in insertDataBackgroundIntoContrastData (called in parseClassToStructs), with an optional offset added in constructBackground.

Function backgrounds are defined in the custom files block of the project and evaluated and applied in constructBackground. Note that only MATLAB background functions are supported at present.

The API for backgrounds and resolutions has changed. We have added the field "source" which contains either the background/resolution parameter, entry in the data block, or entry in the custom file block for constant, data, and function backgrounds respectively. This differentiates this field from the five "value" fields, which now ONLY contain background parameters (the optional offset for data, and up to five function parameters).
NOTE - I'm not entirely sure about the name "source" for this field, feedback on something better is welcome. I've kept it at five value fields, meaning a function background can have up to five arguments, which feels sensible to me.

@DrPaulSharp DrPaulSharp force-pushed the background-types branch 2 times, most recently from 33dd23a to 0c5efdf Compare October 24, 2024 15:35
@DrPaulSharp DrPaulSharp marked this pull request as ready for review October 24, 2024 17:33
Copy link
Collaborator Author

@DrPaulSharp DrPaulSharp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests are required for the new routine "constructBackground". At present our examples and test data consider only constant backgrounds, so our data to test the function section here is limited. How should we approach testing for this routine?

Copy link
Collaborator

@StephenNneji StephenNneji left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good please see comments. I think its fine if constructBackground has no test as its being called by the example tests but if you are up for it we could save the inputs and output that goes in to the function from the two examples and have its own independent test. What I would like in the future is some kind of validation (maybe from ORSO) for the background stuff

docs/.idea/workspace.xml Outdated Show resolved Hide resolved
targetFunctions/common/shiftData.m Outdated Show resolved Hide resolved
API/projectClass/customFileClass.m Outdated Show resolved Hide resolved
API/projectClass/backgroundsClass.m Outdated Show resolved Hide resolved
API/parseClassToStructs.m Outdated Show resolved Hide resolved
API/projectClass/backgroundsClass.m Outdated Show resolved Hide resolved
API/projectClass/backgroundsClass.m Show resolved Hide resolved
arwelHughes and others added 24 commits November 15, 2024 13:57
…kgroundTypes' - this will be the example folder for this
Copy link
Collaborator

@StephenNneji StephenNneji left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good please see comments, in addition to previous comments about the resolutionsClass

API/projectClass/customFileClass.m Outdated Show resolved Hide resolved
API/projectClass/customFileClass.m Outdated Show resolved Hide resolved
API/projectClass/resolutionsClass.m Outdated Show resolved Hide resolved
API/projectClass/backgroundsClass.m Outdated Show resolved Hide resolved
API/projectClass/backgroundsClass.m Outdated Show resolved Hide resolved
API/projectClass/backgroundsClass.m Show resolved Hide resolved
if ~isempty(source)
if strcmpi(inputBlock.type, allowedTypes.Constant.value)
source = obj.validateParam(source, obj.backgroundParams.getNames(), 'Background Param');
maxValues = 0;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maxValues is used in multiple places might be worth making a private/constant struct with these values are reusing that

API/projectClass/backgroundsClass.m Outdated Show resolved Hide resolved
Copy link
Collaborator

@StephenNneji StephenNneji left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, Thanks for persevering on this one.

API/projectClass/customFileClass.m Show resolved Hide resolved
@DrPaulSharp DrPaulSharp merged commit 35f0252 into RascalSoftware:master Nov 27, 2024
5 checks passed
@DrPaulSharp DrPaulSharp deleted the background-types branch November 27, 2024 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants