6. Advanced query features

This Section introduces:

Load alminer

[1]:
import alminer

6.1 Create and run your own TAP query

You can use Astronomical Data Query Language (ADQL) to create more complex queries relevant for your work.

The ALminer querying functions provide an option to print the query string that was used to search the ALMA archive for the user by setting print_query parameter to True.

Once you have created the query string of interest, you can run it using the alminer.run_query function.

Example 6.1.1: Retrieve the ADQL query string used in ALminer query functions

[2]:
obs = alminer.keysearch({'proposal_abstract': ['planet forming disk']},
                        print_targets=False, print_query=True)
================================
alminer.keysearch results
================================
Your query is: SELECT * FROM ivoa.obscore WHERE ((LOWER(proposal_abstract) LIKE '%planet%' AND LOWER(proposal_abstract) LIKE '%forming%' AND LOWER(proposal_abstract) LIKE '%disk%')) AND (LOWER(data_rights) LIKE '%public%') AND (LOWER(scan_intent) LIKE '%target%') ORDER BY proposal_id
--------------------------------
Number of projects = 116
Number of observations = 1876
Number of unique subbands = 974
Total number of subbands = 9086
Total number of targets with ALMA data = 1334
--------------------------------

Example 6.1.2: Modify the query string and run the query

In the previous example, we searched the ALMA archive for projects with the words ‘planet’ AND ‘forming’ AND ‘disk’ in their abstracts. But let’s say you want to search for the phrase ‘planet forming disk’ rather than the words individually.

You can modify the query string accordingly:

[3]:
query_str = "SELECT * FROM ivoa.obscore WHERE ((LOWER(proposal_abstract) LIKE '%planet forming disk%')) AND (LOWER(data_rights) LIKE '%public%') AND (LOWER(scan_intent) LIKE '%target%') ORDER BY proposal_id"

And run the query

[4]:
myquery = alminer.run_query(query_str)

6.2 Convert your own query results into ALminer format

To make use of other alminer functions, the resulting DataFrame returned from running your query has to be converted to alminer format where a few useful columns are added to the DataFrame. This can be done through the alminer.filter_results function.

Example 6.2.1: Convert query results to ALminer format

[5]:
myquery_obs = alminer.filter_results(myquery)
--------------------------------
Number of projects = 3
Number of observations = 6
Number of unique subbands = 13
Total number of subbands = 28
6 target(s) with ALMA data = ['Sz_91', 'AA_Tau', 'L1448-mm', 'HH211', 'B1-c', 'B5-IRS1']
--------------------------------

Now you can use all the analysis and plotting routines presented before on these observations.