@cat_id = @source_number
@accref = "\resdir/{:06d}".format(@cat_id)
@path = pathPattern.format(@accref)
yield row
def read_meta(conn):
res = conn.query(
"select cat_id, epoch_mjd, int_time from \schema.rmtable")
return dict((cat_id, {"epoch_mjd": epoch, "int_time": int_time})
for cat_id, epoch, int_time in res)
if not hasattr(targetTable, "from_cat"):
targetTable.from_cat = read_meta(targetTable.connection)
vars.update(targetTable.from_cat[@cat_id])
mask = numpy.isnan(vars["freq"])
for key in ["freq",
"stokesI", "stokesI_error",
"stokesQ", "stokesQ_error",
"stokesU", "stokesU_error"]:
if vars[key] is not None:
vars[key] = vars[key][~mask]
@functools.cache
def get_bznames(conn):
return dict(
conn.query("SELECT cat_id, bzcat_name"
" FROM \schema.rmtable"))
if get_bznames(targetTable.connection)[@cat_id]:
@ssa_targclass = "blazar"
else:
@ssa_targclass = "radio-g"
with base.getTableConn() as conn:
res = list(conn.query(
"select {}"
" from \schema.spectra"
" where accref=%(accref)s".format(", ".join(colnames)),
self.sourceToken))
if not res:
raise UnknownURI("'{}' is not an accref we know here".format(
self.sourceToken["accref"]))
# we have to rename a few columns in the spectrum vs. the
# database
fieldnames = ("spectral", )+colnames[1:]
for rec in zip(*(res[0])):
vals = dict(zip(fieldnames, rec))
vals["flux"] = math.sqrt(vals["stokesq"]**2+vals["stokesu"]**2)
yield vals
with base.getTableConn() as conn:
res = list(conn.query("SELECT freq, stokesi, stokesq, stokesu"
" FROM \schema.spectra"
" WHERE cat_id=%(cat_id)s",
inputTable.args))
if not res:
raise svcs.UnknownURI("No data for this id known here")
freq, stokesi, stokesq, stokesu = res[0]
x = 3e8/(numpy.array(freq)**2)
fig = figure.Figure((1, 0.4), 200)
ax = fig.add_axes([0,0,1,1], frameon=False)
# once there's stokes I data, re-enable this:
# ax.scatter(x, stokesi, s=0.2, color="green")
ax.scatter(x, stokesq, s=0.2, color="blue")
ax.scatter(x, stokesu, s=0.2, color="red")
rendered = io.BytesIO()
fig.savefig(rendered, format="png")
return ("image/png", rendered.getvalue())
",
"ivo://org.gavo.dc/~?lotsspol/003510 ",
"0.0055555", # the aperture
" 24.0423673997" # the split Dec
)
]]>
/getproduct/lotsspol/003510
/getproduct/lotsspol/003510?preview=True
/lotsspol/q/cone/form
self.assertHasStrings("56805.0 ..", # placeholder of epoch
"-81.269<" # rounded RM
)
sdl/dlget
row1 = self.getFirstVOTableRow(rejectExtras=False)
self.assertAlmostEqual(row1['spectral'], 150144958.496094)
self.assertAlmostEqual(row1['stokesu_error'], 0.0032496917534212957)
self.assertXpath("//v:FIELD[@name='spectral']", {
"unit": "Hz"})
self.assertXpath("//v:PARAM[@name='ssa_specend']", {
"value": "1.9966868085537424"})