diff --git a/_static/nb_html/DP02_03c_Big_deepCoadd_Cutout.html b/_static/nb_html/DP02_03c_Big_deepCoadd_Cutout.html index 10b4171c..a3b11ace 100644 --- a/_static/nb_html/DP02_03c_Big_deepCoadd_Cutout.html +++ b/_static/nb_html/DP02_03c_Big_deepCoadd_Cutout.html @@ -7519,7 +7519,7 @@
(<matplotlib.patches.Circle at 0x7b2407f04410>,)+
(<matplotlib.patches.Circle at 0x7ee10f789090>,)
dataIds defaultdict(<class 'list'>, {3441: [{'tract': 3441, 'patch': 7, 'band': 'r'}, {'tract': 3441, 'patch': 14, 'band': 'r'}], 3442: [{'tract': 3442, 'patch': 13, 'band': 'r'}, {'tract': 3442, 'patch': 19, 'band': 'r'}, {'tract': 3442, 'patch': 20, 'band': 'r'}, {'tract': 3442, 'patch': 12, 'band': 'r'}]}) -dict of images defaultdict(<class 'list'>, {3441: [<lsst.afw.image._exposure.ExposureF object at 0x7b2428582230>, <lsst.afw.image._exposure.ExposureF object at 0x7b2407bc1af0>], 3442: [<lsst.afw.image._exposure.ExposureF object at 0x7b240804c070>, <lsst.afw.image._exposure.ExposureF object at 0x7b240804f370>, <lsst.afw.image._exposure.ExposureF object at 0x7b2428517e70>, <lsst.afw.image._exposure.ExposureF object at 0x7b2407b7f970>]}) +dict of images defaultdict(<class 'list'>, {3441: [<lsst.afw.image._exposure.ExposureF object at 0x7ee12bf21070>, <lsst.afw.image._exposure.ExposureF object at 0x7ee10f6ec230>], 3442: [<lsst.afw.image._exposure.ExposureF object at 0x7ee10fbf5b70>, <lsst.afw.image._exposure.ExposureF object at 0x7ee10f8a3b30>, <lsst.afw.image._exposure.ExposureF object at 0x7ee12bf128f0>, <lsst.afw.image._exposure.ExposureF object at 0x7ee10f8164f0>]})
dI = all_dataIds[0]
-dataset_refs = list(butler.registry.queryDatasets('deepCoadd', dataId=dI))
+dataset_refs = list(butler.query_datasets('deepCoadd', data_id=dI))
dataset_refs = set(dataset_refs)
for dI in all_dataIds[1:]:
- dr = list(butler.registry.queryDatasets('deepCoadd', dataId=dI))
+ dr = list(butler.query_datasets('deepCoadd', data_id=dI))
dataset_refs = dataset_refs.union(set(dr))
coadd_deferred_dataset_handle = [butler.getDeferred(dr) for dr in dataset_refs]
@@ -9442,7 +9442,7 @@ lsst.getTemplate INFO: Using template input tract=3441, patch=7
+">lsst.getTemplate INFO: Using template input tract=3442, patch=13
dictionary of dataIds for overlapping exposures: defaultdict(<class 'list'>, {3442: [{band: 'r', skymap: 'DC2', tract: 3442, patch: 20}, {band: 'r', skymap: 'DC2', tract: 3442, patch: 13}], 3441: [{band: 'r', skymap: 'DC2', tract: 3441, patch: 14}, {band: 'r', skymap: 'DC2', tract: 3441, patch: 7}]}) -dictionary of overlapping exposures: defaultdict(<class 'list'>, {3442: [<lsst.afw.image._exposure.ExposureF object at 0x7b2428485130>, <lsst.afw.image._exposure.ExposureF object at 0x7b2428347270>], 3441: [<lsst.afw.image._exposure.ExposureF object at 0x7b24285559b0>, <lsst.afw.image._exposure.ExposureF object at 0x7b2428349470>]}) +dictionary of overlapping exposures: defaultdict(<class 'list'>, {3442: [<lsst.afw.image._exposure.ExposureF object at 0x7ee12bd0dcf0>, <lsst.afw.image._exposure.ExposureF object at 0x7ee12bd631f0>], 3441: [<lsst.afw.image._exposure.ExposureF object at 0x7ee12be08030>, <lsst.afw.image._exposure.ExposureF object at 0x7ee12bd1aff0>]})
Packages: lsst.daf.butler, lsst.sphgeom
+Packages: lsst.daf.butler
def get_corners_radec(wcs, bbox):
- """
- Return the corners in RA,Dec in degrees given the WCS and bounding box for an image.
-
- Parameters
- ----------
- wcs: image WCS returned by the Butler
- bbox: bounding box returned by the Butler
-
- Returns
- -------
- corners_ra, corners_dec in decimal degrees
- """
-
- corners_x = [bbox.beginX, bbox.beginX, bbox.endX, bbox.endX]
- corners_y = [bbox.beginY, bbox.endY, bbox.endY, bbox.beginY]
- corners_ra = []
- corners_dec = []
- for i in range(4):
- radec = wcs.pixelToSky(corners_x[i], corners_y[i])
- corners_ra.append(radec.getRa().asDegrees())
- corners_dec.append(radec.getDec().asDegrees())
-
- return corners_ra, corners_dec
-
Butler repositories have both a database component and a file-like storage component. The database component can be accessed through the Butler registry, while file-like storage can be local (i.e., pointing to a directory on the local file system) or remote (i.e., pointing to cloud storage resources). DP0 uses Simple Storage Service (S3) buckets, which are public cloud storage resources that are similar to file folders. @@ -7758,7 +7709,7 @@
# help(registry)
@@ -7799,15 +7750,15 @@ 2.1. The Butler registry
-2.1.1. queryCollections¶
Collections are lightweight groups of datasets such as the set of raw images for a particular instrument, self-consistent calibration datasets, and the outputs of a processing run.
+
2.1.1. Querying collections¶
Collections are lightweight groups of datasets such as the set of raw images for a particular instrument, self-consistent calibration datasets, and the outputs of a processing run.
For DP0.2, we use the 2.2i/runs/DP0.2
collection, which we specified when creating our instance of the Butler.
-It is possible to access other collections, which can be queried with queryCollections
.
+
It is possible to access other collections, which can be queried with butler.collections.query
.
More about collections can be found in the lsst.daf.butler documentation and in the middleware FAQ.
Risk reminder: for DP0 there are no read/write restrictions on the Butler repository.
The above risk means all users can see everything in the Butler, including intermediate processing steps, test runs, staff repositories, and other user repositories.
-This fact makes the queryCollections functionality less useful for data discovery than it will be in the future, due to the sheer number of Butler collections exposed to users.
+This fact makes the butler.collections.query functionality less useful for data discovery than it will be in the future, due to the sheer number of Butler collections exposed to users.
# for c in sorted(registry.queryCollections()):
-# print(c)
+# for c in sorted(butler.collections.query('*')):
+# print(c)
The only collections users need is the DP0.2 collection.
+The only collection users need is the DP0.2 collection, which is named "2.2i/runs/DP0.2." Use butler.collections.query_info
to learn more about the contents of that collection. This will produce a long list of collections that are children of the DP0.2 parent collection.
for c in sorted(registry.queryCollections()):
- if c == '2.2i/runs/DP0.2':
- print(c)
+butler.collections.query_info('2.2i/runs/DP0.2')
2.2i/runs/DP0.2 -+
[CollectionInfo(name='2.2i/runs/DP0.2', type=<CollectionType.CHAINED: 3>, doc='', children=('2.2i/runs/DP0.2/w_2022_22/PREOPS-1209/20220601T202430Z', '2.2i/runs/DP0.2/w_2022_22/PREOPS-1209/20220602T165151Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step7/20220501T161443Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step6_1/20220512T201515Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step6_10/20220514T021220Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step6_11/20220514T051259Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step6_12/20220514T081014Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step6_13/20220514T110509Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step6_14/20220514T140812Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step6_15/20220514T171751Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step6_16/20220514T201929Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step6_17/20220514T232440Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step6_17/20220516T033516Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step6_18/20220515T023234Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step6_19/20220515T054618Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step6_2/20220513T015911Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step6_20/20220515T144944Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step6_3/20220513T050000Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step6_4/20220515T113417Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step6_5/20220513T110250Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step6_6/20220513T140400Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step6_7/20220513T170841Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step6_8/20220513T201047Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step6_9/20220513T231122Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step5_52/20220511T193037Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step5_51/20220511T172849Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step5_50/20220511T152602Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step5_49/20220511T224921Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step5_48/20220511T115326Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step5_47/20220511T093215Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step5_46/20220511T072551Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step5_45/20220511T051607Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step5_44/20220511T030333Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step5_43/20220511T010324Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step5_42/20220510T225220Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step5_41/20220510T204315Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step5_40/20220510T182122Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step5_39/20220510T165619Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step5_38/20220510T144157Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step5_37/20220510T122823Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step5_36/20220510T102009Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step5_35/20220510T082734Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step5_34/20220510T062419Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step5_30/20220511T210005Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step5_12/20220507T050423Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step5_1/20220512T001721Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step5_1/20220503T191629Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step5_10/20220506T225821Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step5_11/20220507T020003Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step5_13/20220507T224408Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step5_14/20220508T012319Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step5_15/20220508T042652Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step5_16/20220508T072602Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step5_17/20220508T103019Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step5_18/20220508T124926Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step5_19/20220508T155145Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step5_2/20220505T095134Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step5_2/20220505T200125Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step5_20/20220508T185905Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step5_21/20220508T221147Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step5_22/20220509T011312Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step5_23/20220509T041228Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step5_24/20220509T071757Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step5_25/20220509T102239Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step5_26/20220509T132805Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step5_27/20220509T155625Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step5_28/20220509T180251Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step5_29/20220509T200842Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step5_3/20220505T200225Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step5_31/20220509T234815Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step5_32/20220510T020028Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step5_33/20220510T041257Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step5_4/20220505T233000Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step5_5/20220506T040307Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step5_6/20220506T080709Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step5_7/20220506T121157Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step5_8/20220506T160546Z', '2.2i/runs/DP0.2/v23_0_2/PREOPS-905/step5_9/20220506T195012Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step4_38/20220429T022751Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step4_1/20220419T041129Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step4_10/20220429T200139Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step4_11/20220430T013535Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step4_12/20220430T070958Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step4_13/20220422T152623Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step4_14/20220423T111506Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step4_15/20220423T171322Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step4_16/20220423T220848Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step4_17/20220424T030657Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step4_18/20220424T081202Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step4_19/20220424T131819Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step4_2/20220419T082436Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step4_20/20220424T182451Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step4_21/20220425T033108Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step4_22/20220425T090248Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step4_23/20220425T143818Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step4_24/20220425T200112Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step4_25/20220426T012543Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step4_26/20220426T070107Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step4_27/20220426T123155Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step4_28/20220426T180134Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step4_29/20220426T233505Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step4_3/20220419T123328Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step4_30/20220427T050650Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step4_31/20220427T103906Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step4_32/20220427T161652Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step4_33/20220427T215556Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step4_34/20220428T033022Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step4_35/20220428T091545Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step4_36/20220428T145517Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step4_37/20220428T203907Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step4_39/20220429T081628Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step4_4/20220419T163046Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step4_40/20220429T135816Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step4_5/20220419T204203Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step4_6/20220420T005103Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step4_7/20220420T173758Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step4_8/20220420T233604Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step4_9/20220421T052720Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_32/20220418T184335Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_32/20220418T180525Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_32/20220418T172818Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_32/20220418T165935Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_32/20220418T165845Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_9/20220405T164242Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_9/20220330T170001Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_7/20220330T145650Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_5/20220329T232416Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_32/20220410T153911Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_32/20220410T130944Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_32/20220407T030512Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_20/20220406T145057Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_20/20220331T124128Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_19/20220331T110357Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_18/20220406T130306Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_18/20220331T084313Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_17/20220406T111701Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_17/20220331T063809Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_16/20220406T095810Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_16/20220331T050027Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_15/20220406T081059Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_15/20220331T025327Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_14/20220406T063431Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_14/20220331T004509Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_13/20220406T045526Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_13/20220330T224603Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_12/20220405T182718Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_12/20220330T204043Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_11/20220330T190852Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_27/20220322T202545Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_4/20220325T122210Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_29/20220325T223049Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_26/20220325T204503Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_25/20220325T190019Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_24/20220325T174013Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_23/20220325T155617Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_22/20220325T141557Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_2/20220325T104104Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_1/20220326T032806Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_8/20220316T205925Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_6/20220318T134046Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_27/20220316T171018Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_1/20220317T233937Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_6/20220316T192214Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_10/20220315T122041Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_8/20220309T160814Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_6/20220309T170243Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_4/20220315T051405Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_4/20220309T042312Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_31/20220314T212509Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_31/20220307T050825Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_30/20220314T194916Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_30/20220306T160359Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_3/20220315T012904Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_3/20220309T040429Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_29/20220314T204515Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_29/20220306T172459Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_28/20220314T185100Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_28/20220306T041600Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_27/20220306T050001Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_26/20220305T162808Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_25/20220305T164554Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_24/20220305T052326Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_23/20220305T044606Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_22/20220304T174139Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_21/20220314T170839Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_21/20220304T163449Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_2/20220308T164354Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_10/20220310T050847Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_1/20220308T153907Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_11/20220220T032646Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_12/20220218T172932Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_13/20220220T142359Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_13/20220302T190942Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_14/20220219T051120Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_15/20220221T015820Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_15/20220302T200340Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_16/20220219T164501Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_16/20220302T210859Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_17/20220220T035232Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_18/20220220T153612Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_19/20220221T031952Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_19/20220302T215536Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_20/20220225T211807Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_20/20220303T145311Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_5/20220218T163030Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_7/20220219T040206Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_9/20220219T154502Z', '2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_9/20220302T181001Z', '2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20220124T155505Z', '2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20220123T195452Z', '2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20220123T001043Z', '2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20220122T070559Z', '2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20220121T234250Z', '2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20220121T191925Z', '2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20220121T160922Z', '2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20220121T103211Z', '2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20220121T081743Z', '2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20220121T041501Z', '2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20220121T031850Z', '2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20220121T003836Z', '2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20220120T161430Z', '2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20220120T012920Z', '2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20220112T143133Z', '2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20220112T114604Z', '2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20220112T084603Z', '2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20220112T054912Z', '2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20220112T010001Z', '2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20220111T213932Z', '2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20220111T175016Z', '2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20220111T095828Z', '2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20220111T083238Z', '2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20220111T071223Z', '2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20220111T063729Z', '2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20220111T060953Z', '2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20220111T054319Z', '2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20220111T051546Z', '2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20220111T044925Z', '2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20220111T041856Z', '2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20220110T231306Z', '2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20220107T204134Z', '2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20220107T163916Z', '2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20220104T111833Z', '2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20220104T085126Z', '2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20220103T202705Z', '2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20220104T062817Z', '2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20220103T103400Z', '2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20220103T010607Z', '2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20220102T153518Z', '2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20220102T060840Z', '2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20220101T211007Z', '2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20220101T102006Z', '2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20220101T014359Z', '2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20211231T121620Z', '2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20211231T053432Z', '2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20211230T230823Z', '2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20211230T164503Z', '2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20211230T102720Z', '2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20211230T042014Z', '2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20211224T153913Z', '2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20211224T102944Z', '2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20211224T053402Z', '2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20211223T204234Z', '2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20211223T030157Z', '2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20211222T182615Z', '2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20211222T122903Z', '2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20211222T050757Z', '2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20211222T004329Z', '2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20211221T170207Z', '2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20211221T162728Z', '2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20211221T021010Z', '2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20211220T214212Z', '2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20211220T180923Z', '2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20211220T040027Z', '2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20211220T000005Z', '2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20211219T205411Z', '2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20211219T150249Z', '2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20211219T033213Z', '2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20211218T214417Z', '2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20211218T144437Z', '2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20211218T041605Z', '2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20211218T002844Z', '2.2i/raw/DR6/WFD', '2.2i/calib/DM-30694', '2.2i/calib/gen2', '2.2i/calib/DM-30694/unbounded', 'skymaps', 'refcats/PREOPS-301', '2.2i/truth_summary'), parents=None, dataset_types=None)]
# for c in sorted(registry.queryCollections("*calib*")):
-# print(c)
+# for c in sorted(butler.collections.query("*calib*")):
+# print(c)
for dt in sorted(registry.queryDatasetTypes('*_tract')):
@@ -8010,7 +7958,7 @@ 2.1.2. queryDatasetTypes
# for dt in sorted(registry.queryDatasetTypes('deepCoadd*')):
@@ -8049,7 +7997,7 @@ 2.1.3. getDatasetType
dt_deepCoadd = registry.getDatasetType('deepCoadd')
@@ -8079,7 +8027,7 @@ 2.1.3. getDatasetType
-2.1.4. queryDimensionRecords¶
As described in the documentation for queryDimensionRecords
,
+
2.1.4. query_dimension_records¶
As described in the documentation for queryDimensionRecords
,
this method provies a way to inspect metadata tables.
Option: print the different metadata elements that are available to be inspected.
@@ -8090,10 +8038,10 @@ 2.1.4. queryDimensionRecords
-In [13]:
+In [12]:
-# for a in butler.registry.dimensions.getStaticElements():
+# for a in butler.dimensions.getStaticElements():
# print(a)
@@ -8107,8 +8055,8 @@ 2.1.4. queryDimensionRecords
-A call to queryDimensionRecords
will return a set of fields, depending on the element.
-To first see the fields that would be returned for a given element, in this case "detector":
+A call to query_dimension_records
will return a set of fields, depending on the element.
+Use butler.dimensions.schema
to print a list of the fields that would be returned for a given element (in this case "detector").
@@ -8117,10 +8065,10 @@ 2.1.4. queryDimensionRecords
-In [14]:
+In [13]:
-print(butler.registry.dimensions['detector'].RecordClass.fields)
+print(butler.dimensions['detector'].schema)
@@ -8134,12 +8082,16 @@ 2.1.4. queryDimensionRecords
detector:
- instrument: str
+ instrument: string
id: int
- full_name: str
- name_in_raft: str
- raft: str
- purpose: str
+ full_name: string
+ name_in_raft: string
+ raft: string
+ A string name for a group of detectors with an instrument-
+ dependent interpretation.
+ purpose: string
+ Role of the detector; typically one of "SCIENCE", "WAVEFRONT", or
+ "GUIDE", though instruments may define additional values.
@@ -8152,7 +8104,7 @@ 2.1.4. queryDimensionRecords
-Use the queryDimensionRecords
method to return some detector metadata available for DP0 images (LSSTCam-imSim), for detectors 6, 7, and 8 only.
+Use the butler.query_dimension_records
method to return some detector metadata available for DP0 images (LSSTCam-imSim), for detectors 6, 7, and 8 only.
list(butler.registry.queryDimensionRecords('detector', where="instrument='LSSTCam-imSim' "
- "AND detector.id IN (6..8)"))
+butler.query_dimension_records('detector', where="instrument='LSSTCam-imSim' "
+ "AND detector.id IN (6..8)")
[detector.RecordClass(instrument='LSSTCam-imSim', id=6, full_name='R01_S20', name_in_raft='S20', raft='R01', purpose='SCIENCE'), detector.RecordClass(instrument='LSSTCam-imSim', id=7, full_name='R01_S21', name_in_raft='S21', raft='R01', purpose='SCIENCE'), @@ -8192,26 +8144,82 @@2.1.4. queryDimensionRecords
-Option: use the
+queryDimensionRecords
method to return the exposure, visit, and detector metadata available for DP0 visit number 971990 and detector 0.Option: use the
query_dimension_records
method to return the exposure, visit, and detector metadata available for DP0 visit number 971990 and detector 0. (Use "[0]" to print only the first item from the list.)
# for dim in ['exposure', 'visit', 'detector']:
-# print(list(registry.queryDimensionRecords(dim, where='visit = 971990 and detector = 0'))[0])
-# print()
+for dim in ['exposure', 'visit', 'detector']:
+ print(butler.query_dimension_records(dim, where='visit = 971990 and detector = 0', limit=-1)[0])
+ print()
exposure: + instrument: 'LSSTCam-imSim' + id: 971990 + physical_filter: 'z_sim_1.4' + obs_id: '971990' + exposure_time: 30.0 + dark_time: 30.0 + observation_type: 'science' + observation_reason: 'imsim' + day_obs: 20251201 + seq_num: 0 + group_name: '971990' + group_id: 971990 + target_name: 'UNKNOWN' + science_program: '971990' + tracking_ra: 70.37699524983329 + tracking_dec: -37.17573628348882 + sky_angle: 292.6518874660149 + zenith_angle: 19.469782456426444 + timespan: Timespan(begin=astropy.time.Time(2461012.0, -0.36678038888930553, scale='tai', format='jd'), end=astropy.time.Time(2461012.0, -0.36643317129629627, scale='tai', format='jd')) + +visit: + instrument: 'LSSTCam-imSim' + id: 971990 + physical_filter: 'z_sim_1.4' + visit_system: 1 + name: '971990' + day_obs: 20251201 + exposure_time: 30.0 + target_name: 'UNKNOWN' + observation_reason: 'imsim' + science_program: '971990' + zenith_angle: 19.469782456426444 + region: ConvexPolygon([UnitVector3d(0.23777267380834483, 0.7544426088009132, -0.6117846889353334), UnitVector3d(0.23561428564848888, 0.7624248774034458, -0.6026559671277576), UnitVector3d(0.23489129024598346, 0.7650539083853652, -0.599598698323182), UnitVector3d(0.24441246595191043, 0.7719782401906571, -0.5867811714425084), UnitVector3d(0.24856139513406264, 0.7716376940531965, -0.5854848434974846), UnitVector3d(0.2524556778516015, 0.7713013494543077, -0.5842605232689029), UnitVector3d(0.27578892562829005, 0.768993552725668, -0.5767056306012182), UnitVector3d(0.2796539793141923, 0.7685616339568179, -0.5754186881422636), UnitVector3d(0.2934704959089931, 0.7593653588952546, -0.580723100746656), UnitVector3d(0.29426926501388223, 0.7565200998125113, -0.5840230631129711), UnitVector3d(0.2949957827088376, 0.7538756416625922, -0.5870681434823516), UnitVector3d(0.2957168905600652, 0.7512201931774088, -0.5901014675460341), UnitVector3d(0.29993684521247804, 0.7349912179357472, -0.608133043372347), UnitVector3d(0.29039711533056606, 0.7280680544882611, -0.6209560559664141), UnitVector3d(0.28628631986818487, 0.7285155658703246, -0.6223385038232585), UnitVector3d(0.27465017049482865, 0.7297171630289703, -0.6261630345430116), UnitVector3d(0.2707646722601988, 0.7300937569840328, -0.6274150127856101), UnitVector3d(0.2590626697627845, 0.731155302238704, -0.6311089106830992), UnitVector3d(0.25516285417086804, 0.7314837244091129, -0.6323159643532253), UnitVector3d(0.24135746274622868, 0.7406734671751954, -0.627016259916262), UnitVector3d(0.2405974378501948, 0.7436273951325181, -0.6238037913545792), UnitVector3d(0.23989510383043633, 0.7463454425811203, -0.6208210849323466)]) + timespan: Timespan(begin=astropy.time.Time(2461012.0, -0.36678038888930553, scale='tai', format='jd'), end=astropy.time.Time(2461012.0, -0.36643317129629627, scale='tai', format='jd')) + +detector: + instrument: 'LSSTCam-imSim' + id: 0 + full_name: 'R01_S00' + name_in_raft: 'S00' + raft: 'R01' + purpose: 'SCIENCE' + ++
The dataId is a dictionary-like identifier for a data product (more information can be found in the lsst.daf.butler documentation). +
The dataId is a dictionary-like identifier for a data product (more information can be found in the lsst.daf.butler documentation).
Each DatasetType
(i.e., calexp
, deepCoadd
, objectTable
, etc.) uses a different set of keys in its dataId, which are also called "dimensions".
Use the registry to get the DatasetType for a specific named dataset, in this case a calexp
, and list its dimensions.
dt = registry.getDatasetType('calexp')
@@ -8267,7 +8275,7 @@ 2.2. Use a dataId with queryDatase
The dataId contains both implied and required keys.
For example, the value of band
is implied by the visit
, because a single visit refers to a single exposure at a single pointing in a single band.
In other tutorial notebooks, we have seen how to access a specific data product using a fully specified dataId. A query for a fully specified dataId should return one unique entry (however, see the FAQ entry about duplicate results from chained collections).
-As described in the documentation page for queryDatasets
, this method returns datasetRefs
, which can be passed directly to a call to butler.get()
in order to retrieve the desired data (see next section).
+As described in the documentation page for query_datasets
, this method returns datasetRefs
, which can be passed directly to a call to butler.get()
in order to retrieve the desired data (see next section).
datasetType = 'calexp'
dataId = {'visit': 192350, 'detector': 175}
-datasetRefs = registry.queryDatasets(datasetType, dataId=dataId)
+datasetRefs = butler.query_datasets(datasetType, data_id=dataId)
for i, ref in enumerate(datasetRefs):
print(ref.dataId)
@@ -8338,18 +8346,18 @@ 2.2. Use a dataId with queryDatase
-In [19]:
+In [18]:
datasetType = 'calexp'
dataId = {'visit': 192350}
-datasetRefs = set(registry.queryDatasets(datasetType, dataId=dataId))
+datasetRefs = butler.query_datasets(datasetType, data_id=dataId)
for i, ref in enumerate(datasetRefs):
print(ref.dataId)
- if i > 2:
- print('...')
- break
+ if i > 5:
+ print('...')
+ break
print(f"Found {len(datasetRefs)} detectors")
@@ -8364,10 +8372,13 @@ 2.2. Use a dataId with queryDatase
-{instrument: 'LSSTCam-imSim', detector: 52, visit: 192350, band: 'i', physical_filter: 'i_sim_1.4', visit_system: 1}
-{instrument: 'LSSTCam-imSim', detector: 153, visit: 192350, band: 'i', physical_filter: 'i_sim_1.4', visit_system: 1}
-{instrument: 'LSSTCam-imSim', detector: 56, visit: 192350, band: 'i', physical_filter: 'i_sim_1.4', visit_system: 1}
-{instrument: 'LSSTCam-imSim', detector: 181, visit: 192350, band: 'i', physical_filter: 'i_sim_1.4', visit_system: 1}
+{instrument: 'LSSTCam-imSim', detector: 0, visit: 192350, band: 'i', physical_filter: 'i_sim_1.4', visit_system: 1}
+{instrument: 'LSSTCam-imSim', detector: 1, visit: 192350, band: 'i', physical_filter: 'i_sim_1.4', visit_system: 1}
+{instrument: 'LSSTCam-imSim', detector: 2, visit: 192350, band: 'i', physical_filter: 'i_sim_1.4', visit_system: 1}
+{instrument: 'LSSTCam-imSim', detector: 3, visit: 192350, band: 'i', physical_filter: 'i_sim_1.4', visit_system: 1}
+{instrument: 'LSSTCam-imSim', detector: 4, visit: 192350, band: 'i', physical_filter: 'i_sim_1.4', visit_system: 1}
+{instrument: 'LSSTCam-imSim', detector: 5, visit: 192350, band: 'i', physical_filter: 'i_sim_1.4', visit_system: 1}
+{instrument: 'LSSTCam-imSim', detector: 6, visit: 192350, band: 'i', physical_filter: 'i_sim_1.4', visit_system: 1}
...
Found 187 detectors
@@ -8382,10 +8393,51 @@ 2.2. Use a dataId with queryDatase
-The LSST Science Camera has 189 science detectors, total, but this visit is very near the edge of the DC2 simulation region (only 300 square degrees of sky).
-Note the use of the set
method in the previous cell.
-If you remove the set
command, you will find that queryDatasets
returns duplicate entries for some detectors.
-This is the result of a conscious design choice in order to to handle large results efficiently. In essence, the SQL queries that are being executed "under the hood" are not attempting to remove duplicate entries. You can find a more extensive discussion of duplicate query entries in the Middleware FAQ.
+The LSST Science Camera has 189 science detectors, total, but this visit is very near the edge of the DC2 simulation region (only 300 square degrees of sky), so not all detectors are within the dataset.
+2.2.1 Limiting the number of results¶
You can limit the number of query results that are returned by passing a "limit=N" argument to butler.query_datasets
. If you pass "limit=N", the query will return N results. If you instead add a minus sign in front of the number ("limit=-N"), the query will still return N results, but it will tell you that there are more results that were not returned.
+
+
+
+
+
+
+
+
+In [19]:
+
+
+datasetRefs = butler.query_datasets(datasetType, data_id=dataId, limit=-2)
+
+for i, ref in enumerate(datasetRefs):
+ print(ref.dataId)
+
+
+
+
+
+
+
+
+
+
+
+
+lsst.daf.butler._butler WARNING: More datasets are available than the requested limit of 2.
+
+
+
+
+
+{instrument: 'LSSTCam-imSim', detector: 0, visit: 192350, band: 'i', physical_filter: 'i_sim_1.4', visit_system: 1}
+{instrument: 'LSSTCam-imSim', detector: 1, visit: 192350, band: 'i', physical_filter: 'i_sim_1.4', visit_system: 1}
+
+
@@ -8399,7 +8451,7 @@ 2.2. Use a dataId with queryDatase
2.3. Use butler.get() with a datasetRef¶
One of the beauties of the Butler is that there is no need to know exactly where the data live in order to access it.
In previous notebooks we've seen how to pass a dataId to Butler.get to return an instance of the appropriate object.
When you already have a datasetRef, it is faster and more efficient to pass the datasetRef to Butler.get.
-Here we use Butler.get to retrieve the calexp and then get the detector Id from the calexp's properties.
+Use Butler.get to retrieve the calexps from the previous query, and then get the detector Id from the calexp's properties.
@@ -8413,10 +8465,7 @@ 2.3. Use butler.get() with a da
for i, ref in enumerate(datasetRefs):
calexp = butler.get(ref)
- print(i, ' calexp.detector.getId(): ', calexp.detector.getId())
- if i > 2:
- print('...')
- break
+ print(' calexp.detector.getId(): ', calexp.detector.getId())
0 calexp.detector.getId(): 52 -1 calexp.detector.getId(): 153 -2 calexp.detector.getId(): 56 -3 calexp.detector.getId(): 181 -... +calexp.detector.getId(): 0 + calexp.detector.getId(): 1
Optional: display the first four calexps retrieved from the Butler.
+Optional: display the calexps retrieved from the Butler.
As TAP is the recommended way to query the catalogs, the following basic, temporal, and spatial query examples are all for images (calexps).
-Our example above demonstrated a very simple use of queryDatasets
, but additional query terms can also be used, such as band and visit.
+
Our example above demonstrated a very simple use of query_datasets
, but additional query terms can also be used, such as band and visit.
When a query term is an equality, it can be specified as an argument like band=''
.
When a query term is an inequality, it can be specified with where
.
More details on Butler queries can be found here in the lsst.daf.butler documentation.
In the following cell, we query for a list of all calexps corresponding i-band observations of a single detector over a range of visits.
+In the following cell, we query for a list of all calexps corresponding to i-band observations of a single detector over a range of visits.
datasetRefs = registry.queryDatasets(datasetType='calexp', band='i', detector=175,
- where='visit > 192000 and visit < 193000')
+datasetRefs = butler.query_datasets(dataset_type='calexp', band='i', detector=175,
+ where='visit > 192000 and visit < 193000')
for i, ref in enumerate(datasetRefs):
print(ref.dataId)
@@ -8535,7 +8578,7 @@ 3.1. Basic image queries
-Optional: use the datasetRefs to retrieve the calexp image, and display the first four.
+Optional: use the datasetRefs to retrieve and display the first two calexp images.
@@ -8547,16 +8590,13 @@ 3.1. Basic image queriesIn [23]:
# for i, ref in enumerate(datasetRefs):
+# for i, ref in enumerate(datasetRefs[:2]):
# calexp = butler.get(ref)
# fig = plt.figure()
# display = afwDisplay.Display(frame=fig)
# display.scale('asinh', 'zscale')
# display.mtv(calexp.image)
# plt.show()
-# if i > 2:
-# print('...')
-# break
As a precursor to doing temporal and spatial queries below, we demonstrate the temporal and spatial metadata that can be retrieved for calexps via the Butler.
-Retrieving only the metadata (calexp.visitInfo, calexp.bbox, or calexp.wcs) can be faster than retreiving the full calexp, and then extracting the metadata from it.
-Print the full visitInfo record to screen.
+Retrieving only the metadata (calexp.visitInfo, calexp.bbox, or calexp.wcs) can be faster than retreiving the full calexp and then extracting the metadata from it.
+Print the full visitInfo record for the first datasetRef returned by the previous query.
for i, ref in enumerate(datasetRefs):
- visitInfo = butler.get('calexp.visitInfo', dataId=ref.dataId)
- print(visitInfo)
+visitInfo = butler.get('calexp.visitInfo', dataId=datasetRefs[0].dataId)
+print(visitInfo)
VisitInfo(exposureTime=30, darkTime=30, date=2022-09-15T09:07:20.140899826, UT1=nan, ERA=2.28122 rad, boresightRaDec=(53.6003547253, -32.7089000169), boresightAzAlt=(245.0397119707, +83.7529317472), boresightAirmass=1.00506, boresightRotAngle=3.47434 rad, rotType=1, observatory=-30.2446N, -70.7494E 2663, weather=Weather(nan, nan, 40), instrumentLabel='LSSTCam-imSim', id=192350, focusZ=nan, observationType='SKYEXP', scienceProgram='', observationReason='', object='', hasSimulatedContent=false) -VisitInfo(exposureTime=30, darkTime=30, date=2022-09-15T09:08:00.748900099, UT1=nan, ERA=2.28418 rad, boresightRaDec=(52.3636782613, -35.9958442960), boresightAzAlt=(227.6773698597, +81.0873436980), boresightAirmass=1.01087, boresightRotAngle=3.16411 rad, rotType=1, observatory=-30.2446N, -70.7494E 2663, weather=Weather(nan, nan, 40), instrumentLabel='LSSTCam-imSim', id=192351, focusZ=nan, observationType='SKYEXP', scienceProgram='', observationReason='', object='', hasSimulatedContent=false) -VisitInfo(exposureTime=30, darkTime=30, date=2022-09-15T09:09:22.915099862, UT1=nan, ERA=2.29017 rad, boresightRaDec=(50.8415002597, -42.6478842974), boresightAzAlt=(210.1019638007, +75.2390586556), boresightAirmass=1.03157, boresightRotAngle=2.8675 rad, rotType=1, observatory=-30.2446N, -70.7494E 2663, weather=Weather(nan, nan, 40), instrumentLabel='LSSTCam-imSim', id=192353, focusZ=nan, observationType='SKYEXP', scienceProgram='', observationReason='', object='', hasSimulatedContent=false) -VisitInfo(exposureTime=30, darkTime=30, date=2022-09-15T09:10:01.795099843, UT1=nan, ERA=2.29301 rad, boresightRaDec=(54.5372572359, -40.1834782290), boresightAzAlt=(206.1932111969, +78.7505015183), boresightAirmass=1.01802, boresightRotAngle=2.74269 rad, rotType=1, observatory=-30.2446N, -70.7494E 2663, weather=Weather(nan, nan, 40), instrumentLabel='LSSTCam-imSim', id=192354, focusZ=nan, observationType='SKYEXP', scienceProgram='', observationReason='', object='', hasSimulatedContent=false) -VisitInfo(exposureTime=30, darkTime=30, date=2022-09-15T09:10:40.761799838, UT1=nan, ERA=2.29585 rad, boresightRaDec=(56.2862239385, -35.0230765514), boresightAzAlt=(219.4345595929, +83.6964151142), boresightAirmass=1.00531, boresightRotAngle=2.92955 rad, rotType=1, observatory=-30.2446N, -70.7494E 2663, weather=Weather(nan, nan, 40), instrumentLabel='LSSTCam-imSim', id=192355, focusZ=nan, observationType='SKYEXP', scienceProgram='', observationReason='', object='', hasSimulatedContent=false) -VisitInfo(exposureTime=30, darkTime=30, date=2022-09-15T09:11:19.641799818, UT1=nan, ERA=2.29868 rad, boresightRaDec=(58.4357468320, -33.0205890574), boresightAzAlt=(220.8847083431, +86.2861387101), boresightAirmass=1.00171, boresightRotAngle=2.88967 rad, rotType=1, observatory=-30.2446N, -70.7494E 2663, weather=Weather(nan, nan, 40), instrumentLabel='LSSTCam-imSim', id=192356, focusZ=nan, observationType='SKYEXP', scienceProgram='', observationReason='', object='', hasSimulatedContent=false) -VisitInfo(exposureTime=30, darkTime=30, date=2022-09-15T09:12:02.755099887, UT1=nan, ERA=2.30183 rad, boresightRaDec=(55.7954543284, -41.4556164216), boresightAzAlt=(200.8290056154, +77.8760475227), boresightAirmass=1.02116, boresightRotAngle=2.58881 rad, rotType=1, observatory=-30.2446N, -70.7494E 2663, weather=Weather(nan, nan, 40), instrumentLabel='LSSTCam-imSim', id=192357, focusZ=nan, observationType='SKYEXP', scienceProgram='', observationReason='', object='', hasSimulatedContent=false) -VisitInfo(exposureTime=30, darkTime=30, date=2022-09-15T09:12:41.635099867, UT1=nan, ERA=2.30466 rad, boresightRaDec=(55.4352486275, -39.3319483539), boresightAzAlt=(207.6887058604, +79.5735769369), boresightAirmass=1.01538, boresightRotAngle=2.69869 rad, rotType=1, observatory=-30.2446N, -70.7494E 2663, weather=Weather(nan, nan, 40), instrumentLabel='LSSTCam-imSim', id=192358, focusZ=nan, observationType='SKYEXP', scienceProgram='', observationReason='', object='', hasSimulatedContent=false)
Print information from the visitInfo: the date, exposure time, and the boresight (the pointing coordinates of the telescope).
+Print information from the visitInfo for all query results: the date, exposure time, and the boresight (the pointing coordinates of the telescope).
Print spatial information from the bounding box (bbox) and world coordinate system (wcs) metadata: the four corners of the image.
+Print spatial information from the bounding box (bbox) and world coordinate system (wcs) metadata: the four corners of the image. Note that the XY coordinates of the image corners must be converted to RA, Dec using the wcs.pixelToSky method.
for i, ref in enumerate(datasetRefs):
bbox = butler.get('calexp.bbox', dataId=ref.dataId)
wcs = butler.get('calexp.wcs', dataId=ref.dataId)
- crnr_ra, crnr_dec = get_corners_radec(wcs, bbox)
+ corners_xy = bbox.getCorners()
tmp = ''
- for c in range(4):
- tmp += f'({crnr_ra[c]:.3f},{crnr_dec[c]:.3f}) '
+ for corn in corners_xy:
+ radec = wcs.pixelToSky(corn.x, corn.y)
+ tmp += f'({radec.getRa().asDegrees():.4f}, {radec.getDec().asDegrees():.4f}) '
print(i, tmp)
0 (52.963,-33.900) (52.875,-34.109) (53.133,-34.184) (53.221,-33.974) -1 (52.188,-37.293) (52.182,-37.514) (52.467,-37.519) (52.473,-37.297) -2 (51.183,-43.928) (51.268,-44.141) (51.571,-44.078) (51.484,-43.865) -3 (55.075,-41.423) (55.193,-41.626) (55.470,-41.536) (55.352,-41.333) -4 (56.492,-36.317) (56.551,-36.533) (56.826,-36.484) (56.766,-36.268) -5 (58.699,-34.306) (58.767,-34.521) (59.032,-34.463) (58.963,-34.249) -6 (56.596,-42.617) (56.757,-42.804) (57.017,-42.682) (56.855,-42.496) -7 (56.038,-40.552) (56.165,-40.751) (56.433,-40.652) (56.305,-40.453) +0 (52.9633, -33.8997) (53.2206, -33.9742) (53.1326, -34.1836) (52.8748, -34.1089) +1 (52.1884, -37.2926) (52.4725, -37.2974) (52.4670, -37.5191) (52.1821, -37.5143) +2 (51.1828, -43.9284) (51.4842, -43.8655) (51.5706, -44.0783) (51.2683, -44.1414) +3 (55.0753, -41.4227) (55.3518, -41.3328) (55.4699, -41.5361) (55.1928, -41.6262) +4 (56.4921, -36.3167) (56.7660, -36.2679) (56.8258, -36.4844) (56.5513, -36.5333) +5 (58.6988, -34.3065) (58.9634, -34.2488) (59.0323, -34.4632) (58.7671, -34.5209) +6 (56.5957, -42.6167) (56.8548, -42.4955) (57.0168, -42.6825) (56.7573, -42.8040) +7 (56.0375, -40.5519) (56.3048, -40.4529) (56.4331, -40.6520) (56.1653, -40.7513)
-Tip! In the case where metadata is desired for many images at once, you can avoid the time-consuming use of butler.get for individual dataIds by retrieving expanded datasetRefs.
+Tip! In the case where metadata is desired for many images at once, you can avoid the time-consuming use of butler.get for individual dataIds by using the "with_dimension_records" keyword when retrieving datasetRefs.
datasetRefs = butler.registry.queryDatasets(datasetType='calexp', band='i', detector=175,
- where='visit > 192000 and visit < 193000')
-expanded_datasetRefs = datasetRefs.expanded()
+datasetRefs = butler.query_datasets(dataset_type='calexp', band='i', detector=175,
+ where='visit > 192000 and visit < 193000', with_dimension_records=True)
+
+for ref in datasetRefs:
+ print(ref)
calexp@{instrument: 'LSSTCam-imSim', detector: 175, visit: 192350, band: 'i', physical_filter: 'i_sim_1.4', visit_system: 1} [sc=ExposureF] (run=2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20211218T144437Z id=8a953c03-21bd-4878-bfa6-94dbf628ea81) +calexp@{instrument: 'LSSTCam-imSim', detector: 175, visit: 192351, band: 'i', physical_filter: 'i_sim_1.4', visit_system: 1} [sc=ExposureF] (run=2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20211218T144437Z id=86a9abef-fc5f-46f0-bc2a-e9d9939dc22f) +calexp@{instrument: 'LSSTCam-imSim', detector: 175, visit: 192353, band: 'i', physical_filter: 'i_sim_1.4', visit_system: 1} [sc=ExposureF] (run=2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20211218T144437Z id=e314c313-9298-4f8e-8800-58617f945ee0) +calexp@{instrument: 'LSSTCam-imSim', detector: 175, visit: 192354, band: 'i', physical_filter: 'i_sim_1.4', visit_system: 1} [sc=ExposureF] (run=2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20211218T144437Z id=39208c7f-62d2-4e2c-bf5c-f8e628f3e89b) +calexp@{instrument: 'LSSTCam-imSim', detector: 175, visit: 192355, band: 'i', physical_filter: 'i_sim_1.4', visit_system: 1} [sc=ExposureF] (run=2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20211218T144437Z id=d907c683-0856-4f3a-ade8-96c454698a2a) +calexp@{instrument: 'LSSTCam-imSim', detector: 175, visit: 192356, band: 'i', physical_filter: 'i_sim_1.4', visit_system: 1} [sc=ExposureF] (run=2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20211218T144437Z id=308754f0-4d48-4be8-8df9-27408fdab3c1) +calexp@{instrument: 'LSSTCam-imSim', detector: 175, visit: 192357, band: 'i', physical_filter: 'i_sim_1.4', visit_system: 1} [sc=ExposureF] (run=2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20211218T144437Z id=8f31446c-8351-4264-a844-a693f7e54fbc) +calexp@{instrument: 'LSSTCam-imSim', detector: 175, visit: 192358, band: 'i', physical_filter: 'i_sim_1.4', visit_system: 1} [sc=ExposureF] (run=2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20211218T144437Z id=9907f51e-74ec-4049-be12-0178bccfb7b9) ++
Print the id, exposure time, timespan, and bounding box for each datasetRef:
+for i, ref in enumerate(expanded_datasetRefs):
+for i, ref in enumerate(datasetRefs):
record = ref.dataId.records["visit"]
print(i, record.id, record.exposure_time, record.timespan, record.region.getBoundingBox())
@@ -8898,9 +8964,9 @@ 3.2. Temporal image queriesIn [32]:
datasetRefs = registry.queryDatasets("calexp",
- where="visit.timespan OVERLAPS my_timespan",
- bind={"my_timespan": timespan})
+datasetRefs = butler.query_datasets("calexp",
+ where="visit.timespan OVERLAPS my_timespan",
+ bind={"my_timespan": timespan})
{instrument: 'LSSTCam-imSim', detector: 39, visit: 192356, band: 'i', physical_filter: 'i_sim_1.4', visit_system: 1} -{instrument: 'LSSTCam-imSim', detector: 20, visit: 192356, band: 'i', physical_filter: 'i_sim_1.4', visit_system: 1} -{instrument: 'LSSTCam-imSim', detector: 48, visit: 192356, band: 'i', physical_filter: 'i_sim_1.4', visit_system: 1} -{instrument: 'LSSTCam-imSim', detector: 57, visit: 192356, band: 'i', physical_filter: 'i_sim_1.4', visit_system: 1} -{instrument: 'LSSTCam-imSim', detector: 54, visit: 192356, band: 'i', physical_filter: 'i_sim_1.4', visit_system: 1} -{instrument: 'LSSTCam-imSim', detector: 40, visit: 192356, band: 'i', physical_filter: 'i_sim_1.4', visit_system: 1} -{instrument: 'LSSTCam-imSim', detector: 51, visit: 192356, band: 'i', physical_filter: 'i_sim_1.4', visit_system: 1} -{instrument: 'LSSTCam-imSim', detector: 21, visit: 192356, band: 'i', physical_filter: 'i_sim_1.4', visit_system: 1} +{instrument: 'LSSTCam-imSim', detector: 0, visit: 192350, band: 'i', physical_filter: 'i_sim_1.4', visit_system: 1} +{instrument: 'LSSTCam-imSim', detector: 0, visit: 192354, band: 'i', physical_filter: 'i_sim_1.4', visit_system: 1} +{instrument: 'LSSTCam-imSim', detector: 0, visit: 192355, band: 'i', physical_filter: 'i_sim_1.4', visit_system: 1} +{instrument: 'LSSTCam-imSim', detector: 0, visit: 192356, band: 'i', physical_filter: 'i_sim_1.4', visit_system: 1} +{instrument: 'LSSTCam-imSim', detector: 0, visit: 192357, band: 'i', physical_filter: 'i_sim_1.4', visit_system: 1} +{instrument: 'LSSTCam-imSim', detector: 0, visit: 192358, band: 'i', physical_filter: 'i_sim_1.4', visit_system: 1} +{instrument: 'LSSTCam-imSim', detector: 0, visit: 192359, band: 'i', physical_filter: 'i_sim_1.4', visit_system: 1} +{instrument: 'LSSTCam-imSim', detector: 1, visit: 192350, band: 'i', physical_filter: 'i_sim_1.4', visit_system: 1} ... Found 1636 calexps@@ -9069,7 +9135,9 @@3.3. Spatial image queriesIn [36]:
for ref in set(registry.queryDatasets("deepCoadd", dataId=dataId)):
+refs = butler.query_datasets("deepCoadd", data_id=dataId, order_by='tract')
+
+for ref in refs:
print(ref)
deepCoadd@{band: 'i', skymap: 'DC2', tract: 4225, patch: 10} [sc=ExposureF] (run=2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_19/20220221T031952Z id=55cca055-8f22-440f-8202-8ab153107393) -deepCoadd@{band: 'i', skymap: 'DC2', tract: 4225, patch: 3} [sc=ExposureF] (run=2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_19/20220221T031952Z id=0dc74194-599c-45ee-affd-3ffb0f684061) -deepCoadd@{band: 'i', skymap: 'DC2', tract: 4225, patch: 2} [sc=ExposureF] (run=2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_19/20220221T031952Z id=b7d97586-7797-4766-8d95-b9d1a72cf0b8) +deepCoadd@{band: 'i', skymap: 'DC2', tract: 4024, patch: 47} [sc=ExposureF] (run=2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_17/20220220T035232Z id=4ce0e04c-6ff2-47ec-8cab-f62c2ae3b629) deepCoadd@{band: 'i', skymap: 'DC2', tract: 4024, patch: 48} [sc=ExposureF] (run=2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_17/20220220T035232Z id=88d5831d-f06e-4509-90ef-f09368de7765) +deepCoadd@{band: 'i', skymap: 'DC2', tract: 4225, patch: 2} [sc=ExposureF] (run=2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_19/20220221T031952Z id=b7d97586-7797-4766-8d95-b9d1a72cf0b8) +deepCoadd@{band: 'i', skymap: 'DC2', tract: 4225, patch: 3} [sc=ExposureF] (run=2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_19/20220221T031952Z id=0dc74194-599c-45ee-affd-3ffb0f684061) deepCoadd@{band: 'i', skymap: 'DC2', tract: 4225, patch: 9} [sc=ExposureF] (run=2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_19/20220221T031952Z id=12260e6c-5ff6-4f8c-8e79-8d38fa178d36) -deepCoadd@{band: 'i', skymap: 'DC2', tract: 4024, patch: 47} [sc=ExposureF] (run=2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_17/20220220T035232Z id=4ce0e04c-6ff2-47ec-8cab-f62c2ae3b629) +deepCoadd@{band: 'i', skymap: 'DC2', tract: 4225, patch: 10} [sc=ExposureF] (run=2.2i/runs/DP0.2/v23_0_1/PREOPS-905/step3_19/20220221T031952Z id=55cca055-8f22-440f-8202-8ab153107393)
calexp_wcs = butler.get('calexp.wcs', dataId=dataId)
calexp_bbox = butler.get('calexp.bbox', dataId=dataId)
-calexp_corners_ra, calexp_corners_dec = get_corners_radec(calexp_wcs, calexp_bbox)
+
+calexp_corners_ra = []
+calexp_corners_dec = []
+
+for corn in calexp_bbox.getCorners():
+ radec = calexp_wcs.pixelToSky(corn.x, corn.y)
+ calexp_corners_ra.append(radec.getRa().asDegrees())
+ calexp_corners_dec.append(radec.getDec().asDegrees())
+
+calexp_corners_ra.append(calexp_corners_ra[0])
+calexp_corners_dec.append(calexp_corners_dec[0])
fig = plt.figure(figsize=(6, 6))
-xvals = [calexp_corners_ra[0], calexp_corners_ra[1], calexp_corners_ra[2], \
- calexp_corners_ra[3], calexp_corners_ra[0]]
-yvals = [calexp_corners_dec[0], calexp_corners_dec[1], calexp_corners_dec[2], \
- calexp_corners_dec[3], calexp_corners_dec[0]]
-plt.plot(xvals, yvals, ls='solid', color='grey', label='visit detector')
-del xvals, yvals
+plt.plot(calexp_corners_ra, calexp_corners_dec, ls='solid', color='grey', label='visit detector')
-for r, ref in enumerate(set(registry.queryDatasets("deepCoadd", dataId=dataId))):
+for r, ref in enumerate(set(butler.query_datasets("deepCoadd", data_id=dataId))):
deepCoadd_dataId = ref.dataId
str_tract_patch = '(' + str(ref.dataId['tract']) + ', ' + str(ref.dataId['patch'])+')'
deepCoadd_wcs = butler.get('deepCoadd.wcs', dataId=deepCoadd_dataId)
deepCoadd_bbox = butler.get('deepCoadd.bbox', dataId=deepCoadd_dataId)
- deepCoadd_corners_ra, deepCoadd_corners_dec = get_corners_radec(deepCoadd_wcs, deepCoadd_bbox)
- xvals = [deepCoadd_corners_ra[0], deepCoadd_corners_ra[1], deepCoadd_corners_ra[2], \
- deepCoadd_corners_ra[3], deepCoadd_corners_ra[0]]
- yvals = [deepCoadd_corners_dec[0], deepCoadd_corners_dec[1], deepCoadd_corners_dec[2], \
- deepCoadd_corners_dec[3], deepCoadd_corners_dec[0]]
- plt.plot(xvals, yvals, ls='solid', lw=1, label=str_tract_patch)
- del xvals, yvals
- del deepCoadd_dataId, deepCoadd_wcs, deepCoadd_bbox
- del deepCoadd_corners_ra, deepCoadd_corners_dec
+ deepCoadd_corners_ra = []
+ deepCoadd_corners_dec = []
+
+ for corn in deepCoadd_bbox.getCorners():
+ radec = deepCoadd_wcs.pixelToSky(corn.x, corn.y)
+ deepCoadd_corners_ra.append(radec.getRa().asDegrees())
+ deepCoadd_corners_dec.append(radec.getDec().asDegrees())
+
+ deepCoadd_corners_ra.append(deepCoadd_corners_ra[0])
+ deepCoadd_corners_dec.append(deepCoadd_corners_dec[0])
+
+ plt.plot(deepCoadd_corners_ra, deepCoadd_corners_dec, ls='solid', lw=1, label=str_tract_patch)
plt.xlabel('RA')
plt.ylabel('Dec')
@@ -9171,7 +9247,7 @@ 3.3. Spatial image queries
-
+
Figure 1: The bounding box of one detector from a single visit image (a
+and six of the nearestcalexp
) is drawn in gray, -and six of the nearestdeepCoadd
patches are drawn in colors (as in legend), all but one (purple) overlapping thecalexp
.deepCoadd
patches are drawn in colors (as in legend), all but one overlapping thecalexp
.
Arbitrary spatial queries are not supported at this time, such as the "POINT() IN (REGION)" example found in this Butler queries documentation. -In other words, at this time it is only possible to do queries involving regions that are already "in" the data repository, either because they are hierarchical triangular mesh (HTM) pixel regions or because they are tract/patch/visit/visit+detector regions.
-Thus, for this example we use the set of dimensions that correspond to different levels of the HTM pixelization of the sky (HTM primer).
-The process is to transform a region or point into one or more HTM identifiers (HTM IDs), and then create a query using the HTM ID as the spatial dataId.
-The lsst.sphgeom
library supports region objects and HTM pixelization in the LSST Science Pipelines.
Using the lsst.sphgeom
package, initialize a sky pixelization to level 10 (the level at which one sky pixel is about five arcmin radius).
Often one wants to know what images overlap a given point on the sky. Such spatial queries can be accomplished using the "region OVERLAPS POINT(ra, dec)" syntax (e.g., see this Butler queries documentation). Let us see how this works.
+Specify the desired sky coordinate for the search. Below, the RA and Dec could be user-specified, but here we use the telescope boresight accessed from the calexp visitInfo retrieved above.
level = 10 # the resolution of the HTM grid
-pixelization = lsst.sphgeom.HtmPixelization(level)
+ra, dec = visitInfo.boresightRaDec
Find the HTM ID for a desired sky coordinate. Below, the RA and Dec could be user-specified, but here we use the telescope boresight accessed from the calexp visitInfo retrieved above.
+Specify a small timespan for the query:
ra, dec = visitInfo.boresightRaDec
-htm_id = pixelization.index(
- lsst.sphgeom.UnitVector3d(
- lsst.sphgeom.LonLat.fromDegrees(ra.asDegrees(), dec.asDegrees())
- )
-)
+small_timespan = dafButler.Timespan(time - minute, time + minute)
Obtain and print the scale to provide a sense of the size of the sky pixelization being used. The opening angle for the circle is "the angle between its center vector and points on its boundary", i.e., the radius (from the documentation for .getOpeningAngle in doxygen).
+Pass the RA and Dec to the query_datasets command, using "visit_detector_region.region OVERLAPS POINT(ra, dec)" in the "where" clause of the query. Also apply the same timespan constraints as above.
circle = pixelization.triangle(htm_id).getBoundingCircle()
-scale = circle.getOpeningAngle().asDegrees()*3600.
-level = pixelization.getLevel()
-print(f'HTM ID={htm_id} at level={level} is bounded by a circle of radius ~{scale:0.2f} arcsec.')
+datasetRefs = butler.query_datasets("calexp", where="visit.timespan OVERLAPS my_timespan AND \
+ visit_detector_region.region OVERLAPS POINT(ra, dec)",
+ bind={"my_timespan": small_timespan, "ra": ra.asDegrees(), "dec": dec.asDegrees()})
+
+print(datasetRefs)
+
+print(f"\nFound {len(datasetRefs)} calexps")
HTM ID=9415276 at level=10 is bounded by a circle of radius ~279.99 arcsec. +[DatasetRef(DatasetType('calexp', {band, instrument, detector, physical_filter, visit_system, visit}, ExposureF), {instrument: 'LSSTCam-imSim', detector: 94, visit: 192350, band: 'i', physical_filter: 'i_sim_1.4', visit_system: 1}, run='2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20211218T041605Z', id=1a773da5-9db5-4413-8457-c194bfe52b28)] + +Found 1 calexps
small_timespan = dafButler.Timespan(time - minute, time + minute)
-
Thus, with the above query, we have uniquely recovered the visit for our desired temporal and spatial constraints.
Pass the htm_id to the queryDatasets command, and also apply the same timespan constraints as above.
+You may have wondered how we knew to use "visit_detector_region.region" in the above query. Constraints provided in the "where" clause of butler.query_datasets
can be based on any of the attributes associated with each dimension
or element
(elements can be thought of as joins or combinations of dimension traits).
See more about querying dimension records here.
+First, list the available dimensions and elements:
datasetRefs = registry.queryDatasets("calexp", htm20=htm_id,
- where="visit.timespan OVERLAPS my_timespan",
- bind={"my_timespan": small_timespan})
-
-for i, ref in enumerate(datasetRefs):
- print(ref)
- if i > 6:
- print('...')
- break
-
-print(f"Found {len(list(datasetRefs))} calexps")
+print("Dimensions:\n", butler.dimensions.getStaticDimensions())
+print("\nElements:\n", butler.dimensions.getStaticElements())
calexp@{instrument: 'LSSTCam-imSim', detector: 94, visit: 192350, band: 'i', physical_filter: 'i_sim_1.4', visit_system: 1} [sc=ExposureF] (run=2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20211218T041605Z id=1a773da5-9db5-4413-8457-c194bfe52b28) -Found 1 calexps +Dimensions: + {band, healpix1, healpix2, healpix3, healpix4, healpix5, healpix6, healpix7, healpix8, healpix9, healpix10, healpix11, healpix12, healpix13, healpix14, healpix15, healpix16, healpix17, htm1, htm2, htm3, htm4, htm5, htm6, htm7, htm8, htm9, htm10, htm11, htm12, htm13, htm14, htm15, htm16, htm17, htm18, htm19, htm20, htm21, htm22, htm23, htm24, instrument, skymap, detector, physical_filter, subfilter, tract, visit_system, exposure, patch, visit} + +Elements: + {band, healpix1, healpix2, healpix3, healpix4, healpix5, healpix6, healpix7, healpix8, healpix9, healpix10, healpix11, healpix12, healpix13, healpix14, healpix15, healpix16, healpix17, htm1, htm2, htm3, htm4, htm5, htm6, htm7, htm8, htm9, htm10, htm11, htm12, htm13, htm14, htm15, htm16, htm17, htm18, htm19, htm20, htm21, htm22, htm23, htm24, instrument, skymap, detector, physical_filter, subfilter, tract, visit_system, exposure, patch, visit, visit_definition, visit_detector_region}
Thus, with the above query, we have uniquely recovered the visit for our desired temporal and spatial constraints.
-Note that since we used the boresight as the RA, Dec for the htm_id
and not the center of detector 175, a different detector (one in the center of the focal plane) has been returned - but the point here is that it is the same visit, 192350.
Note that if a smaller HTM level is used (like 7), which is a larger sky pixel (~2200 arcseconds), the above query will return many more visits and detectors which overlap with that larger region. Try it and see!
-The level 7 HTM IDs that overlap each visit and detector are already loaded into the registry and can accessed directly using queryDataIds.
-This will be a faster and more efficient way to look-up overlapping regions, but use of queryDataIds
is a less general approach that is not appropriate for all cases.
-The documentation page for queryDataIds
outlines when not to use it.
Note that these are the same except for the additional two entries at the end of the "elements" list.
+For an example dimension and element, use their "schema" attribute to see what fields are associated with them:
for i, data_id in enumerate(registry.queryDataIds("htm7", where="visit = 192350 and detector = 175")):
- print(data_id)
+print(butler.dimensions["exposure"].schema)
+print("\n", butler.dimensions.elements["visit_detector_region"].schema)
{htm7: 147116} -{htm7: 147119} +exposure: + instrument: string + id: int + physical_filter: string + obs_id: string + exposure_time: float + Duration of the exposure with shutter open (seconds). + dark_time: float + Duration of the exposure with shutter closed (seconds). + observation_type: string + The observation type of this exposure (e.g. dark, bias, science). + observation_reason: string + The reason this observation was taken. (e.g. science, filter scan, + unknown). + day_obs: int + Day of observation as defined by the observatory (YYYYMMDD + format). + seq_num: int + Counter for the observation within a larger sequence. Context of + the sequence number is observatory specific. Can be a global + counter or counter within day_obs. + group_name: string + String group identifier associated with this exposure by the + acquisition system. + group_id: int + Integer group identifier associated with this exposure by the + acquisition system. + target_name: string + Object of interest for this observation or survey field name. + science_program: string + Observing program (survey, proposal, engineering project) + identifier. + tracking_ra: float + Tracking ICRS Right Ascension of boresight in degrees. Can be NULL + for observations that are not on sky. + tracking_dec: float + Tracking ICRS Declination of boresight in degrees. Can be NULL for + observations that are not on sky. + sky_angle: float + Angle of the instrument focal plane on the sky in degrees. Can be + NULL for observations that are not on sky, or for observations + where the sky angle changes during the observation. + zenith_angle: float + Angle in degrees from the zenith at the start of the exposure. + timespan: timespan + + visit_detector_region: + instrument: string + detector: int + visit: int + region: region
These "fields" contain information that can be used in query constraints.
+The query_data_ids
method is a less general approach that will return the combinations of dimensions that could be used to identify datasets. The documentation page for query_data_ids
outlines when not to use it.
Use it to find the dataIds overlapping the small timespan defined above:
+datasetRefs = registry.queryDatasets("calexp", htm7=147116,
- where="visit.timespan OVERLAPS my_timespan",
- bind={"my_timespan": small_timespan})
-
-for i, ref in enumerate(datasetRefs):
- print(ref)
- if i > 6:
- print('...')
- break
-
-print(f"Found {len(list(datasetRefs))} calexps that overlap with htm7 = 147116")
+for i, data_id in enumerate(butler.query_data_ids("visit", where="visit.timespan OVERLAPS my_timespan",
+ bind={"my_timespan": small_timespan})):
+ print(data_id)
calexp@{instrument: 'LSSTCam-imSim', detector: 18, visit: 192351, band: 'i', physical_filter: 'i_sim_1.4', visit_system: 1} [sc=ExposureF] (run=2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20211218T002844Z id=9521954c-a94d-48bc-a6c7-cc1cde45b4f7) -calexp@{instrument: 'LSSTCam-imSim', detector: 19, visit: 192351, band: 'i', physical_filter: 'i_sim_1.4', visit_system: 1} [sc=ExposureF] (run=2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20211218T002844Z id=27a310e8-d3bb-476d-9ae4-be7c5332feed) -calexp@{instrument: 'LSSTCam-imSim', detector: 20, visit: 192351, band: 'i', physical_filter: 'i_sim_1.4', visit_system: 1} [sc=ExposureF] (run=2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20211218T002844Z id=1cca6eea-5eb9-4c85-8882-a9b0a6d86f1d) -calexp@{instrument: 'LSSTCam-imSim', detector: 139, visit: 192350, band: 'i', physical_filter: 'i_sim_1.4', visit_system: 1} [sc=ExposureF] (run=2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20211218T144437Z id=29ec97bc-58bb-4ace-a054-9b3ce60561af) -calexp@{instrument: 'LSSTCam-imSim', detector: 140, visit: 192350, band: 'i', physical_filter: 'i_sim_1.4', visit_system: 1} [sc=ExposureF] (run=2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20211218T144437Z id=8a20e299-f318-4a54-8d57-f6d5aec056e1) -calexp@{instrument: 'LSSTCam-imSim', detector: 142, visit: 192350, band: 'i', physical_filter: 'i_sim_1.4', visit_system: 1} [sc=ExposureF] (run=2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20211218T144437Z id=ec97c46f-4fee-45cb-9185-f5b4224c7ef9) -calexp@{instrument: 'LSSTCam-imSim', detector: 143, visit: 192350, band: 'i', physical_filter: 'i_sim_1.4', visit_system: 1} [sc=ExposureF] (run=2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20211218T144437Z id=60d261b3-c4ba-4a85-92c8-586528383dc1) -calexp@{instrument: 'LSSTCam-imSim', detector: 150, visit: 192350, band: 'i', physical_filter: 'i_sim_1.4', visit_system: 1} [sc=ExposureF] (run=2.2i/runs/DP0.2/v23_0_0_rc5/PREOPS-905/20211218T144437Z id=bed30484-e1eb-42cb-9236-c8393132ab6b) -... -Found 22 calexps that overlap with htm7 = 147116 +{instrument: 'LSSTCam-imSim', visit: 192352, band: 'i', physical_filter: 'i_sim_1.4', visit_system: 1} +{instrument: 'LSSTCam-imSim', visit: 192351, band: 'i', physical_filter: 'i_sim_1.4', visit_system: 1} +{instrument: 'LSSTCam-imSim', visit: 192350, band: 'i', physical_filter: 'i_sim_1.4', visit_system: 1}
The recommended method for querying and retrieving catalog data is to use the TAP service, as demonstrated in other tutorials. -However, it is also possible to query catalog data using the same HTM ID and same temporal constraints as used for images, above.
+However, it is also possible to query catalog data using the same spatial and temporal constraints as used above for images.The Butler's spatial reasoning is designed to work well for regions the size of full data products, like detector- or patch-level images and catalogs, and it's a poor choice for smaller-scale searches.
-The following search is a bit slow in part because queryDatasets
searches for all src
datasets that overlap a larger region and then filters the results down to the specified HTM ID pixel.
query_datasets
searches for all src
datasets that overlap a larger region and then filters the results down to the specified region.
for i, src_ref in enumerate(registry.queryDatasets("source", htm20=htm_id, band="i",
- where="visit.timespan OVERLAPS my_timespan",
- bind={"my_timespan": small_timespan})):
+for i, src_ref in enumerate(butler.query_datasets("source", band="i",
+ where="visit.timespan OVERLAPS my_timespan AND \
+ visit_detector_region.region OVERLAPS POINT(ra, dec)",
+ bind={"my_timespan": small_timespan, "ra": ra.asDegrees(), "dec": dec.asDegrees()})):
print(src_ref)
sources = butler.get(src_ref)
print('Number of sources: ', len(sources))
@@ -9534,7 +9652,7 @@ 3.4. Catalog spatial and temp
-In [47]:
+In [46]:
sources
@@ -9548,7 +9666,7 @@ 3.4. Catalog spatial and temp
-Out[47]:
+Out[46]: