From b5b9808f8854ef5770e7518d87a61f241c65423a Mon Sep 17 00:00:00 2001 From: iskren-y-g Date: Sat, 12 Dec 2020 18:15:29 +0100 Subject: [PATCH 1/6] Added hyperleda --- astroquery/hyperleda/__init__.py | 35 ++++ astroquery/hyperleda/core.py | 269 +++++++++++++++++++++++++++++++ 2 files changed, 304 insertions(+) create mode 100644 astroquery/hyperleda/__init__.py create mode 100644 astroquery/hyperleda/core.py diff --git a/astroquery/hyperleda/__init__.py b/astroquery/hyperleda/__init__.py new file mode 100644 index 0000000000..7eb0fa6857 --- /dev/null +++ b/astroquery/hyperleda/__init__.py @@ -0,0 +1,35 @@ +# Licensed under a 3-clause BSD style license - see LICENSE.rst + +""" +HyperLEDA Query Tool +------------------- + +A tool to query HyperLEDA +http://leda.univ-lyon1.fr/ + +:author: Iskren Y. Georgiev (iskren.y.g@gmail.com) +""" + +from astropy import config as _config + +class Conf(_config.ConfigNamespace): + """ + Configuration parameters for `astroquery.hyperleda`. + """ + server = _config.ConfigItem( + ['http://leda.univ-lyon1.fr/'], + 'Base URL for HyperLeda http requests' + ) + + timeout = _config.ConfigItem( + 30, + 'Time timeout for the HyperLeda query.' + ) + +conf = Conf() + +from .core import hyperleda, HyperLEDAClass + +__all__ = ['hyperleda', 'HyperLEDAClass', + 'Conf', 'conf', + ] diff --git a/astroquery/hyperleda/core.py b/astroquery/hyperleda/core.py new file mode 100644 index 0000000000..f59f1ad6a3 --- /dev/null +++ b/astroquery/hyperleda/core.py @@ -0,0 +1,269 @@ +# Licensed under a 3-clause BSD style license - see LICENSE.rst + +__author__ = "Iskren Y. Georgiev" +__author_email__ = "iskren.y.g@gmail.com" +__date__ = '2020/12/06' + +# Imports organized as shown below + +# 1. local imports relative imports +# all Query classes should inherit from BaseQuery. +from ..query import BaseQuery +# has common functions required by most modules +from ..utils import commons +# prepend_docstr is a way to copy docstrings between methods +from ..utils import prepend_docstr_nosections +# async_to_sync generates the relevant query tools from _async methods +from ..utils import async_to_sync +from ..utils.class_or_instance import class_or_instance +# import configurable items declared in __init__.py +from . import conf + +# 2. standard library imports + +# 3. third party imports +import astropy.units as u +import astropy.coordinates as coord +import astropy.io.votable as votable +from astropy.table import Table, vstack +from astropy.io import fits + + +# export all the public classes and methods +__all__ = ['hyperleda', 'HyperLEDAClass'] + +# declare global variables and constants if any + + +# Begin main class +# Should be decorated with the async_to_sync imported previously + +@async_to_sync +class HyperLEDAClass(BaseQuery): + + """ + Base class for querying data from the HyperLEDA database. + + http://leda.univ-lyon1.fr + + """ + + URL = conf.server + TIMEOUT = conf.timeout + # The URL with the table of the main object properties + URL_PROPERTIES = URL + '/leda/meandata.html' + URL_HTTP_REQUEST = URL + '/fG.cgi' + + @class_or_instance + def get_properties(self): + + """ + + Get the available object properties in the HyperLEDA database. + (See http://leda.univ-lyon1.fr/leda/meandata.html) + + Returns an `~astropy.table.Table` object. + + Returns + ------- + + prop_tbl : An `~astropy.table.Table` object with the available object + properties in HyperLEDA + + Example + -------- + >>> from astroquery.hyperleda import hyperleda + >>> + >>> properties_tbl = hyperleda.get_properties() + >>> properties_tbl.pprint_all() + + """ + + url_prop = self.URL_PROPERTIES + response = self._request("GET", url_prop) + prop_tbl = self._parse_result(response) + + return prop_tbl + + def _perp_param_lst(self, param_lst): + # Prepare the parameter's list + #print('Full list of parameters number:',len(str(param_lst).split(','))) + + # These params are no longer in the leda tables + for param in ['numtype','hptr','logavmm','e_logavmm']: + if param in param_lst: + param_lst.remove(param) + + param_str = str(param_lst) + param_str = param_str[2:param_str.rfind('\'')] + param_str = param_str.replace('\', \'', ',') + return param_str + + @class_or_instance + def query_object(self, obj_name, properties = 'all'): + """ + + Query an object from the HyperLEDA database. + + Returns the object properties in an `~astropy.table.Table` object. + + Example + -------- + >>> from astroquery.hyperleda import hyperleda + >>> result_table = hyperleda.query_object(obj_name = 'UGC12591', + properties = 'objname,type,logr25, + btc,v,modbest,al2000,de2000, + celposJ(pgc)') + >>> result_table.pprint() + + Parameters + ---------- + obj_name : str + + Object ID recognizable by HyperLEDA or SIMBAD + + properties : str, or comma separated strings. Default: 'all' + + The full list of properties in HyperLEDA is available at + http://leda.univ-lyon1.fr/leda/meandata.html + or via + hyperleda.get_properties().pprint_all() + + Returns + ------- + + Table : An `~astropy.table.Table` object with the object properties + from HyperLEDA + + """ + + if properties == 'all': + prop_tbl = self.get_properties() + param_lst = prop_tbl['field'].data.tolist() + param_str = self._perp_param_lst(param_lst) + else: + param_str = properties + + url_http_request = self.URL_HTTP_REQUEST + + ls_SQL_search = "objname = objname('{:}')".format(obj_name) + + request_payload = dict(n = 'meandata', c = 'o', of = '1,leda,simbad', + nra = 'l', nakd = '1', + d = '{:}'.format(param_str), + sql = '{:}'.format(ls_SQL_search), ob = '', + a = 'csv[|]') + response = self._request("GET", url_http_request, + params=request_payload) + sql_result_tbl = Table.read(response.url, format='ascii', delimiter='|') + + return sql_result_tbl + + @class_or_instance + def query_sql(self, search, properties = 'all'): + + """ + + Perform SQL search in the HyperLEDA database. + (See http://leda.univ-lyon1.fr/fullsql.html) + + Returns an `~astropy.table.Table` object with the results from the + search containing the object properties. + + Parameters + ---------- + search : str + + A string containing a valid SQL WHERE clause. + + properties : str, or comma separated strings. Default: 'all' + + The full list of properties in HyperLEDA is available at + http://leda.univ-lyon1.fr/leda/meandata.html + or via + hyperleda.get_properties().pprint_all() + + Returns + ------- + + Table : An `~astropy.table.Table` object with the object properties from + HyperLEDA + + Example + -------- + >>> from astroquery.hyperleda import hyperleda + >>> hl = hyperleda() + >>> sql_tbl = hl.query_sql(search = "(mod0<=27 and t>=-3 and t<=0 and + type='S0') or (mod0<=27 and t>=-3 + and t<=0 and type='S0-a')", + properties = 'objname,type,logr25,btc,v, + modbest,al2000,de2000,hl_names(pgc), + celposJ(pgc)') + >>> result_table.pprint() + """ + + if properties == 'all': + prop_tbl = self.get_properties() + param_lst = prop_tbl['field'].data.tolist() + param_str = self._perp_param_lst(param_lst) + else: + param_str = properties + + url_http_request = self.URL_HTTP_REQUEST + + ls_SQL_search = search + + request_payload = dict(n = 'meandata', c = 'o', of = '1,leda,simbad', + nra = 'l', nakd = '1', + d = '{:}'.format(param_str), + sql = '{:}'.format(ls_SQL_search), ob = '', + a = 'csv[|]') + response = self._request("GET", url_http_request, + params=request_payload) + sql_result_tbl = Table.read(response.url, format='ascii', delimiter='|') + + return sql_result_tbl + + def _parse_result(self, response, verbose=False): + # if verbose is False then suppress any VOTable related warnings + if not verbose: + commons.suppress_vo_warnings() + # try to parse the result into an astropy.Table, else + # return the raw result with an informative error message. + try: + # do something with regex to get the result into + # astropy.Table form. return the Table. + + lind = response.text.find('/fG.cgi') + rind = lind + response.text[lind:].find('"') + ls_url_props_src = response.text[lind:rind] + ls_url_props = self.URL + ls_url_props_src + + # Get the main table + prop_tbl = Table.read(ls_url_props, format = 'ascii.html') + prop_tbl.rename_columns(prop_tbl.colnames, + ['field', 'type', 'units', 'description']) + + # Get the table with the available SQL functions + sql_func_tbl = Table.read(response.url, format='ascii.html', + htmldict={'table_id' : 2}) + + sql_func_tbl.add_column(col='--', name='units', index=2) + sql_func_tbl.rename_columns(sql_func_tbl.colnames, + ['field', 'type', 'units', 'description']) + prop_tbl = vstack([prop_tbl, sql_func_tbl]) + except ValueError: + # catch common errors here, but never use bare excepts + # return raw result/ handle in some way + pass + + return prop_tbl + +# the default tool for users to interact with is an instance of the Class +hyperleda = HyperLEDAClass() + +# once your class is done, tests should be written +# See ./tests for examples on this + +# Next you should write the docs in astroquery/docs/module_name +# using Sphinx. \ No newline at end of file From 14e6a49d834c4da831a31e262daffe7cc1a3ef12 Mon Sep 17 00:00:00 2001 From: iskren-y-g Date: Mon, 22 Mar 2021 14:53:39 +0100 Subject: [PATCH 2/6] New service to access HyperLEDA [#298] --- astroquery/hyperleda/core.py | 3 +- astroquery/hyperleda/tests/__init__.py | 0 .../hyperleda/tests/data/query_object.dat | 100 +++++++++ astroquery/hyperleda/tests/data/query_sql.dat | 102 +++++++++ astroquery/hyperleda/tests/setup_package.py | 15 ++ astroquery/hyperleda/tests/test_hyperleda.py | 76 +++++++ .../hyperleda/tests/test_hyperleda_remote.py | 22 ++ docs/hyperleda/hyperleda.rst | 204 ++++++++++++++++++ 8 files changed, 521 insertions(+), 1 deletion(-) create mode 100644 astroquery/hyperleda/tests/__init__.py create mode 100644 astroquery/hyperleda/tests/data/query_object.dat create mode 100644 astroquery/hyperleda/tests/data/query_sql.dat create mode 100644 astroquery/hyperleda/tests/setup_package.py create mode 100644 astroquery/hyperleda/tests/test_hyperleda.py create mode 100644 astroquery/hyperleda/tests/test_hyperleda_remote.py create mode 100644 docs/hyperleda/hyperleda.rst diff --git a/astroquery/hyperleda/core.py b/astroquery/hyperleda/core.py index f59f1ad6a3..37d394e6a3 100644 --- a/astroquery/hyperleda/core.py +++ b/astroquery/hyperleda/core.py @@ -2,7 +2,8 @@ __author__ = "Iskren Y. Georgiev" __author_email__ = "iskren.y.g@gmail.com" -__date__ = '2020/12/06' + +# Based on: https://astroquery.readthedocs.io/en/latest/template.html # Imports organized as shown below diff --git a/astroquery/hyperleda/tests/__init__.py b/astroquery/hyperleda/tests/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/astroquery/hyperleda/tests/data/query_object.dat b/astroquery/hyperleda/tests/data/query_object.dat new file mode 100644 index 0000000000..2aa7376810 --- /dev/null +++ b/astroquery/hyperleda/tests/data/query_object.dat @@ -0,0 +1,100 @@ +# Query Description +# Type of request: Extract data from a table +# Name of the selected table: meandata +# Restrict with the SQL clause: objname = objname('UGC12591') +# Display the fields: pgc,objname,objtype,al1950,de1950,al2000,de2000,l2,b2,sgl,sgb,type,bar,ring,multiple,compactness,t,e_t,logd25,e_logd25,logr25,e_logr25,pa,brief,e_brief,bt,e_bt,it,e_it,ut,vt,ube,bve,vmaxg,e_vmaxg,vmaxs,e_vmaxs,vdis,e_vdis,m21,e_m21,mfir,vrad,e_vrad,vopt,e_vopt,v,e_v,ag,ai,incl,a21,logdc,btc,itc,ubtc,bvtc,bri25,vrot,e_vrot,mg2,e_mg2,m21c,hic,vlg,vgsr,vvir,v3k,modz,mod0,mabs,agnclass,f_astrom,e_mod0,e_modz,e_mabs,modbest,e_modbest,kt,e_kt,e_ut,e_vt,hl_names(pgc),celposB(pgc),celposJ(pgc) +# Description of each column +# pgc: ----------------- +# objname: ------------- +# objtype: ------------- +# al1950: -------------- +# de1950: -------------- +# al2000: -------------- +# de2000: -------------- +# l2: ------------------ +# b2: ------------------ +# sgl: ----------------- +# sgb: ----------------- +# type: ---------------- +# bar: ----------------- +# ring: ---------------- +# multiple: ------------ +# compactness: --------- +# t: ------------------- +# e_t: ----------------- +# logd25: -------------- +# e_logd25: ------------ +# logr25: -------------- +# e_logr25: ------------ +# pa: ------------------ +# brief: --------------- +# e_brief: ------------- +# bt: ------------------ +# e_bt: ---------------- +# it: ------------------ +# e_it: ---------------- +# ut: ------------------ +# vt: ------------------ +# ube: ----------------- +# bve: ----------------- +# vmaxg: --------------- +# e_vmaxg: ------------- +# vmaxs: --------------- +# e_vmaxs: ------------- +# vdis: ---------------- +# e_vdis: -------------- +# m21: ----------------- +# e_m21: --------------- +# mfir: ---------------- +# vrad: ---------------- +# e_vrad: -------------- +# vopt: ---------------- +# e_vopt: -------------- +# v: ------------------- +# e_v: ----------------- +# ag: ------------------ +# ai: ------------------ +# incl: ---------------- +# a21: ----------------- +# logdc: --------------- +# btc: ----------------- +# itc: ----------------- +# ubtc: ---------------- +# bvtc: ---------------- +# bri25: --------------- +# vrot: ---------------- +# e_vrot: -------------- +# mg2: ----------------- +# e_mg2: --------------- +# m21c: ---------------- +# hic: ----------------- +# vlg: ----------------- +# vgsr: ---------------- +# vvir: ---------------- +# v3k: ----------------- +# modz: ---------------- +# mod0: ---------------- +# mabs: ---------------- +# agnclass: ------------ +# f_astrom: ------------ +# e_mod0: -------------- +# e_modz: -------------- +# e_mabs: -------------- +# modbest: ------------- +# e_modbest: ----------- +# kt: ------------------ +# e_kt: ---------------- +# e_ut: ---------------- +# e_vt: ---------------- +# hl_names(pgc): ------- +# celposB(pgc): -------- +# celposJ(pgc): -------- +#---|-------|-------|------|------|------|------|--|--|---|---|----|---|----|--------|-----------|-|---|------|--------|------|--------|--|-----|-------|--|----|--|----|--|--|---|---|-----|-------|-----|-------|----|------|---|-----|----|----|------|----|------|-|---|--|--|----|---|-----|---|---|----|----|-----|----|------|---|-----|----|---|---|----|----|---|----|----|----|--------|--------|------|------|------|-------|---------|--|----|----|----|-------------|------------|------------ +pgc|objname|objtype|al1950|de1950|al2000|de2000|l2|b2|sgl|sgb|type|bar|ring|multiple|compactness|t|e_t|logd25|e_logd25|logr25|e_logr25|pa|brief|e_brief|bt|e_bt|it|e_it|ut|vt|ube|bve|vmaxg|e_vmaxg|vmaxs|e_vmaxs|vdis|e_vdis|m21|e_m21|mfir|vrad|e_vrad|vopt|e_vopt|v|e_v|ag|ai|incl|a21|logdc|btc|itc|ubtc|bvtc|bri25|vrot|e_vrot|mg2|e_mg2|m21c|hic|vlg|vgsr|vvir|v3k|modz|mod0|mabs|agnclass|f_astrom|e_mod0|e_modz|e_mabs|modbest|e_modbest|kt|e_kt|e_ut|e_vt|hl_names(pgc)|celposB(pgc)|celposJ(pgc) +#---|-------|-------|------|------|------|------|--|--|---|---|----|---|----|--------|-----------|-|---|------|--------|------|--------|--|-----|-------|--|----|--|----|--|--|---|---|-----|-------|-----|-------|----|------|---|-----|----|----|------|----|------|-|---|--|--|----|---|-----|---|---|----|----|-----|----|------|---|-----|----|---|---|----|----|---|----|----|----|--------|--------|------|------|------|-------|---------|--|----|----|----|-------------|------------|------------ +71392|UGC12591|G |23.3815858|28.2202179|23.4227381|28.4951858|100.9202008|-30.6712342|320.8496493|26.8558166|S0-a|||||0.1|0.8|1.166|0.087|0.354|0.051|58.5|||13.919|0.324|||||||471|11.86|||287.95|23.89|16.801|0.42||6944.7|6.6|6915|14.4|6939.5|9|0.496|0.145|74.67|0.06|1.199|13.174||||23.274|488.38|12.54|||16.738|3.564|7219.3|7130.4|7067.7|6596.1|35.067||-21.893||0||0.154|0.358|35.067|0.154|8.915|0.04|||2MASXJ23252175+2829425,2MIG3158,CGCG497-015,MCG+05-55-015,PGC071392,UGC12591,UZC232254+28130|B232253.7+281313|J232521.9+282943 +#-- end of data table ---------------------------------------------------------- +# 1 lines were successfully retrieved +#------------------------------------------------------------------------------- +# Pleinpot version: 8.18.11 +# Date: 2020-12-08T11:12:40 diff --git a/astroquery/hyperleda/tests/data/query_sql.dat b/astroquery/hyperleda/tests/data/query_sql.dat new file mode 100644 index 0000000000..f68e1074f1 --- /dev/null +++ b/astroquery/hyperleda/tests/data/query_sql.dat @@ -0,0 +1,102 @@ +# Query Description +# Type of request: Extract data from a table +# Name of the selected table: meandata +# Restrict with the SQL clause: (mod0<=29 and t>=-3 and t<=0 and type='S0') or (mod0<=29 and t>=-3 and t<=0 and type='S0-a') +# Display the fields: pgc,objname,objtype,al1950,de1950,al2000,de2000,l2,b2,sgl,sgb,type,bar,ring,multiple,compactness,t,e_t,logd25,e_logd25,logr25,e_logr25,pa,brief,e_brief,bt,e_bt,it,e_it,ut,vt,ube,bve,vmaxg,e_vmaxg,vmaxs,e_vmaxs,vdis,e_vdis,m21,e_m21,mfir,vrad,e_vrad,vopt,e_vopt,v,e_v,ag,ai,incl,a21,logdc,btc,itc,ubtc,bvtc,bri25,vrot,e_vrot,mg2,e_mg2,m21c,hic,vlg,vgsr,vvir,v3k,modz,mod0,mabs,agnclass,f_astrom,e_mod0,e_modz,e_mabs,modbest,e_modbest,kt,e_kt,e_ut,e_vt,hl_names(pgc),celposB(pgc),celposJ(pgc) +# Description of each column +# pgc: ----------------- +# objname: ------------- +# objtype: ------------- +# al1950: -------------- +# de1950: -------------- +# al2000: -------------- +# de2000: -------------- +# l2: ------------------ +# b2: ------------------ +# sgl: ----------------- +# sgb: ----------------- +# type: ---------------- +# bar: ----------------- +# ring: ---------------- +# multiple: ------------ +# compactness: --------- +# t: ------------------- +# e_t: ----------------- +# logd25: -------------- +# e_logd25: ------------ +# logr25: -------------- +# e_logr25: ------------ +# pa: ------------------ +# brief: --------------- +# e_brief: ------------- +# bt: ------------------ +# e_bt: ---------------- +# it: ------------------ +# e_it: ---------------- +# ut: ------------------ +# vt: ------------------ +# ube: ----------------- +# bve: ----------------- +# vmaxg: --------------- +# e_vmaxg: ------------- +# vmaxs: --------------- +# e_vmaxs: ------------- +# vdis: ---------------- +# e_vdis: -------------- +# m21: ----------------- +# e_m21: --------------- +# mfir: ---------------- +# vrad: ---------------- +# e_vrad: -------------- +# vopt: ---------------- +# e_vopt: -------------- +# v: ------------------- +# e_v: ----------------- +# ag: ------------------ +# ai: ------------------ +# incl: ---------------- +# a21: ----------------- +# logdc: --------------- +# btc: ----------------- +# itc: ----------------- +# ubtc: ---------------- +# bvtc: ---------------- +# bri25: --------------- +# vrot: ---------------- +# e_vrot: -------------- +# mg2: ----------------- +# e_mg2: --------------- +# m21c: ---------------- +# hic: ----------------- +# vlg: ----------------- +# vgsr: ---------------- +# vvir: ---------------- +# v3k: ----------------- +# modz: ---------------- +# mod0: ---------------- +# mabs: ---------------- +# agnclass: ------------ +# f_astrom: ------------ +# e_mod0: -------------- +# e_modz: -------------- +# e_mabs: -------------- +# modbest: ------------- +# e_modbest: ----------- +# kt: ------------------ +# e_kt: ---------------- +# e_ut: ---------------- +# e_vt: ---------------- +# hl_names(pgc): ------- +# celposB(pgc): -------- +# celposJ(pgc): -------- +#---|-------|-------|------|------|------|------|--|--|---|---|----|---|----|--------|-----------|-|---|------|--------|------|--------|--|-----|-------|--|----|--|----|--|--|---|---|-----|-------|-----|-------|----|------|---|-----|----|----|------|----|------|-|---|--|--|----|---|-----|---|---|----|----|-----|----|------|---|-----|----|---|---|----|----|---|----|----|----|--------|--------|------|------|------|-------|---------|--|----|----|----|-------------|------------|------------ +pgc|objname|objtype|al1950|de1950|al2000|de2000|l2|b2|sgl|sgb|type|bar|ring|multiple|compactness|t|e_t|logd25|e_logd25|logr25|e_logr25|pa|brief|e_brief|bt|e_bt|it|e_it|ut|vt|ube|bve|vmaxg|e_vmaxg|vmaxs|e_vmaxs|vdis|e_vdis|m21|e_m21|mfir|vrad|e_vrad|vopt|e_vopt|v|e_v|ag|ai|incl|a21|logdc|btc|itc|ubtc|bvtc|bri25|vrot|e_vrot|mg2|e_mg2|m21c|hic|vlg|vgsr|vvir|v3k|modz|mod0|mabs|agnclass|f_astrom|e_mod0|e_modz|e_mabs|modbest|e_modbest|kt|e_kt|e_ut|e_vt|hl_names(pgc)|celposB(pgc)|celposJ(pgc) +#---|-------|-------|------|------|------|------|--|--|---|---|----|---|----|--------|-----------|-|---|------|--------|------|--------|--|-----|-------|--|----|--|----|--|--|---|---|-----|-------|-----|-------|----|------|---|-----|----|----|------|----|------|-|---|--|--|----|---|-----|---|---|----|----|-----|----|------|---|-----|----|---|---|----|----|---|----|----|----|--------|--------|------|------|------|-------|---------|--|----|----|----|-------------|------------|------------ +45917|ESO269-068|G |13.1717727|-43.0001265|13.2198401|-43.2650589|307.1284821|19.429432|159.3859661|-7.4716467|S0|||||-2.1|2.1|1.054|0.04|0.122|0.03|130.7|||14.335|0.247|13.25|0.087||13.95||||||||||||||647|96|647|96|0.522|0|48.33|0.02|1.109|13.803|13.02|||23.342|||||||393.6|480|511.6|908.2|29.52|27.87|-14.067||1|0.016|2.159|0.247|27.87|0.016|11.41|0.217||0.07|ESO269-068,ESOLV2690680,FAIR0464,LGG339:[G93]013,NGC5011C,PGC045917,[DCL86]531|B131018.4-430000|J131311.4-431554 +3792|PGC003792|G |1.0206031|21.6197689|1.0653111|21.8878333|126.7628311|-40.8910332|318.1311181|3.7983249|S0-a|||||-1|2|1.079|0.143|0.237|0.1|175|||16.18|0.5||||15.45||0.83|7.07|0.29|||7.77|4.03|16.637|0.126||-285.6|2.5|-283.3|2.4|-284.4|1.5|0.175|0|63.83|0.04|1.087|16.01||||25.269|7.87|0.34|||16.6|0.59|-71.9|-152.6|-244|-601.7||24.419|-8.41||0|0.091||0.508|24.419|0.091||||0.15|AGC110007,LGS3,PGC003792|B010114.2+213711|J010355.1+215316 +46957|NGC5128|G |13.3755878|-42.7581473|13.424479|-43.0181183|309.5176614|19.4180996|159.7526765|-5.248104|S0|||M||-2.1|0.6|2.408|0.014|0.107|0.035|32.17|21.885|0.856|7.788|0.26||||7.217|0.27|1.14|256.4|10.47|107.69|31.22|103.39|6.15|12.587|0.236|7.185|563.8|5.8|547.2|3.6|551.9|5.7|0.497|0|45.33|0.02|2.46|7.282|||0.873|23.567|360.54|15.53|||12.565|5.283|305.6|390.8|422.8|806.2||27.828|-20.546|?|0|0.025||0.261|27.828|0.025|3.968|0.129||0.32|2MASXJ13252775-4301073,ARP153,CENTAURUS_A,ESO270-009,ESOLV2700090,HIPASSJ1324-42,IRAS13225-4245,LGG344:[G93]002,MCG-07-28-001,MRC1322-427,NGC5128,PGC046957|B132232.1-424529|J132528.1-430105 +#-- end of data table ---------------------------------------------------------- +# 3 lines were successfully retrieved +#------------------------------------------------------------------------------- +# Pleinpot version: 8.18.11 +# Date: 2020-12-08T11:14:52 diff --git a/astroquery/hyperleda/tests/setup_package.py b/astroquery/hyperleda/tests/setup_package.py new file mode 100644 index 0000000000..5ba92bfcb7 --- /dev/null +++ b/astroquery/hyperleda/tests/setup_package.py @@ -0,0 +1,15 @@ +# Licensed under a 3-clause BSD style license - see LICENSE.rst + +import os + +# setup paths to the test data +# can specify a single file or a list of files +def get_package_data(): + + paths = [os.path.join('data', '*.dat'), + os.path.join('data', '*.html') + ] # etc, add other extensions + # you can also enlist files individually by names + # finally construct and return a dict for the sub module + + return {'astroquery.hyperleda.tests': paths} diff --git a/astroquery/hyperleda/tests/test_hyperleda.py b/astroquery/hyperleda/tests/test_hyperleda.py new file mode 100644 index 0000000000..463f68b404 --- /dev/null +++ b/astroquery/hyperleda/tests/test_hyperleda.py @@ -0,0 +1,76 @@ +# Licensed under a 3-clause BSD style license - see LICENSE.rst + +# Based on astroquery/template_module +# https://github.com/astropy/astroquery/tree/8248ba8fd0aa3a4c8221db729a127db047e18f4e/astroquery/template_module + +import pytest + +# Import commonly used modules for tests +import os +import requests +from numpy import testing as npt +from astropy.table import Table + +from ...utils.testing_tools import MockResponse + +# Import the module which is to be tested +# and the various configuration items created +from ... import hyperleda +from ...hyperleda import conf + + +# Local tests should have the corresponding data stored +# in the ./data folder. This is the actual HTTP response +# one would expect from the server when a valid query is made. + +DATA_FILES = {'query': 'query_object.dat', + #'query_sql': 'query_sql.dat', + } + + +# ./setup_package.py helps the test function locate the data file +# define a function that can construct the full path to the file in the +# ./data directory: +def data_path(filename): + data_dir = os.path.join(os.path.dirname(__file__), 'data') + return os.path.join(data_dir, filename) + + +# Define a monkeypatch replacement request function that returns the +# dummy HTTP response for the dummy 'get' function, by +# reading in data from some data file: +def nonremote_request(self, request_type, url, **kwargs): + # kwargs are ignored in this case, but they don't have to be + # (you could use them to define which data file to read) + pick_file = 'query' + with open(data_path(DATA_FILES[pick_file]), 'rb') as f: + response = MockResponse(content=f.read(), url=url) + return response + + +# pytest fixture creates a dummy 'requests.get' function, that +# mocks(monkeypatches) the actual 'requests.get' function: +@pytest.fixture +def patch_request(request): + try: + mp = request.getfixturevalue("monkeypatch") + except AttributeError: # pytest < 3 + mp = request.getfuncargvalue("monkeypatch") + mp.setattr(hyperleda.core.HyperLEDAClass, '_request', + nonremote_request) + return mp + + +# Test the methods using the mock HTTP response +def test_query_object(patch_request): + result = hyperleda.core.HyperLEDAClass().query_object('UGC12591', + properties=['bt', 'vt']) + assert isinstance(result, Table) + +def test_query_sql(patch_request): + sample_query = "(mod0<=27 and t>=-3 and t<=0 and type='S0') \ + or (mod0<=27 and t>=-3 and t<=0 and type='S0-a')" + result = hyperleda.core.HyperLEDAClass().query_sql(sample_query, + properties=['bt', 'vt']) + assert isinstance(result, Table) + \ No newline at end of file diff --git a/astroquery/hyperleda/tests/test_hyperleda_remote.py b/astroquery/hyperleda/tests/test_hyperleda_remote.py new file mode 100644 index 0000000000..9b8871eae5 --- /dev/null +++ b/astroquery/hyperleda/tests/test_hyperleda_remote.py @@ -0,0 +1,22 @@ +# Licensed under a 3-clause BSD style license - see LICENSE.rst + + +import pytest +from astropy.table import Table + +from ..core import hyperleda + +@pytest.mark.remote_data +class TestHyperLEDAClass: + + def test_query_object(self): + result = hyperleda.query_object('UGC12591', properties=['bt', 'vt']) + assert isinstance(result, Table) + assert len(result) == 1 + + def test_query_sql(self): + sample_query = "(modbest<=30 and t>=-3 and t<=0 and type='S0') \ + or (modbest<=30 and t>=-3 and t<=0 and type='S0-a')" + result = hyperleda.query_sql(sample_query, properties='all') + assert isinstance(result, Table) + assert len(result) >= 1 diff --git a/docs/hyperleda/hyperleda.rst b/docs/hyperleda/hyperleda.rst new file mode 100644 index 0000000000..7c82d60ef7 --- /dev/null +++ b/docs/hyperleda/hyperleda.rst @@ -0,0 +1,204 @@ +HyperLEDA Queries (astroquery.hyperleda) +======================================== + +Getting Started +--------------- + +This module can be used to query from the HyperLEDA web service. The +queries will return the resultsin an astropy Table. Below are two +working examples illustrating how to retrieve data for a single +object,or using an SQL query request to the HyperLEDA SQL data access +service. + +-------------- + +Query an object +--------------- + +Query the object by name. For instance if you want to query UGC 1259 + +.. code:: ipython3 + + from astroquery.hyperleda import hyperleda + + result_table = hyperleda.query_object('UGC12591' , properties='all') + print(result_table) # an astropy.table.Table + + + +.. parsed-literal:: + + pgc objname objtype ... celposB(pgc) celposJ(pgc) + ----- -------- ------- ... ---------------- ---------------- + 71392 UGC12591 G ... B232253.7+281313 J232521.9+282943 + + +-------------- + +To see all available properties use: + +.. code:: ipython3 + + properties_tbl = hyperleda.get_properties() + properties_tbl.pprint_all() + + +.. parsed-literal:: + + field type units description + ------------- ------ --------------- --------------------------------------------------------------------------------- + pgc int -- PGC number + objname char -- Principal name + objtype char -- Type of object (G=galaxy; S=Star ...) + al1950 double hour RA 1950 (hours decimal value) + de1950 double deg DEC 1950 (degrees decimal value) + al2000 double hour RA 2000 (hours decimal value) + de2000 double deg DEC 2000 (degrees decimal value) + l2 double deg Galactic longitude + b2 double deg Galactic latitude + sgl double deg Supergalactic longitude + sgb double deg Supergalactic latitude + type char -- Morphological type + bar char -- Barred galaxy (B) + ring char -- Galaxy with ring (R) + multiple char -- Multiple galaxy (M) + compactness char -- Compact (C) or diffuse (D) + t float -- Morphological type code + e_t float -- Actual error on t (Morphological type code) + logd25 float log(0.1 arcmin) log of apparent diameter (d25 in 0.1 arcmin) + e_logd25 float log(0.1 arcmin) Actual error on logd25 (log of apparent diameter in 0.1 arcmin) + logr25 float log log of axis ratio (major axis/minor axis) + e_logr25 float log Actual error on logr25 (log of axis ratio: major axis/minor axis) + pa float deg Major axis position angle (North Eastwards) + brief float mag/arcsec2 Mean effective surface brightness + e_brief float mag/arcsec2 Actual error on brief (Mean effective surface brightness) + bt float mag Total B-magnitude + e_bt float mag Actual error on bt (Total B-magnitude) + it float mag Total I-magnitude + e_it float mag Actual error on it (Total I-magnitude) + ut float mag Total U-magnitude + vt float mag Total V-magnitude + ube float mag Effective U-B color + bve float mag Effective B-V color + vmaxg float km/s Apparent maximum rotation velocity of gas + e_vmaxg float km/s Actual error on vmaxg (Apparent maximum rotation velocity of gas) + vmaxs float km/s Apparent maximum rotation velocity of stars + e_vmaxs float km/s Actual error on vmaxs (Apparent maximum rotation velocity of stars) + vdis float km/s Central velocity dispersion + e_vdis float km/s Actual error on vdis (Central velocity dispersion) + m21 float mag 21-cm line flux in magnitude + e_m21 float mag Actual error on m21 (21-cm line flux in magnitude) + mfir float mag Far infrared magnitude + vrad float km/s Heliocentric radial velocity (cz) from radio measurement + e_vrad float km/s Actual error on vrad (Heliocentric radial velocity (cz) from radio measurement) + vopt float km/s Heliocentric radial velocity (cz) from optical measurement + e_vopt float km/s Actual error on vopt (Heliocentric radial velocity (cz) from optical measurement) + v float km/s Mean Heliocentric radial velocity (cz) + e_v float km/s Actual error on v (Mean Heliocentric radial velocity) + ag float mag Galactic extinction in B-band + ai float mag Internal extinction due to inclination in B-band + incl float deg Inclination between line of sight and polar axis of a galaxy + a21 float mag 21-cm self absorption + logdc float log(0.1 arcmin) log of apparent corrected diameter (dc in 0.1 arcmin) + btc float mag Total apparent corrected B-magnitude + itc float mag Total apparent corrected I-magnitude + ubtc float mag Total apparent corrected U-B color + bvtc float mag Total apparent corrected B-V color + bri25 float mag/arcsec2 Mean surface brightness within isophote 25 + vrot float km/s Maximum rotation velocity corrected for inclination + e_vrot float km/s Actual error on vrot (Maximum rotation velocity corrected for inclination) + mg2 float mag Central Lick Mg2 index + e_mg2 float mag Actual error on mg2( Central Lick Mg2 index ) + logavmm float -- -- + e_logavmm float -- -- + m21c float mag Corrected 21-cm line flux in magnitude + hic float mag 21-cm index btc-m21c in magnitude + vlg float km/s Radial velocity (cz) with respect to the Local Group + vgsr float km/s Radial velocity (cz) with respect to the GSR + vvir float km/s Radial velocity (cz) corrected for LG infall onto Virgo + v3k float km/s Radial velocity (cz) with respect to the CMB radiation + modz float mag Cosmological distance modulus (from vvir with ΛCDM) + mod0 float mag Distance modulus from distance measurements + mabs float mag Absolute B-band magnitude + numtype char -- -- + hptr char -- -- + agnclass char -- Activity class of AGN + f_astrom char -- Precision flag on astrometry + e_mod0 float mag Actual error on mod0 (Distance modulus from distance measurements) + e_modz float mag Actual error on modz (Cosmological distance modulus from vvir with ΛCDM) + e_mabs float -- -- + modbest float mag Best distance modulus, combining mod0 and modz + e_modbest float mag Actual error on modbest (Best distance modulus, combining mod0 and modz) + kt float mag Total K-magnitude + e_kt float mag Actual error on kt (Total K-magnitude) + e_ut float mag Actual error on ut (Total U-magnitude) + e_vt float mag Actual error on vt (Total V-magnitude) + hl_names(pgc) string -- Comma separated list of all the designations for the object "pgc" + celposB(pgc) string -- Return the B1950 celestial position of object "pgc" in sexagesimal format + celposJ(pgc) string -- Return the J2000 celestial position of object "pgc" in sexagesimal format + + +-------------- + +An example to retrieve only a subset from the available properties: + +.. code:: ipython3 + + from astroquery.hyperleda import hyperleda + result_table = hyperleda.query_object('UGC12591' , properties='objname, type,\ + logr25, btc, v, modbest, al2000, de2000,\ + celposJ(pgc)') + result_table.pprint_all() + + +.. parsed-literal:: + + objname type logr25 btc v modbest al2000 de2000 celposJ(pgc) + -------- ---- ------ ------ ------ ------- ---------- ---------- ---------------- + UGC12591 S0-a 0.354 13.174 6939.5 35.067 23.4227381 28.4951858 J232521.9+282943 + + +-------------- + +Query using SQL syntax +---------------------- + +An example for querying with an SQL syntax used for an SQL query in +HyperLEDA (http://leda.univ-lyon1.fr/fullsql.html). + +.. code:: ipython3 + + from astroquery.hyperleda import hyperleda + + # Define an SQL query + sample_query = "(modbest<=30 and t>=-3 and t<=0 and type='S0') \ + or (modbest<=30 and t>=-3 and t<=0 and type='S0-a')" + + # Select some properties to retrieve + sample_properties= 'objname, al2000, de2000, type, logr25, btc, e_bt, v, modbest' + + # Run the query + result_table = hyperleda.query_sql(sample_query, properties=sample_properties) + +.. code:: ipython3 + + result_table.pprint(max_lines=5, max_width=-1) + + +.. parsed-literal:: + + objname al2000 de2000 type logr25 btc e_bt v modbest + ---------- ---------- ----------- ---- ------ ------ ----- ----- ------- + PGC131397 5.1038562 -38.054287 S0-a 0.17 15.801 0.5 855.0 29.67 + NGC4600 12.6730486 3.1177156 S0 0.149 13.141 0.052 834.9 29.832 + ... ... ... ... ... ... ... ... ... + PGC029300 10.0948898 -7.9814444 S0 0.04 12.97 0.096 714.6 29.942 + ESO269-068 13.2198401 -43.2650589 S0 0.122 13.803 0.247 647.0 27.87 + Length = 19 rows + + +Reference/API +============= + +.. automodapi:: astroquery.hyperleda + :no-inheritance-diagram: \ No newline at end of file From daaaee86575d0c6b202ad6021a351e7ee51830d7 Mon Sep 17 00:00:00 2001 From: iskren-y-g Date: Mon, 22 Mar 2021 17:55:09 +0100 Subject: [PATCH 3/6] New service to access HyperLEDA [#298] --- astroquery/hyperleda/__init__.py | 3 +-- astroquery/hyperleda/core.py | 2 -- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/astroquery/hyperleda/__init__.py b/astroquery/hyperleda/__init__.py index 7eb0fa6857..10ad4e2f3c 100644 --- a/astroquery/hyperleda/__init__.py +++ b/astroquery/hyperleda/__init__.py @@ -4,8 +4,7 @@ HyperLEDA Query Tool ------------------- -A tool to query HyperLEDA -http://leda.univ-lyon1.fr/ +A tool to query HyperLEDA http://leda.univ-lyon1.fr/ :author: Iskren Y. Georgiev (iskren.y.g@gmail.com) """ diff --git a/astroquery/hyperleda/core.py b/astroquery/hyperleda/core.py index 37d394e6a3..4a7e882f47 100644 --- a/astroquery/hyperleda/core.py +++ b/astroquery/hyperleda/core.py @@ -29,13 +29,11 @@ from astropy.table import Table, vstack from astropy.io import fits - # export all the public classes and methods __all__ = ['hyperleda', 'HyperLEDAClass'] # declare global variables and constants if any - # Begin main class # Should be decorated with the async_to_sync imported previously From 3a4c017a0688ec17655262e659c98765c0dbb65f Mon Sep 17 00:00:00 2001 From: iskren-y-g Date: Mon, 22 Mar 2021 18:37:58 +0100 Subject: [PATCH 4/6] cleared pep8 style issues --- astroquery/hyperleda/__init__.py | 6 +- astroquery/hyperleda/core.py | 116 +++++++++--------- astroquery/hyperleda/tests/setup_package.py | 6 +- astroquery/hyperleda/tests/test_hyperleda.py | 7 +- .../hyperleda/tests/test_hyperleda_remote.py | 3 +- 5 files changed, 71 insertions(+), 67 deletions(-) diff --git a/astroquery/hyperleda/__init__.py b/astroquery/hyperleda/__init__.py index 10ad4e2f3c..b8ae70dc1a 100644 --- a/astroquery/hyperleda/__init__.py +++ b/astroquery/hyperleda/__init__.py @@ -11,6 +11,7 @@ from astropy import config as _config + class Conf(_config.ConfigNamespace): """ Configuration parameters for `astroquery.hyperleda`. @@ -19,15 +20,16 @@ class Conf(_config.ConfigNamespace): ['http://leda.univ-lyon1.fr/'], 'Base URL for HyperLeda http requests' ) - + timeout = _config.ConfigItem( 30, 'Time timeout for the HyperLeda query.' ) + conf = Conf() -from .core import hyperleda, HyperLEDAClass +from .core import hyperleda, HyperLEDAClass __all__ = ['hyperleda', 'HyperLEDAClass', 'Conf', 'conf', diff --git a/astroquery/hyperleda/core.py b/astroquery/hyperleda/core.py index 4a7e882f47..22f1c74a62 100644 --- a/astroquery/hyperleda/core.py +++ b/astroquery/hyperleda/core.py @@ -37,16 +37,17 @@ # Begin main class # Should be decorated with the async_to_sync imported previously + @async_to_sync class HyperLEDAClass(BaseQuery): - + """ Base class for querying data from the HyperLEDA database. - + http://leda.univ-lyon1.fr - + """ - + URL = conf.server TIMEOUT = conf.timeout # The URL with the table of the main object properties @@ -55,41 +56,40 @@ class HyperLEDAClass(BaseQuery): @class_or_instance def get_properties(self): - """ - + Get the available object properties in the HyperLEDA database. (See http://leda.univ-lyon1.fr/leda/meandata.html) - + Returns an `~astropy.table.Table` object. - + Returns ------- - + prop_tbl : An `~astropy.table.Table` object with the available object properties in HyperLEDA - + Example -------- >>> from astroquery.hyperleda import hyperleda - >>> + >>> >>> properties_tbl = hyperleda.get_properties() >>> properties_tbl.pprint_all() - + """ - + url_prop = self.URL_PROPERTIES response = self._request("GET", url_prop) prop_tbl = self._parse_result(response) - return prop_tbl + return prop_tbl def _perp_param_lst(self, param_lst): # Prepare the parameter's list #print('Full list of parameters number:',len(str(param_lst).split(','))) # These params are no longer in the leda tables - for param in ['numtype','hptr','logavmm','e_logavmm']: + for param in ['numtype', 'hptr', 'logavmm', 'e_logavmm']: if param in param_lst: param_lst.remove(param) @@ -99,13 +99,13 @@ def _perp_param_lst(self, param_lst): return param_str @class_or_instance - def query_object(self, obj_name, properties = 'all'): + def query_object(self, obj_name, properties='all'): """ - + Query an object from the HyperLEDA database. - + Returns the object properties in an `~astropy.table.Table` object. - + Example -------- >>> from astroquery.hyperleda import hyperleda @@ -118,76 +118,75 @@ def query_object(self, obj_name, properties = 'all'): Parameters ---------- obj_name : str - + Object ID recognizable by HyperLEDA or SIMBAD - + properties : str, or comma separated strings. Default: 'all' - + The full list of properties in HyperLEDA is available at http://leda.univ-lyon1.fr/leda/meandata.html or via hyperleda.get_properties().pprint_all() - + Returns ------- - - Table : An `~astropy.table.Table` object with the object properties + + Table : An `~astropy.table.Table` object with the object properties from HyperLEDA - + """ - + if properties == 'all': prop_tbl = self.get_properties() param_lst = prop_tbl['field'].data.tolist() param_str = self._perp_param_lst(param_lst) else: param_str = properties - + url_http_request = self.URL_HTTP_REQUEST ls_SQL_search = "objname = objname('{:}')".format(obj_name) - - request_payload = dict(n = 'meandata', c = 'o', of = '1,leda,simbad', - nra = 'l', nakd = '1', - d = '{:}'.format(param_str), - sql = '{:}'.format(ls_SQL_search), ob = '', - a = 'csv[|]') + + request_payload = dict(n='meandata', c='o', of='1,leda,simbad', + nra='l', nakd='1', + d='{:}'.format(param_str), + sql='{:}'.format(ls_SQL_search), ob='', + a='csv[|]') response = self._request("GET", url_http_request, params=request_payload) sql_result_tbl = Table.read(response.url, format='ascii', delimiter='|') - + return sql_result_tbl @class_or_instance - def query_sql(self, search, properties = 'all'): - + def query_sql(self, search, properties='all'): """ - + Perform SQL search in the HyperLEDA database. (See http://leda.univ-lyon1.fr/fullsql.html) - + Returns an `~astropy.table.Table` object with the results from the search containing the object properties. Parameters ---------- search : str - + A string containing a valid SQL WHERE clause. - + properties : str, or comma separated strings. Default: 'all' - + The full list of properties in HyperLEDA is available at http://leda.univ-lyon1.fr/leda/meandata.html or via hyperleda.get_properties().pprint_all() - + Returns ------- - + Table : An `~astropy.table.Table` object with the object properties from HyperLEDA - + Example -------- >>> from astroquery.hyperleda import hyperleda @@ -200,27 +199,27 @@ def query_sql(self, search, properties = 'all'): celposJ(pgc)') >>> result_table.pprint() """ - + if properties == 'all': prop_tbl = self.get_properties() param_lst = prop_tbl['field'].data.tolist() param_str = self._perp_param_lst(param_lst) else: param_str = properties - + url_http_request = self.URL_HTTP_REQUEST ls_SQL_search = search - - request_payload = dict(n = 'meandata', c = 'o', of = '1,leda,simbad', - nra = 'l', nakd = '1', - d = '{:}'.format(param_str), - sql = '{:}'.format(ls_SQL_search), ob = '', - a = 'csv[|]') + + request_payload = dict(n='meandata', c='o', of='1,leda,simbad', + nra='l', nakd='1', + d='{:}'.format(param_str), + sql='{:}'.format(ls_SQL_search), ob='', + a='csv[|]') response = self._request("GET", url_http_request, params=request_payload) sql_result_tbl = Table.read(response.url, format='ascii', delimiter='|') - + return sql_result_tbl def _parse_result(self, response, verbose=False): @@ -239,13 +238,13 @@ def _parse_result(self, response, verbose=False): ls_url_props = self.URL + ls_url_props_src # Get the main table - prop_tbl = Table.read(ls_url_props, format = 'ascii.html') + prop_tbl = Table.read(ls_url_props, format='ascii.html') prop_tbl.rename_columns(prop_tbl.colnames, ['field', 'type', 'units', 'description']) # Get the table with the available SQL functions - sql_func_tbl = Table.read(response.url, format='ascii.html', - htmldict={'table_id' : 2}) + sql_func_tbl = Table.read(response.url, format='ascii.html', + htmldict={'table_id': 2}) sql_func_tbl.add_column(col='--', name='units', index=2) sql_func_tbl.rename_columns(sql_func_tbl.colnames, @@ -258,6 +257,7 @@ def _parse_result(self, response, verbose=False): return prop_tbl + # the default tool for users to interact with is an instance of the Class hyperleda = HyperLEDAClass() @@ -265,4 +265,4 @@ def _parse_result(self, response, verbose=False): # See ./tests for examples on this # Next you should write the docs in astroquery/docs/module_name -# using Sphinx. \ No newline at end of file +# using Sphinx. diff --git a/astroquery/hyperleda/tests/setup_package.py b/astroquery/hyperleda/tests/setup_package.py index 5ba92bfcb7..4117ae60dd 100644 --- a/astroquery/hyperleda/tests/setup_package.py +++ b/astroquery/hyperleda/tests/setup_package.py @@ -4,11 +4,13 @@ # setup paths to the test data # can specify a single file or a list of files + + def get_package_data(): - + paths = [os.path.join('data', '*.dat'), os.path.join('data', '*.html') - ] # etc, add other extensions + ] # etc, add other extensions # you can also enlist files individually by names # finally construct and return a dict for the sub module diff --git a/astroquery/hyperleda/tests/test_hyperleda.py b/astroquery/hyperleda/tests/test_hyperleda.py index 463f68b404..1b889f8890 100644 --- a/astroquery/hyperleda/tests/test_hyperleda.py +++ b/astroquery/hyperleda/tests/test_hyperleda.py @@ -24,8 +24,7 @@ # one would expect from the server when a valid query is made. DATA_FILES = {'query': 'query_object.dat', - #'query_sql': 'query_sql.dat', - } + } # ./setup_package.py helps the test function locate the data file @@ -48,7 +47,7 @@ def nonremote_request(self, request_type, url, **kwargs): return response -# pytest fixture creates a dummy 'requests.get' function, that +# pytest fixture creates a dummy 'requests.get' function, that # mocks(monkeypatches) the actual 'requests.get' function: @pytest.fixture def patch_request(request): @@ -67,10 +66,10 @@ def test_query_object(patch_request): properties=['bt', 'vt']) assert isinstance(result, Table) + def test_query_sql(patch_request): sample_query = "(mod0<=27 and t>=-3 and t<=0 and type='S0') \ or (mod0<=27 and t>=-3 and t<=0 and type='S0-a')" result = hyperleda.core.HyperLEDAClass().query_sql(sample_query, properties=['bt', 'vt']) assert isinstance(result, Table) - \ No newline at end of file diff --git a/astroquery/hyperleda/tests/test_hyperleda_remote.py b/astroquery/hyperleda/tests/test_hyperleda_remote.py index 9b8871eae5..df87bc54ae 100644 --- a/astroquery/hyperleda/tests/test_hyperleda_remote.py +++ b/astroquery/hyperleda/tests/test_hyperleda_remote.py @@ -6,9 +6,10 @@ from ..core import hyperleda + @pytest.mark.remote_data class TestHyperLEDAClass: - + def test_query_object(self): result = hyperleda.query_object('UGC12591', properties=['bt', 'vt']) assert isinstance(result, Table) From 5db66e833fc27c06b42de23008db6bf3bc0ec865 Mon Sep 17 00:00:00 2001 From: iskren-y-g Date: Mon, 22 Mar 2021 18:41:06 +0100 Subject: [PATCH 5/6] cleared pep8 style issues --- astroquery/hyperleda/core.py | 1 - 1 file changed, 1 deletion(-) diff --git a/astroquery/hyperleda/core.py b/astroquery/hyperleda/core.py index 22f1c74a62..9e0e43826c 100644 --- a/astroquery/hyperleda/core.py +++ b/astroquery/hyperleda/core.py @@ -86,7 +86,6 @@ def get_properties(self): def _perp_param_lst(self, param_lst): # Prepare the parameter's list - #print('Full list of parameters number:',len(str(param_lst).split(','))) # These params are no longer in the leda tables for param in ['numtype', 'hptr', 'logavmm', 'e_logavmm']: From 3ac1663100890b2b695bf1a1a3093b028d6c58d2 Mon Sep 17 00:00:00 2001 From: iskren-y-g Date: Mon, 22 Mar 2021 18:44:20 +0100 Subject: [PATCH 6/6] cleared pep8 style issues --- astroquery/hyperleda/core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/astroquery/hyperleda/core.py b/astroquery/hyperleda/core.py index 9e0e43826c..b59dfc4cd4 100644 --- a/astroquery/hyperleda/core.py +++ b/astroquery/hyperleda/core.py @@ -85,8 +85,8 @@ def get_properties(self): return prop_tbl def _perp_param_lst(self, param_lst): - # Prepare the parameter's list + # Prepare the parameter's list # These params are no longer in the leda tables for param in ['numtype', 'hptr', 'logavmm', 'e_logavmm']: if param in param_lst: