Skip to content

add integrability filter#29

Open
vschutze-alt wants to merge 2 commits intomainfrom
integrability
Open

add integrability filter#29
vschutze-alt wants to merge 2 commits intomainfrom
integrability

Conversation

@vschutze-alt
Copy link
Copy Markdown
Collaborator

No description provided.

Comment on lines +117 to +120
# filter from integrability outliers
log.info("Filtering out non-integrable replicas")
log.info(f"Integrability threshold: {integrability_threshold}")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

These run unconditionally even if filter_integrability=False

Comment on lines +122 to +139
v_grid = pdf_array[
:, FLAVOUR_TO_ID_MAPPING["V"], :
] # extract V flavour from all replicas
mask = (
np.abs(v_grid[:, :20].sum(axis=1)) <= integrability_threshold
) # Sum first 20 x-points
# Count how many replicas are being discarded
n_discarded = (~mask).sum() # Count False values
n_kept = mask.sum() # Count True values
log.info(
f"Filtering V integrability: discarded {n_discarded} replicas, kept {n_kept}"
)
pdf_array = pdf_array[mask, :, :] # keep only replicas where mask is 'true'

v3_grid = pdf_array[:, FLAVOUR_TO_ID_MAPPING["V3"], :]
mask = np.abs(v3_grid[:, :20].sum(axis=1)) <= integrability_threshold
n_discarded = (~mask).sum()
n_kept = mask.sum()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The inner loop in here could be factored in something like:

  for flavour in ["V", "V3", "V8", "T3", "T8"]:                                                                                                               
      grid = pdf_array[:, FLAVOUR_TO_ID_MAPPING[flavour], :]                                                                                                  
      mask = np.abs(grid[:, :20].sum(axis=1)) <= integrability_threshold  

Comment on lines +70 to 72
filter_integrability: bool = True,
integrability_threshold: float = 0.5,
):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This new parameters should be documented in the docstring

Comment on lines +125 to +127
mask = (
np.abs(v_grid[:, :20].sum(axis=1)) <= integrability_threshold
) # Sum first 20 x-points
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

20 is a number that we might want to not keep hardcoded? If we want to keep it hardcoded, instead, then it needs explaining (eg 1e-7 ...)

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.

2 participants