#astroqueryExample1.py - A script demonstrating how to use astroquery. # #Written by George J. Bendo (UK ALMA Regional Centre Node). #Import various packages. import numpy import astropy.units as u from astropy import coordinates from astroquery.alma import Alma #Set coordinates for querying the ALMA archive. coordQuery=coordinates.SkyCoord('12 37 43.597','+11 49 05.12',\ frame='icrs',unit=(u.hourangle,u.deg)) #Query the ALMA archive at this position. almaQuery1=Alma().query_region(coordQuery,radius=1*u.arcmin) print('Coordinate query results:') for i in range(len(almaQuery1)): print(almaQuery1[i]['proposal_id'],almaQuery1[i]['schedblock_name']) print() #Query the ALMA archive for an object. This will resolve the coordinates #of the objects and do a search at that position. almaQuery2=Alma().query_object('NGC 5128') print('Object query results:') for i in range(len(almaQuery2)): print(almaQuery2[i]['proposal_id'],almaQuery2[i]['schedblock_name'],\ almaQuery2[i]['target_name']) print() #Query the ALMA archive for all Cycle 5 programs (which begin with the digits #2017) that performed band 3 observations. almaQuery3=Alma().query_tap("select * from ivoa.obscore where proposal_id like '2017%' and band_list=3") print('Parameter query results:') for proposalID in numpy.sort(numpy.unique(numpy.asarray(\ almaQuery3['proposal_id'],dtype='U'))): print(proposalID) #Perform the next steps only to export data. exportFlag=False if exportFlag==True: #Identify the first Scheduling Block in the first search results. mous=almaQuery1['member_ous_uid'][0] #Download the data for that Scheduling Block. linkList=Alma.stage_data(mous) downloadAlma=Alma() downloadAlma.cache_location='[Insert directory name here]' downloadAlma.retrieve_data_from_uid(mous)