2

I have extracted a list of Simbad names from a VizieR catalog and would like to find the axis ratio of the objects from the diameters table in NED. Code below.

import numpy as np
from astropy.table import Table,Column
from astroquery.vizier import Vizier
from astroquery.ned import Ned

v = Vizier(columns = ['SimbadName','W50max'])
catalist = v.find_catalogs('VIII/73')
v.ROW_LIMIT = -1
a = v.get_catalogs(catalist.keys())

filter = a[0]['W50max'] > 500
targets = a[0][filter]
print targets
simName = targets['SimbadName']
W50max = targets['W50max']

counter  = 1
for objects in simName:

    result_table = Ned.get_table(objects, table='diameters')
    ## find where  Axis Ratio results are not masked
    notMasked = (np.where(result_table['NED Axis Ratio'].mask == False)) 
    ## calculate average value of Axis Ratio
    print counter, np.sum(result_table['NED Axis Ratio'])/np.size(notMasked)
    counter += 1

The fourth object in simNames has no diameters table so creates an error:

   File "/home/tom/VizRauto.py", line 40, in <module>
    result_table = Ned.get_table(objects, table='diameters')
  File "/usr/local/lib/python2.7/dist-packages/astroquery/ned/core.py", line 505, in get_table
    result = self._parse_result(response, verbose=verbose)
  File "/usr/local/lib/python2.7/dist-packages/astroquery/ned/core.py", line 631, in _parse_result
    raise RemoteServiceError("The remote service returned the following error message.\nERROR: {err_msg}".format(err_msg=err_msg))
RemoteServiceError: The remote service returned the following error message.
ERROR:  Unknown error 

So I tried:

counter  = 1
for objects in simName:

try:
        result_table = Ned.get_table(objects, table='diameters')
        ## find where  Axis Ratio results are not masked
        notMasked = (np.where(result_table['NED Axis Ratio'].mask == False)) 

        ## calculate average value of Axis Ratio
        print counter, np.sum(result_table['NED Axis Ratio'])/np.size(notMasked)

except RemoteServiceError:
        continue


counter += 1

which produces:

Traceback (most recent call last):
  File "/home/tom/Dropbox/AST03CosmoLarge/Project/scripts/VizRauto.py", line 57, in <module>
    except RemoteServiceError:
NameError: name 'RemoteServiceError' is not defined

So obviously the RemoteServiceError from core.py is not recognized. What is the best way to handle this or is there a better method for querying NED with a list of objects?

MSeifert
  • 145,886
  • 38
  • 333
  • 352
tommw
  • 123
  • 5
  • 2
    How did you import `RemoteServiceError`? `from astroquery.ned.core import RemoteServiceError`? The message you got looks like a missing import statement. – keflavich Mar 16 '15 at 02:11
  • 1
    Which thing are you actually asking about here? Because the second issue just looks like a missing import statement in your code. – Iguananaut Mar 16 '15 at 16:41
  • 1
    You are right, adding `from astroquery.ned.core import RemoteServiceError` fixes the error. Thanks – tommw Mar 16 '15 at 21:38

0 Answers0