A stream defining a SIAPv2-style POS par over an obscore table. You can pass the name of a pgsphere geometry in the geom_name macro. The default is set up for ivoa.obscore. from gavo.protocols import siap for inStr in inPars["POS"]: yield '\geom_name &&%%(%s)s'%( base.getSQLKey("pos", siap.parseSIAP2Geometry(inStr), outPars)) A DALI-style phrase maker that matches an interval against a pair of lower/upper bound columns. This is for using with multiplicity=multiple inputKeys. name = inputKeys[0].name for lower, upper in inPars[name]: # make BAND0=lowerVal predictable: build dict in two steps pars = { "lowerVal": base.getSQLKey(name, lower, outPars), "upperCol": hiColName, "lowerCol": loColName,} pars["upperVal"] = base.getSQLKey(name, upper, outPars) yield ("%%(%(upperVal)s)s >= %(lowerCol)s" " AND %(upperCol)s >= %%(%(lowerVal)s)s")%pars A DALI-style phrase maker that matches an input interval against a a single value in the database. This is for using with multiplicity=multiple inputKeys. name = inputKeys[0].name for lower, upper in inPars[name]: yield ("%(colName)s BETWEEN" " %%(%(lowerVal)s)s AND %%(%(upperVal)s)s")%{ "upperVal": base.getSQLKey(name, upper, outPars), "lowerVal": base.getSQLKey(name, lower, outPars), "colName": colName } A DALI-style phrase maker that matches an input literally. This is for using with multiplicity=multiple inputKeys. name = inputKeys[0].name yield "%(colName)s in %%(%(key)s)s"%{ "colName": colName, "key": base.getSQLKey(name, inPars[name], outPars)} A stream defining the SIAPv2 BAND par over an obscore-like table. For non-obscore use, you can the min/max column names in the min_name and max_name macros. "\min_name" "\max_name" A stream defining the SIAPv2 TIME par over an obscore-like table. For non-obscore use, you can the min/max column names in the min_name and max_name macros. "\min_name" "\max_name" A stream defining the SIAPv2 POL par over an obscore-like table (i.e., one with pol_states). This can have multiple values, and the pol_states in obscore can have multiple states. Hence, we need a somewhat tricky phrase maker. name = inputKeys[0].name for val in inPars[name]: yield 'pol_states LIKE %%(%s)s'%( base.getSQLKey(name, "%%/%s/%%"%val, outPars)) parName, colName, tablehead, unit, description FOV, s_fov, Field of View, deg, the field of view of the observation SPATRES, s_resolution, Spat. Res., deg, the spatial resolution of the image(s) SPECRP, em_res_power,Res. Power, , the spectral resolving power λ/Δλ in spectrally resolved observations EXPTIME, t_exptime, Exposure Time, s, the integration times of the observation TIMERES, t_resolution,Time res., s, the (absolute) resolution on the time axis A stream defining the SIAPv2 \parName parameter over an obscore-like table (i.e., one with \colName). For non-obscore use, you can override the colName macro to use another column than \colName. "\colName" parName, colName, tablehead, type, description ID, obs_publisher_did, DID, text, "A dataset identifier to match. Note that contrary to the SIAP v2 REC, we do not compare the IVOIDs case-insensitively. This should not be an issue if you got the IVOID from this service. For IVOIDs obtained in other ways, you may need to use ILIKE or a similar facility through ObsTAP." COLLECTION, obs_collection, Collection, text, A name of a data collection within the service (use ObsTAP to find out the possible values). FACILITY, facility_name, Facility, text, A name of a facility (usually a telescope) used to make the observation. INSTRUMENT, instrument_name, Instrument, text, A name of an instrument used to acquire the data. DPTYPE, dataproduct_type, Type, text, Select either image or cube. CALIB, calib_level, Calib. Level,smallint, "Calibration level of the data (0=raw data .. 3=processed science-ready data)" TARGET, target_name, Target, text, A name of an observation target. FORMAT, access_format, Format, text, Media type (like application/fits) or similar of the data product searched A stream defining the SIAPv2 \parName parameter over an obscore-like table (i.e., one with \colName). "\colName" A mixin pulling in all columns necessary to support SIAP2. This is pulls in all obscore columns, including any you define locally in %#obscore-extracolumns. In DaCHS, we additionally have the columns coming from the products table. This latter fact means that the grammar filling tables mixing this in will need a `//products#define`_ rowfilter. To feed these tables, use the `//siap2#computePGS`_ and the `//siap2#setMeta`_ applies in the rowmaker. *Added in 2.7.3.* False from gavo import rscdef if base.parseBooleanLiteral(mixinPars["have_bandpass_id"]): substrate.feedObject("column", base.makeStruct( rscdef.Column, name="bandpass_id", type="text", ucd="instr.bandpass", tablehead="Bandpass", description="Free-form name of the bandpass (filter, detector," " whatever else defines the spectral response) this" " observation was taken in.", verbLevel=10)) Computes the spatial coverage of an image based on WCS keys it looks for in the rawdict. The minimum is CRVAL1, CRVAL2, CRPIX1, CRPIX2, CRVAL1, CRVAL2, CUNIT1, CUNIT2, NAXISn, and CDi_j or CDELTn. Interpretation of more WCS may or may not happen. You can override the indexes of the spatial axes using naxis, which will of course change the parameter names, too. Records without or with insufficient wcs keys are furnished with all-NULL spatial columns if the missingIsError setup parameter is False, else they bomb out with a DataError (the default). This writes directly into rowdict; do *not* use ``idmaps="*"`` on rowmakers with computePGS. *Added in 2.7.3.* True "1,2" False WCSKEYS = ["s_region", "s_ra", "s_dec", "s_fov", "s_pixel_scale", "s_resolution"] NAXIS = [int(v) for v in naxis.split(",")] class PixelGauge(object): """is a container for information about pixel sizes. It is constructed with an wcs.WCS instance and an (x, y) pair of pixel coordinates that should be close to the center of the frame. """ def __init__(self, wcs, centerPix): self.centerPos = coords.pix2sky(wcs, centerPix) self.pixelScale = coords.getPixelSizeDeg(wcs) offCenterPos = coords.pix2sky(wcs, (centerPix[0]+1, centerPix[1]+1)) def computeFromWCS(vars, wcs, result): """fills the spatial obscore fields in result from what it can make out in the wcs header. vars should be a FITS image header. """ result["mime"] = "application/fits" result["s_ra"], result["s_dec" ] = coords.getCenterFromWCSFields(wcs) result["nAxes"] = int(vars["NAXIS"]) axeInds = range(1, result["nAxes"]+1) dims = list(int(vars["NAXIS%d"%i]) for i in axeInds) result["s_xel1"] = dims[0] result["s_xel2"] = dims[1] pixelGauge = PixelGauge(wcs, (dims[0]/2., dims[1]/2.)) result["s_resolution"] = min(r*3600 for r in coords.getPixelSizeDeg(wcs)) result["s_pixel_scale"] = result["s_resolution"] result["s_region"] = coords.getSpolyFromWCSFields(wcs) # FoV computation assumes we always have rectangular # (4-vertex) polygons. Can we do better than that? vertices = result["s_region"].asCooPairs() result["s_fov"] = coords.getGCDist(vertices[0], vertices[2]) def nullOutWCS(result): """clears all wcs fields, plus the ones in additonalKeys. """ for key in WCSKEYS: result[key] = None def addWCS(vars, result): wcs = coords.getWCS(vars, naxis=NAXIS) if wcs is None: result["s_xel1"] = int(vars["NAXIS1"]) result["s_xel2"] = int(vars["NAXIS2"]) if missingIsError: raise base.DataError("No WCS information") else: nullOutWCS(result) else: computeFromWCS(vars, wcs, result) try: addWCS(vars, result) except KeyError: # presumably some basic FITS keyword missing if missingIsError: raise except Exception as msg: # somehow broken WCS if ignoreBrokenWCS: nullOutWCS(result) base.ui.notifyWarning(f"Broken WCS ignored ({msg})") else: raise Fills non-spatial information in an obscore record for an image. If you define the bandpasses yourself, do *not* change bandpassUnit and give all values in metres. For optical images, we recommend to fill out bandpassId and then let the //siap2#getBandFromFilter apply compute the actual limits. Do *not* use ``idmaps="*"`` when using this procDef; it writes directly into result, and you would be clobbering what it does. The proc parameters use the obscore names wherever possible, but accept most of the names of the version 1 ``//siap#setMeta`` and the ``//obscore#publishSIAP`` mixins. easy migration. *Added in 2.7.3.* "image" None 2 None None \standardPubDID None None None None None None None None None None None "phot.count" None base.getMetaText(targetTable, "facility", default=None) base.getMetaText(targetTable, "instrument", default=None) 1 1 None None None # computed here result["source_table"] = @prodtblTable result["access_url"] = @prodtblAccref result["access_format"] = @prodtblMime result["access_estsize"] = @prodtblFsize and @prodtblFsize/1024 # Stuff passed in by the user. All par-s are copied into the # result below, but some of them are manipulated before. if dateObs is not None: dateObs = toMJD(dateObs) if t_exptime is not None: if t_min is None: t_min = dateObs-t_exptime/86400/2 if t_max is None: t_max = dateObs+t_exptime/86400/2 # obs_id needs to be non-NULL for now. Hopefully, this # restriction can be lifted soon; in that case, just drop # the next line if obs_id is None: obs_id = obs_publisher_did for par in procDef.getSetupPars(): parName = par.key result[parName] = eval(parName) sets the bandpassId, bandpassUnit, bandpassRefval, bandpassHi, and bandpassLo from a set of standard band Ids. The bandpass ids known are contained in a file supplied by DaCHS that you should consult for supported values by running ``dachs admin dumpDF data/filters.txt``. If you pass in an unknown filter name, no keys will be generated, but no diagnostics will be emitted either. Make sure to dachs info on the imported table if you expect no NULLs in the bandpass columns. All values filled in here are in meters. If this is used, it must run after //siap#setMeta since setMeta clobbers our result fields. *Added in 2.7.3.* None _filterMap, _aliases = base.getFilterMap() def setBandpass(result, filterId): if not _filterMap: parseFilterMap() try: short, mid, long = _filterMap[_aliases.get(filterId, filterId)] except KeyError: # nothing known, do nothing return result["em_min"] = short result["em_max"] = long if sourceCol is None: val = result['bandpass_id'] else: val = vars[sourceCol] setBandpass(result, val) siap.xml pos = inPars["hPOS"] try: ra, dec = base.parseCooPair(pos) except ValueError: data = base.caches.getSesame("web").query(pos) if not data: raise base.ValidationError("%r is neither a RA,DEC pair nor" " a simbad resolvable object"%inPars.get("hPOS", "Not given"), "hPOS") ra, dec = float(data["RA"]), float(data["dec"]) yield "s_region && %({})s".format( base.getSQLKey("roi", pgsphere.SCircle.fromDALI([ ra, dec, inPars["hSIZE"]]), outPars)) \getConfig{web}{siteName} Obscore yield "dataproduct_type in ('image', 'cube')"