Scientific problem
Task:
- Do a cone search on the Pleiades and retrieve pmra and pmdec for all stars from Gaia archive:
SELECT pmra, pmdec FROM gaiadr3.gaia_source_lite WHERE 1 = CONTAINS(POINT(56.75, 24.12),CIRCLE(ra,dec,2.0)) AND ruwe <1.4
- Make a further downselection by requiring that (pmra-(20))^2 + (pmdec-(-45))^2 < 5^2
- Compute the average pmra and pmdec for this subset using numpy
- Compute the standard deviation for this subset w.r.t. the average using numpy
- Write these four numbers to output file.
Python code for one CPU program:
#PLEIADES - one CPU program
#Searching the Pleiades and computing the mean value and standard deviation of proper motion
import numpy as np
#launching asynchronous job using astroquery
job = Gaia.launch_job_async(query="select pmra,pmdec "
"from gaiadr3.gaia_source_lite "
"where 1 = contains(point(56.75, 34.12),circle(ra, dec, 2.0)) "
"and ruwe<1.4 ")
r = job.get_results()
#constants are defined in an input config file
with open("Symbolic_config") as f:
line = f.readlines()[0].split(' ')
pmra0=float(line[0])
pmdec0=float(line[1])
#filtering the output from Gaia archive for objects with (pmra-pmra0)**2+(pmdec-pmdec0**2) < 5**2
#and saving results to numpy arrays
pm_ra=np.array([])
pm_dec=np.array([])
for row in r:
if (row["pmra"]-pmra0)**2+(row["pmdec"]-pmdec0)**2 < 25.0:
pm_ra=np.append(pm_ra,row["pmra"])
pm_dec=np.append(pm_dec,row["pmdec"])
#computing mean values and standard deviation using numpy
mean_pmra=np.mean(pm_ra)
mean_pmdec=np.mean(pm_dec)
stdev_pmra=np.std(pm_ra)
stdev_pmdec=np.std(pm_dec)
#saving results to output file
with open("Symbolic_result",'a') as f:
f.write(f'{mean_pmra},{mean_pmdec}\n{stdev_pmra},{stdev_pmdec}\n')
Input file:
config.inp
20
-45
Next, Paralleling the issue