#Here's an sql query to use at the des.ncsa.illinois.edu DR1 web site.
# May wish to tweak the magnitude select range brighter to get better S/N for the Y-band.
select ra,dec,wavg_mag_psf_g,wavg_mag_psf_r,wavg_mag_psf_i,wavg_mag_psf_z,wavg_mag_psf_Y,ebv_sfd98,spread_model_i,wavg_magerr_psf_g,wavg_magerr_psf_r,wavg_magerr_psf_i,wavg_magerr_psf_z,wavg_magerr_psf_Y,l,b from dr1_main where spread_model_i between -0.002 and 0.002 and imaflags_iso_i = 0 and flags_i = 0 and imaflags_iso_g = 0 and flags_g = 0 and imaflags_iso_r = 0 and flags_r = 0 and imaflags_iso_z = 0 and flags_z = 0 and imaflags_iso_Y = 0 and flags_Y = 0 and wavg_spread_model_i between -0.002 and 0.002 and wavg_mag_psf_i between 20 and 20.02; > stars.csv

#Here's an awk manipulation of the previous file to give the stars.dat file and do reddening correction

awk -F, 'NR>1 && $3 > 0 && $3 < 30 && $4 > 0 && $4 < 30 && $5 > 0 && $5 < 30 && $6 > 0 && $6 < 30 && $7 > 0 && $7 < 30 {print $1,$2,$3,$4,$5,$6,$7,$8,$9,$3-$8*3.184,$4-$8*2.130,$5-$8*1.568,$6-$8*1.196,$7-$8*1.048,$3-$4-$8*(3.184-2.13),$4-$5-$8*(2.13-1.568),$5-$6-$8*(1.568-1.196),$6-$7-$8*(1.196-1.048),$3-$4,$4-$5,$5-$6,$6-$7,$10,$11,$12,$13,$14,$15,$16;}' stars.csv > stars.dat

