|
2 | 2 | "cells": [ |
3 | 3 | { |
4 | 4 | "cell_type": "markdown", |
| 5 | + "id": "ec28e7e2", |
5 | 6 | "metadata": {}, |
6 | 7 | "source": [ |
7 | | - "# Extracting and Plotting Position-Velocity Diagrams\n", |
| 8 | + "fig.savefig(\"saved_pvdiagram.png\", bbox_inches='tight')fig.savefig(\"saved_pvdiagram.png\", bbox_inches='tight')fig.savefig(\"saved_pvdiagram.png\", bbox_inches='tight')fig.savefig(\"saved_pvdiagram.png\", bbox_inches='tight')fig.savefig(\"saved_pvdiagram.png\", bbox_inches='tight')fig.savefig(\"saved_pvdiagram.png\", bbox_inches='tight')fig.savefig(\"saved_pvdiagram.png\", bbox_inches='tight')fig.savefig(\"saved_pvdiagram.png\", bbox_inches='tight')# Extracting and Plotting Position-Velocity Diagrams\n", |
8 | 9 | "\n", |
9 | 10 | "## Authors\n", |
10 | 11 | "Adam Ginsburg, Eric Koch\n", |
|
25 | 26 | }, |
26 | 27 | { |
27 | 28 | "cell_type": "markdown", |
| 29 | + "id": "5b7f1268", |
28 | 30 | "metadata": {}, |
29 | 31 | "source": [ |
30 | 32 | "### Header material\n", |
|
35 | 37 | { |
36 | 38 | "cell_type": "code", |
37 | 39 | "execution_count": null, |
| 40 | + "id": "9f9d06e1", |
38 | 41 | "metadata": {}, |
39 | 42 | "outputs": [], |
40 | 43 | "source": [ |
|
54 | 57 | }, |
55 | 58 | { |
56 | 59 | "cell_type": "markdown", |
| 60 | + "id": "d44ca9f9", |
57 | 61 | "metadata": {}, |
58 | 62 | "source": [ |
59 | 63 | "Retrieve and open a cube from astropy-data:" |
|
62 | 66 | { |
63 | 67 | "cell_type": "code", |
64 | 68 | "execution_count": null, |
| 69 | + "id": "f51a1376", |
65 | 70 | "metadata": {}, |
66 | 71 | "outputs": [], |
67 | 72 | "source": [ |
|
71 | 76 | }, |
72 | 77 | { |
73 | 78 | "cell_type": "markdown", |
| 79 | + "id": "b205d98a", |
74 | 80 | "metadata": {}, |
75 | 81 | "source": [ |
76 | 82 | "We show a single channel from the cube to visualize the data spatially.\n", |
|
80 | 86 | { |
81 | 87 | "cell_type": "code", |
82 | 88 | "execution_count": null, |
| 89 | + "id": "7b2db3eb", |
83 | 90 | "metadata": {}, |
84 | 91 | "outputs": [], |
85 | 92 | "source": [ |
|
88 | 95 | }, |
89 | 96 | { |
90 | 97 | "cell_type": "markdown", |
| 98 | + "id": "9e946c8c", |
91 | 99 | "metadata": {}, |
92 | 100 | "source": [ |
93 | 101 | "# PV Extraction from Pixel Coordinates\n", |
|
100 | 108 | { |
101 | 109 | "cell_type": "code", |
102 | 110 | "execution_count": null, |
| 111 | + "id": "7cc19bc3", |
103 | 112 | "metadata": {}, |
104 | 113 | "outputs": [], |
105 | 114 | "source": [ |
|
108 | 117 | }, |
109 | 118 | { |
110 | 119 | "cell_type": "markdown", |
| 120 | + "id": "5e83296d", |
111 | 121 | "metadata": {}, |
112 | 122 | "source": [ |
113 | 123 | "Then we can overplot it on our figure, now with WCS shown. The plotting uses [WCSAxes](https://docs.astropy.org/en/stable/visualization/wcsaxes/index.html)" |
|
116 | 126 | { |
117 | 127 | "cell_type": "code", |
118 | 128 | "execution_count": null, |
| 129 | + "id": "1b5e2815", |
119 | 130 | "metadata": {}, |
120 | 131 | "outputs": [], |
121 | 132 | "source": [ |
|
126 | 137 | }, |
127 | 138 | { |
128 | 139 | "cell_type": "markdown", |
| 140 | + "id": "b0d00e33", |
129 | 141 | "metadata": {}, |
130 | 142 | "source": [ |
131 | 143 | "`spacing` gives the separation between these points in pixels; we finely sampled by picking one-pixel spacing." |
132 | 144 | ] |
133 | 145 | }, |
134 | 146 | { |
135 | 147 | "cell_type": "markdown", |
| 148 | + "id": "cea5c40f", |
136 | 149 | "metadata": {}, |
137 | 150 | "source": [ |
138 | 151 | "We can then extract the pv diagram, specifying the same spacing." |
|
141 | 154 | { |
142 | 155 | "cell_type": "code", |
143 | 156 | "execution_count": null, |
| 157 | + "id": "99297938", |
144 | 158 | "metadata": {}, |
145 | 159 | "outputs": [], |
146 | 160 | "source": [ |
|
150 | 164 | }, |
151 | 165 | { |
152 | 166 | "cell_type": "markdown", |
| 167 | + "id": "65b62bb8", |
153 | 168 | "metadata": {}, |
154 | 169 | "source": [ |
155 | 170 | "and plot it. `pvdiagram` is a `PrimaryHDU` object, so we need to grab the data separately from the header and convert the header to a WCS object:" |
|
158 | 173 | { |
159 | 174 | "cell_type": "code", |
160 | 175 | "execution_count": null, |
| 176 | + "id": "9c602ebf", |
161 | 177 | "metadata": {}, |
162 | 178 | "outputs": [], |
163 | 179 | "source": [ |
|
172 | 188 | }, |
173 | 189 | { |
174 | 190 | "cell_type": "markdown", |
| 191 | + "id": "e4179ebc", |
175 | 192 | "metadata": {}, |
176 | 193 | "source": [ |
177 | 194 | "Changing units to the more commonly used km/s and more readable arcminutes can be done with [wcsaxes tools](https://docs.astropy.org/en/stable/visualization/wcsaxes/controlling_axes.html):" |
|
180 | 197 | { |
181 | 198 | "cell_type": "code", |
182 | 199 | "execution_count": null, |
| 200 | + "id": "9bebb46f", |
183 | 201 | "metadata": {}, |
184 | 202 | "outputs": [], |
185 | 203 | "source": [ |
|
201 | 219 | }, |
202 | 220 | { |
203 | 221 | "cell_type": "markdown", |
| 222 | + "id": "ec773f53", |
204 | 223 | "metadata": {}, |
205 | 224 | "source": [ |
206 | 225 | "We can put all this together:" |
|
209 | 228 | { |
210 | 229 | "cell_type": "code", |
211 | 230 | "execution_count": null, |
| 231 | + "id": "ea8c2fd2", |
212 | 232 | "metadata": {}, |
213 | 233 | "outputs": [], |
214 | 234 | "source": [ |
|
221 | 241 | { |
222 | 242 | "cell_type": "code", |
223 | 243 | "execution_count": null, |
| 244 | + "id": "4a3ba59a", |
224 | 245 | "metadata": {}, |
225 | 246 | "outputs": [], |
226 | 247 | "source": [ |
|
245 | 266 | }, |
246 | 267 | { |
247 | 268 | "cell_type": "markdown", |
| 269 | + "id": "f04373b1", |
248 | 270 | "metadata": {}, |
249 | 271 | "source": [ |
250 | 272 | "# PV Extraction from Sky Coordinates" |
251 | 273 | ] |
252 | 274 | }, |
253 | 275 | { |
254 | 276 | "cell_type": "markdown", |
| 277 | + "id": "f7643042", |
255 | 278 | "metadata": {}, |
256 | 279 | "source": [ |
257 | 280 | "We can also make paths using celestial coordinates by passing coordinates defined in an`~astropy.coordinates.SkyCoord` object to `~pvextractor.Path`." |
|
260 | 283 | { |
261 | 284 | "cell_type": "code", |
262 | 285 | "execution_count": null, |
| 286 | + "id": "4f0f1d40", |
263 | 287 | "metadata": {}, |
264 | 288 | "outputs": [], |
265 | 289 | "source": [ |
|
269 | 293 | { |
270 | 294 | "cell_type": "code", |
271 | 295 | "execution_count": null, |
| 296 | + "id": "b3299ae2", |
272 | 297 | "metadata": {}, |
273 | 298 | "outputs": [], |
274 | 299 | "source": [ |
|
277 | 302 | }, |
278 | 303 | { |
279 | 304 | "cell_type": "markdown", |
| 305 | + "id": "27c2224d", |
280 | 306 | "metadata": {}, |
281 | 307 | "source": [ |
282 | 308 | "We can plot again; the coordinates will be automatically determined" |
|
285 | 311 | { |
286 | 312 | "cell_type": "code", |
287 | 313 | "execution_count": null, |
| 314 | + "id": "2d3f42c3", |
288 | 315 | "metadata": {}, |
289 | 316 | "outputs": [], |
290 | 317 | "source": [ |
|
296 | 323 | { |
297 | 324 | "cell_type": "code", |
298 | 325 | "execution_count": null, |
| 326 | + "id": "65c46371", |
299 | 327 | "metadata": {}, |
300 | 328 | "outputs": [], |
301 | 329 | "source": [ |
|
306 | 334 | { |
307 | 335 | "cell_type": "code", |
308 | 336 | "execution_count": null, |
| 337 | + "id": "cbfa2a87", |
309 | 338 | "metadata": {}, |
310 | 339 | "outputs": [], |
311 | 340 | "source": [ |
|
330 | 359 | }, |
331 | 360 | { |
332 | 361 | "cell_type": "markdown", |
| 362 | + "id": "2bca4a13", |
333 | 363 | "metadata": {}, |
334 | 364 | "source": [ |
335 | 365 | "We can also change the aspect ratio of the PV diagram:" |
|
338 | 368 | { |
339 | 369 | "cell_type": "code", |
340 | 370 | "execution_count": null, |
| 371 | + "id": "fcf34393", |
341 | 372 | "metadata": {}, |
342 | 373 | "outputs": [], |
343 | 374 | "source": [ |
|
363 | 394 | }, |
364 | 395 | { |
365 | 396 | "cell_type": "markdown", |
| 397 | + "id": "e8deae20", |
366 | 398 | "metadata": {}, |
367 | 399 | "source": [ |
368 | 400 | "## PV Extraction with Spatial Averaging" |
369 | 401 | ] |
370 | 402 | }, |
371 | 403 | { |
372 | 404 | "cell_type": "markdown", |
| 405 | + "id": "0824ae9d", |
373 | 406 | "metadata": {}, |
374 | 407 | "source": [ |
375 | 408 | "`~pvextractor.Path` allows you to specify a `width` to average over, which specifies a spatial range around the path to average over:" |
|
378 | 411 | { |
379 | 412 | "cell_type": "code", |
380 | 413 | "execution_count": null, |
| 414 | + "id": "91f5420f", |
381 | 415 | "metadata": {}, |
382 | 416 | "outputs": [], |
383 | 417 | "source": [ |
|
387 | 421 | { |
388 | 422 | "cell_type": "code", |
389 | 423 | "execution_count": null, |
| 424 | + "id": "bb057443", |
390 | 425 | "metadata": {}, |
391 | 426 | "outputs": [], |
392 | 427 | "source": [ |
|
395 | 430 | }, |
396 | 431 | { |
397 | 432 | "cell_type": "markdown", |
| 433 | + "id": "1cf3ccc5", |
398 | 434 | "metadata": {}, |
399 | 435 | "source": [ |
400 | 436 | "We can plot this path as a set of patches to show where we averaged. The default spacing is 1 pixel,so we plot 1-pixel chunks." |
|
403 | 439 | { |
404 | 440 | "cell_type": "code", |
405 | 441 | "execution_count": null, |
| 442 | + "id": "9a866a1f", |
406 | 443 | "metadata": {}, |
407 | 444 | "outputs": [], |
408 | 445 | "source": [ |
|
434 | 471 | }, |
435 | 472 | { |
436 | 473 | "cell_type": "markdown", |
| 474 | + "id": "d70082ef", |
437 | 475 | "metadata": {}, |
438 | 476 | "source": [ |
439 | 477 | "We can also have more widely spaced chunks.\n", |
|
444 | 482 | { |
445 | 483 | "cell_type": "code", |
446 | 484 | "execution_count": null, |
| 485 | + "id": "98faa709", |
447 | 486 | "metadata": {}, |
448 | 487 | "outputs": [], |
449 | 488 | "source": [ |
|
475 | 514 | }, |
476 | 515 | { |
477 | 516 | "cell_type": "markdown", |
| 517 | + "id": "c8203c9d", |
478 | 518 | "metadata": {}, |
479 | 519 | "source": [ |
480 | 520 | "## Saving\n", |
|
485 | 525 | { |
486 | 526 | "cell_type": "code", |
487 | 527 | "execution_count": null, |
| 528 | + "id": "d59d2ff3", |
488 | 529 | "metadata": {}, |
489 | 530 | "outputs": [], |
490 | 531 | "source": [ |
491 | 532 | "pvdiagram.writeto(\"saved_pvdiagram.fits\", overwrite=True)" |
492 | 533 | ] |
| 534 | + }, |
| 535 | + { |
| 536 | + "cell_type": "markdown", |
| 537 | + "id": "560c2f93-ee95-4d60-825a-83ec9f3acba7", |
| 538 | + "metadata": {}, |
| 539 | + "source": [ |
| 540 | + "We can also save the figure as a png or pdf:" |
| 541 | + ] |
| 542 | + }, |
| 543 | + { |
| 544 | + "cell_type": "code", |
| 545 | + "execution_count": null, |
| 546 | + "id": "74de9f99-e2fd-411f-9249-a39fa0b35908", |
| 547 | + "metadata": {}, |
| 548 | + "outputs": [], |
| 549 | + "source": [ |
| 550 | + "fig.savefig(\"saved_pvdiagram.png\", bbox_inches='tight')\n", |
| 551 | + "fig.savefig(\"saved_pvdiagram.pdf\", bbox_inches='tight')" |
| 552 | + ] |
493 | 553 | } |
494 | 554 | ], |
495 | 555 | "metadata": { |
|
0 commit comments