|
365 | 365 | " \"hspace\": 0})\n", |
366 | 366 | "\n", |
367 | 367 | " axes = axes.flatten()\n", |
368 | | - " #fig, axes = plt.subplots(n_rows, n_cols, figsize=figsize)\n", |
369 | | - " #axes = axes.flatten() if n_subplots > 1 else [axes]\n", |
370 | 368 | "\n", |
371 | 369 | " for ax in axes:\n", |
372 | 370 | " ax.axis(\"off\")\n", |
|
456 | 454 | "print(ra, dec)" |
457 | 455 | ] |
458 | 456 | }, |
| 457 | + { |
| 458 | + "cell_type": "markdown", |
| 459 | + "id": "823d68a9-210e-4201-99b0-b520be6fe80f", |
| 460 | + "metadata": {}, |
| 461 | + "source": [ |
| 462 | + "The cell below will perform a query to make sure the images retrieved span the time during which the DIAObject was changing and thus detectable as a DIASource. " |
| 463 | + ] |
| 464 | + }, |
| 465 | + { |
| 466 | + "cell_type": "code", |
| 467 | + "execution_count": null, |
| 468 | + "id": "15af811d-db19-4592-ad04-cde33486b11f", |
| 469 | + "metadata": {}, |
| 470 | + "outputs": [], |
| 471 | + "source": [ |
| 472 | + "dia_query = f\"\"\"\n", |
| 473 | + "SELECT MIN(midpointMjdTai) as first_detect_time,\n", |
| 474 | + " MAX(midpointMjdTai) as last_detect_time\n", |
| 475 | + "FROM dp1.DiaSource\n", |
| 476 | + "WHERE CONTAINS(POINT('ICRS', coord_ra, coord_dec), \n", |
| 477 | + " CIRCLE('ICRS', {ra}, {dec}, 0.001)) = 1\n", |
| 478 | + "\"\"\"\n", |
| 479 | + "\n", |
| 480 | + "dia_job = service.submit_job(dia_query)\n", |
| 481 | + "dia_job.run()\n", |
| 482 | + "dia_job.wait(phases=['COMPLETED', 'ERROR'])\n", |
| 483 | + "dia_results = dia_job.fetch_result().to_table()\n", |
| 484 | + "\n", |
| 485 | + "first_detect = dia_results['first_detect_time'][0]\n", |
| 486 | + "last_detect = dia_results['last_detect_time'][0]" |
| 487 | + ] |
| 488 | + }, |
459 | 489 | { |
460 | 490 | "cell_type": "markdown", |
461 | 491 | "id": "e49e571a-c652-4e7b-9a06-81fd8a17e6d1", |
462 | 492 | "metadata": {}, |
463 | 493 | "source": [ |
464 | | - "Use the SIA service to search for calibration level 2 images (`visit_images`) that overlap the search `circle`. Filter the results for r-band `visit_images` and sort them by observation time." |
| 494 | + "Use the SIA service to search for calibration level 2 images (`visit_images`) that overlap the search `circle`. " |
465 | 495 | ] |
466 | 496 | }, |
467 | 497 | { |
|
473 | 503 | "source": [ |
474 | 504 | "results_sci = sia_service.search(pos=circle, calib_level=2)\n", |
475 | 505 | "\n", |
476 | | - "lvl2_table = results_sci.to_table()\n", |
| 506 | + "lvl2_table = results_sci.to_table()\n" |
| 507 | + ] |
| 508 | + }, |
| 509 | + { |
| 510 | + "cell_type": "markdown", |
| 511 | + "id": "e95d41db-dc67-4d75-b1cd-911fef74c112", |
| 512 | + "metadata": {}, |
| 513 | + "source": [ |
| 514 | + "Filter the results for r-band `visit_images`, and to only return the visit images during which there was a DIA detection. The `if` statement ensures that a DIA detection was identified for that object. Lastly, sort the query results by observation time." |
| 515 | + ] |
| 516 | + }, |
| 517 | + { |
| 518 | + "cell_type": "code", |
| 519 | + "execution_count": null, |
| 520 | + "id": "47c923a8-8001-4ad6-9474-6dd31d2b683a", |
| 521 | + "metadata": {}, |
| 522 | + "outputs": [], |
| 523 | + "source": [ |
| 524 | + "if (not np.ma.is_masked(first_detect) and first_detect is not None and\n", |
| 525 | + " not np.ma.is_masked(last_detect) and last_detect is not None):\n", |
| 526 | + "\n", |
| 527 | + " tx = np.where(\n", |
| 528 | + " (lvl2_table['dataproduct_subtype'] == 'lsst.visit_image')\n", |
| 529 | + " & (lvl2_table['lsst_band'] == 'r')\n", |
| 530 | + " & (lvl2_table['t_min'] >= first_detect)\n", |
| 531 | + " & (lvl2_table['t_min'] <= last_detect)\n", |
| 532 | + " )[0]\n", |
| 533 | + "\n", |
| 534 | + " print(f\"Found {len(tx)} visits taken between MJD {first_detect: .2f} and {last_detect: .2f}.\")\n", |
| 535 | + "\n", |
| 536 | + "else:\n", |
| 537 | + " print(\"No DIA sources were ever detected in this region. Returning empty table.\")\n", |
| 538 | + " tx = []\n", |
477 | 539 | "\n", |
478 | | - "tx = np.where((lvl2_table['dataproduct_subtype'] == 'lsst.visit_image')\n", |
479 | | - " & (lvl2_table['lsst_band'] == 'r'))[0]\n", |
480 | 540 | "scitab = lvl2_table[tx]\n", |
481 | 541 | "scitab.sort('t_max')" |
482 | 542 | ] |
|
527 | 587 | "source": [ |
528 | 588 | "print('begin date:', scitab['t_max'][0], difftab['t_max'][0])\n", |
529 | 589 | "print('end date:', scitab['t_max'][len(scitab['t_max'])-1])\n", |
530 | | - "print('number of visits:', len(scitab['t_max']))" |
| 590 | + "print('number of visits:', len(scitab['t_max']))\n" |
531 | 591 | ] |
532 | 592 | }, |
533 | 593 | { |
|
724 | 784 | "source": [ |
725 | 785 | "## 3. Bulk image cutouts\n", |
726 | 786 | "\n", |
727 | | - "Bulk image cutouts will be a key visualization tool for DIA objects. Below, demonstrate how to retrieve many image cutouts (and save as png files)." |
| 787 | + "Bulk image cutouts will be a key visualization tool for DIA objects. Below, demonstrate how to retrieve many image cutouts (and save as png files). Since many visits span the time during which the target was a DIA source, limit the number to visualize to the first 20 (to save time). The full set of cutouts can be visualized by replacing the first line with `num_visits = len(scitab['t_max'])`" |
728 | 788 | ] |
729 | 789 | }, |
730 | 790 | { |
|
734 | 794 | "metadata": {}, |
735 | 795 | "outputs": [], |
736 | 796 | "source": [ |
737 | | - "num_visits = 20 #len(scitab['t_max'])\n", |
| 797 | + "num_visits = 20\n", |
738 | 798 | "print('number of visits:', num_visits)\n", |
739 | 799 | "for i in range(num_visits):\n", |
740 | 800 | " plt.title(f\"MJD {np.round(scitab['t_max'][i], 4)}\")\n", |
|
803 | 863 | "source": [ |
804 | 864 | "print(tempdir)\n", |
805 | 865 | "make_gif(tempdir)\n", |
806 | | - "display(dimg(data=open(tempdir+'/animation.gif', 'rb').read()))" |
| 866 | + "dimg(data=open(tempdir+'/animation.gif', 'rb').read())" |
807 | 867 | ] |
808 | 868 | }, |
809 | 869 | { |
|
813 | 873 | "source": [ |
814 | 874 | "> **Figure 4**: A gif animation generated from the reproject visit images in Figure 3." |
815 | 875 | ] |
816 | | - }, |
817 | | - { |
818 | | - "cell_type": "markdown", |
819 | | - "id": "172dc7bb-67ee-49f9-bee1-a6f50ad96c89", |
820 | | - "metadata": {}, |
821 | | - "source": [ |
822 | | - "## 4. Future functionality\n", |
823 | | - "\n", |
824 | | - "when rotate, don't do grid in final version, then get to a releasable version if you explain that the wcs rotate and just produce a rotated image (png, no wcs info) rotated visit image stamp that you can make a png image out of. Say a few things about how we're working on how to overplot grid lines and wcs functionality. this gets us to a publishable thing " |
825 | | - ] |
826 | | - }, |
827 | | - { |
828 | | - "cell_type": "markdown", |
829 | | - "id": "a8eb043b-5afe-4990-9050-bd059aaf5abf", |
830 | | - "metadata": {}, |
831 | | - "source": [ |
832 | | - "\n", |
833 | | - "\n", |
834 | | - "\n", |
835 | | - "only for epochs where it was detected in visit images. users can extrapolate to get all images. \n", |
836 | | - "\n", |
837 | | - "show how to do smaller more constrained part (i.e timeline over which visits are retrieved; where a dia ). \n", |
838 | | - "\n", |
839 | | - "\n", |
840 | | - "start with an ra/dec and date range where you already know. don't even need to refer to the other notebook\n" |
841 | | - ] |
842 | 876 | } |
843 | 877 | ], |
844 | 878 | "metadata": { |
|
0 commit comments