|
15 | 15 | "metadata": {}, |
16 | 16 | "outputs": [], |
17 | 17 | "source": [ |
18 | | - "# Client for Dask distributed computing\n", |
19 | 18 | "from dask.distributed import Client\n", |
20 | | - "\n", |
21 | | - "# For reading the HATS catalogs and performing the cross-match\n", |
22 | 19 | "import lsdb\n", |
23 | | - "\n", |
24 | | - "# For reading and working with skymaps for tract and patch searches\n", |
25 | | - "import lsst.skymap\n", |
26 | | - "import pickle\n", |
27 | | - "\n", |
28 | | - "# For accessing Rubin-specific lsdb methods; in this case, tract_patch_search\n", |
29 | | - "from lsdb_rubin import tract_patch_search\n", |
30 | | - "\n", |
31 | | - "lsdb.catalog.Catalog.tract_patch_search = tract_patch_search" |
| 20 | + "import skymap_convert\n", |
| 21 | + "from lsdb_rubin import tract_patch_search" |
32 | 22 | ] |
33 | 23 | }, |
34 | 24 | { |
|
60 | 50 | "# Load GAIA DR3 data.\n", |
61 | 51 | "\n", |
62 | 52 | "gaia = lsdb.read_hats(\n", |
63 | | - " \"https://data.lsdb.io/hats/gaia_dr3/gaia\", margin_cache=\"https://data.lsdb.io/hats/gaia_dr3/gaia_10arcs\"\n", |
| 53 | + " \"https://data.lsdb.io/hats/gaia_dr3/gaia\", margin_cache=\"https://data.lsdb.io/hats/gaia_dr3/gaia_10arcs\", columns=[\"ra\", \"dec\", \"source_id\"]\n", |
64 | 54 | ")\n", |
65 | 55 | "gaia" |
66 | 56 | ] |
|
74 | 64 | "source": [ |
75 | 65 | "# Load the LSST skymap.\n", |
76 | 66 | "\n", |
77 | | - "lsst_skymap_path = \"/sdf/home/o/olynn/LINCC/Skymaps/skyMap_lsst_cells_v1_skymaps.pickle\"\n", |
| 67 | + "import skymap_convert\n", |
78 | 68 | "\n", |
79 | | - "with open(lsst_skymap_path, \"rb\") as f:\n", |
80 | | - " lsst_skymap = pickle.load(f)\n", |
81 | | - " print(lsst_skymap)" |
| 69 | + "lsst_skymap = skymap_convert.ConvertedSkymapReader(preset=\"lsst_skymap\")" |
82 | 70 | ] |
83 | 71 | }, |
84 | 72 | { |
85 | 73 | "cell_type": "markdown", |
86 | | - "id": "bb4bac82", |
| 74 | + "id": "e68839f6", |
87 | 75 | "metadata": {}, |
88 | 76 | "source": [ |
89 | | - "## Use RA/Dec to get tract and patch IDs" |
| 77 | + "## Search by tract ID" |
90 | 78 | ] |
91 | 79 | }, |
92 | 80 | { |
93 | 81 | "cell_type": "code", |
94 | 82 | "execution_count": null, |
95 | | - "id": "e4595bbb", |
| 83 | + "id": "4ae3dcb6", |
96 | 84 | "metadata": {}, |
97 | 85 | "outputs": [], |
98 | 86 | "source": [ |
99 | | - "# Get tract and patch numbers for a given RA and Dec.\n", |
100 | | - "\n", |
101 | | - "ra_float = 42.0\n", |
102 | | - "dec_float = 2.0\n", |
103 | | - "\n", |
104 | | - "longitude = lsst.geom.Angle(ra_float, lsst.geom.degrees)\n", |
105 | | - "latitude = lsst.geom.Angle(dec_float, lsst.geom.degrees)\n", |
106 | | - "sphere_point = lsst.geom.SpherePoint(longitude, latitude)\n", |
107 | | - "\n", |
108 | | - "tract_patch_list = lsst_skymap.findTractPatchList([sphere_point])\n", |
109 | | - "tract_patch_list\n", |
110 | | - "\n", |
111 | | - "tract_index = tract_patch_list[0][0]._id\n", |
112 | | - "patch_index = tract_patch_list[0][1][0]._sequentialIndex\n", |
113 | | - "\n", |
114 | | - "print(f\"Tract: {tract_index}, Patch: {patch_index}\")" |
| 87 | + "tract_index = 10_000" |
115 | 88 | ] |
116 | 89 | }, |
117 | 90 | { |
118 | 91 | "cell_type": "code", |
119 | 92 | "execution_count": null, |
120 | | - "id": "e9009c07", |
| 93 | + "id": "c06826c7", |
121 | 94 | "metadata": {}, |
122 | 95 | "outputs": [], |
123 | 96 | "source": [ |
124 | | - "# Get tract and patch numbers for a given RA and Dec.\n", |
125 | | - "\n", |
126 | | - "ra_float = 300\n", |
127 | | - "dec_float = -15\n", |
128 | | - "\n", |
129 | | - "longitude = lsst.geom.Angle(ra_float, lsst.geom.degrees)\n", |
130 | | - "latitude = lsst.geom.Angle(dec_float, lsst.geom.degrees)\n", |
131 | | - "sphere_point = lsst.geom.SpherePoint(longitude, latitude)\n", |
132 | | - "\n", |
133 | | - "tract_patch_list = lsst_skymap.findTractPatchList([sphere_point])\n", |
134 | | - "tract_patch_list\n", |
135 | | - "\n", |
136 | | - "tract_index = tract_patch_list[0][0]._id\n", |
137 | | - "patch_index = tract_patch_list[0][1][0]._sequentialIndex\n", |
| 97 | + "# Only specify the tract (and not patch) to search by tract.\n", |
138 | 98 | "\n", |
139 | | - "print(f\"Tract: {tract_index}, Patch: {patch_index}\")\n", |
| 99 | + "lsdb.catalog.Catalog.tract_patch_search = tract_patch_search\n", |
140 | 100 | "\n", |
141 | | - "# TODO : Account for multiple tracts/patches (eg, ra: 42, dec: 3)" |
| 101 | + "gaia_tract = gaia.tract_patch_search(\n", |
| 102 | + " skymap_reader=lsst_skymap,\n", |
| 103 | + " tract=tract_index\n", |
| 104 | + ")\n", |
| 105 | + "gaia_tract" |
142 | 106 | ] |
143 | 107 | }, |
144 | 108 | { |
145 | | - "cell_type": "markdown", |
146 | | - "id": "e68839f6", |
| 109 | + "cell_type": "code", |
| 110 | + "execution_count": null, |
| 111 | + "id": "dc2fb6a5", |
147 | 112 | "metadata": {}, |
| 113 | + "outputs": [], |
148 | 114 | "source": [ |
149 | | - "## Search by tract and patch IDs" |
| 115 | + "gaia_tract.plot_pixels(\n", |
| 116 | + " plot_title=\"Gaia DR3 Tract Search\",\n", |
| 117 | + " fc=\"#00000000\",\n", |
| 118 | + " ec=\"red\",\n", |
| 119 | + " alpha=0.5,\n", |
| 120 | + ")" |
150 | 121 | ] |
151 | 122 | }, |
152 | 123 | { |
153 | 124 | "cell_type": "markdown", |
154 | | - "id": "97bfbbfc", |
| 125 | + "id": "734b21fc", |
155 | 126 | "metadata": {}, |
156 | 127 | "source": [ |
157 | | - "### Search by tract" |
| 128 | + "### Plot the points within our tract search" |
158 | 129 | ] |
159 | 130 | }, |
160 | 131 | { |
161 | 132 | "cell_type": "code", |
162 | 133 | "execution_count": null, |
163 | | - "id": "c06826c7", |
| 134 | + "id": "f0393287", |
164 | 135 | "metadata": {}, |
165 | 136 | "outputs": [], |
166 | 137 | "source": [ |
167 | | - "# Only specify the tract (and not patch) to search by tract.\n", |
168 | | - "\n", |
169 | | - "gaia_tract = gaia.tract_patch_search(\n", |
170 | | - " skymap=lsst_skymap,\n", |
171 | | - " tract=tract_index,\n", |
172 | | - " fine=True,\n", |
173 | | - ")\n", |
174 | | - "gaia_tract" |
| 138 | + "df = gaia_tract.compute()\n", |
| 139 | + "df" |
175 | 140 | ] |
176 | 141 | }, |
177 | 142 | { |
178 | 143 | "cell_type": "code", |
179 | 144 | "execution_count": null, |
180 | | - "id": "dc2fb6a5", |
| 145 | + "id": "97c9e7d3", |
181 | 146 | "metadata": {}, |
182 | 147 | "outputs": [], |
183 | 148 | "source": [ |
184 | | - "gaia_tract.plot_pixels(\n", |
185 | | - " plot_title=\"Gaia DR3 Tract Search\",\n", |
186 | | - " fc=\"#00000000\",\n", |
187 | | - " ec=\"red\",\n", |
188 | | - " alpha=0.5,\n", |
| 149 | + "from lsdb.core.plotting import plot_points\n", |
| 150 | + "\n", |
| 151 | + "plot_points.plot_points(\n", |
| 152 | + " df,\n", |
| 153 | + " ra_column=\"ra\",\n", |
| 154 | + " dec_column=\"dec\",\n", |
| 155 | + " title=\"Gaia DR3 Tract Search\",\n", |
189 | 156 | ")" |
190 | 157 | ] |
191 | 158 | }, |
|
194 | 161 | "id": "c5fe192e", |
195 | 162 | "metadata": {}, |
196 | 163 | "source": [ |
197 | | - "### Search by tract and patch" |
| 164 | + "## Search by patch ID" |
| 165 | + ] |
| 166 | + }, |
| 167 | + { |
| 168 | + "cell_type": "code", |
| 169 | + "execution_count": null, |
| 170 | + "id": "88c3d2fd", |
| 171 | + "metadata": {}, |
| 172 | + "outputs": [], |
| 173 | + "source": [ |
| 174 | + "tract_index = 12_345\n", |
| 175 | + "patch_index = 67" |
198 | 176 | ] |
199 | 177 | }, |
200 | 178 | { |
|
207 | 185 | "# Specify both tract and patch to search by tract and patch.\n", |
208 | 186 | "\n", |
209 | 187 | "gaia_tract_patch = gaia.tract_patch_search(\n", |
210 | | - " skymap=lsst_skymap,\n", |
| 188 | + " skymap_reader=lsst_skymap,\n", |
211 | 189 | " tract=tract_index,\n", |
212 | 190 | " patch=patch_index,\n", |
213 | | - " fine=True,\n", |
214 | 191 | ")\n", |
215 | 192 | "gaia_tract_patch" |
216 | 193 | ] |
|
230 | 207 | ")" |
231 | 208 | ] |
232 | 209 | }, |
| 210 | + { |
| 211 | + "cell_type": "markdown", |
| 212 | + "id": "6f0b05b7", |
| 213 | + "metadata": {}, |
| 214 | + "source": [ |
| 215 | + "### Plot the points within our patch search" |
| 216 | + ] |
| 217 | + }, |
233 | 218 | { |
234 | 219 | "cell_type": "code", |
235 | 220 | "execution_count": null, |
|
257 | 242 | " title=\"Gaia DR3 Tract and Patch Search\",\n", |
258 | 243 | ")" |
259 | 244 | ] |
260 | | - }, |
261 | | - { |
262 | | - "cell_type": "markdown", |
263 | | - "id": "898e778d", |
264 | | - "metadata": {}, |
265 | | - "source": [ |
266 | | - "### Set `user_inner` to True to search the \"inner\" region of the tract or patch" |
267 | | - ] |
268 | | - }, |
269 | | - { |
270 | | - "cell_type": "markdown", |
271 | | - "id": "2b72add3", |
272 | | - "metadata": {}, |
273 | | - "source": [ |
274 | | - "Read more at the [LSST Skymap Docs](https://github.com/lsst/skymap/blob/main/doc/main.dox):\n", |
275 | | - "\n", |
276 | | - "> Tracts contain an inner region described by a collection of vertices. The inner regions exactly tile the portion of sky covered by the sky map. All pixels beyond the inner region provide overlap with neighboring tracts.\n", |
277 | | - "\n", |
278 | | - "> Patches contain rectangular inner and outer regions. The inner regions exactly tile the tract, and all patches in a tract have the same inner dimensions. Each patch has a border around the inner region to provide some overlap with adjacent patches, but there is no border on patch edges that lie against tract boundaries." |
279 | | - ] |
280 | | - }, |
281 | | - { |
282 | | - "cell_type": "markdown", |
283 | | - "id": "098369c0", |
284 | | - "metadata": {}, |
285 | | - "source": [ |
286 | | - "Note that `use_inner` may be specified for either a tract or a patch search." |
287 | | - ] |
288 | | - }, |
289 | | - { |
290 | | - "cell_type": "code", |
291 | | - "execution_count": null, |
292 | | - "id": "2f2819d7", |
293 | | - "metadata": {}, |
294 | | - "outputs": [], |
295 | | - "source": [ |
296 | | - "gaia_tract_patch_outer = gaia.tract_patch_search(\n", |
297 | | - " skymap=lsst_skymap,\n", |
298 | | - " tract=tract_index,\n", |
299 | | - " patch=patch_index,\n", |
300 | | - " fine=True,\n", |
301 | | - " use_inner=True,\n", |
302 | | - ")\n", |
303 | | - "gaia_tract_patch_outer" |
304 | | - ] |
305 | | - }, |
306 | | - { |
307 | | - "cell_type": "code", |
308 | | - "execution_count": null, |
309 | | - "id": "cac0bf23", |
310 | | - "metadata": {}, |
311 | | - "outputs": [], |
312 | | - "source": [ |
313 | | - "df = gaia_tract_patch_outer.compute()\n", |
314 | | - "df" |
315 | | - ] |
316 | 245 | } |
317 | 246 | ], |
318 | 247 | "metadata": { |
319 | 248 | "kernelspec": { |
320 | | - "display_name": "Python 3 (ipykernel)", |
| 249 | + "display_name": "p311", |
321 | 250 | "language": "python", |
322 | 251 | "name": "python3" |
323 | 252 | }, |
|
331 | 260 | "name": "python", |
332 | 261 | "nbconvert_exporter": "python", |
333 | 262 | "pygments_lexer": "ipython3", |
334 | | - "version": "3.12.9" |
| 263 | + "version": "3.11.13" |
335 | 264 | } |
336 | 265 | }, |
337 | 266 | "nbformat": 4, |
|
0 commit comments