tableio

lsmtool.tableio.RADec2Angle(RA, Dec)

Returns normalized Angle objects for input RA, Dec values.

Parameters:
  • RA (str, float or list of str, float) – Values of RA to convert. Can be strings in makesourcedb format or floats in degrees (astropy.coordinates.Angle are also supported)

  • Dec (str, float or list of str, float) – Values of Dec to convert. Can be strings in makesourcedb format or floats in degrees (astropy.coordinates.Angle are also supported)

Returns:
lsmtool.tableio.broadcastTable(fileName)

Sends a table via SAMP.

Parameters:

fileName (str) – Name of sky model file to broadcast

lsmtool.tableio.casaRegionWriter(table, fileName)

Writes model to a casa region file.

Parameters:
  • table (astropy.table.Table) – Input sky model table

  • fileName (str) – Output file to which the sky model is written

lsmtool.tableio.coneSearch(VOService, position, radius)

Returns table from a VO cone search.

Parameters:
  • VOService (str) – Name of VO service to query (must be one of allowedVOServices)

  • position (list of floats) – A list specifying a position as [RA, Dec] in either makesourcedb format (e.g., [‘12:23:43.21’, ‘+22.34.21.2’]) or in degrees (e.g., [123.2312, 23.3422])

  • radius (float or str, optional) – Radius in degrees (if float) or ‘value unit’ (if str; e.g., ‘30 arcsec’) for cone search region

lsmtool.tableio.convertExternalTable(table, columnMapping, catalogProperties)

Converts an external table to a makesourcedb compatible one.

Parameters:
  • table (Table) – External table to convert

  • columnMapping (dict) – Dict that defines the column name mapping from external table to makesourcedb columns

  • catalogProperties (dict) – Dict that defines the catalog properties. Currently, these consist of ‘fluxtype’, ‘deconvolved’, ‘psf’, ‘referencefrequency’, and ‘fluxunits’

lsmtool.tableio.createTable(outlines, metaDict, colNames, colDefaults)

Creates an astropy table from inputs.

Parameters:
  • outlines (list of str) – Input lines

  • metaDict (dict) – Input meta data

  • colNames (list of str) – Input column names

  • colDefaults (list) – Input column default values

Returns:

table (astropy.table.Table)

lsmtool.tableio.decformat(val)

Column formatter for Dec values.

Parameters:

val (float) – Input Dec value in deg

Returns:

valstr (str) – Formatted string as ‘dd.mm.ss.s’

lsmtool.tableio.ds9RegionWriter(table, fileName)

Writes table to a ds9 region file.

Parameters:
  • table (astropy.table.Table) – Input sky model table

  • fileName (str) – Output file to which the sky model is written

lsmtool.tableio.facetRegionWriter(table, fileName)

Writes the model patches to a ds9 facet region file.

The resulting file is suitable for use with WSClean in faceting mode.

Parameters:
  • table (astropy.table.Table) – Input sky model table; must have patches defined

  • fileName (str) – Output file to which the sky model is written

lsmtool.tableio.factorDirectionsWriter(table, fileName)

Writes patches to a Factor directions file.

Note that Factor respects the order of patches and they are sorted here by apparent flux from brightest to faintest.

Parameters:
  • table (astropy.table.Table) – Input sky model table; must have patches defined

  • fileName (str) – Output file to which the sky model is written

lsmtool.tableio.fluxformat(val)

Column formatter for flux density values.

Parameters:

val (float) – Input flux density value in Jy

Returns:

valstr (str) – Formatted string to 3 digits

lsmtool.tableio.getGSM(position, radius)

Returns the table from a GSM search.

Parameters:
  • position (list of floats) – A list specifying a position as [RA, Dec] in either makesourcedb format (e.g., [‘12:23:43.21’, ‘+22.34.21.2’]) or in degrees (e.g., [123.2312, 23.3422])

  • radius (float or str) – Radius in degrees (if float) or ‘value unit’ (if str; e.g., ‘30 arcsec’) for cone search region

lsmtool.tableio.getLoTSS(position, radius)

Returns table from a LoTSS search.

Parameters:
  • position (list of floats) – A list specifying a position as [RA, Dec] in either makesourcedb format (e.g., [‘12:23:43.21’, ‘+22.34.21.2’]) or in degrees (e.g., [123.2312, 23.3422])

  • radius (float or str) – Radius in degrees (if float) or ‘value unit’ (if str; e.g., ‘30 arcsec’) for cone search region

lsmtool.tableio.getQueryInputs(position, radius)

Returns the inputs for a non-VO-compatible catalog search.

Parameters:
  • position (list of floats) – A list specifying a position as [RA, Dec] in either makesourcedb format (e.g., [‘12:23:43.21’, ‘+22.34.21.2’]) or in degrees (e.g., [123.2312, 23.3422])

  • radius (float or str) – Radius in degrees (if float) or ‘value unit’ (if str; e.g., ‘30 arcsec’) for cone search region

Returns:
  • RA (float) – RA in degrees of query position

  • Dec (float) – Dec in degrees of query position

  • radius (float) – Radius in degrees of query cone

Raises:

ValueError – Raised when the input radius cannot be converted to degrees, usually due to improperly specified units

lsmtool.tableio.getTGSS(position, radius)

Returns the table from a TGSS search.

Parameters:
  • position (list of floats) – A list specifying a position as [RA, Dec] in either makesourcedb format (e.g., [‘12:23:43.21’, ‘+22.34.21.2’]) or in degrees (e.g., [123.2312, 23.3422])

  • radius (float or str) – Radius in degrees (if float) or ‘value unit’ (if str; e.g., ‘30 arcsec’) for cone search region

lsmtool.tableio.iteritems(d)
lsmtool.tableio.itervalues(d)
lsmtool.tableio.kvisAnnWriter(table, fileName)

Writes table to a kvis annotation file.

Parameters:
  • table (astropy.table.Table) – Input sky model table

  • fileName (str) – Output file to which the sky model is written

lsmtool.tableio.makeEmptyTable()

Returns an empty sky model table.

lsmtool.tableio.processFormatString(formatString)

Proccesses the header string.

Parameters:

formatString (str) – Header line

Returns:
  • colNames (list of str) – Output column names

  • hasPatches (bool) – Flag for patches

  • colDefaults (dict) – Default values

  • metaDict (dict) – Output meta data

lsmtool.tableio.processLine(line, metaDict, colNames)

Processes a makesourcedb line.

Parameters:
  • line (str) – Data line

  • metaDict (dict) – Input meta data

  • colNames (list of str) – Input column names

Returns:
  • line (str) – Processed line

  • metaDict (dict) – Output meta data

lsmtool.tableio.queryNonVOService(url, format='makesourcedb')

Returns the table from a non-VO service.

Parameters:
  • url (str) – URL of catalog

  • format (str, optional) – Format to use when reading the catalog. Any format accepted by Table.read() is valid

Raises:

ConnectionError – Raised when the wget call returns a nonzero return code, indicating a problem with the connection to the service

lsmtool.tableio.raformat(val)

Column formatter for RA values.

Parameters:

val (float) – Input RA value in deg

Returns:

valstr (str) – Formatted string as ‘hh:mm:ss.s’

lsmtool.tableio.rowStr(row, metaDict)

Returns makesourcedb representation of a row.

Parameters:
Returns:

line (str) – Sting representing a row in a makesourcedb sky model file

lsmtool.tableio.skyModelIdentify(origin, *args, **kwargs)

Identifies valid makesourcedb sky model files.

lsmtool.tableio.skyModelReader(fileName, header_start=0)

Reads a makesourcedb sky model file into an astropy table.

See https://www.astron.nl/lofarwiki/doku.php?id=public:user_software:documentation:makesourcedb for details. Note that source names, types, and patch names are limited to a length of 100 characters.

Parameters:
  • fileName (str) – Input ASCII file from which the sky model is read. Must respect the makesourcedb format

  • header_start (int, optional) – Line number at which header starts

Returns:

table (astropy.table.Table)

lsmtool.tableio.skyModelWriter(table, fileName)

Writes table to a makesourcedb sky model file.

Parameters:

fileName (str) – Output ASCII file to which the sky model is written