astro.services.dbview package

Submodules

astro.services.dbview.HtmlClassOverview module

Class generates html for showing overview of class

astro specific implementation, showing UCD’s

WJ Vriend

class astro.services.dbview.HtmlClassOverview.HtmlClassOverview(args, parent)

Bases: common.services.dbview.HtmlClassOverview.HtmlClassOverview

astro specific class for rendering a class overview in html

extra_attributes(column)

(overrided) return extra attribute(s)

extra_headers()

(overrided) return extra headers

astro.services.dbview.HtmlClassOverview.getUcd(attrname)

given the column object return the ucd

astro.services.dbview.HtmlClassTree module

Class generates html for showing the tree of a class

astro specific implementation

WJ Vriend

class astro.services.dbview.HtmlClassTree.HtmlClassTree(args, parent)

Bases: common.services.dbview.HtmlClassTree.HtmlClassTree

Default call the base class implementation, and for some link attributes extend the tree leaf

classmethod extra_export_options(export_options)

(override) add astro specific export_options to dictionary

getHtml()

generate the html

classmethod get_AssociateList_attributes(ID)

get the attributes of the AsosciateList with ALID == ID

classmethod get_SourceList_attributes(slid)

get the attributes of the SourceList with SLID == slid

get_attr_tooltip_items(column)

return the items (name,value) for the attribute tooltip table

classmethod get_attributes(class_str_id)

(override) Given the class_str and ID return for special classes all attributes. For normal classes the attributes can be determined by the class definition.

get_desc_property_value(column, element_id)

Return a string to be filled in as value and operator for the element

Return the descs and links properties, implementation for SourceList and AssociateList. Default to the common implementation.

init_instrument()

initialize the instrument name (and project)

classmethod split_class_str_id(class_str)

does the class string include an ID, like class[ID]

classmethod update_result_dict_for_class(class_str, result, hidden_columns, tree_id)

update the result dict for astro specifics (chip/filter/instrument)

astro.services.dbview.HtmlDbView module

The astro dbview web services

This is a specialized version of the common dbview web service

class astro.services.dbview.HtmlDbView.HtmlDbView(args)

Bases: common.services.dbview.HtmlDbView.HtmlDbView

class extending the common dbview functionality for astro

class HtmlClassOverview(args, parent)

Bases: common.services.dbview.HtmlClassOverview.HtmlClassOverview

astro specific class for rendering a class overview in html

extra_attributes(column)

(overrided) return extra attribute(s)

extra_headers()

(overrided) return extra headers

class HtmlClassTree(args, parent)

Bases: common.services.dbview.HtmlClassTree.HtmlClassTree

Default call the base class implementation, and for some link attributes extend the tree leaf

classmethod extra_export_options(export_options)

(override) add astro specific export_options to dictionary

getHtml()

generate the html

classmethod get_AssociateList_attributes(ID)

get the attributes of the AsosciateList with ALID == ID

classmethod get_SourceList_attributes(slid)

get the attributes of the SourceList with SLID == slid

get_attr_tooltip_items(column)

return the items (name,value) for the attribute tooltip table

classmethod get_attributes(class_str_id)

(override) Given the class_str and ID return for special classes all attributes. For normal classes the attributes can be determined by the class definition.

get_desc_property_value(column, element_id)

Return a string to be filled in as value and operator for the element

Return the descs and links properties, implementation for SourceList and AssociateList. Default to the common implementation.

init_instrument()

initialize the instrument name (and project)

classmethod split_class_str_id(class_str)

does the class string include an ID, like class[ID]

classmethod update_result_dict_for_class(class_str, result, hidden_columns, tree_id)

update the result dict for astro specifics (chip/filter/instrument)

class HtmlHelp(args, parent)

Bases: common.services.dbview.HtmlHelp.HtmlHelp

export_options = '<ul>\n<li>VOTable XML: XML VOTable format, compatible with current VO programs.</li>\n<li>FITS: write table in fits format.</li>\n</ul>\n'
external_help()

method that returns help texts for astro specific issues

get_external_menu_entries()

get menu entries for non-common, return samp

classmethod parameters_help_strings()

method that returns a dictionary describing the various preferences, add export help forvotable and fits

samphelp = '<a name="SAMPhelp"></a><h3>SAMP connection</h3>\n<p>The result of a DbView query can be send to another (VO) application via SAMP.\nFor example topcat can be used, the advantage of topcat is that it comes with a SAMP hub.\nA SAMP hub must be running, otherwise the connection can not be made.</p>\n<p>Click on the "Send via SAMP" button to send the current result to other SAMP enabled applications.\nWhen sending via SAMP it is not the data that is send, but the URL of the data. The receiving application\nwill open the URL and interpret the resulting VO table.</p>\n<p>If the SAMP connection does not work please try the following:</p>\n<ul>\n<li>On the command line try connecting to the SAMP hub "curl http://localhost:21012/", that should give back HTML about the XML-RPC server (hub) running. If you get "Connection refused" then the hub is not running and sending via SAMP will not work.</li>\n<li>Try to ping the SAMP hub <button type="button" onclick="javascript:samp.ping(function(result){alert(\'Ping result is \'+result);});">Ping SAMP</button>, if that gives True then the hub can be pinged, otherwise not and probably the hub is not running.</li>\n</ul>\n'
class HtmlObjectTree(args, parent)

Bases: common.services.dbview.HtmlObjectTree.HtmlObjectTree

extended astro verion of HtmlObjectTree

dataserver_linkable(class_str, headertitle)

can we link this attribute to the corresponding file on the dataserver ?

extra_desc_property(attribute)

(override) modify the value of the desc property

get_tooltip_attr_table_elements(attr)

Add the UCD to the tooltip attr table.

put link to quality view on object_view html page

class HtmlQueryResult(args, parent)

Bases: common.services.dbview.HtmlQueryResult.HtmlQueryResult

puts astro specific html in query html page

add_mandatory_attributes()

Return attributes that should always be visible in the dbview table.

get_SAMPhtml()

construct html code for SAMP functionality; currently in astro but this may be put in common in the future…

get_header()

return html which is meant for astro specific header

revise_request_dict()

(override) Do some changes in the request_dict for astro specific classes

samp_javascript = '\n<script type="text/javascript">\nfunction connectAndSendSAMPWithSession(sampButton, tableURL) {\n $.get("Session?init_session=samp",\n function(data){\n // session id should be first and only content of returned data\n connectAndSendSAMP(sampButton, tableURL + "&%(loginsession)s=" + encodeURIComponent(data.firstChild.textContent));\n }, "xml");\n}\nfunction pingSAMP() {\n samp.ping( function(result) {alert(result);});\n}\nfunction _makeSAMPSuccessHandler(sampButton, tableURL) {\n // returns the callback for a successful hub connection\n return function(conn) {\n conn.declareMetadata([%(metadata)s]);\n // set the button up so clicks send again without reconnection.\n sampButton.unbind("click");\n sampButton.click(function(e) {\n sendSAMP(conn, tableURL);\n });\n // make sure we unregister when the user leaves the page\n $(window).unload(function() {\n conn.unregister();\n });\n // send the stuff once, since the connection has been established in response to a click already\n sendSAMP(conn, tableURL);\n };\n}\nfunction connectAndSendSAMP(sampButton, tableURL) {\n samp.register(\'Astro-WISE-DbView\',\n _makeSAMPSuccessHandler($(sampButton), tableURL),\n function(err) {\n alert("Could not connect to SAMP hub: " + err);\n }\n );\n}\nfunction sendSAMP(conn, tableURL) {\n var msg = new samp.Message("table.load.votable", {\n "table-id": \'%(table_id)s\',\n "url": tableURL,\n "name": \'%(name)s\'});\n conn.notifyAll([msg]);\n}\n$(document).ready(function() {\n var sampButton = $(\'#sendViaSAMP\');\n sampButton.click(function (e) {%(sendSAMPmethod)s(sampButton, \'%(xml_url_votable)s\');})\n});\n</script>\n'
samp_metadata = {'author.affiliation': 'Rijks Universiteit Groningen - Kapteyn', 'author.email': 'wjvriend@astro.rug.nl', 'author.name': 'Willem-Jan Vriend', 'home.page': 'http://www.astro-wise.org', 'samp.description': 'DbView-Query-Result', 'samp.icon.url': 'http://dbview.astro-wise.org/builds/omegacen/astro/services/dbview/static/favicon.png', 'samp.name': 'DbView'}
class HtmlTableRender(parent)

Bases: common.services.dbview.HtmlTableRender.HtmlTableRender

Astro specific Table (HTML) Renderer input : some astro specific entries like: quality control output : html entries

celltransform_columns_SL_onerow(datarow, filename, SLID, cutout_dict, AIDdeplink=False)

produce link in the SID-cell (in front) in the sourcelist*sources table: - to imgserver: to produce a single cutout, visualize in separate window; - to imgserver dependency-cutout: link to alternative server

celltransform_get_framefilenamefromSLID(SLID)

find filename for SLIDnumber

convert_sid(row)

method that converts a SID into a URL, pointing to the cutout

convert_slid_alid(datarow, id)

convert a SLID or ALID to a link which points to the accompanying SourceList or AssociateList respectively

insert_preview(datarow)

insert link to preview (filename and/or DataObject mandatory

insert_quality_view(datarow)

provide and insert links w.r.t. qualityview

insert_reprocess(row_num, datarow)

provide and insert link w.r.t. re-process

pre_th(headers)

Alter the headers; headers is a list with header names for the table input : list of headers output : list of headers

pre_tr(row_num, row)

convert values in record set to appropriate astro specific values

write_extra(cursor, wfile, Exportselect)

(override) determine Exportselect and return data

write_fits_catalog(headers, cursor, wfile)

method that will write a VO table

method that will return an astro specific error message when exporting links in a file

write_votable(headers, cursor, wfile)

method that will write a VO table

class QueryGenerator(args, request_dict, parent)

Bases: common.services.dbview.QueryGenerator.QueryGenerator

class which constructs astro specific SQL queries

astro_query_maker(tablename, tree)

method for astro specific SQL generator (only for SourceLists and AssociateLists

check_binary(i, j)

checks if (binary) j is in (binary) i

determine_base_attributes(base_attributes)

Return a particular order for base atrributes to be visible in the output. Add re-process and quality_view, rearrange mandatory to proper place.

make()

astro querygenerator make method

make_AssociateListQuery(alid)

make a AssociateList query for a specific ALID

make_SourceListQuery(slid)

make a SourceList query for a specific SLID

return_mask(tbc, length)

returns whether queried SLIDs (these are in tbc) are in (or not in) all possible binary combinations (FLAG) method return shortest list

return_mask_dict(tbc, length, mask_in)

returns all possible FLAGS for a set of SLIDS (determined by length) with the constraint that the queried SLIDS (present in tbc) obey these FLAGs.

uniqueCombinations(items, n)

take n distinct items, order is irrelevant; from python cookbook (GS)

URL_NAME = 'DbView'
calfiledict = {'AstrometricParameters': ['634: Astrometric Parameters', 'x'], 'BiasFrame': ['541: Master Bias frame', 'x'], 'CoaddedRegriddedFrame': ['636: Dedithered image', ''], 'ColdPixelMap': ['535: Cold pixel map', 'x'], 'CosmicMap': ['633: Cosmic pixel map', ''], 'DarkCurrent': ['531: Dark count rate for each CCD', 'x'], 'DomeFlatFrame': ['542: Master Domeflat frame', 'x'], 'FringeFrame': ['545: ff-fringe', 'x'], 'GAstrometric': ['n.a.: Global Astrometric Solution', ''], 'GainLinearity': ['523: QC parameter gain e-/ADU', 'x'], 'HotPixelMap': ['522: bad/hot pixel map', 'x'], 'IlluminationCorrection': ['548F: Illumination correction fit coefficients', 'x'], 'IlluminationCorrectionFrame': ['548: Illumination Correction Frame', 'x'], 'LVCatalogue': ['n.a.: LV catalogue', ''], 'LVFrame': ['n.a.: LV Catalog optical data: ', ''], 'MasterFlatFrame': ['546: Master flatfield', 'x'], 'NightSkyFlatFrame': ['544: Nightsky flat frame', 'x'], 'PhotExtinctionCurve': ['564E: Extinction curve', ''], 'PhotRefCatalog': ['569E: Secondary Standard Catalog', ''], 'PhotSkyBrightness': ['562S: Sky brightness table', ''], 'PhotSrcCatalog': ['562T: Photom + Sky', 'x'], 'PhotTransformation': ['565C: composite -> monolithic', ''], 'PhotometricExtinctionReport': ['562: Extinction-night report', 'x'], 'PhotometricParameters': ['563: Zeropoint + extinction', 'x'], 'QuickCheckFrame': ['547: Quick check', 'x'], 'RadioCube': ['n.a. : Westerbork radio data ', ''], 'RadioFrame': ['n.a. : Westerbork radio data ', ''], 'RawBiasFrame': ['541: Raw bias frame', ''], 'RawDarkFrame': ['531: Raw dark frame', ''], 'RawDomeFlatFrame': ['542: Raw domeflat frame', ''], 'RawScienceFrame': ['631: Raw science frame', ''], 'RawTwilightFlatFrame': ['543: Raw twilightflat frame', ''], 'ReadNoise': ['521: QC-parameter read-noise', 'x'], 'ReducedScienceFrame': ['632: Reduced science frame', 'x'], 'RegriddedFrame': ['636: regridded frame', ''], 'SatelliteMap': ['633S: Satellite map', ''], 'SaturatedPixelMap': ['633A: Saturated pixel map', ''], 'ScienceFrame': ['n.a. : OBSOLETE, superseded by ReducedScienceFrame', ''], 'ShutterCheckFrame': ['561: Shutter check frame', ''], 'TwilightFlatFrame': ['543: Master Twilightflat frame', 'x'], 'WeightFrame': ['633: individual weight map', '']}
comments_table = 'COMMENT#'
convert_args()

convert arguments, this ensures that (old) links to the dbview web service keep working

classmethod convert_bytes_to_string(data)

String keys and values in the pickled dict can turn up as bytes (p2 vs p3 issue ?) decode back to ascii.

default_sort_attrs = ('creation_date', 'DATE_OBS', 'obs_start', 'SID')
execute_manual_sql()

Execute SQL send to the DbView ? (yes always, also for anonymous users)

get_docu_url(table)

method to construct an url which points to requirements files in astro

get_extra_additional_headers(Exportselect, class_str, now_str)

(override) return astro specific additional header

get_extra_content_type(Exportselect)

(override) return astro specific content type

get_head_extra()

(override) return HTML for external stylesheets

get_python_dict()

Return the python dict from the args

html_welcome()

(override) generate the welcome screen

page_title()

(override) return page title

portalurl_reqs = 'http://www.astro-wise.org/portal/requirements/'
rebuild_python_dict(python_dict)

method that rebuilds the (old astro) python_dict so that it will work in the current version of the DBviewer

table_config = <astro.services.dbview.TableConfig.TableConfig object>
table_information(table_list)

return link to documentation for a table

table_listing(table_sel)

(override) return a list with all tables for the given table selection

table_listings()

(override) return a dictionary with table selections to show

astro.services.dbview.HtmlHelp module

Class generates html to show the help

class astro.services.dbview.HtmlHelp.HtmlHelp(args, parent)

Bases: common.services.dbview.HtmlHelp.HtmlHelp

export_options = '<ul>\n<li>VOTable XML: XML VOTable format, compatible with current VO programs.</li>\n<li>FITS: write table in fits format.</li>\n</ul>\n'
external_help()

method that returns help texts for astro specific issues

get_external_menu_entries()

get menu entries for non-common, return samp

classmethod parameters_help_strings()

method that returns a dictionary describing the various preferences, add export help forvotable and fits

samphelp = '<a name="SAMPhelp"></a><h3>SAMP connection</h3>\n<p>The result of a DbView query can be send to another (VO) application via SAMP.\nFor example topcat can be used, the advantage of topcat is that it comes with a SAMP hub.\nA SAMP hub must be running, otherwise the connection can not be made.</p>\n<p>Click on the "Send via SAMP" button to send the current result to other SAMP enabled applications.\nWhen sending via SAMP it is not the data that is send, but the URL of the data. The receiving application\nwill open the URL and interpret the resulting VO table.</p>\n<p>If the SAMP connection does not work please try the following:</p>\n<ul>\n<li>On the command line try connecting to the SAMP hub "curl http://localhost:21012/", that should give back HTML about the XML-RPC server (hub) running. If you get "Connection refused" then the hub is not running and sending via SAMP will not work.</li>\n<li>Try to ping the SAMP hub <button type="button" onclick="javascript:samp.ping(function(result){alert(\'Ping result is \'+result);});">Ping SAMP</button>, if that gives True then the hub can be pinged, otherwise not and probably the hub is not running.</li>\n</ul>\n'

astro.services.dbview.HtmlObjectTree module

Class generates html for showing the tree of a object, astro version

WJ Vriend

class astro.services.dbview.HtmlObjectTree.HtmlObjectTree(args, parent)

Bases: common.services.dbview.HtmlObjectTree.HtmlObjectTree

extended astro verion of HtmlObjectTree

dataserver_linkable(class_str, headertitle)

can we link this attribute to the corresponding file on the dataserver ?

extra_desc_property(attribute)

(override) modify the value of the desc property

get_tooltip_attr_table_elements(attr)

Add the UCD to the tooltip attr table.

put link to quality view on object_view html page

astro.services.dbview.HtmlQueryResult module

The astro specifics for the Query Result page.

class astro.services.dbview.HtmlQueryResult.HtmlQueryResult(args, parent)

Bases: common.services.dbview.HtmlQueryResult.HtmlQueryResult

puts astro specific html in query html page

add_mandatory_attributes()

Return attributes that should always be visible in the dbview table.

get_SAMPhtml()

construct html code for SAMP functionality; currently in astro but this may be put in common in the future…

get_header()

return html which is meant for astro specific header

revise_request_dict()

(override) Do some changes in the request_dict for astro specific classes

samp_javascript = '\n<script type="text/javascript">\nfunction connectAndSendSAMPWithSession(sampButton, tableURL) {\n $.get("Session?init_session=samp",\n function(data){\n // session id should be first and only content of returned data\n connectAndSendSAMP(sampButton, tableURL + "&%(loginsession)s=" + encodeURIComponent(data.firstChild.textContent));\n }, "xml");\n}\nfunction pingSAMP() {\n samp.ping( function(result) {alert(result);});\n}\nfunction _makeSAMPSuccessHandler(sampButton, tableURL) {\n // returns the callback for a successful hub connection\n return function(conn) {\n conn.declareMetadata([%(metadata)s]);\n // set the button up so clicks send again without reconnection.\n sampButton.unbind("click");\n sampButton.click(function(e) {\n sendSAMP(conn, tableURL);\n });\n // make sure we unregister when the user leaves the page\n $(window).unload(function() {\n conn.unregister();\n });\n // send the stuff once, since the connection has been established in response to a click already\n sendSAMP(conn, tableURL);\n };\n}\nfunction connectAndSendSAMP(sampButton, tableURL) {\n samp.register(\'Astro-WISE-DbView\',\n _makeSAMPSuccessHandler($(sampButton), tableURL),\n function(err) {\n alert("Could not connect to SAMP hub: " + err);\n }\n );\n}\nfunction sendSAMP(conn, tableURL) {\n var msg = new samp.Message("table.load.votable", {\n "table-id": \'%(table_id)s\',\n "url": tableURL,\n "name": \'%(name)s\'});\n conn.notifyAll([msg]);\n}\n$(document).ready(function() {\n var sampButton = $(\'#sendViaSAMP\');\n sampButton.click(function (e) {%(sendSAMPmethod)s(sampButton, \'%(xml_url_votable)s\');})\n});\n</script>\n'
samp_metadata = {'author.affiliation': 'Rijks Universiteit Groningen - Kapteyn', 'author.email': 'wjvriend@astro.rug.nl', 'author.name': 'Willem-Jan Vriend', 'home.page': 'http://www.astro-wise.org', 'samp.description': 'DbView-Query-Result', 'samp.icon.url': 'http://dbview.astro-wise.org/builds/omegacen/astro/services/dbview/static/favicon.png', 'samp.name': 'DbView'}

astro.services.dbview.HtmlTableRender module

DbView module for rendering the output of a query

class astro.services.dbview.HtmlTableRender.HtmlTableRender(parent)

Bases: common.services.dbview.HtmlTableRender.HtmlTableRender

Astro specific Table (HTML) Renderer input : some astro specific entries like: quality control output : html entries

celltransform_columns_SL_onerow(datarow, filename, SLID, cutout_dict, AIDdeplink=False)

produce link in the SID-cell (in front) in the sourcelist*sources table: - to imgserver: to produce a single cutout, visualize in separate window; - to imgserver dependency-cutout: link to alternative server

celltransform_get_framefilenamefromSLID(SLID)

find filename for SLIDnumber

convert_sid(row)

method that converts a SID into a URL, pointing to the cutout

convert_slid_alid(datarow, id)

convert a SLID or ALID to a link which points to the accompanying SourceList or AssociateList respectively

insert_preview(datarow)

insert link to preview (filename and/or DataObject mandatory

insert_quality_view(datarow)

provide and insert links w.r.t. qualityview

insert_reprocess(row_num, datarow)

provide and insert link w.r.t. re-process

pre_th(headers)

Alter the headers; headers is a list with header names for the table input : list of headers output : list of headers

pre_tr(row_num, row)

convert values in record set to appropriate astro specific values

write_extra(cursor, wfile, Exportselect)

(override) determine Exportselect and return data

write_fits_catalog(headers, cursor, wfile)

method that will write a VO table

method that will return an astro specific error message when exporting links in a file

write_votable(headers, cursor, wfile)

method that will write a VO table

astro.services.dbview.QueryGenerator module

Module with the astro specifics for the DbView Query Generator

class astro.services.dbview.QueryGenerator.QueryGenerator(args, request_dict, parent)

Bases: common.services.dbview.QueryGenerator.QueryGenerator

class which constructs astro specific SQL queries

astro_query_maker(tablename, tree)

method for astro specific SQL generator (only for SourceLists and AssociateLists

check_binary(i, j)

checks if (binary) j is in (binary) i

determine_base_attributes(base_attributes)

Return a particular order for base atrributes to be visible in the output. Add re-process and quality_view, rearrange mandatory to proper place.

make()

astro querygenerator make method

make_AssociateListQuery(alid)

make a AssociateList query for a specific ALID

make_SourceListQuery(slid)

make a SourceList query for a specific SLID

return_mask(tbc, length)

returns whether queried SLIDs (these are in tbc) are in (or not in) all possible binary combinations (FLAG) method return shortest list

return_mask_dict(tbc, length, mask_in)

returns all possible FLAGS for a set of SLIDS (determined by length) with the constraint that the queried SLIDS (present in tbc) obey these FLAGs.

uniqueCombinations(items, n)

take n distinct items, order is irrelevant; from python cookbook (GS)

astro.services.dbview.TableConfig module

Module with python code for configuration of (html) tables in the dbview web service

astro version

class astro.services.dbview.TableConfig.TableConfig

Bases: common.services.dbview.TableConfig.TableConfig

class for html table configuration

astro.services.dbview.XMLTable module

Attempt to separate export formats that a user can request in the DBviewer webservice from the code in Output.py

Author: Ewout Helmich

class astro.services.dbview.XMLTable.GOBITable(sql_result)

Bases: object

get()

generates GGOBI format XML from resultlist

class astro.services.dbview.XMLTable.VOTable(description, sql_result, tablename)

Bases: object

VarConvert = {<class 'cx_Oracle.STRING'>: 'str', <class 'cx_Oracle.TIMESTAMP'>: 'str', <class 'cx_Oracle.DATETIME'>: 'str', <class 'cx_Oracle.NATIVE_FLOAT'>: 'float64', <class 'cx_Oracle.NUMBER'>: 'int64'}
check_lists(headers)

(override) return list that contains the indices of values which are binary

get()

Return the entire VOTable as an iterator (as produced by the yield function)

make_FITS()
make_UCD(colheadername, tablename, unitstr='nounitstr')

UCD-lookup and Unit lookup/write-function for dependency -table and input-form store attr-unit pairs in Unit-dict for table-headers output

make_VO()
translate_to_RA_DEC = {'#.DEC': 'DEC', '#.RA': 'RA', 'astrom.CRVAL1': 'RA', 'astrom.CRVAL2': 'DEC'}

Module contents