-
Notifications
You must be signed in to change notification settings - Fork 0
Geomag ctao sorting #39
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Add CTAO-specific support for telescope indexing/sorting and geomagnetic angle calculation by introducing an observatory configuration, new geomagnetic field presets, and updated sorting behavior (mirror area first, then size). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| """Unit tests for telescope sorting logic (mirror area first, then size).""" | ||
|
|
||
| import numpy as np | ||
|
|
||
|
|
||
| def test_sort_logic_equal_area_by_size(): | ||
| """Test sorting with equal mirror areas: secondary sort by size descending.""" | ||
| max_tel_id = 3 | ||
| mirror_lookup = np.array([np.nan, 100.0, np.nan, 100.0], dtype=np.float32) | ||
| sizes_row = np.array([np.nan, 3725.51, np.nan, 2640.01], dtype=np.float32) | ||
|
|
||
| # Apply the new sort logic: area priority, then size within equal area | ||
| tel_entries = [] | ||
| for tel_idx in range(max_tel_id + 1): | ||
| area = mirror_lookup[tel_idx] | ||
| size_val = sizes_row[tel_idx] | ||
| area_valid = 0 if not np.isnan(area) else 1 | ||
| size_valid = 0 if not np.isnan(size_val) else 1 | ||
| area_key = -area if area_valid == 0 else 0.0 | ||
| size_key = -size_val if size_valid == 0 else 0.0 | ||
| tel_entries.append((tel_idx, area_valid, area_key, size_valid, size_key)) | ||
|
|
||
| tel_entries.sort(key=lambda x: (x[1], x[2], x[3], x[4])) | ||
| sort_indices = np.array([t[0] for t in tel_entries]) | ||
GernotMaier marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| # Expect: tel 1 (area 100, size 3725.51), tel 3 (area 100, size 2640.01), then NaN areas | ||
| assert np.array_equal(sort_indices, np.array([1, 3, 0, 2])) | ||
|
|
||
|
|
||
| def test_sort_logic_mixed_areas_and_nan_sizes(): | ||
| """Test sorting with mixed mirror areas and some NaN sizes: area priority always.""" | ||
| max_tel_id = 4 | ||
| # Areas: tel 0=200, tel 1=100 (NaN size), tel 2=200, tel 3=100, tel 4=NaN | ||
| mirror_lookup = np.array([200.0, 100.0, 200.0, 100.0, np.nan], dtype=np.float32) | ||
| # Sizes: tel 0=1000, tel 1=NaN, tel 2=500, tel 3=2000, tel 4=3000 | ||
| sizes_row = np.array([1000.0, np.nan, 500.0, 2000.0, 3000.0], dtype=np.float32) | ||
|
|
||
| # Apply sorting | ||
| tel_entries = [] | ||
| for tel_idx in range(max_tel_id + 1): | ||
| area = mirror_lookup[tel_idx] | ||
| size_val = sizes_row[tel_idx] | ||
| area_valid = 0 if not np.isnan(area) else 1 | ||
| size_valid = 0 if not np.isnan(size_val) else 1 | ||
| area_key = -area if area_valid == 0 else 0.0 | ||
| size_key = -size_val if size_valid == 0 else 0.0 | ||
| tel_entries.append((tel_idx, area_valid, area_key, size_valid, size_key)) | ||
|
|
||
| tel_entries.sort(key=lambda x: (x[1], x[2], x[3], x[4])) | ||
| sort_indices = np.array([t[0] for t in tel_entries]) | ||
|
|
||
| # Expect: area 200 desc (tel 0 size 1000, tel 2 size 500), then area 100 desc (tel 3 size 2000, tel 1 size NaN), then NaN area (tel 4) | ||
| assert np.array_equal(sort_indices, np.array([0, 2, 3, 1, 4])) | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.