Package ivs :: Package catalogs :: Module gator
[hide private]
[frames] | no frames]

Module gator

source code

Interface to the GATOR search engine

Functions [hide private]
    Basic interfaces
str/ record array, dict, list of str
search(catalog, **kwargs)
Search and retrieve information from a Gator catalog.
source code
list of string tuples
list_catalogs()
Return a list of all availabe GATOR catalogues.
source code
 
get_photometry(ID=None, extra_fields=['dist','ra','dec'], **kwargs)
Download all available photometry from a star to a record array.
source code
    Convenience functions
record array, dict, list of str
txt2recarray(filename)
Read a GATOR outfmt=1__ (ASCII) file into a record array.
source code
record array
gator2phot(source, results, units, master=None, extra_fields=['_r','_RAJ2000','_DEJ2000'])
Convert/combine Gator record arrays to measurement record arrays.
source code
    Internal helper functions
str
_get_URI(name, ID=None, ra=None, dec=None, radius=1., filetype='1', spatial='cone', **kwargs)
Build GATOR URI from available options.
source code
Variables [hide private]
  logger = logging.getLogger("CAT.GATOR")
  basedir = os.path.dirname(os.path.abspath(__file__))
  cat_info = ConfigParser.ConfigParser()
Function Details [hide private]

search(catalog, **kwargs)

source code 

Search and retrieve information from a Gator catalog.

Two ways to search for data within a catalog name:

  1. You're looking for info on one target, then give the target's ID or coordinates (ra and dec), and a search radius.
  2. You're looking for information of a whole field, then give the field's coordinates (ra and dec), and radius.

If you have a list of targets, you need to loop this function.

If you supply a filename, the results will be saved to that path, and you will get the filename back as received from urllib.URLopener (should be the same as the input name, unless something went wrong).

If you don't supply a filename, you should leave filetype to the default tsv, and the results will be saved to a temporary file and deleted after the function is finished. The content of the file will be read into a dictionary, as well as the units (two separate dictionaries with the same keys, depending on the colum names in the catalog). The entries in the dictionary are of type ndarray, and will be converted to a float-array if possible. If not, the array will consist of strings. The comments are also returned as a list of strings.

Parameters:
  • catalog (str) - name of a GATOR catalog (e.g. 'II/246/out')
  • filename (str) - name of the file to write the results to (no extension)
Returns: str/ record array, dict, list of str
filename / catalog data columns, units, comments

list_catalogs()

source code 

Return a list of all availabe GATOR catalogues.

Returns: list of string tuples
list of gator catalogs and discriptions

get_photometry(ID=None, extra_fields=['dist','ra','dec'], **kwargs)

source code 

Download all available photometry from a star to a record array.

For extra kwargs, see _get_URI and gator2phot

Example usage:

>>> import pylab
>>> import vizier
>>> name = 'kr cam'
>>> master = vizier.get_photometry(name,to_units='erg/s/cm2/AA',extra_fields=[])
>>> master = get_photometry(name,to_units='erg/s/cm2/AA',extra_fields=[],master=master)
>>> p = pylab.figure()
>>> wise = np.array(['WISE' in photband and True or False for photband in master['photband']])
>>> p = pylab.errorbar(master['cwave'],master['cmeas'],yerr=master['e_cmeas'],fmt='ko')
>>> p = pylab.errorbar(master['cwave'][wise],master['cmeas'][wise],yerr=master['e_cmeas'][wise],fmt='ro',ms=8)
>>> p = pylab.gca().set_xscale('log')
>>> p = pylab.gca().set_yscale('log')
>>> p = pylab.show()

Other examples: >>> master = get_photometry(ra=71.239527,dec=-70.589427,to_units='erg/s/cm2/AA',extra_fields=[],radius=1.) >>> master = get_photometry(ID='J044458.39-703522.6',to_units='W/m2',extra_fields=[],radius=1.)

txt2recarray(filename)

source code 

Read a GATOR outfmt=1__ (ASCII) file into a record array.

Parameters:
  • filename (str) - name of the TSV file
Returns: record array, dict, list of str
catalog data columns, units, comments

gator2phot(source, results, units, master=None, extra_fields=['_r','_RAJ2000','_DEJ2000'])

source code 

Convert/combine Gator record arrays to measurement record arrays.

Every line in the combined array represents a measurement in a certain band.

This is probably only useful if results contains only information on one target (or you have to give 'ID' as an extra field, maybe).

The standard columns are:

  1. meas: containing the photometric measurement
  2. e_meas: the error on the photometric measurement
  3. flag: an optional quality flag
  4. unit: the unit of the measurement
  5. photband: the photometric passband (FILTER.BAND)
  6. source: name of the source catalog

You can add extra information from the Gator catalog via the list of keys extra_fields.

If you give a master, the information will be added to a previous record array. If not, a new master will be created.

The result is a record array with each row a measurement.

Parameters:
  • source (str) - name of the Gator source
  • results (record array) - results from Gator search
  • units (dict) - header of Gator catalog with key name the column name and key value the units of that column
  • master (record array) - master record array to add information to
  • extra_fields (list of str) - any extra columns you want to add information from
Returns: record array
array with each row a measurement

_get_URI(name, ID=None, ra=None, dec=None, radius=1., filetype='1', spatial='cone', **kwargs)

source code 

Build GATOR URI from available options.

Filetype should be one of:

6___ returns a program interface in XML 3___ returns a VO Table (XML) 2___ returns SVC (Software handshaking structure) message 1___ returns an ASCII table 0___ returns Gator Status Page in HTML (default)

kwargs are to catch unused arguments.

Parameters:
  • name (str) - name of a GATOR catalog (e.g. 'wise_prelim_p3as_psd')
  • ID (str) - target name
  • filetype (str (one of '0','1','2','3','6'... see GATOR site)) - type of the retrieved file
  • radius (float) - search radius (arcseconds)
  • ra (float) - target's right ascension
  • dec (float) - target's declination
  • spatial (str (one of Cone, Box (NIY), Polygon (NIY), NONE (NIY))) - type of spatial query
Returns: str
url