From 9084e69a160cd9c39c32084c79eb786e36458d09 Mon Sep 17 00:00:00 2001 From: Nico Vermaas <vermaas@astron.nl> Date: Tue, 6 Sep 2022 08:55:32 +0200 Subject: [PATCH] fan-out alta conversion algorithm --- dev_scripts/convert_alta_to_adex_cache.py | 54 +++++++++++++---------- 1 file changed, 31 insertions(+), 23 deletions(-) diff --git a/dev_scripts/convert_alta_to_adex_cache.py b/dev_scripts/convert_alta_to_adex_cache.py index b93e238..fe2e8aa 100644 --- a/dev_scripts/convert_alta_to_adex_cache.py +++ b/dev_scripts/convert_alta_to_adex_cache.py @@ -41,6 +41,35 @@ def calc_beam(name): return 0 +# conversion algorithm to extract a bit more metadata from an ALTA record +def convert_dataproduct(row): + name, pid, access_url, ra, dec, dt, dst, observation = row + + if dt in ['inspectionPlot']: + return None + + if dst in ['calibrationTable']: + return None + + # determine collection + collection = 'apertif-imaging' + if dt == 'timeSeries': + collection = 'apertif-timeseries' + + level = 0 + if dst == 'uncalibratedVisibility': + level = 0 + if dst == 'calibratedVisibility': + level = 1 + if dst in ['continuumMF','continuumChunk','imageCube','beamCube','polarisationImage','polarisationCube','continuumCube']: + level = 2 + + beam = calc_beam(name) + + record_to_insert = (name, observation, beam, ra, dec, collection, level, dt, dst, access_url) + return record_to_insert + + def do_convert(source, target): try: @@ -82,31 +111,10 @@ def do_convert(source, target): insert_count = 0 for row in rows: name, pid, access_url,ra,dec,dt,dst,observation = row - - # TODO: move this algorithm to a sane place, finish it and have scientists review it. - # determine which dataproducts to skip - insert_this_record = True - if dt in ['inspectionPlot']: - continue - - if dst in ['calibrationTable']: + record_to_insert = convert_dataproduct(row) + if not record_to_insert: continue - # determine collection - collection = 'apertif-imaging' - if dt == 'timeSeries': - collection = 'apertif-timeseries' - - level = 0 - if dst == 'calibratedVisibility': - level=1 - if 'cube' in dt: - level=2 - - # todo: calculate beam - beam = calc_beam(name) - - record_to_insert = (name, pid, observation, beam, ra, dec, collection, level, dt,dst, access_url) target_cursor.execute(sql_scripts.insert_into_skyviews,record_to_insert) target_connection.commit() insert_count = insert_count + 1 -- GitLab