"""Download the raw public catalogues (skipped when already present in the raw directory).""" import os, shutil, urllib.request, urllib.parse from common import RAW FILES = { 'galah_dr4_allstar_240705.fits': 'https://cloud.datacentral.org.au/teamdata/GALAH/public/GALAH_DR4/catalogs/galah_dr4_allstar_240705.fits', 'GALAH_DR3_main_allstar_v2.fits': 'https://cloud.datacentral.org.au/teamdata/GALAH/public/GALAH_DR3/GALAH_DR3_main_allstar_v2.fits', 'allStarLite-dr17-synspec_rev1.fits': 'https://data.sdss.org/sas/dr17/apogee/spectro/aspcap/dr17/synspec_rev1/allStarLite-dr17-synspec_rev1.fits', } MIN_SIZE = {'galah_dr4_allstar_240705.fits': 7.5e8, 'GALAH_DR3_main_allstar_v2.fits': 8.7e8, 'allStarLite-dr17-synspec_rev1.fits': 1.8e9} VIZ = 'https://tapvizier.cds.unistra.fr/TAPVizieR/tap/sync' VIZ_TABLES = { 'escorza2026_srich.csv': 'SELECT GALAH, GaiaDR3, Teff, logg, "[Fe/H]", "[Y/Fe]", "[Zr/Fe]", "[Ba/Fe]", "[La/Fe]", ' '"[Ce/Fe]", "[Nd/Fe]" FROM "J/A+A/712/A111/catalog"', 'bisterzo2014_table1.csv': 'SELECT * FROM "J/ApJ/787/10/table1"', 'renson2009.csv': 'SELECT * FROM "III/260/catalog"', } def main(): for name, url in FILES.items(): p = RAW + name if os.path.exists(p) and os.path.getsize(p) >= MIN_SIZE[name]: continue print('downloading', name) with urllib.request.urlopen(url, timeout=600) as r, open(p + '.part', 'wb') as fh: shutil.copyfileobj(r, fh, 1 << 22) os.replace(p + '.part', p) for name, q in VIZ_TABLES.items(): p = RAW + name if os.path.exists(p) and os.path.getsize(p) > 500: continue data = urllib.parse.urlencode({'REQUEST': 'doQuery', 'LANG': 'ADQL', 'FORMAT': 'csv', 'QUERY': q}).encode() with urllib.request.urlopen(urllib.request.Request(VIZ, data=data), timeout=600) as r: open(p, 'wb').write(r.read()) if __name__ == '__main__': main()