Skip to content

Conversation

@wael-mika
Copy link
Contributor

Description

This PR implements cone distance for spatial sampling. The core logic uses angular distance (in degrees/radii) to determine the spacing between the centers of the Teacher and Student cones/crops.

Key Features:
Geodesic Support: Currently optimized to work specifically with geodesic_disk.
Multi-Level Sampling: Allows Student and Teacher crops to be sampled from different hl_level masks.
Performance Optimizations: I’ve implemented caching for the Healpix object initialization to improve efficiency.
Geometric Logic: Uses spherical trigonometry to calculate destination points given a starting (lon, lat), distance, and azimuth (bearing).

Configuration:
Usage Example: Refer to default_config for the necessary parameters and an explanation of how center_distance_degrees is used for overlap control.
Documentation: I have included long/detailed docstrings for all new functions to make the review process easier.

Issue Number

Closes #1515

Is this PR a draft? Mark it as draft.

Checklist before asking for review

  • I have performed a self-review of my code
  • My changes comply with basic sanity checks:
    • I have fixed formatting issues with ./scripts/actions.sh lint
    • I have run unit tests with ./scripts/actions.sh unit-test
    • I have documented my code and I have updated the docstrings.
    • I have added unit tests, if relevant
  • I have tried my changes with data and code:
    • I have run the integration tests with ./scripts/actions.sh integration-test
    • (bigger changes) I have run a full training and I have written in the comment the run_id(s): launch-slurm.py --time 60
    • (bigger changes and experiments) I have shared a hegdedoc in the github issue with all the configurations and runs for this experiments
  • I have informed and aligned with people impacted by my change:
    • for config changes: the MatterMost channels and/or a design doc
    • for changes of dependencies: the MatterMost software development channel
image image image

hl_mask: 3 # Can be different from teacher
rate: 0.4 # Student cone: 40% of sphere (~72° radius)
method: "geodesic_disk" # Must be geodesic_disk
center_distance_degrees: 180 # REQUIRED: Student center is 45° from teacher
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment is a little unclear, the center_distance_degrees is required, but the center_distance_degrees can be any chosen angle right?

Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps you could also include a range as below

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed, the comment is confusing as I had to set center_distance_degrees to 45 before submitting the PR ( I was trying different values to see if they work)
Any angle you choose should work as demonstrated in the example below.

# number of healpix cells
self.healpix_level_data = cf.healpix_level
self.healpix_num_cells = 12 * (4**cf.healpix_level)
self._hp_cache = {}
Copy link
Contributor

Choose a reason for hiding this comment

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

Good, I think this is helpful

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True, it helped speeding up the computation (we do not have to repeat hp calculation every single time)

instance default if None.
masking_strategy_config : dict | None
Optional override of strategy config (e.g., {'hl_mask': 3}).
target_metadata : dict | None
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps state here that this is required when we do overlap with the cones? Otherwise it is unused right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree, this is only used when doing cone overlap. I am not sure if there is a more elegant way to do it without adding target_metadata

"relationship 'cone_distance' requires 'center_cell' in target_metadata"
)
# Get teacher's hl_mask level to properly convert coordinates
teacher_hl_mask = target_metadata.get("hl_mask", masking_strategy_config.get("hl_mask", 0))
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this default to 0? Perhaps should check that hl_mask is specified with an assert like the above lines? Do we default to 0 in other parts of the code?

@wael-mika wael-mika force-pushed the wm/dev/cropping_overlap branch from 4fb73fd to 613f606 Compare January 19, 2026 12:49
@wael-mika wael-mika force-pushed the wm/dev/cropping_overlap branch from 0882da9 to 796b919 Compare January 21, 2026 13:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Explore student-teacher view overlap with positions and cones

2 participants