diff --git a/README.md b/README.md index 24d1f24..ad1bbc7 100644 --- a/README.md +++ b/README.md @@ -18,27 +18,18 @@ To improve cross-match query execution speed, we install `SQLxMatch` in a SQL Se The advantage of this `in-database` remote cross-match, compared to other `in-memory` local cross-match software libraries, is that the users leverage the remote database server's own (and potentially bigger) computing/memory/storage resources to filter and cross-match the full catalogs right away, having only a relatively small-sized cross-match output table returned to them. This can be faster and more efficient than having users to download the full catalogs into their own computers (if they have enough storage), and then load them in python for filtering and running the cross-match, for instance. - - ## **Documentation** - Instructions on how to install and operate `SQLxMatch` can found under the [docs](https://github.com/sciserver/sqlxmatch/tree/main/docs) folder. - ## **Examples** Example Jupyter Notebooks and demos can be found under [demo](https://github.com/sciserver/sqlxmatch/tree/main/demo) folder. - ## **Citation** Taghizadeh-Popp, M. and Dobos, L. (2023) “SQLxMatch: In-Database Spatial Cross-Match of Astronomical Catalogs”. Zenodo. doi: 10.5281/zenodo.10142771. - - - - [](https://doi.org/10.5281/zenodo.10142770) ## **License** diff --git a/demo/SQLxMatch_CasJobs_demo.ipynb b/demo/SQLxMatch_CasJobs_demo.ipynb index 3ef8b70..839ddf6 100644 --- a/demo/SQLxMatch_CasJobs_demo.ipynb +++ b/demo/SQLxMatch_CasJobs_demo.ipynb @@ -39,7 +39,7 @@ "\n", "\n", "\n", - "### The `SQLxMatch` stored procedure\n", + "### The SQLxMatch stored procedure\n", "\n", "The first input parameters are the names of 2 catalog tables, views, or temporary tables located in the CasJobs `xmatch` database context. This context already contains several table views from specific astronomical catalogs, and are named with the following format: `CatalogName_TableName`.\n", "\n", @@ -69,17 +69,21 @@ "
52 rows × 4 columns
\n", + "55 rows × 4 columns
\n", "" ], "text/plain": [ @@ -259,11 +263,11 @@ "3 CHANDRA The Chandra Source Catalog, Release 1.1 \n", "4 CNOC2 The Canadian Network for Observational Cosmol... \n", ".. ... ... \n", - "47 VVDS The VIMOS VLT Deep Survey \n", - "48 WiggleZ WiggleZ Dark Energy Survey Data Release 1 \n", - "49 WISE \\tThe WISE All-Sky data Release \n", - "50 WMAP \\tNine-year WMAP point source catalogs \n", - "51 zCOSMOS zCOSMOS-bright DR2 catalog \n", + "50 VVDS The VIMOS VLT Deep Survey \n", + "51 WiggleZ WiggleZ Dark Energy Survey Data Release 1 \n", + "52 WISE \\tThe WISE All-Sky data Release \n", + "53 WMAP \\tNine-year WMAP point source catalogs \n", + "54 zCOSMOS zCOSMOS-bright DR2 catalog \n", "\n", " remarks \\\n", "0 \\r\\n The ASAS-3 Catalog of Variable Stars... \n", @@ -272,11 +276,11 @@ "3 \\r\\n The first official release of the CS... \n", "4 \\r\\n The Canadian Network for Observation... \n", ".. ... \n", - "47 \\r\\n A total of 11 564 objects have been ... \n", - "48 \\r\\n The WiggleZ Dark Energy Survey is a ... \n", - "49 \\n NASA's Wide-field Infrared Survey Expl... \n", - "50 \\r\\n Nine-year WMAP point source catalogs \n", - "51 \\r\\n zCOSMOS is a large-redshift survey t... \n", + "50 \\r\\n A total of 11 564 objects have been ... \n", + "51 \\r\\n The WiggleZ Dark Energy Survey is a ... \n", + "52 \\n NASA's Wide-field Infrared Survey Expl... \n", + "53 \\r\\n Nine-year WMAP point source catalogs \n", + "54 \\r\\n zCOSMOS is a large-redshift survey t... \n", "\n", " url \n", "0 http://www.astrouw.edu.pl/asas/?page=main \n", @@ -285,13 +289,13 @@ "3 http://cxc.cfa.harvard.edu/csc/ \n", "4 http://www.astro.utoronto.ca/~cnoc/cnoc2.html \n", ".. ... \n", - "47 http://cesam.lam.fr/vvdsproject/index.html \n", - "48 http://wigglez.swin.edu.au/site/index.html \n", - "49 http://wise2.ipac.caltech.edu/docs/release/all... \n", - "50 https://heasarc.gsfc.nasa.gov/W3Browse/radio-c... \n", - "51 http://vizier.cfa.harvard.edu/viz-bin/VizieR?-... \n", + "50 http://cesam.lam.fr/vvdsproject/index.html \n", + "51 http://wigglez.swin.edu.au/site/index.html \n", + "52 http://wise2.ipac.caltech.edu/docs/release/all... \n", + "53 https://heasarc.gsfc.nasa.gov/W3Browse/radio-c... \n", + "54 http://vizier.cfa.harvard.edu/viz-bin/VizieR?-... \n", "\n", - "[52 rows x 4 columns]" + "[55 rows x 4 columns]" ] }, "execution_count": 2, @@ -321,11 +325,11 @@ "id": "5be240a8-716b-4b38-aefd-45a61ff3d9e0", "metadata": { "execution": { - "iopub.execute_input": "2023-11-16T02:06:21.170985Z", - "iopub.status.busy": "2023-11-16T02:06:21.170300Z", - "iopub.status.idle": "2023-11-16T02:06:22.829568Z", - "shell.execute_reply": "2023-11-16T02:06:22.826593Z", - "shell.execute_reply.started": "2023-11-16T02:06:21.170937Z" + "iopub.execute_input": "2023-11-17T17:36:06.832406Z", + "iopub.status.busy": "2023-11-17T17:36:06.832000Z", + "iopub.status.idle": "2023-11-17T17:36:08.599315Z", + "shell.execute_reply": "2023-11-17T17:36:08.597605Z", + "shell.execute_reply.started": "2023-11-17T17:36:06.832336Z" }, "tags": [] }, @@ -361,34 +365,10 @@ " \n", "42 rows × 13 columns
\n", + "59 rows × 13 columns
\n", "" ], "text/plain": [ - " catalog_name table_name column_name \\\n", - "0 SPITZER SPITZER_goodsnIRS16micron cx \n", - "1 SPITZER SPITZER_goodsnIRS16micron cy \n", - "2 SPITZER SPITZER_goodsnIRS16micron cz \n", - "3 SPITZER SPITZER_goodsnIRS16micron htmid \n", - "4 SPITZER SPITZER_goodsnIRS16micron zoneid \n", - ".. ... ... ... \n", - "37 SPITZER SPITZER_goodsnIRS16micron ebmag \n", - "38 SPITZER SPITZER_goodsnIRS16micron evmag \n", - "39 SPITZER SPITZER_goodsnIRS16micron eimag \n", - "40 SPITZER SPITZER_goodsnIRS16micron ezmag \n", - "41 SPITZER SPITZER_goodsnIRS16micron icls \n", + " catalog_name table_name column_name \\\n", + "0 IRAS IRAS_PhotoObj objID \n", + "1 IRAS IRAS_PhotoObj name \n", + "2 IRAS IRAS_PhotoObj ra \n", + "3 IRAS IRAS_PhotoObj dec \n", + "4 IRAS IRAS_PhotoObj cx \n", + ".. ... ... ... \n", + "54 IRAS IRAS_PhotoObj mhcon \n", + "55 IRAS IRAS_PhotoObj fcor_12 \n", + "56 IRAS IRAS_PhotoObj fcor_25 \n", + "57 IRAS IRAS_PhotoObj fcor_60 \n", + "58 IRAS IRAS_PhotoObj fcor_100 \n", "\n", - " description unit \\\n", - "0 Cartesian X (J2000) \n", - "1 Cartesian Y (J2000) \n", - "2 Cartesian Z (J2000) \n", - "3 HTM ID (J2000) \n", - "4 Zone ID (J2000) \n", - ".. ... ... \n", - "37 HST B magnitude uncertainty mag \n", - "38 HST V magnitude uncertainty mag \n", - "39 HST I magnitude uncertainty mag \n", - "40 HST z magnitude uncertainty mag \n", - "41 Number of I-band sources within 1 arcsec mag \n", + " description unit \\\n", + "0 unique object identifier \n", + "1 IRAS Source Name \n", + "2 J2000 right ascension deg \n", + "3 J2000 declination deg \n", + "4 Cartesian coordinate x \n", + ".. ... ... \n", + "54 Possible number of HCONs, 99 for NULL \n", + "55 Flux correction factor applied (times 1000),99... \n", + "56 Flux correction factor applied (times 1000),99... \n", + "57 Flux correction factor applied (times 1000),99... \n", + "58 Flux correction factor applied (times 1000),99... \n", "\n", - " ucd utype datatype size precision scale \\\n", - "0 pos.eq.x;pos.frame=j2000 float 8 53 0 \n", - "1 pos.eq.y;pos.frame=j2000 float 8 53 0 \n", - "2 pos.eq.z;pos.frame=j2000 float 8 53 0 \n", - "3 pos.eq.HTM; pos.frame=j2000 bigint 8 19 0 \n", - "4 pos.eq.zone;pos.frame=j2000 int 4 10 0 \n", - ".. ... ... ... ... ... ... \n", - "37 stat.error;phot.mag;em.opt.B real 4 24 0 \n", - "38 stat.error;phot.mag;em.opt.V real 4 24 0 \n", - "39 stat.error;phot.mag;em.opt.I real 4 24 0 \n", - "40 stat.error;phot.mag;em.opt.SDDS.z real 4 24 0 \n", - "41 meta.number;src;em.opt.I tinyint 1 3 0 \n", + " ucd utype datatype size precision \\\n", + "0 meta.id bigint 8 19 \n", + "1 meta.id varchar 11 0 \n", + "2 pos.eq.ra;pos.frame=j2000 float 8 53 \n", + "3 pos.eq.dec;pos.frame=j2000 float 8 53 \n", + "4 pos.eq.x;pos.frame=j2000 float 8 53 \n", + ".. ... ... ... ... ... \n", + "54 meta.number smallint 2 5 \n", + "55 stat.param;phot.flux;em.IR.IRAS.12 int 4 10 \n", + "56 stat.param;phot.flux;em.IR.IRAS.25 int 4 10 \n", + "57 stat.param;phot.flux;em.IR.IRAS.60 int 4 10 \n", + "58 stat.param;phot.flux;em.IR.IRAS.100 int 4 10 \n", "\n", - " column_index schema_name \n", - "0 1 dbo \n", - "1 2 dbo \n", - "2 3 dbo \n", - "3 4 dbo \n", - "4 5 dbo \n", - ".. ... ... \n", - "37 38 dbo \n", - "38 39 dbo \n", - "39 40 dbo \n", - "40 41 dbo \n", - "41 42 dbo \n", + " scale column_index schema_name \n", + "0 0 1 dbo \n", + "1 0 2 dbo \n", + "2 0 3 dbo \n", + "3 0 4 dbo \n", + "4 0 5 dbo \n", + ".. ... ... ... \n", + "54 0 55 dbo \n", + "55 0 56 dbo \n", + "56 0 57 dbo \n", + "57 0 58 dbo \n", + "58 0 59 dbo \n", "\n", - "[42 rows x 13 columns]" + "[59 rows x 13 columns]" ] }, "execution_count": 4, @@ -733,7 +707,7 @@ } ], "source": [ - "sql = \"SELECT * FROM Columns WHERE catalog_name = 'SPITZER' and table_name = 'SPITZER_goodsnIRS16micron' ORDER BY column_index\"\n", + "sql = \"SELECT * FROM Columns WHERE table_name = 'IRAS_PhotoObj' ORDER BY column_index\"\n", "cj.executeQuery(sql, context='xmatch')" ] }, @@ -752,11 +726,11 @@ "id": "fa28b430-8353-4ddc-99be-07f1f4288a8e", "metadata": { "execution": { - "iopub.execute_input": "2023-11-16T02:06:24.900326Z", - "iopub.status.busy": "2023-11-16T02:06:24.899949Z", - "iopub.status.idle": "2023-11-16T02:06:24.912028Z", - "shell.execute_reply": "2023-11-16T02:06:24.909680Z", - "shell.execute_reply.started": "2023-11-16T02:06:24.900279Z" + "iopub.execute_input": "2023-11-17T17:36:10.460832Z", + "iopub.status.busy": "2023-11-17T17:36:10.460374Z", + "iopub.status.idle": "2023-11-17T17:36:10.468721Z", + "shell.execute_reply": "2023-11-17T17:36:10.467134Z", + "shell.execute_reply.started": "2023-11-17T17:36:10.460783Z" }, "tags": [] }, @@ -778,7 +752,7 @@ "source": [ "### Cross-matching two small catalogs - Pandas DataFrame output\n", "\n", - "Here we cross-match 2 local tables (the `PhotoObjAll` tables in the `FUSE` and `FIRST` catalogs). \n", + "Here we cross-match 2 local infrared catalog tables: `IRAS_PhotoObj` and `AKARI_FIS`.\n", "\n", "We can retrieve the cross-match output table as a Pandas dataframe by using the syncronous `executeQuery` function in CasJobs, as this cross-match takes less time than its `1 minute timeout`. " ] @@ -789,11 +763,11 @@ "id": "7816e30a-0190-41bd-b38e-cde897a15faa", "metadata": { "execution": { - "iopub.execute_input": "2023-11-16T02:06:24.916295Z", - "iopub.status.busy": "2023-11-16T02:06:24.915580Z", - "iopub.status.idle": "2023-11-16T02:06:30.473359Z", - "shell.execute_reply": "2023-11-16T02:06:30.471394Z", - "shell.execute_reply.started": "2023-11-16T02:06:24.916216Z" + "iopub.execute_input": "2023-11-17T17:36:10.470812Z", + "iopub.status.busy": "2023-11-17T17:36:10.470393Z", + "iopub.status.idle": "2023-11-17T17:36:17.020050Z", + "shell.execute_reply": "2023-11-17T17:36:17.018116Z", + "shell.execute_reply.started": "2023-11-17T17:36:10.470766Z" }, "tags": [] }, @@ -802,9 +776,9 @@ "name": "stdout", "output_type": "stream", "text": [ - "There are 84 matches.\n", - "CPU times: user 38.7 ms, sys: 4.59 ms, total: 43.3 ms\n", - "Wall time: 5.52 s\n" + "There are 97 matches.\n", + "CPU times: user 29.8 ms, sys: 2.27 ms, total: 32.1 ms\n", + "Wall time: 6.52 s\n" ] }, { @@ -836,33 +810,33 @@ " \n", "84 rows × 3 columns
\n", + "97 rows × 3 columns
\n", "" ], "text/plain": [ - " id1 id2 sep\n", - "0 748 420609 21.133745\n", - "1 1061 753859 2.683405\n", - "2 39 406505 29.820647\n", - "3 39 406467 2.344853\n", - "4 39 406486 4.631321\n", - ".. ... ... ...\n", - "79 752 671376 0.425636\n", - "80 1259 449080 0.187065\n", - "81 85 566564 0.612966\n", - "82 82 329941 1.084348\n", - "83 31 463142 1.271296\n", + " id1 id2 sep\n", + "0 125607 3251473 0.881630\n", + "1 217378 3393112 0.566069\n", + "2 170663 3122486 0.681755\n", + "3 27009 3096636 0.563840\n", + "4 135385 3268209 0.771273\n", + ".. ... ... ...\n", + "92 95744 3074376 0.352167\n", + "93 121214 3231044 0.205401\n", + "94 33112 3137825 0.621349\n", + "95 92458 3207524 0.741632\n", + "96 108160 3231002 0.428036\n", "\n", - "[84 rows x 3 columns]" + "[97 rows x 3 columns]" ] }, "execution_count": 6, @@ -931,10 +905,10 @@ "%%time\n", "\n", "sql = f\"\"\"\n", - "EXECUTE SQLxMatch @table1='FUSE_PhotoObjAll', @table2='FIRST_PhotoObjAll', @radius={radius}\n", + "EXECUTE SQLxMatch @table1='IRAS_PhotoObj', @table2='AKARI_FIS', @radius=1\n", "\n", - "-- Note that we could be more explicit by specifying the columns names, but that was not needed:\n", - "--EXECUTE SQLxMatch @table1='FUSE_PhotoObjAll', @id_col1='objid', @ra_col1='ra', @dec_col1='dec', @table2='FIRST_PhotoObjAll', @radius={radius}\n", + "-- Note that we could be more explicit by specifying the columns names, but that was not needed.\n", + "--EXECUTE SQLxMatch @table1='IRAS_PhotoObj', @id_col1='objid', @ra_col1='ra', @dec_col1='dec', @table2='AKARI_FIS', @radius={radius}\n", "\"\"\"\n", "\n", "df = cj.executeQuery(sql, context=\"xmatch\")\n", @@ -949,9 +923,12 @@ "source": [ "### Cross-matching two filtered catalogs - Pandas DataFrame output\n", "\n", - "Here we use 2 local tables (the `PhotoObjAll` tables in the `BestDR17` and `GalexDR3` catalogs), which we filter by `ra` and `dec` in rectangular regions and store in local temporary tables. These temporary tables are then passed as input to the `sp_xmatch` procedure.\n", + "Here we use 2 local tables (the `PhotoObjAll` tables in the `BestDR17` and `GalexDR6` catalogs), which we filter by `ra` and `dec` in rectangular regions and store in local temporary tables. These temporary tables are then passed as input to the `SQLxMatch` procedure.\n", + "\n", + "Note that we can also store the (`cx`, `cy`, `cz`) columns in the temporary tables in order to avaoid having the code to compute them later internally on the fly.\n", "\n", - "Note that we can also store the (`cx`, `cy`, `cz`) columns in the temporary tables in order to avaoid having the code to compute them later internally on the fly." + "Also, note that time we also give `@include_radec`=1, `@include_sep_rank`=1, `@sort_by_separation`=1 as input parameters. \n", + "\n" ] }, { @@ -960,11 +937,11 @@ "id": "6db61e21-b49a-4ea1-83e7-18f372d7acb8", "metadata": { "execution": { - "iopub.execute_input": "2023-11-16T02:06:30.476586Z", - "iopub.status.busy": "2023-11-16T02:06:30.476001Z", - "iopub.status.idle": "2023-11-16T02:06:34.889511Z", - "shell.execute_reply": "2023-11-16T02:06:34.887782Z", - "shell.execute_reply.started": "2023-11-16T02:06:30.476527Z" + "iopub.execute_input": "2023-11-17T17:36:17.022509Z", + "iopub.status.busy": "2023-11-17T17:36:17.022058Z", + "iopub.status.idle": "2023-11-17T17:36:25.781444Z", + "shell.execute_reply": "2023-11-17T17:36:25.779510Z", + "shell.execute_reply.started": "2023-11-17T17:36:17.022418Z" }, "tags": [] }, @@ -974,8 +951,8 @@ "output_type": "stream", "text": [ "There are 14482 matches.\n", - "CPU times: user 118 ms, sys: 24.5 ms, total: 142 ms\n", - "Wall time: 4.39 s\n" + "CPU times: user 145 ms, sys: 57.4 ms, total: 202 ms\n", + "Wall time: 8.72 s\n" ] }, { @@ -1002,95 +979,168 @@ "14482 rows × 3 columns
\n", + "14482 rows × 8 columns
\n", "" ], "text/plain": [ - " id1 id2 sep\n", - "0 1237667430101877625 6387874658268480342 24.713197\n", - "1 1237667430101877625 6387874658268480335 24.360351\n", - "2 1237667430101877799 6387874658268480335 21.183498\n", - "3 1237667430101877631 6387874658268480335 23.689764\n", - "4 1237667430101877644 6387874658268480316 28.674751\n", - "... ... ... ...\n", - "14477 1237667323247329512 6387874658268481830 27.112988\n", - "14478 1237667323247329953 6387874658268481830 13.102262\n", - "14479 1237667323247263986 6387874658268481805 16.845794\n", - "14480 1237667430638878978 6387874658268481805 16.813032\n", - "14481 1237667323247264396 6387874658268481811 11.216161\n", + " id1 id2 sep sep_rank \\\n", + "0 1237667322710261954 6387874658268479704 1.798951 1 \n", + "1 1237667322710261954 6387874659342225269 12.009139 2 \n", + "2 1237667322710261955 6387874658268479704 1.792355 1 \n", + "3 1237667322710261955 6387874659342225269 12.022925 2 \n", + "4 1237667322710261983 6387874658268479748 23.739031 1 \n", + "... ... ... ... ... \n", + "14477 1237667430638814217 6387874658270578860 27.791207 1 \n", + "14478 1237667430638814217 6387874658269533411 29.379765 2 \n", + "14479 1237667430638814224 6387874658268481825 23.994318 1 \n", + "14480 1237667430638814224 6387874658270578846 26.040727 2 \n", + "14481 1237667430638878978 6387874658268481805 16.813032 1 \n", "\n", - "[14482 rows x 3 columns]" + " ra1 dec1 ra2 dec2 \n", + "0 160.008407 25.004219 160.008487 25.003724 \n", + "1 160.008407 25.004219 160.011864 25.003073 \n", + "2 160.008402 25.004216 160.008487 25.003724 \n", + "3 160.008402 25.004216 160.011864 25.003073 \n", + "4 160.027793 25.022443 160.034873 25.020916 \n", + "... ... ... ... ... \n", + "14477 160.041967 25.474943 160.033920 25.477554 \n", + "14478 160.041967 25.474943 160.042697 25.466809 \n", + "14479 160.036649 25.495353 160.029969 25.498194 \n", + "14480 160.036649 25.495353 160.037995 25.488222 \n", + "14481 160.173026 25.499917 160.173691 25.495285 \n", + "\n", + "[14482 rows x 8 columns]" ] }, "execution_count": 7, @@ -1109,7 +1159,7 @@ "SELECT objid, ra, dec, cx, cy, cz INTO #temp2 \n", "FROM GalexGR6_PhotoObjAll WHERE ra BETWEEN {ra1} AND {ra2} AND dec BETWEEN {dec1} AND {dec2}\n", "\n", - "EXECUTE SQLxMatch @table1='#temp1', @table2='#temp2', @radius={radius}\n", + "EXECUTE SQLxMatch @table1='#temp1', @table2='#temp2', @radius={radius}, @include_radec=1, @include_sep_rank=1, @sort_by_separation=1\n", "\"\"\"\n", "\n", "df = cj.executeQuery(sql, context=\"xmatch\")\n", @@ -1143,11 +1193,11 @@ "id": "85ee81f3-4a05-4db2-a191-26e3b16bf925", "metadata": { "execution": { - "iopub.execute_input": "2023-11-16T02:06:34.892065Z", - "iopub.status.busy": "2023-11-16T02:06:34.891534Z", - "iopub.status.idle": "2023-11-16T02:06:36.517757Z", - "shell.execute_reply": "2023-11-16T02:06:36.515931Z", - "shell.execute_reply.started": "2023-11-16T02:06:34.892017Z" + "iopub.execute_input": "2023-11-17T17:36:25.784040Z", + "iopub.status.busy": "2023-11-17T17:36:25.783641Z", + "iopub.status.idle": "2023-11-17T17:36:27.475685Z", + "shell.execute_reply": "2023-11-17T17:36:27.473606Z", + "shell.execute_reply.started": "2023-11-17T17:36:25.783989Z" }, "tags": [] }, @@ -1158,7 +1208,7 @@ "sql = f\"\"\"\n", "IF EXISTS (select * from sys.objects WHERE object_id = OBJECT_ID(N'{mydb_output_table_name}') AND TYPE = 'U')\n", "DROP TABLE {mydb_output_table_name} \n", - "CREATE TABLE {mydb_output_table_name}(id1 bigint, id2 bigint, sep float, ra1 float, dec1 float, ra2 float, dec2 float)\n", + "CREATE TABLE {mydb_output_table_name}(id1 BIGINT, id2 BIGINT, sep FLOAT, sep_rank INTEGER, ra1 BIGINT, dec1 FLOAT, ra2 FLOAT, dec2 FLOAT)\n", "\"\"\"\n", "df = cj.executeQuery(sql, context=\"mydb\")" ] @@ -1179,11 +1229,11 @@ "id": "7597e6c7-5293-49cd-be7c-1b4875f14ea7", "metadata": { "execution": { - "iopub.execute_input": "2023-11-16T02:06:36.520397Z", - "iopub.status.busy": "2023-11-16T02:06:36.520003Z", - "iopub.status.idle": "2023-11-16T02:06:53.297130Z", - "shell.execute_reply": "2023-11-16T02:06:53.295273Z", - "shell.execute_reply.started": "2023-11-16T02:06:36.520349Z" + "iopub.execute_input": "2023-11-17T17:36:27.478255Z", + "iopub.status.busy": "2023-11-17T17:36:27.477869Z", + "iopub.status.idle": "2023-11-17T17:36:44.297308Z", + "shell.execute_reply": "2023-11-17T17:36:44.294953Z", + "shell.execute_reply.started": "2023-11-17T17:36:27.478205Z" }, "tags": [] }, @@ -1192,7 +1242,8 @@ "name": "stdout", "output_type": "stream", "text": [ - "CPU times: user 145 ms, sys: 22.9 ms, total: 168 ms\n", + "Job Message: Query Complete\n", + "CPU times: user 136 ms, sys: 19.8 ms, total: 156 ms\n", "Wall time: 16.8 s\n" ] } @@ -1208,10 +1259,10 @@ "FROM GALEXGR6_PhotoObjAll WHERE ra BETWEEN {ra1} AND {ra2} AND dec BETWEEN {dec1} AND {dec2}\n", "\n", "-- Creating temporary output table\n", - "CREATE TABLE #out(id1 bigint, id2 bigint, sep float, ra1 float, dec1 float, ra2 float, dec2 float)\n", + "CREATE TABLE #out(id1 BIGINT, id2 BIGINT, sep FLOAT, sep_rank INTEGER, ra1 BIGINT, dec1 FLOAT, ra2 FLOAT, dec2 FLOAT)\n", "\n", "-- Executing cross-match that fills output table.\n", - "EXECUTE SQLxMatch @table1='#temp1', @table2='#temp2', @radius={radius}, @output_table='#out', @radec_in_output=1\n", + "EXECUTE SQLxMatch @table1='#temp1', @table2='#temp2', @radius={radius}, @output_table='#out', @include_radec=1, @include_sep_rank=1\n", "\n", "-- Filling up table in MyDB:\n", "INSERT INTO mydb.{mydb_output_table_name}\n", @@ -1221,7 +1272,8 @@ "job_id = cj.submitJob(sql, context=\"xmatch\")\n", "\n", "# this line will make the code wait until the job is done, if desired:\n", - "job_description = cj.waitForJob(job_id)" + "job_description = cj.waitForJob(job_id)\n", + "print(f\"Job Message: {job_description.get('Message')}\")" ] }, { @@ -1239,11 +1291,11 @@ "id": "2843127a-f8fd-4596-b514-973a85b43e42", "metadata": { "execution": { - "iopub.execute_input": "2023-11-16T02:06:53.299629Z", - "iopub.status.busy": "2023-11-16T02:06:53.299209Z", - "iopub.status.idle": "2023-11-16T02:06:55.879003Z", - "shell.execute_reply": "2023-11-16T02:06:55.877149Z", - "shell.execute_reply.started": "2023-11-16T02:06:53.299581Z" + "iopub.execute_input": "2023-11-17T17:36:44.300412Z", + "iopub.status.busy": "2023-11-17T17:36:44.299961Z", + "iopub.status.idle": "2023-11-17T17:36:46.684560Z", + "shell.execute_reply": "2023-11-17T17:36:46.682578Z", + "shell.execute_reply.started": "2023-11-17T17:36:44.300337Z" }, "tags": [] }, @@ -1279,6 +1331,7 @@ "14482 rows × 7 columns
\n", + "14482 rows × 8 columns
\n", "" ], "text/plain": [ - " id1 id2 sep ra1 \\\n", - "0 1237667430102008414 6387874666859466785 160.348991 25.105292 \n", - "1 1237667430102008414 6387874666858417103 160.348991 25.105292 \n", - "2 1237667430102008414 6387874658269533031 160.348991 25.105292 \n", - "3 1237667430102008414 2486974493255277081 160.348991 25.105292 \n", - "4 1237667430102008414 6387874658268480014 160.348991 25.105292 \n", - "... ... ... ... ... \n", - "14477 1237667323247329512 6387874658268481830 160.424081 25.492595 \n", - "14478 1237667323247329953 6387874658268481830 160.425375 25.496309 \n", - "14479 1237667323247263986 6387874658268481805 160.172991 25.499922 \n", - "14480 1237667430638878978 6387874658268481805 160.173026 25.499917 \n", - "14481 1237667323247264396 6387874658268481811 160.245373 25.499857 \n", + " id1 id2 sep sep_rank ra1 \\\n", + "0 1237667322710261954 6387874658268479704 1.798951 1 160 \n", + "1 1237667322710261954 6387874659342225269 12.009139 2 160 \n", + "2 1237667322710261955 6387874658268479704 1.792355 1 160 \n", + "3 1237667322710261955 6387874659342225269 12.022925 2 160 \n", + "4 1237667322710261983 6387874658268479748 23.739031 1 160 \n", + "... ... ... ... ... ... \n", + "14477 1237667430638814217 6387874658270578860 27.791207 1 160 \n", + "14478 1237667430638814217 6387874658269533411 29.379765 2 160 \n", + "14479 1237667430638814224 6387874658268481825 23.994318 1 160 \n", + "14480 1237667430638814224 6387874658270578846 26.040727 2 160 \n", + "14481 1237667430638878978 6387874658268481805 16.813032 1 160 \n", "\n", - " dec1 ra2 dec2 \n", - "0 160.347935 25.105733 3.789954 \n", - "1 160.352474 25.105610 11.411807 \n", - "2 160.352479 25.105861 11.553421 \n", - "3 160.352513 25.105603 11.535380 \n", - "4 160.353779 25.104910 15.667722 \n", - "... ... ... ... \n", - "14477 160.426413 25.499826 27.112988 \n", - "14478 160.426413 25.499826 13.102262 \n", - "14479 160.173691 25.495285 16.845794 \n", - "14480 160.173691 25.495285 16.813032 \n", - "14481 160.246752 25.497001 11.216161 \n", + " dec1 ra2 dec2 \n", + "0 25.004219 160.008487 25.003724 \n", + "1 25.004219 160.011864 25.003073 \n", + "2 25.004216 160.008487 25.003724 \n", + "3 25.004216 160.011864 25.003073 \n", + "4 25.022443 160.034873 25.020916 \n", + "... ... ... ... \n", + "14477 25.474943 160.033920 25.477554 \n", + "14478 25.474943 160.042697 25.466809 \n", + "14479 25.495353 160.029969 25.498194 \n", + "14480 25.495353 160.037995 25.488222 \n", + "14481 25.499917 160.173691 25.495285 \n", "\n", - "[14482 rows x 7 columns]" + "[14482 rows x 8 columns]" ] }, "execution_count": 10, @@ -1438,7 +1502,7 @@ ], "source": [ "sql = f\"\"\"\n", - "SELECT * FROM mydb.{mydb_output_table_name}\n", + "SELECT * FROM mydb.{mydb_output_table_name} ORDER BY id1, sep\n", "\"\"\"\n", "df = cj.executeQuery(sql, context=\"mydb\")\n", "print(f\"There are {df.shape[0]} matches.\")\n", diff --git a/docs/README.md b/docs/README.md index 9fc8597..339262c 100644 --- a/docs/README.md +++ b/docs/README.md @@ -106,7 +106,8 @@ Taghizadeh-Popp, M. and Dobos, L. (2023) “SQLxMatch: In-Database Spatial Cross