201.04. DiaObject table#
201.4. DiaObject table¶
For the Rubin Science Platform at data.lsst.cloud.
Data Release: Data Preview 2
Container Size: Large
LSST Science Pipelines version: r30.0.10
Last verified to run: 2026-07-22
Repository: github.com/lsst/tutorial-notebooks
DOI: 10.11578/rubin/dc.20250909.20
Learning objective: To understand the contents of the DiaObject table and how to access it.
LSST data products: DiaObject
Packages: lsst.rsp, lsst.daf.butler
Credit: Originally developed by the Rubin Community Science team with feedback from Eric Bellm. Please consider acknowledging them if this notebook is used for the preparation of journal articles, software releases, or other notebooks.
Get Support: Everyone is encouraged to ask questions or raise issues in the Support Category of the Rubin Community Forum. Rubin staff will respond to all questions posted there.
1. Introduction¶
The DiaObject table contains $ugrizy$ light curve summary statistics for static-sky time-varying astronomical objects.
These light curve summary statistics (e.g., mean, standard deviation in the flux measurements) are primarily derived from the difference-image flux measurements, and only for visits for which the object was detected at $>5\sigma$ in the difference image (i.e., not from forced photometry; from the DiaSource table, not from ForcedSourceOnDiaObject table).
Difference-image detections (called "diaSources" and stored in the DiaSource table) are associated into "diaObjects" using a 1-arcsecond radius.
- TAP table name:
dp2.DiaObject - butler table name:
dia_object - columns: 64
- rows: 232,004,216
Related tutorials: The TAP and butler data access services are demonstrated in the 100-level "How to" tutorials. There are a 200-level tutorials on the difference images and the DiaSource and ForcedSourceOnDiaObject tables.
1.1. Import packages¶
Import standard python packages numpy, matplotlib, and astropy.
From the lsst package, import modules for the TAP service and the butler.
import re
import numpy as np
import matplotlib.pyplot as plt
from lsst.rsp import RSPDiscovery
from lsst.daf.butler import Butler
1.2. Define parameters and functions¶
Create an instance of the TAP service, and assert that it exists.
discovery = RSPDiscovery("dp2")
tap_service = discovery.get_tap_client()
Create an instance of the Rubin data butler, and assert that it exists.
butler = Butler("dp2", collections="dp2")
2. Schema (columns)¶
To browse the table schema visit the Rubin schema browser, or use the TAP service via the Portal Aspect or as demonstrated in Section 2.1.
2.1. Retrieve table schema¶
To retrieve the table schema, define a query for the schema columns of the DiaObject table and run the query job.
query = "SELECT column_name, datatype, description, unit " \
"FROM tap_schema.columns " \
"WHERE table_name = 'dp2.DiaObject'"
job = tap_service.submit_job(query)
job.run()
job.wait(phases=['COMPLETED', 'ERROR'])
print('Job phase is', job.phase)
if job.phase == 'ERROR':
job.raise_if_error()
assert job.phase == 'COMPLETED'
Job phase is COMPLETED
Retrieve the query results and display them as an astropy table with the to_table() attribute.
results = job.fetch_result().to_table()
results
| column_name | datatype | description | unit |
|---|---|---|---|
| str64 | str64 | str512 | str64 |
| diaObjectId | long | Unique identifier of this DiaObject. | |
| ra | double | Right Ascension coordinate of the position of the DiaObject. | deg |
| dec | double | Declination coordinate of the position of the DiaObject. | deg |
| u_psfFluxMean | double | Weighted mean point-source model magnitude for u filter. | nJy |
| u_psfFluxMeanErr | double | Standard error of u_psfFluxMean. | nJy |
| u_psfFluxSigma | double | Standard deviation of the distribution of u_psfFlux. | nJy |
| u_psfFluxNdata | int | The number of u-band data points. | |
| g_psfFluxMean | double | Weighted mean point-source model magnitude for g filter. | nJy |
| g_psfFluxMeanErr | double | Standard error of g_psfFluxMean. | nJy |
| g_psfFluxSigma | double | Standard deviation of the distribution of g_psfFlux. | nJy |
| g_psfFluxNdata | int | The number of g-band data points. | |
| r_psfFluxMean | double | Weighted mean point-source model magnitude for r filter. | nJy |
| r_psfFluxMeanErr | double | Standard error of r_psfFluxMean. | nJy |
| r_psfFluxSigma | double | Standard deviation of the distribution of r_psfFlux. | nJy |
| r_psfFluxNdata | int | The number of r-band data points. | |
| i_psfFluxMean | double | Weighted mean point-source model magnitude for i filter. | nJy |
| i_psfFluxMeanErr | double | Standard error of i_psfFluxMean. | nJy |
| i_psfFluxSigma | double | Standard deviation of the distribution of i_psfFlux. | nJy |
| i_psfFluxNdata | int | The number of i-band data points. | |
| z_psfFluxMean | double | Weighted mean point-source model magnitude for z filter. | nJy |
| z_psfFluxMeanErr | double | Standard error of z_psfFluxMean. | nJy |
| z_psfFluxSigma | double | Standard deviation of the distribution of z_psfFlux. | nJy |
| ... | ... | ... | ... |
| u_psfFluxErrMean | float | Mean of the u band flux errors. | nJy |
| g_psfFluxMin | double | Minimum observed g band fluxes. | nJy |
| g_psfFluxMax | double | Maximum observed g band fluxes. | nJy |
| g_psfFluxMaxSlope | double | Maximum slope between g band flux obsevations max(delta_flux/delta_time). | nJy/d |
| g_psfFluxErrMean | float | Mean of the g band flux errors. | nJy |
| r_psfFluxMin | double | Minimum observed r band fluxes. | nJy |
| r_psfFluxMax | double | Maximum observed r band fluxes. | nJy |
| r_psfFluxMaxSlope | double | Maximum slope between r band flux obsevations max(delta_flux/delta_time). | nJy/d |
| r_psfFluxErrMean | float | Mean of the r band flux errors. | nJy |
| i_psfFluxMin | double | Minimum observed i band fluxes. | nJy |
| i_psfFluxMax | double | Maximum observed i band fluxes. | nJy |
| i_psfFluxMaxSlope | double | Maximum slope between i band flux obsevations max(delta_flux/delta_time). | nJy/d |
| i_psfFluxErrMean | float | Mean of the i band flux errors. | nJy |
| z_psfFluxMin | double | Minimum observed z band fluxes. | nJy |
| z_psfFluxMax | double | Maximum observed z band fluxes. | nJy |
| z_psfFluxMaxSlope | double | Maximum slope between z band flux obsevations max(delta_flux/delta_time). | nJy/d |
| z_psfFluxErrMean | float | Mean of the z band flux errors. | nJy |
| y_psfFluxMin | double | Minimum observed y band fluxes. | nJy |
| y_psfFluxMax | double | Maximum observed y band fluxes. | nJy |
| y_psfFluxMaxSlope | double | Maximum slope between y band flux obsevations max(delta_flux/delta_time). | nJy/d |
| y_psfFluxErrMean | float | Mean of the y band flux errors. | nJy |
| nDiaSources | long | Total number of DiaSources associated with this DiaObject. |
The table displayed above has been truncated.
Option to print every column name as a list.
# for col in results['column_name']:
# print(col)
Option to use the regular expressions package re to find all column names that hold the psfFluxMean for the six filters.
# for col in results['column_name']:
# if re.fullmatch('[ugrizy]_psfFluxMean', col):
# print(col)
Option to search column names that contain the string defined as temp.
# temp = 'Max'
# temp = 'Slope'
# temp = 'psfFluxMean'
# for col in results['column_name']:
# if re.search(temp, col):
# print(col)
Delete the job, but not the results.
del query
job.delete()
2.2. Column descriptions¶
There are few columns in the DiaObject table, and all are described below.
2.2.1. Identifier¶
The long integer that uniquely identifies each row of the DiaObject table.
diaObjectId
2.2.2. Coordinates¶
The sky coordinates in decimal degrees for each diaObject.
radec
2.2.3. Number of detections¶
Total number of detections across all filters (i.e., number of associated diaSources.
nDiaSources
2.2.4. Flux statistics¶
A limited number of flux statistics are calculated for DP2, and they are calculated from the $>5\sigma$ detections in the DiaSource table (not from the forced photometry).
Fluxes are used for difference-image photometry (not magnitudes) because difference-images fluxes can be negative.
Several types of statistics on the Point Spread Function (PSF) fluxes measured on the difference image detections in the DiaSource table are calculated for diaObjects, as follows.
[f]_psfFluxMean,[f]_psfFluxMeanErr: Weighted mean of PSF flux in band [f], and error on the mean.[f]_psfFluxSigma: Standard deviation of the distribution of [f]_psfFlux values.[f]_psfFluxErrMean: Mean of the flux errors.[f]_psfFluxMaxandMin: Maximum and minimum PSF flux.[f]_psfFluxMaxSlope: Maximum slope between any two sequential [f]-band observations.[f]_psfFluxNdata: Number of [f]-band data points (from theDiaSourcetable; number of [f]-band detections).
Average fluxes based on PSF photometry on the visit images (i.e., the "direct" or "science" image) at the position of the detected diaSources associated with a diaObject are also provided ([f]_scienceFluxMean).
Use caution with all science-image fluxes for time-varying objects as there may be contamination from static sources (e.g., host galaxies).
2.3. Descriptions and units¶
For a subset of the key columns show the table of their descriptions and units.
col_list = set(['diaObjectId', 'ra', 'dec', 'nDiaSources',
'r_psfFluxMean', 'r_psfFluxMeanErr', 'r_psfFluxSigma', 'r_psfFluxErrMean',
'r_psfFluxMax', 'r_psfFluxMin', 'r_psfFluxMaxSlope', 'r_psfFluxNdata'])
tx = [i for i, item in enumerate(results['column_name']) if item in col_list]
results[tx]
| column_name | datatype | description | unit |
|---|---|---|---|
| str64 | str64 | str512 | str64 |
| diaObjectId | long | Unique identifier of this DiaObject. | |
| ra | double | Right Ascension coordinate of the position of the DiaObject. | deg |
| dec | double | Declination coordinate of the position of the DiaObject. | deg |
| r_psfFluxMean | double | Weighted mean point-source model magnitude for r filter. | nJy |
| r_psfFluxMeanErr | double | Standard error of r_psfFluxMean. | nJy |
| r_psfFluxSigma | double | Standard deviation of the distribution of r_psfFlux. | nJy |
| r_psfFluxNdata | int | The number of r-band data points. | |
| r_psfFluxMin | double | Minimum observed r band fluxes. | nJy |
| r_psfFluxMax | double | Maximum observed r band fluxes. | nJy |
| r_psfFluxMaxSlope | double | Maximum slope between r band flux obsevations max(delta_flux/delta_time). | nJy/d |
| r_psfFluxErrMean | float | Mean of the r band flux errors. | nJy |
| nDiaSources | long | Total number of DiaSources associated with this DiaObject. |
Clean up.
del col_list, tx, results
3. Data access¶
The DiaObject table is available via the TAP service and the butler.
Recommended access method: TAP.
3.1. Advisory: avoid full-table queries¶
Avoid full-table queries. Always include spatial constraints.
Skipping spatial constraints is not a good habit to form, because future data release DiaObject tables will contain billions of rows.
3.2. TAP (Table Access Protocol)¶
The DiaObject table is stored in Qserv and accessible via the TAP services using ADQL queries.
Include spatial constraints:
Qserv stores catalog data sharded by coordinate (RA, Dec), so ADQL query statements that include constraints by coordinate do not requre a whole-catalog search and are typically faster (and can be much faster) than ADQL query statements which only include constraints for other columns.
Use either an ADQL cone or polygon search for faster queries (do not use WHERE ... BETWEEN statements to set boundaries on RA and Dec).
3.2.1. Demo query¶
Define a query to return, as an example, $r$-band flux statistics and other key columns for a sample from the DiaObject table.
Impose spatial constraints: search within 0.2 degrees of the center of Extended Chandra Deep Field South (ECDFS), RA, Dec = $53.13, -28.10$. (This is not a special region, just used as an example.) Also impose the constraint that a diaObject must be detected more than 5 times in the $r$-band to be returned.
query = """SELECT diaObjectId, ra, dec, nDiaSources,
r_psfFluxMean, r_psfFluxMeanErr, r_psfFluxSigma, r_psfFluxErrMean
r_psfFluxMax, r_psfFluxMin, r_psfFluxMaxSlope, r_psfFluxNdata
FROM dp2.DiaObject
WHERE CONTAINS(POINT('ICRS', ra, dec), CIRCLE('ICRS', 53.13, -28.10, 0.2)) = 1
AND r_psfFluxNdata > 5"""
job = tap_service.submit_job(query)
job.run()
job.wait(phases=['COMPLETED', 'ERROR'])
print('Job phase is', job.phase)
if job.phase == 'ERROR':
job.raise_if_error()
Job phase is COMPLETED
Fetch the results as an astropy table.
assert job.phase == 'COMPLETED'
results = job.fetch_result().to_table()
print(len(results))
143
Option to display the table.
results
| diaObjectId | ra | dec | nDiaSources | r_psfFluxMean | r_psfFluxMeanErr | r_psfFluxSigma | r_psfFluxMax | r_psfFluxMin | r_psfFluxMaxSlope | r_psfFluxNdata |
|---|---|---|---|---|---|---|---|---|---|---|
| deg | deg | nJy | nJy | nJy | nJy | nJy | nJy / d | |||
| int64 | float64 | float64 | int64 | float64 | float64 | float64 | float32 | float64 | float64 | int32 |
| 753904749157285963 | 53.14832869656018 | -28.269922609388026 | 65 | 1452.173095703125 | 90.1224136352539 | 2293.283203125 | 399.116 | -4651.71630859375 | 7349594.0546763055 | 15 |
| 755369504803913742 | 53.317067913368284 | -28.065950468747108 | 50 | 1347.314697265625 | 96.15044403076172 | 895.3720703125 | 344.23 | -392.6014099121094 | 5672649.624738062 | 12 |
| 755369504803913739 | 53.33693488938166 | -28.177236196683403 | 82 | -1086.5665283203125 | 226.78231811523438 | 2771.3349609375 | 600.068 | -5173.630859375 | 672289.1952654346 | 6 |
| 755369504803913736 | 53.278304420554484 | -28.153992727748907 | 68 | 792.35302734375 | 53.17058563232422 | 2240.653076171875 | 220.214 | -1986.34228515625 | 714026.389804091 | 16 |
| 755369504803913829 | 53.32501128602706 | -28.119075044574025 | 41 | 81.85987091064453 | 74.57477569580078 | 1235.632568359375 | 250.089 | -1603.5677490234375 | 2738816.39066981 | 11 |
| 755369504803913773 | 53.29169666040039 | -28.147946939339093 | 47 | 2660.990478515625 | 149.6099090576172 | 1558.83203125 | 505.097 | 510.4138488769531 | 160.2960186757777 | 10 |
| 755369504803913779 | 53.33076218263827 | -28.11934205117699 | 90 | 11265.4365234375 | 228.516845703125 | 3788.96337890625 | 1066.3 | 5264.23193359375 | 11995031.701225795 | 19 |
| 755369504803913766 | 53.35594282265226 | -28.092876695563337 | 47 | 34017.62109375 | 375.82025146484375 | 8091.06591796875 | 1546.95 | 21943.568359375 | 41806365.64615777 | 15 |
| 755369504803913788 | 53.28594620840545 | -28.16034732567813 | 90 | 3134.499755859375 | 151.6095733642578 | 2816.849365234375 | 490.329 | -128.31414794921875 | 1025336.091491876 | 9 |
| 755369504803913795 | 53.345871637348694 | -28.06365082391602 | 64 | -707.553955078125 | 134.01622009277344 | 1970.005859375 | 339.339 | -2759.22314453125 | 9794073.172698513 | 6 |
| 755369504803913790 | 53.28928332887084 | -28.123854674330964 | 74 | -5756.42529296875 | 281.1304626464844 | 4956.833984375 | 1124.04 | -11155.8388671875 | 26606819.553509325 | 15 |
| 755369642242867310 | 53.07382012546077 | -28.065094906777208 | 34 | 811.4575805664062 | 120.51480865478516 | 2210.29833984375 | 397.763 | -3830.444091796875 | 4828912.136808052 | 9 |
| 755369642242867268 | 53.07078140715689 | -28.184983326153162 | 58 | -465.148193359375 | 85.08258819580078 | 1350.8214111328125 | 311.77 | -2041.347412109375 | 7342760.725445082 | 13 |
| 755369573523390753 | 53.10697024119684 | -28.13976912631172 | 8 | -1487.439208984375 | 93.8515625 | 133.97791300624658 | 254.755 | -1751.6385498046875 | 244435.93006496434 | 7 |
| 755369642242867220 | 53.08663547242815 | -28.109397928460112 | 74 | -2153.93603515625 | 84.38945770263672 | 772.01953125 | 352.277 | -3027.033203125 | 1806874.1233449995 | 17 |
| 755369573523390565 | 53.15537450638214 | -28.14646799841838 | 77 | -4579.794921875 | 96.74684143066406 | 138.47796771247502 | 279.127 | -4779.17236328125 | 117088.87022238046 | 6 |
| 755369573523390561 | 53.184230260966935 | -28.174641393612728 | 24 | -485.1006164550781 | 83.73290252685547 | 1439.6682610730215 | 208.378 | -1476.043701171875 | 569978.9185009337 | 6 |
| 755369573523390554 | 53.27314636928788 | -28.175025854605916 | 28 | -1726.572021484375 | 108.04766082763672 | 904.509388707277 | 269.926 | -2982.804931640625 | 71890.08016981928 | 6 |
| 755369573523390551 | 53.10558381452512 | -28.123553494762746 | 28 | 1445.5987548828125 | 109.66188049316406 | 526.3585184536604 | 269.138 | 445.97369384765625 | 158630.57080357178 | 6 |
| 755369573523390549 | 53.21015380153802 | -28.166538342012714 | 67 | -2233.6611328125 | 101.32133483886719 | 1240.1850850029646 | 388.32 | -4264.63037109375 | 908227.8840665489 | 14 |
| 755369573523390585 | 53.16445521116566 | -28.158445898934758 | 40 | -1505.214111328125 | 74.87256622314453 | 925.4451937386344 | 292.783 | -2637.38427734375 | 9050792.102908118 | 15 |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 755370329437634677 | 52.96665960571907 | -27.96385690726116 | 11 | 1671.095947265625 | 74.33536529541016 | 281.780625757808 | 224.591 | 1151.5048828125 | 1812230.0651059921 | 9 |
| 755370329437634671 | 53.047748309684984 | -27.975415265940793 | 26 | -202.60452270507812 | 100.34101867675781 | 1571.735859364193 | 251.904 | -1522.898681640625 | 2881452.1273804307 | 6 |
| 755370329437634712 | 53.03908426287628 | -27.959472587952106 | 16 | -1162.4127197265625 | 97.1867446899414 | 500.3712379624397 | 293.932 | -1945.5924072265625 | 451172.897629002 | 9 |
| 753904817876762673 | 53.041801736092566 | -28.283187846779615 | 87 | -333.50543212890625 | 292.84564208984375 | 8671.607421875 | 1219.75 | -9973.9609375 | 11277885.47519608 | 16 |
| 755369642242867236 | 53.01504717320839 | -28.161064295052206 | 64 | -1378.846435546875 | 291.3768005371094 | 7380.541015625 | 1158.67 | -9190.3759765625 | 38569339.65934865 | 15 |
| 755369642242867229 | 52.93201400135129 | -28.09200303469767 | 91 | 466.9998474121094 | 219.19773864746094 | 5881.619140625 | 954.939 | -10358.580078125 | 16162920.576765658 | 18 |
| 755369642242867241 | 53.037238852224476 | -28.087686425024565 | 57 | 542.850341796875 | 75.90445709228516 | 1677.7506103515625 | 312.028 | -2131.47265625 | 8460600.536757926 | 15 |
| 755369642242867239 | 52.955175463803315 | -28.18622025017223 | 92 | -2045.4259033203125 | 140.6403350830078 | 3333.327880859375 | 509.885 | -4794.95703125 | 1439171.1190151158 | 10 |
| 755369642242867215 | 53.0183572617236 | -28.085546962216817 | 76 | 13025.775390625 | 290.8138427734375 | 7332.29833984375 | 1277.62 | -297.9818420410156 | 26360312.123108085 | 18 |
| 755369642242867246 | 52.939860440097355 | -28.12765837724968 | 72 | 416.6441650390625 | 111.24632263183594 | 1516.1920166015625 | 276.935 | -1392.1236572265625 | 46923.14890119695 | 6 |
| 755369642242867270 | 52.915465524285345 | -28.10265553429223 | 57 | 2212.272705078125 | 158.49856567382812 | 1784.3719482421875 | 420.536 | -83.61923217773438 | 3378064.524850892 | 7 |
| 755369642242867470 | 52.986114257377 | -28.158321097494763 | 80 | 257.8424377441406 | 277.3099670410156 | 5602.517578125 | 1085.02 | -15901.640625 | 54604113.77074105 | 14 |
| 755369642242867334 | 53.0322195223229 | -28.11756963624152 | 18 | -1332.7474365234375 | 101.0776138305664 | 291.2225036621094 | 250.055 | -1584.59814453125 | 372421.64815243613 | 6 |
| 755369642242867306 | 52.96706721760997 | -28.10591250041826 | 43 | 1771.8594970703125 | 156.97015380859375 | 902.9248046875 | 384.763 | 390.86029052734375 | 1249678.1663150864 | 6 |
| 755369642242867304 | 52.915149142426834 | -28.15776288677715 | 31 | -1892.4197998046875 | 109.08297729492188 | 879.3125610351562 | 368.647 | -3202.69091796875 | 1707679.7622829515 | 11 |
| 755369642242867303 | 52.92387316378402 | -28.14181947910142 | 68 | -348.50323486328125 | 143.35914611816406 | 1486.083740234375 | 361.295 | -1661.521240234375 | 69572.70894125159 | 6 |
| 755369642242867361 | 53.03484115001042 | -28.097884038734115 | 23 | 967.0272216796875 | 71.70084381103516 | 801.0784912109375 | 218.872 | -1107.025390625 | 21046.73298647284 | 9 |
| 755368955048099842 | 52.95639372755654 | -28.193807206510982 | 79 | 1592.03759765625 | 149.0597686767578 | 2705.080322265625 | 472.759 | -5168.74853515625 | 5467921.5564886145 | 10 |
| 755368955048099873 | 52.97256713957272 | -28.23271250863613 | 97 | -1564.447998046875 | 292.197265625 | 4573.9423828125 | 848.132 | -8610.498046875 | 4246480.1344348015 | 8 |
| 755368955048099860 | 53.02383257525794 | -28.189513811093505 | 44 | 1418.7335205078125 | 95.9287338256836 | 317.6007385253906 | 238.662 | 1077.6998291015625 | 22229.822133445992 | 6 |
| 755368955048099889 | 52.98245983757812 | -28.235556215644692 | 81 | -1542.438232421875 | 181.07656860351562 | 2586.773193359375 | 572.749 | -4588.62548828125 | 6652470.451894295 | 9 |
| 755368955048099876 | 53.03351939853918 | -28.243267610701082 | 91 | -10179.51953125 | 248.3534393310547 | 7034.67724609375 | 1203.83 | -25118.478515625 | 38772002.23159717 | 21 |
Plot a histogram of the number of detections per diaObject.
plt.figure(figsize=(4, 3))
plt.hist(results['nDiaSources'], bins=20, log=True, color='gray')
plt.xlabel('nDiaSources')
plt.ylabel('Counts of diaObjects')
plt.tight_layout()
plt.show()
Figure 1: Histogram of the number of detections (
nDiaSources) perdiaObject.
Plot histograms for a subset of the $r$-band light curve summary statistics.
fig, ax = plt.subplots(3, 2, figsize=(8, 9))
axes = ['r_psfFluxMean', 'r_psfFluxSigma',
'r_psfFluxMax', 'r_psfFluxMin',
'r_psfFluxMaxSlope', 'r_psfFluxNdata']
a = 0
for i in range(3):
for j in range(2):
ax[i, j].hist(results[axes[a]], bins=30, color='gray')
ax[i, j].set_xlabel(axes[a])
ax[i, 0].set_ylabel('Counts of diaObjects')
a += 1
plt.tight_layout()
plt.show()
Figure 2: Histograms of the $r$-band light curve summary statistics for the retrieved sample, to show the range of values.
Clean up.
job.delete()
del results
3.3. Butler¶
TAP is the recommended way to access the object table, but the butler is a convenient way to retrieve all the objects in a given tract.
Show that the only dimension for the dia_object table is the skymap's tract, and that it is required.
butler.get_dataset_type('dia_object')
DatasetType('dia_object', {skymap, tract}, ArrowAstropy)
butler.get_dataset_type('dia_object').dimensions.required
{skymap, tract}
3.3.1. Demo query¶
Include spatial constraints:
The butler dia_object table contents are stored and retrieved by individual tract.
Retrieve all dataset_refs for dia_object tables for tracts that overlap the coordinates near the center of the ECDFS field.
query = "tract.region OVERLAPS POINT(53.13, -28.10)"
refs = butler.query_datasets("dia_object", where=query)
Show that one tract overlaps the coordinates.
for ref in refs:
print(ref.dataId)
{skymap: 'lsst_cells_v2', tract: 5063}
Define the columns to retrieve.
col_list = ['diaObjectId', 'ra', 'dec', 'nDiaSources',
'r_psfFluxMean', 'r_psfFluxMeanErr',
'r_psfFluxSigma', 'r_psfFluxErrMean',
'r_psfFluxMax', 'r_psfFluxMin', 'r_psfFluxMaxSlope', 'r_psfFluxNdata']
Get the data from the butler, and retrieve it as an astropy table.
results = butler.get(refs[0],
parameters={'columns': col_list},
storageClass='ArrowAstropy')
print(len(results))
63527
Option to display the results.
Notice that because no columns constraints can be applied (e.g., r_psfFluxNdata $>5$, as in the TAP query), many values are NAN because there were insufficient detections to derive a flux statistic.
# results
Constrain the results to diaObjects with more than 5 $r$-band detections.
tx = np.where(results['r_psfFluxNdata'] > 5)[0]
print(len(tx))
2301
To visualize the data, plot the sky coordinates and mean vs. max r-band fluxes for the diaObjects in the tract.
fig, ax = plt.subplots(1, 2, figsize=(7, 3))
ax[0].plot(results['ra'][tx], results['dec'][tx],
'o', ms=2, mew=0, alpha=0.4, color='grey')
ax[0].set_xlabel('Right Ascension')
ax[0].set_ylabel('Declination')
ax[1].plot(results['r_psfFluxMean'][tx],
results['r_psfFluxMax'][tx],
'o', ms=2, mew=0, alpha=0.4, color='grey')
ax[1].set_xlabel('r_psfFluxMean')
ax[1].set_ylabel('r_psfFluxMax')
ax[1].ticklabel_format(axis='both', style='sci', scilimits=(0, 0))
plt.tight_layout()
plt.show()
Figure 3: At left, the RA vs. Dec of retrieved objects demonstrates the extent of the tract for which they were retrieved from the Butler. At right, the maximum vs. the mean r-band difference-image fluxes are plotted just as an example.
del query, refs, col_list, results, tx