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 preparation functions for the Kr map computation #865

Open
wants to merge 53 commits into
base: master
Choose a base branch
from

Conversation

bpalmeiro
Copy link
Member

This PR links to Issue #862 and presents a proposal for the set of functions to perform the data selection and checking for the preparation for the Kr map creation. However, there are a couple of things pending up for discussion:

  • The band selection relies on the lt functions that we considered adding in the map_creation PR (since we don't think they belong in this PR workflow), but this is convoluted. It may be worth adding a previous PR with those functions.
  • The previous point makes the band selection function only a scheme of the final implementation, being the only function not tested for the present PR.
  • The workflow related to implementing this function in the city was left for the general PR —or even a posterior PR—related to the city itself. We considered that this makes this one much clearer since it relates only to adding the functions. Thoughts?

@bpalmeiro bpalmeiro linked an issue Mar 7, 2024 that may be closed by this pull request
3 tasks
@bpalmeiro bpalmeiro changed the title Data preparation Add data preparation functions for the Kr map computation Mar 8, 2024
@jahernando
Copy link
Collaborator

Some comments:

  1. check_if_values_in_interval seems a decorator of in_range, can be done in a more elegant way?
  2. apply_geo_correction is not a good name: something more as get_xy_geo_correction_function
  3. apply_geo_correction is a useful wrapper, but what is a ASectorMap object? Do we need it? Do you keep it for backward compatibility?
  4. selection_nS_mask_and_checking is not a good name, something as check_nS_efficiency_is_in_range, add comment that what are the values, I guess the range interval of the allowed efficiencies on S1 and S2.
  5. band_selector_and_check, replace name for select_and_check_S2signal_vs_dtime_band
  6. selection_in_band this is a generic function, maybe it is better in a more general scope, it is in fact an operation over a 2d profile.

Tests:

  • ok check_if_values_in_interval
  • ok apply_geo_correction
  • ok selection_nS_mask_and_checking

@bpalmeiro bpalmeiro force-pushed the data_preparation branch 4 times, most recently from d287075 to 4578a4b Compare December 27, 2024 11:30
Copy link
Collaborator

@gonzaponte gonzaponte left a comment

Choose a reason for hiding this comment

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

First round. This is being done with peras, more or less.

invisible_cities/core/core_functions.py Outdated Show resolved Hide resolved
invisible_cities/core/core_functions.py Outdated Show resolved Hide resolved
invisible_cities/core/core_functions_test.py Outdated Show resolved Hide resolved
invisible_cities/reco/icaro_components.py Outdated Show resolved Hide resolved
invisible_cities/reco/icaro_components.py Outdated Show resolved Hide resolved
invisible_cities/reco/icaro_components.py Outdated Show resolved Hide resolved
invisible_cities/reco/icaro_components_test.py Outdated Show resolved Hide resolved
invisible_cities/reco/icaro_components_test.py Outdated Show resolved Hide resolved
invisible_cities/reco/icaro_components_test.py Outdated Show resolved Hide resolved
invisible_cities/reco/icaro_components_test.py Outdated Show resolved Hide resolved
@bpalmeiro bpalmeiro force-pushed the data_preparation branch 3 times, most recently from 9520347 to a898d85 Compare December 30, 2024 11:28
Copy link
Collaborator

@gonzaponte gonzaponte left a comment

Choose a reason for hiding this comment

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

A more in-depth review now. Mostly cosmetics though.

invisible_cities/core/core_functions.py Outdated Show resolved Hide resolved
invisible_cities/core/core_functions.py Outdated Show resolved Hide resolved
invisible_cities/core/core_functions.py Outdated Show resolved Hide resolved
True if values are in the interval. False if not and strictness
is set to 'warning'. Otherwise, it raises an exception.
"""

Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove blank line.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Still there

invisible_cities/core/core_functions.py Outdated Show resolved Hide resolved
invisible_cities/reco/icaro_components_test.py Outdated Show resolved Hide resolved
invisible_cities/reco/icaro_components_test.py Outdated Show resolved Hide resolved
invisible_cities/reco/icaro_components_test.py Outdated Show resolved Hide resolved
invisible_cities/reco/icaro_components_test.py Outdated Show resolved Hide resolved
invisible_cities/reco/icaro_components_test.py Outdated Show resolved Hide resolved
@bpalmeiro bpalmeiro mentioned this pull request Jan 14, 2025
4 tasks
Copy link
Collaborator

@gonzaponte gonzaponte left a comment

Choose a reason for hiding this comment

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

Mostly cosmetics

invisible_cities/reco/icaro_components.py Outdated Show resolved Hide resolved
invisible_cities/core/core_functions.py Outdated Show resolved Hide resolved
invisible_cities/core/core_functions.py Outdated Show resolved Hide resolved
invisible_cities/core/core_functions.py Outdated Show resolved Hide resolved
invisible_cities/reco/icaro_components.py Outdated Show resolved Hide resolved
invisible_cities/reco/icaro_components.py Outdated Show resolved Hide resolved
invisible_cities/reco/icaro_components_test.py Outdated Show resolved Hide resolved
invisible_cities/reco/icaro_components_test.py Outdated Show resolved Hide resolved
invisible_cities/reco/icaro_components_test.py Outdated Show resolved Hide resolved
True if values are in the interval. False if not and strictness
is set to 'warning'. Otherwise, it raises an exception.
"""

Copy link
Collaborator

Choose a reason for hiding this comment

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

Still there


**kwargs:
Optional arguments being passed to `in_range`.
Returns
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
Returns
Returns

add blank line before Returns

norm_value : Float(optional)
If norm_strat is selected to be custom, user must provide the
desired scale.
Returns
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add blank line before Returns

Comment on lines +259 to +263
norm_strat : NormStrategy
Provides the desired normalization to be used.
norm_value : Float(optional)
If norm_strat is selected to be custom, user must provide the
desired scale.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
norm_strat : NormStrategy
Provides the desired normalization to be used.
norm_value : Float(optional)
If norm_strat is selected to be custom, user must provide the
desired scale.
norm_strat : NormStrategy, optional
Provides the desired normalization to be used. Default: NormStrategy.max.
norm_value : float, optional
If norm_strat is selected to be custom, user must provide the
desired scale.

Comment on lines +288 to +291
@given(float_arrays(size = 1, min_value = -198, max_value = 198),
float_arrays(size = 1, min_value = -198, max_value = 198),
float_arrays(size = 1, min_value = 0, max_value = 500),
float_arrays(size = 1, min_value = 0, max_value = 100*1000))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove unnecessary spaces after "size"

Comment on lines +21 to +22
input_mask : Optional[np.ndarray] = None ,
eff_interval : Optional[Tuple[float, float]] = [0,1] ,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would remove the default value for these two arguments (and thus their Optional type hint)

Comment on lines +70 to +76
norm_strat : Optional[NormStrategy] = NormStrategy.max,
input_mask : Optional[np.ndarray] = None ,
range_DT : Optional[Tuple[np.ndarray, np.ndarray]] = (10, 1300) ,
range_E : Optional[Tuple[np.ndarray, np.ndarray]] = (10.0e+3,14e+3) ,
nsigma_sel : Optional[float] = 3.5 ,
eff_interval: Optional[Tuple[float, float]] = [0,1] ,
strictness : Optional[Strictness] = Strictness.raise_error
Copy link
Collaborator

Choose a reason for hiding this comment

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

Of these, I think nsigma_sel and strictness could/should be optional, the rest I prefer that they are not. I'm not sure about norm_strat, because there might be some assumptions in the code that are optimized for that choice. I think you will have a better feeling for that one.

nsigma_sel: float (Optional)
Number of sigmas to set the band width.
Defaults to 3.5.
eff_interval (Optional)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
eff_interval (Optional)
eff_interval: (float, float), optional
Suggested change
eff_interval (Optional)
eff_interval: Tuple[float, float], optional

Please keep on of these formats everywhere to make the style of the documentation consistent. We are heavily inspired by numpy's documentation, so in case of doubt, that is the reference.

Comment on lines +142 to +146
def select_band(dt : np.ndarray ,
e : np.ndarray ,
range_dt : Tuple[float, float],
range_e : Tuple[float, float],
nsigma : Optional[float] = 3.5) ->np.ndarray:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
def select_band(dt : np.ndarray ,
e : np.ndarray ,
range_dt : Tuple[float, float],
range_e : Tuple[float, float],
nsigma : Optional[float] = 3.5) ->np.ndarray:
def select_band(dt : np.ndarray ,
e : np.ndarray ,
range_dt : Tuple[float, float],
range_e : Tuple[float, float],
nsigma : Optional[float] = 3.5) ->np.ndarray:

nsigma: float (Optional)
Number of sigmas to set the band width
Defaults to 3.5
Returns
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add blank line before Returns

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ICAROS: data preparation
4 participants