Error querying server for dp02_dc2_catalogs.object table

Hello everyone. I am an astrophysics undergrad still trying to get acquainted with the RSP and am running into an issue with retrieving the dp02_dc2_catalogs.object table. My goal is to query the server for this data, which will give me regions to inject simulated satellites into and characterize the performance of a searching algorithm. Here is the code I use to query:

def query(service, ra, dec, radius=1.0, gmax=23.5):
    """Return data queried from Rubin TAP
    service : TAP service [str]
    ra      : Right Ascension [deg]
    dec     : Declination [deg]
    radius  : radius around (ra, dec) [deg]

    good_results : pd.Dataframe

    # Define our reference position on the sky and cone radius in arcseconds
    # to use in all following examples
    coord = SkyCoord(ra=ra*, dec=dec*, frame='icrs')
    radius = radius * u.deg
    query = f"""
            coord_ra, coord_dec,
        FROM dp02_dc2_catalogs.object
        WHERE CONTAINS(POINT('ICRS', ra, dec), CIRCLE('ICRS', {coord.ra.value}, {coord.dec.value}, {radius.value})) = 1

    job = service.submit_job(query)
    job.wait(phases=['COMPLETED', 'ERROR'])
    async_results = job.fetch_result()
    results = async_results.to_table().to_pandas()
    return results

And here is the error it throws when I call it:

I realized initially that I was requesting columns that do not exist but after checking the portal and verifying that the columns I now query do exist, I am still having this issue.

Hi Kabelo,

Perhaps try the query again, but with capitalized “Object” as the table name? Table names are case-sensitive, and need to match capitalization as presented in the schema browser at Data Preview 0.2 Schema | sdm_schemas.

In addition to what Fritz said, to aid in query debugging you’ll want to access the error message that the TAP service is returning. It’s available at job.job.message.

Hi @Kabelo ,

There’s the objectObject error that @fritzm mentioned (thank you!) and also in the query statement’s WHERE clause, change racoord_ra and deccoord_dec. Like this:

    query = f"""
        SELECT coord_ra, coord_dec
        FROM dp02_dc2_catalogs.Object
        WHERE CONTAINS(POINT('ICRS', coord_ra, coord_dec), CIRCLE('ICRS', {coord.ra.value}, {coord.dec.value}, {radius.value})) = 1

I used that query statement and tested your function with:

results = query(service, 62.0, -37.0, radius=0.10)

and len(results) was 26115.

Hi Fritz, unfortunately it is returning the same error.

Oh nevermind, it is fine now, thank you!

Hi Melissa, thank you, this worked!

1 Like

I didn’t know I could do this, thanks for the tip!