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_mask to InjectiveData #71

Merged
merged 9 commits into from
Nov 24, 2023
Merged

Add data_mask to InjectiveData #71

merged 9 commits into from
Nov 24, 2023

Conversation

phajy
Copy link
Contributor

@phajy phajy commented Nov 22, 2023

This pull request adds a new field data_mask to the InjectiveData struct. The data_mask is a BitVector that allows for masking specific data points in the codomain array. This feature is useful for filtering out certain data points during analysis or modeling. The data_mask is initialized with all true values by default.

@phajy
Copy link
Contributor Author

phajy commented Nov 22, 2023

I think adding a data_mask to InjectiveData will be helpful. However, I'm not certain of the easiest way to update make_model_domain to create a suitable "high-low" energy grid. Do we need an equivalent of the objective_transformer in, e.g., spectraldata.jl to take care of things?

This is the bit of code that needs work:

https://github.com/phajy/SpectralFitting.jl/blob/ef6bd6627cb06578a10a45072ebd07f80a4aeb13/src/datasets/injectivedata.jl#L25-L31

Maybe we need to update objective_transformer?

https://github.com/phajy/SpectralFitting.jl/blob/ef6bd6627cb06578a10a45072ebd07f80a4aeb13/src/datasets/injectivedata.jl#L49

@fjebaker
Copy link
Owner

Hi Andy! This looks like a really good start!

Maybe we need to update objective_transformer?

Yes -- as you have no doubt noticed, if we mask the obective (co)domain, then there will be a discontinuity between the domain we evaluate the model on and the domain we want to calculate the fit statistic on. The role of the objective_transformer is to transform the objective (e.g. flux) of the model onto the same domain as the data that we have (optionally to do things like response folding etc.).

So in this case, for injective model and data, we can just have a transformer that applies the mask to the model as well, and our work is done.

For the cases we were discussing in #70, we will need to handle the transformation somehow, but we can do that in a seperate pull request. Let's focus on getting your changes in first, and then iterate from there.

Copy link
Owner

@fjebaker fjebaker left a comment

Choose a reason for hiding this comment

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

objective_transformer needs modifying, and ideally some test cases added

@phajy
Copy link
Contributor Author

phajy commented Nov 23, 2023

Oops - thanks for adding the qualifiers.

phajy and others added 3 commits November 23, 2023 10:26
Co-authored-by: Fergus Baker <fergusbkr@gmail.com>
Co-authored-by: Fergus Baker <fergusbkr@gmail.com>
@phajy
Copy link
Contributor Author

phajy commented Nov 23, 2023

When making the objective variance we have:

if !isnothing(dataset.domain_variance)

I think this should be codomain_varaiance so I've updated it in the PR.

@fjebaker
Copy link
Owner

I think this should be codomain_varaiance so I've updated it in the PR.

Well noticed! Thanks!

@phajy
Copy link
Contributor Author

phajy commented Nov 24, 2023

Third time lucky with the test case? Shouldn't cut and paste into a Julia environment where all the undeclared variables are already declared! Assuming it passes this time, this PR can probably be closed.

@codecov-commenter
Copy link

Codecov Report

Attention: 11 lines in your changes are missing coverage. Please review.

Comparison is base (2ff89dd) 67.11% compared to head (56f0ba4) 66.90%.
Report is 5 commits behind head on main.

Files Patch % Lines
src/model-data-io.jl 66.66% 11 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #71      +/-   ##
==========================================
- Coverage   67.11%   66.90%   -0.21%     
==========================================
  Files          40       40              
  Lines        1952     1988      +36     
==========================================
+ Hits         1310     1330      +20     
- Misses        642      658      +16     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@fjebaker fjebaker marked this pull request as ready for review November 24, 2023 13:37
@fjebaker fjebaker merged commit f851af6 into fjebaker:main Nov 24, 2023
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