Commit 7bdcbfba authored by Markus Demleitner's avatar Markus Demleitner

svc_2019: draft of a datalink service.

parent 34b7566f
......@@ -20,37 +20,60 @@
<meta name="coverage.waveband">Radio</meta>
<table id="main" onDisk="True" mixin="//siap#pgs" adql="False">
<!-- <mixin
collectionName="'%a few letters identifying this data%'"
targetName="%column name of an object designation%"
expTime="%column name of an exposure time%"
targetClass="'%simbad taget class%'"
<STREAM id="localcolumns">
<column name="beam_major"
unit="arcsec" ucd=""
unit="arcsec" ucd="phys.angsize;instr.beam"
tablehead="Beam (maj)"
description="Major axis of beam (perhaps half-sensitivity) size."
<column name="beam_minor"
unit="arcsec" ucd=""
unit="arcsec" ucd="phys.angsize;instr.beam"
tablehead="Beam (min)"
description="Minor axis of beam (perhaps half-sensitivity) size."
<column name="beam_pa"
unit="degree" ucd=""
unit="degree" ucd="pos.angsize;instr.beam"
tablehead="Beam (PA)"
description="Position agle of beam."
<column name="object" type="text"
description="Target object observed"
<column name="obsid" type="text"
tablehead="Obs. Id"
description="APERTIF observation id; use datalink to discover other
data products from this observation."
<column name="datalink" type="text"
tablehead="Datalink Access"
description="URL of a datalink document for the dataset (raw data,
derived data"
<property name="targetType"
<property name="targetTitle">Datalink</property>
<table id="main" onDisk="True" mixin="//siap#pgs" adql="False">
<meta name="_associatedDatalinkService">
<meta name="serviceId">dl</meta>
<meta name="idColumn">accref</meta>
<!-- <mixin
collectionName="'%a few letters identifying this data%'"
targetName="%column name of an object designation%"
expTime="%column name of an exposure time%"
targetClass="'%simbad taget class%'"
<FEED source="localcolumns"/>
......@@ -72,12 +95,16 @@
with open(self.sourceToken, "rb") as f:
fitses = pickle.load(f)
for fitsdesc in fitses:
# relpath must be the path relative to the root URL given below.
relpath = fitsdesc["name"][2:]
rawdict = dict(
(card.keyword.replace("-", "_"), card.value)
for card in fitstools.parseCards(fitsdesc["header"]))
rawdict["accref"] = fitsdesc["name"]
rawdict["relpath"] = relpath
rawdict["accref"] = "svc_2019/"+relpath
rawdict["fsize"] = fitsdesc["size"]
yield rawdict
......@@ -87,10 +114,10 @@
<bind key="accref">@accref</bind>
<bind key="fsize">@fsize</bind>
<bind key="path"
<bind key="preview"
<bind key="preview_mime">"image/png"</bind>
......@@ -98,14 +125,12 @@
<make table="main">
<map key="beam_major">@BMAJ</map>
<map key="beam_minor">@BMIN</map>
<map key="beam_pa">@BPA</map>
<map key="beam_major" nullExcs="KeyError">@BMAJ</map>
<map key="beam_minor" nullExcs="KeyError">@BMIN</map>
<map key="beam_pa" nullExcs="KeyError">@BPA</map>
<map key="object">@OBJECT</map>
<map key="bandpassRefval">LIGHT_C/@CRVAL3</map>
<map key="bandpassLo">LIGHT_C/(@CRVAL3+@CDELT3)</map>
<map key="bandpassHi">LIGHT_C/(@CRVAL3-@CDELT3)</map>
<map key="obsid">@relpath.split("/")[0]</map>
<map key="datalink">\dlMetaURI{dl}</map>
<apply procDef="//siap#setMeta">
<bind key="dateObs">@DATE_OBS</bind>
......@@ -116,21 +141,85 @@
if @NAXIS4==1:
@NAXIS -= 1
if @NAXIS3==1:
if "NAXIS4" in vars:
if @NAXIS4==1:
@NAXIS -= 1
if @NAXIS3==1:
@NAXIS -= 1
<apply procDef="//siap#computePGS"/>
<!-- any custom columns need to be mapped here; do *not* use
idmaps="*" with SIAP -->
<apply name="computeBandpass">
# right now, the spectral axis is always 3, so let's try
# this. If this ever becomes variable, we'll probably
# want to look at CTYPEn for FREQ-OBS
specAxis = getWCSAxis(vars, 3, True)
nSpecPix = vars.get("NAXIS3")
if not nSpecPix:
elif nSpecPix==1:
result["bandpassRefval"] = LIGHT_C/specAxis.pixToPhys(1)
result["bandpassLo"] = LIGHT_C/specAxis.pixToPhys(0.5)
result["bandpassHi"] = LIGHT_C/specAxis.pixToPhys(1.5)
elif nSpecPix>1:
result["bandpassRefval"] = LIGHT_C/specAxis.pixToPhys(nSpecPix/2)
result["bandpassHi"] = LIGHT_C/specAxis.pixToPhys(nSpecPix+0.5)
result["bandpassLo"] = LIGHT_C/specAxis.pixToPhys(0.5)
<service id="dl" allowed="dlmeta">
<meta name="description">
This datalink service gives all data products related to an observation.
Pass in accrefs of any product that's resulted from the observation.
accref = pubDID.split("?")[-1]
desc = ProductDescriptor.fromAccref(pubDID, accref)
return desc
<par name="fnameToMeta"> {
"image_mf_V.fits": (
"Continuum image generated by summing along the spectral axis"),
obsid = descriptor.pubDID.split("/")[1]
with base.getTableConn() as conn:
for row in conn.queryToDicts(
"SELECT * FROM \schema.main"
" WHERE obsid=%(obsid)s", locals()):
sem, desc = fnameToMeta.get(
("#unknown", "Missing Description"))
yield descriptor.makeLink(
<!-- if you want to build an attractive form-based service from
SIAP, you probably want to have a custom form service; for
just basic functionality, this should do, however. -->
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment