Class: VORuby::SkyQuery::Service
- Inherits:
-
Object
- Object
- VORuby::SkyQuery::Service
- Defined in:
- lib/voruby/sky_query/sky_query.rb
Instance Attribute Summary collapse
-
#end_point ⇒ Object
Returns the value of attribute end_point.
-
#namespace ⇒ Object
Returns the value of attribute namespace.
Class Method Summary collapse
-
.query(adql, node = nil, options = {}) ⇒ Object
Query the SkyQuery service.
Instance Method Summary collapse
-
#column_info(node, table, column) ⇒ Object
Retrieve the metadata associated with the specified column.
-
#columns(node, table) ⇒ Object
Retrieve the list of columns associated with the specified table.
-
#initialize(options = {}) ⇒ Service
constructor
Create a new SkyQuery service instance.
-
#meta_columns(node, table) ⇒ Object
Retrieve the metadata associated with the columns of the specified table.
-
#query(adql, node = nil) ⇒ Object
Query the SkyQuery service.
-
#sky_nodes ⇒ Object
Find all nodes available from the SkyPortal service.
-
#table_info(node, table) ⇒ Object
Retrieve the metadata associated with the specified table.
-
#tables(node) ⇒ Object
Retrieve the list of tables associated with the specified node.
Constructor Details
#initialize(options = {}) ⇒ Service
Create a new SkyQuery service instance. Currently the only valid keys in the options
hash is :end_point
representing the location of the SkyQuery soap service and :namespace
representing the namespace of that service. The default is to use OpenSkyQuery (i.e. end_point = openskyquery.net/Sky/SkyPortal/SkyPortal.asmx and namespace = SkyPortal.ivoa.net)
portal = SkyQuery.new
33 34 35 36 |
# File 'lib/voruby/sky_query/sky_query.rb', line 33 def initialize(={}) self.namespace = [:namespace] || 'SkyPortal.ivoa.net' self.end_point = [:end_point] || 'http://openskyquery.net/Sky/SkyPortal/SkyPortal.asmx' end |
Instance Attribute Details
#end_point ⇒ Object
Returns the value of attribute end_point.
16 17 18 |
# File 'lib/voruby/sky_query/sky_query.rb', line 16 def end_point @end_point end |
#namespace ⇒ Object
Returns the value of attribute namespace.
15 16 17 |
# File 'lib/voruby/sky_query/sky_query.rb', line 15 def namespace @namespace end |
Class Method Details
.query(adql, node = nil, options = {}) ⇒ Object
22 23 24 |
# File 'lib/voruby/sky_query/sky_query.rb', line 22 def self.query(adql, node=nil, ={}) self.new().query(adql, node) end |
Instance Method Details
#column_info(node, table, column) ⇒ Object
Retrieve the metadata associated with the specified column. Returns an object with #name, #unit, #description and #ucd fields.
info = portal.column_info('SDSS', 'PhotoPrimary', 'modelMag_i')
144 145 146 147 148 |
# File 'lib/voruby/sky_query/sky_query.rb', line 144 def column_info(node, table, column) response = @portal.call('GetColumnInfo', node.to_s, table.to_s, column.to_s) xml = XML::Parser.string(response).parse.root.find_first("//*[local-name()='GetColumnInfoResult']") (xml) end |
#columns(node, table) ⇒ Object
Retrieve the list of columns associated with the specified table. Returns a list of column names.
column_names = portal.columns('SDSS', 'PhotoPrimary')
153 154 155 156 |
# File 'lib/voruby/sky_query/sky_query.rb', line 153 def columns(node, table) response = @portal.call('GetColumns', node.to_s, table.to_s) XML::Parser.string(response).parse.root.find("//*[local-name()='string']").collect { |c| c.content } end |
#meta_columns(node, table) ⇒ Object
Retrieve the metadata associated with the columns of the specified table. Returns a list of objects with #name, #unit, #description and #ucd fields.
columns = portal.('SDSS', 'PhotoPrimary')
136 137 138 139 |
# File 'lib/voruby/sky_query/sky_query.rb', line 136 def (node, table) response = @portal.call('GetMetaColumns', node.to_s, table.to_s) XML::Parser.string(response).parse.root.find("//*[local-name()='MetaColumn']").collect{ |mc| (mc) } end |
#query(adql, node = nil) ⇒ Object
Query the SkyQuery service. A VOTable::V1_1::VOTable is returned.
votable = portal.query('SELECT o.objid, o.ra, o.dec FROM SDSS:PhotoPrimary o WHERE o.type = 3') # typical, distributed query
votable = portal.query('SELECT o.objid, o.ra, o.dec FROM SDSS:PhotoPrimary o WHERE o.type = 3', 'SDSS') # query a particular node (unusual)
108 109 110 111 112 113 114 |
# File 'lib/voruby/sky_query/sky_query.rb', line 108 def query(adql, node=nil) response = node ? @portal.call('SubmitQuery', adql.to_s, node, 'votable') : @portal.call('SubmitDistributedQuery', adql.to_s, 'votable') parse_votable(response) end |
#sky_nodes ⇒ Object
Find all nodes available from the SkyPortal service. Returns a VOTable::V1_1::VOTable.
100 101 102 103 |
# File 'lib/voruby/sky_query/sky_query.rb', line 100 def sky_nodes response = @portal.call('GetAllSkyNodesVOTable') parse_votable(response, 'GetAllSkyNodesVOTableResult') end |
#table_info(node, table) ⇒ Object
Retrieve the metadata associated with the specified table. Returns an object with #name, #description and #rows fields.
info = portal.table_info('SDSS', 'PhotoPrimary')
127 128 129 130 131 |
# File 'lib/voruby/sky_query/sky_query.rb', line 127 def table_info(node, table) response = @portal.call('GetTableInfo', node.to_s, table.to_s) xml = XML::Parser.string(response).parse.root.find_first("//*[local-name()='GetTableInfoResult']") (xml) end |
#tables(node) ⇒ Object
Retrieve the list of tables associated with the specified node. Returns a list of objects with #name, #description and #rows fields.
tables = portal.tables('SDSS')
119 120 121 122 |
# File 'lib/voruby/sky_query/sky_query.rb', line 119 def tables(node) response = @portal.call('GetTables', node.to_s) XML::Parser.string(response).parse.root.find("//*[local-name()='MetaTable']").collect{ |mt| (mt) } end |