Skip to content

Commit 9790746

Browse files
committed
sia with dpsubtype
1 parent b70c5b8 commit 9790746

2 files changed

Lines changed: 119 additions & 193 deletions

File tree

DP1/100_How_to_Use_RSP_Tools/103_Image_access_and_display/103_2_Simple_Image_Access_SIA.ipynb

Lines changed: 65 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@
331331
"source": [
332332
"# coord = SkyCoord(target_ra, target_dec, unit=\"deg\")\n",
333333
"# coord_circle = (coord, 0.05)\n",
334-
"# results = sia_service.search(pos=coord_circle, maxrec=3)\n",
334+
"# results = sia_service.search(pos=coord_circle, maxrec=use_maxrec)\n",
335335
"# results.to_table()"
336336
]
337337
},
@@ -361,7 +361,7 @@
361361
"outputs": [],
362362
"source": [
363363
"# bounds = (target_ra-0.05, target_ra+0.05, target_dec-0.05, target_dec+0.05)\n",
364-
"# results = sia_service.search(pos=bounds, maxrec=3)\n",
364+
"# results = sia_service.search(pos=bounds, maxrec=use_maxrec)\n",
365365
"# results.to_table()"
366366
]
367367
},
@@ -394,7 +394,7 @@
394394
"# target_ra+0.05, target_dec-0.05,\n",
395395
"# target_ra+0.05, target_dec+0.05,\n",
396396
"# target_ra-0.05, target_dec+0.05)\n",
397-
"# results = sia_service.search(pos=polygon, maxrec=3)\n",
397+
"# results = sia_service.search(pos=polygon, maxrec=use_maxrec)\n",
398398
"# results.to_table()"
399399
]
400400
},
@@ -421,9 +421,10 @@
421421
"id": "d04e2397-b075-46d9-bdff-80e0ec0a7321",
422422
"metadata": {},
423423
"source": [
424-
"Query by image type, which in the SIA2 service is the calibration level (`calib_level`).\n",
424+
"Query by image type, which in the SIA2 service is specified by the calibration level (`calib_level`)\n",
425+
"and by the data product subtype (`dpsubtype`).\n",
425426
"\n",
426-
"Calibration levels are:\n",
427+
"Calibration levels and data product subtypes names are:\n",
427428
" - 1 : `raw`\n",
428429
" - 2 : `visit_image`\n",
429430
" - 3 : `deep_coadd`, `template_coadd`, `difference_image`"
@@ -442,163 +443,146 @@
442443
"id": "4361b7b0-cee1-44ba-96dd-1829f4b10fa3",
443444
"metadata": {},
444445
"source": [
445-
"Query for `visit_images` by setting `calib_level=2`."
446-
]
447-
},
448-
{
449-
"cell_type": "code",
450-
"execution_count": null,
451-
"id": "11fe7623-125e-4afc-94f6-4246e2844662",
452-
"metadata": {},
453-
"outputs": [],
454-
"source": [
455-
"results = sia_service.search(pos=circle, calib_level=2, maxrec=5)\n",
456-
"results.to_table()"
446+
"Query for `visit_images` by setting `calib_level=2` *OR* `dpsubtype='lsst.visit_image'`,\n",
447+
"since there is only one dataproduct subtype (`visit_image`) for calibration level 2.\n",
448+
"\n",
449+
"Return the results as Astropy tables using `.to_table()`.\n",
450+
"\n",
451+
"Set `calib_level`."
457452
]
458453
},
459454
{
460455
"cell_type": "code",
461456
"execution_count": null,
462-
"id": "769206dd-3fcb-475c-98bc-190258d9901d",
457+
"id": "00b558f2-90e8-4266-aa64-65237e462002",
463458
"metadata": {},
464459
"outputs": [],
465460
"source": [
466-
"del results"
467-
]
468-
},
469-
{
470-
"cell_type": "markdown",
471-
"id": "7e872f8f-0251-4a6d-ac0b-6952c98deaf1",
472-
"metadata": {},
473-
"source": [
474-
"#### 3.2.2. Deep coadd images"
461+
"results = sia_service.search(pos=circle, calib_level=2).to_table()\n",
462+
"print(len(results))"
475463
]
476464
},
477465
{
478466
"cell_type": "markdown",
479-
"id": "08b71293-d3ab-49ca-9a95-2566488eec33",
467+
"id": "76e5918b-0321-4782-a36f-2a5de4ee03fb",
480468
"metadata": {},
481469
"source": [
482-
"Query for `deep_coadd` images by setting `calib_level=3`.\n",
483-
"\n",
484-
"This will also return the `template_coadd` images and `difference_images`."
470+
"Option to redo the query by setting `dpsubtype` to confirm they return the same number of visit images."
485471
]
486472
},
487473
{
488474
"cell_type": "code",
489475
"execution_count": null,
490-
"id": "f597b4e1-f377-46fd-83cd-2ee6ae5e45bc",
476+
"id": "11fe7623-125e-4afc-94f6-4246e2844662",
491477
"metadata": {},
492478
"outputs": [],
493479
"source": [
494-
"results = sia_service.search(pos=circle, calib_level=3)\n",
495-
"print(len(results))"
480+
"# results = sia_service.search(pos=circle, dpsubtype='lsst.visit_image').to_table()\n",
481+
"# print(len(results))"
496482
]
497483
},
498484
{
499485
"cell_type": "markdown",
500-
"id": "8f62bb47-7a7c-49cd-969a-6d60b5488abe",
486+
"id": "4c126fe2-8bdb-4888-97e6-12ee4ae5dbaa",
501487
"metadata": {},
502488
"source": [
503-
"Convert the `results` to an `astropy` `table`."
489+
"Option to show the results table, which will be displayed as truncated."
504490
]
505491
},
506492
{
507493
"cell_type": "code",
508494
"execution_count": null,
509-
"id": "ef4601bd-0936-4a32-b3d9-14a26fe99218",
495+
"id": "2475d930-0896-4751-b38a-cb8e552f4776",
510496
"metadata": {},
511497
"outputs": [],
512498
"source": [
513-
"table = results.to_table()"
499+
"# results"
514500
]
515501
},
516502
{
517-
"cell_type": "markdown",
518-
"id": "9239fea9-0dc7-4586-b1bb-54b2952f4f30",
503+
"cell_type": "code",
504+
"execution_count": null,
505+
"id": "769206dd-3fcb-475c-98bc-190258d9901d",
519506
"metadata": {},
507+
"outputs": [],
520508
"source": [
521-
"Option to show the full table of results."
509+
"del results"
522510
]
523511
},
524512
{
525-
"cell_type": "code",
526-
"execution_count": null,
527-
"id": "cc57c45c-2c02-447b-bd64-19979959bff2",
513+
"cell_type": "markdown",
514+
"id": "7e872f8f-0251-4a6d-ac0b-6952c98deaf1",
528515
"metadata": {},
529-
"outputs": [],
530516
"source": [
531-
"# table"
517+
"#### 3.2.2. Deep coadd images"
532518
]
533519
},
534520
{
535521
"cell_type": "markdown",
536-
"id": "fde6bcb0-48c2-4c6b-a476-30ec6be2adde",
522+
"id": "08b71293-d3ab-49ca-9a95-2566488eec33",
537523
"metadata": {},
538524
"source": [
539-
"Print the number of `deep_coadd`, `template_coadd`, and `difference_images` that were returned."
525+
"Query for `deep_coadd` images by setting `calib_level=3` and `dpsubtype='lsst.deep_coadd'`.\n",
526+
"\n",
527+
"Do not pass `use_maxrec` here, retrieve all the `deep_coadd` images that match the search constraints."
540528
]
541529
},
542530
{
543531
"cell_type": "code",
544532
"execution_count": null,
545-
"id": "da7aa11c-93f2-43bd-9014-b3edc07b34de",
533+
"id": "f597b4e1-f377-46fd-83cd-2ee6ae5e45bc",
546534
"metadata": {},
547535
"outputs": [],
548536
"source": [
549-
"values, counts = np.unique(table['dataproduct_subtype'],\n",
550-
" return_counts=True)\n",
551-
"for value, count in zip(values, counts):\n",
552-
" print(value, count)"
537+
"results = sia_service.search(pos=circle, calib_level=3, dpsubtype='lsst.deep_coadd').to_table()\n",
538+
"print(len(results))"
553539
]
554540
},
555541
{
556542
"cell_type": "markdown",
557-
"id": "5a3bc533-3865-4d63-8593-9f588b19c810",
543+
"id": "9239fea9-0dc7-4586-b1bb-54b2952f4f30",
558544
"metadata": {},
559545
"source": [
560-
"Subset the resulting images that are deep coadds in the r-band."
546+
"Option to show the full table of results."
561547
]
562548
},
563549
{
564550
"cell_type": "code",
565551
"execution_count": null,
566-
"id": "62654699-3b7d-4864-9f0e-a854d969d2e3",
552+
"id": "cc57c45c-2c02-447b-bd64-19979959bff2",
567553
"metadata": {},
568554
"outputs": [],
569555
"source": [
570-
"tx = np.where((table['dataproduct_subtype'] == 'lsst.deep_coadd')\n",
571-
" & (table['lsst_band'] == 'r'))[0]\n",
572-
"print(len(tx))"
556+
"# results"
573557
]
574558
},
575559
{
576560
"cell_type": "markdown",
577-
"id": "d34c068c-2191-488c-9ef3-deb6d5de043c",
561+
"id": "fde6bcb0-48c2-4c6b-a476-30ec6be2adde",
578562
"metadata": {},
579563
"source": [
580-
"All `deep_coadd` images overlap at the edges.\n",
581-
"The fact that there are two r-band `deep_coadd` images means the target coordinates used are near the image edges and in the overlap region.\n",
582-
"\n",
583-
"Print the table of the r-band `deep_coadd` images only."
564+
"Print the number of unique values of `lsst_band` (filters)."
584565
]
585566
},
586567
{
587568
"cell_type": "code",
588569
"execution_count": null,
589-
"id": "44c100ac-3296-4846-ae0c-8b39051679b6",
570+
"id": "da7aa11c-93f2-43bd-9014-b3edc07b34de",
590571
"metadata": {},
591572
"outputs": [],
592573
"source": [
593-
"table[tx]"
574+
"values, counts = np.unique(results['lsst_band'],\n",
575+
" return_counts=True)\n",
576+
"for value, count in zip(values, counts):\n",
577+
" print(value, count)"
594578
]
595579
},
596580
{
597581
"cell_type": "markdown",
598-
"id": "197a2b2a-cf18-4b40-ba7f-ec9300116a18",
582+
"id": "5a3bc533-3865-4d63-8593-9f588b19c810",
599583
"metadata": {},
600584
"source": [
601-
"Keep only the `table` to use in the next sections."
585+
"There are 2 overlapping patches for the search coordinates, and thus 2 `deep_coadd` images for each of the six filters."
602586
]
603587
},
604588
{
@@ -608,7 +592,7 @@
608592
"metadata": {},
609593
"outputs": [],
610594
"source": [
611-
"del results, tx"
595+
"del results, values, counts"
612596
]
613597
},
614598
{
@@ -618,7 +602,9 @@
618602
"source": [
619603
"#### 3.2.3. Template coadd images\n",
620604
"\n",
621-
"Use the same initial query as in Section 3.2.2, but then subset only to the results with `dataproduct_subtype` equal to `lsst.template_coadd`."
605+
"Query for `template_coadd` images by setting `calib_level=3` and `dpsubtype='lsst.template_coadd'`.\n",
606+
"\n",
607+
"Since the `template_coadd` images are also stored by patch, there are also 12 that match the query constraints."
622608
]
623609
},
624610
{
@@ -628,27 +614,8 @@
628614
"metadata": {},
629615
"outputs": [],
630616
"source": [
631-
"tx = np.where((table['dataproduct_subtype'] == 'lsst.template_coadd')\n",
632-
" & (table['lsst_band'] == 'r'))[0]\n",
633-
"print(len(tx))"
634-
]
635-
},
636-
{
637-
"cell_type": "markdown",
638-
"id": "653f6e5e-af41-4207-a5e2-4dce8ea98ade",
639-
"metadata": {},
640-
"source": [
641-
"Option to display the subsetted table."
642-
]
643-
},
644-
{
645-
"cell_type": "code",
646-
"execution_count": null,
647-
"id": "ef5f1c7a-c8af-44a1-b352-5399ff92a111",
648-
"metadata": {},
649-
"outputs": [],
650-
"source": [
651-
"# table[tx]"
617+
"results = sia_service.search(pos=circle, calib_level=3, dpsubtype='lsst.template_coadd')\n",
618+
"print(len(results))"
652619
]
653620
},
654621
{
@@ -658,7 +625,7 @@
658625
"metadata": {},
659626
"outputs": [],
660627
"source": [
661-
"del tx"
628+
"del results"
662629
]
663630
},
664631
{
@@ -668,7 +635,9 @@
668635
"source": [
669636
"#### 3.2.4. Difference images\n",
670637
"\n",
671-
"Use the same initial query as in Section 3.2.2, but then subset only to the results with `dataproduct_subtype` equal to `lsst.difference_image`."
638+
"Query for `difference_images` by setting `calib_level=3` and `dpsubtype='lsst.difference_image'`.\n",
639+
"\n",
640+
"There will be as many difference images returned as there are `visit_images`."
672641
]
673642
},
674643
{
@@ -678,27 +647,8 @@
678647
"metadata": {},
679648
"outputs": [],
680649
"source": [
681-
"tx = np.where((table['dataproduct_subtype'] == 'lsst.difference_image')\n",
682-
" & (table['lsst_band'] == 'r'))[0]\n",
683-
"print(len(tx))"
684-
]
685-
},
686-
{
687-
"cell_type": "markdown",
688-
"id": "160d484b-b1be-4303-9ef7-e5d89f265b25",
689-
"metadata": {},
690-
"source": [
691-
"Option to display the subsetted table."
692-
]
693-
},
694-
{
695-
"cell_type": "code",
696-
"execution_count": null,
697-
"id": "81e0ac68-f7b4-4155-8386-74c5ffdee8cd",
698-
"metadata": {},
699-
"outputs": [],
700-
"source": [
701-
"# table[tx]"
650+
"results = sia_service.search(pos=circle, calib_level=3, dpsubtype='lsst.difference_image')\n",
651+
"print(len(results))"
702652
]
703653
},
704654
{
@@ -708,7 +658,7 @@
708658
"metadata": {},
709659
"outputs": [],
710660
"source": [
711-
"del table, tx"
661+
"del results"
712662
]
713663
},
714664
{

0 commit comments

Comments
 (0)