-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
93ebf5c
commit 2234508
Showing
2 changed files
with
502 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,239 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 47, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import hipscat\n", | ||
"import healpy as hp\n", | ||
"import pandas as pd\n", | ||
"from tqdm import tqdm\n", | ||
"from hipscat.inspection import plot_pixel_list\n", | ||
"from hipscat.pixel_math import HealpixPixel\n", | ||
"import numpy as np\n", | ||
"import matplotlib.pyplot as plt" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 37, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# plot_pixel_list([HealpixPixel(0,11), HealpixPixel(4, 78)])" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 38, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"step = 2" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 39, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"## i know this is dumb. i don't care.\n", | ||
"\n", | ||
"def min_max_sep(bounds_a, bounds_b):\n", | ||
" min_sep = float(\"inf\")\n", | ||
" max_sep = 0.0\n", | ||
"\n", | ||
" for i in range(4*step):\n", | ||
" for j in range (4*step):\n", | ||
" sep_sq = (bounds_a[0][i]-bounds_b[0][j])**2 + (bounds_a[1][i]-bounds_b[1][j])**2\n", | ||
" min_sep = min(min_sep, sep_sq)\n", | ||
" max_sep = max(max_sep, sep_sq)\n", | ||
" return (min_sep, max_sep)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 40, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"3933 partitions\n", | ||
"7732278 iterations\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"\n", | ||
"\n", | ||
"gaia_full_partition_frame = pd.read_csv(\"gaia_partition_info.csv\")\n", | ||
"gaia_full_partition_list = [\n", | ||
" HealpixPixel(order, pixel)\n", | ||
" for order, pixel in zip(\n", | ||
" gaia_full_partition_frame[\"Norder\"],\n", | ||
" gaia_full_partition_frame[\"Npix\"],\n", | ||
" )\n", | ||
" ]\n", | ||
"num_partitions = len(gaia_full_partition_list)\n", | ||
"print(num_partitions, \"partitions\")\n", | ||
"print(int(.5 * num_partitions * (num_partitions - 1)), \"iterations\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 41, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stderr", | ||
"output_type": "stream", | ||
"text": [ | ||
"100%|██████████| 3933/3933 [09:51<00:00, 6.64it/s] \n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"\n", | ||
"all_seps = []\n", | ||
"\n", | ||
"for a in tqdm(range(0, num_partitions)):\n", | ||
" for b in range(a, num_partitions):\n", | ||
"\n", | ||
" bounds_a = hp.vec2dir(hp.boundaries(2**gaia_full_partition_list[a].order, gaia_full_partition_list[a].pixel, step=step, nest=True), lonlat=True)\n", | ||
" bounds_b = hp.vec2dir(hp.boundaries(2**gaia_full_partition_list[b].order, gaia_full_partition_list[b].pixel, step=step, nest=True), lonlat=True)\n", | ||
" all_seps.append(min_max_sep(bounds_a, bounds_b))" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 42, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"7736211" | ||
] | ||
}, | ||
"execution_count": 42, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"len(all_seps)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 43, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"[(0.0, 506.24999999999966),\n", | ||
" (0.0, 1236.6206396835553),\n", | ||
" (6299.120639683556, 15411.620639683555),\n", | ||
" (4972.652051530026, 13072.652051530025),\n", | ||
" (8516.402051530025, 18641.402051530025),\n", | ||
" (11289.449049432578, 23391.34255485142),\n", | ||
" (7239.44904943258, 16351.949049432578),\n", | ||
" (10791.34255485142, 24620.924450944753),\n", | ||
" (6066.342554851419, 15516.34255485142),\n", | ||
" (9433.42445094475, 26107.389504989897)]" | ||
] | ||
}, | ||
"execution_count": 43, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"all_seps[:10]" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 46, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"min_map_arrays = np.array(all_seps).T\n", | ||
"min_map_arrays[0:10]\n", | ||
"mins = min_map_arrays[0]\n", | ||
"maxs = min_map_arrays[1]" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 48, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stderr", | ||
"output_type": "stream", | ||
"text": [ | ||
"100%|██████████| 3933/3933 [00:01<00:00, 2135.54it/s]\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"pix_a_order = []\n", | ||
"pix_a_pixel = []\n", | ||
"pix_b_order = []\n", | ||
"pix_b_pixel = []\n", | ||
"\n", | ||
"for a in tqdm(range(0, num_partitions)):\n", | ||
" for b in range(a, num_partitions):\n", | ||
" pix_a_order.append(gaia_full_partition_list[a].order)\n", | ||
" pix_a_pixel.append(gaia_full_partition_list[a].pixel)\n", | ||
" pix_b_order.append(gaia_full_partition_list[b].order)\n", | ||
" pix_b_pixel.append(gaia_full_partition_list[b].pixel)\n", | ||
"\n", | ||
"\n", | ||
"big_beautiful_frame = pd.DataFrame({\"Norder_a\": pix_a_order,\n", | ||
" \"Npix_a\": pix_a_pixel,\n", | ||
" \"Norder_b\": pix_b_order,\n", | ||
" \"Npix_b\": pix_b_pixel,\n", | ||
" \"min_sep\": mins,\n", | ||
" \"max_sep\": maxs,\n", | ||
" })\n", | ||
"big_beautiful_frame.to_csv(\"bbf.csv\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "hipscatenv", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.10.14" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
Oops, something went wrong.