Skip to content

Commit

Permalink
Autocorrelation alignment method.
Browse files Browse the repository at this point in the history
  • Loading branch information
delucchi-cmu committed Jun 14, 2024
1 parent fc85aa2 commit 03f8651
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 0 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ dynamic = ["version"]
requires-python = ">=3.9, <3.12"
dependencies = [
"lsdb",
"hipscat",
"gundam",
]

Expand Down
37 changes: 37 additions & 0 deletions src/corrgi/alignment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import itertools

import pandas as pd
from hipscat.catalog import Catalog
from hipscat.pixel_tree.pixel_alignment import PixelAlignment
from hipscat.pixel_tree.pixel_alignment_types import PixelAlignmentType

column_names = [
PixelAlignment.PRIMARY_ORDER_COLUMN_NAME,
PixelAlignment.PRIMARY_PIXEL_COLUMN_NAME,
PixelAlignment.JOIN_ORDER_COLUMN_NAME,
PixelAlignment.JOIN_PIXEL_COLUMN_NAME,
PixelAlignment.ALIGNED_ORDER_COLUMN_NAME,
PixelAlignment.ALIGNED_PIXEL_COLUMN_NAME,
]


def autocorrelation_alignment(catalog: Catalog) -> PixelAlignment:
"""TODO"""
upper_triangle = [
[left.order, left.pixel, right.order, right.pixel, left.order, left.pixel]
for (left, right) in itertools.combinations(catalog.get_healpix_pixels(), 2)
]
upper_triangle = pd.DataFrame(upper_triangle, columns=column_names)
diagonal = pd.DataFrame(
[
[pix.order, pix.pixel, pix.order, pix.pixel, pix.order, pix.pixel]
for pix in catalog.get_healpix_pixels()
]
)
result_mapping = pd.concat([upper_triangle, diagonal])
return PixelAlignment(catalog.pixel_tree, result_mapping, PixelAlignmentType.OUTER)


def crosscorrelation_alignment(catalog_left: Catalog, catalog_right: Catalog) -> PixelAlignment:
"""TODO"""
pass
28 changes: 28 additions & 0 deletions tests/corrgi/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from pathlib import Path

import pytest


@pytest.fixture
def test_data_dir():
return Path(__file__).parent.parent / "data"


@pytest.fixture
def data_catalog_dir(test_data_dir):
return test_data_dir / "DATA"


@pytest.fixture
def raw_catalog_dir(test_data_dir):
return test_data_dir / "RAW"


@pytest.fixture
def dr7_lrg_catalog_dir(test_data_dir):
return test_data_dir / "DR7-lrg"


@pytest.fixture
def dr7_lrg_rand_catalog_dir(test_data_dir):
return test_data_dir / "DR7-lrg-rand"
8 changes: 8 additions & 0 deletions tests/corrgi/test_alignment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import hipscat
from corrgi.alignment import autocorrelation_alignment


def test_autocorrelation_alignment(data_catalog_dir):
data_catalog = hipscat.read_from_hipscat(data_catalog_dir)
alignment = autocorrelation_alignment(data_catalog)
assert len(alignment.pixel_mapping) == 28
3 changes: 3 additions & 0 deletions tests/ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
lint.ignore = [
"D103", # Allow Missing docstring in public function
]

0 comments on commit 03f8651

Please sign in to comment.