astwro.starlist Module

Star lists, are objects of class StarList which inherits directly from :class:pandas.DataFrame.

StarList class

class astwro.starlist.StarList(data=None, index=None, columns=None, dtype=None, copy=False)[source]

Bases: pandas.core.frame.DataFrame

static new()[source]

Returns empty StarList instance with columns id,x,y

DAO_hdr

DAO file header dict if any

DAO_type

DAO file header dict if any

import_metadata(src)[source]

Copies metdata (dao type, dao hdr) from src

Parameters:src (StarList) – source of metadata
stars_number()[source]

returns number of stars in list

renumber(start=1)[source]

Renumbers starlist (in place), updating id column and index to range start.. start+stars_number

refresh_id()[source]

Cheks for id column existence and renumber if needed then recreate index basin on id

If id column exist but cannot be casted to int (by pandas.Series.to_numeric), ValueError exception is raised

to_table()[source]

Return a astropy.table.Table instance

classmethod from_table(table)[source]

Create a StarList from a astropy.table.Table instance

table : astropy.table.Table
The astropy astropy.table.Table instance
sl : StarList
A `StarList`instance
classmethod from_skycoord(coo)[source]

Create a StarList from a astropy.coordinates.SkyCoord instance

coo : astropy.coordinates.SkyCoord
Source
sl : StarList
A `StarList`instance
radec_hmsdms_from_skycoord(coo)[source]

Uses external xy2sky tool

radec_deg_from_hmsdms()[source]

Uses external xy2sky tool

radec_hmsdms_from_deg()[source]

Uses external xy2sky tool

magnitudes()[source]

Returns magnitudes array from columns mag, A2, A3, …

magnitudes_err()[source]

Returns magnitudes errors array from columns mag_err, A2_err, A3_err, …

IO of daophot/allstar files

astwro.starlist.daofiles.convert_dao_type(starlist, new_daotype, update_daotype=True)[source]

Converts from one daotype to another

Only subset of conversions supported. You can also provide own map (directory) of column names

astwro.starlist.daofiles.read_dao_file(file, dao_type=None)[source]

Construct StarList from daophot output file. The header lines in file may be missing. :rtype: StarList :param file: open stream or filename, if stream dao_type must be specified :param dao_type: file format, one of DAO.XXX_FILE constants:

  • DAO.COO_FILE
  • DAO.AP_FILE
  • DAO.LST_FILE
  • DAO.NEI_FILE
  • DAO.ALS_FILE

If missing filename extension will be used to determine file type if file is provided as filename

Returns:StarList instance
astwro.starlist.daofiles.write_dao_file(starlist, file, dao_type=None, with_header=None)[source]

Write StarList object into daophot file. :param starlist: StarList instance to be writen :param file: writable stream or filename, if stream dao_type must be specified :param dao_type: file format, one of DAO.XXX_FILE constants:

  • DAO.COO_FILE
  • DAO.AP_FILE
  • DAO.LST_FILE
  • DAO.NEI_FILE
  • DAO.ALS_FILE

If missing extension of file will be used to determine file type if file is provided as filename

Parameters:with_header – True, False or None. If None header will be written if not None in starlist
Return type:None
astwro.starlist.daofiles.dump_dao_hdr(hdr, line_prefix='')[source]

returns two line string representation of header dictionary :param dict hdr: dao header dictionary like StarList.DAO_hdr :param str line_prefix: add this prefix at beginning of every line (e.g. comment char) :rtype:str

astwro.starlist.daofiles.write_dao_header(hdr, stream, line_prefix='')[source]

writes two lines of dao header :param dict hdr: dao header dictionary like StarList.DAO_hdr :param file stream: to write :param str line_prefix: add this prefix at beginning of every line (e.g. comment char)

astwro.starlist.daofiles.read_dao_header(stream, line_prefix='')[source]

tries to read dao header, if fails returns already read characters :param file stream: open input file :param line_prefix: additional prefix expected on the beginning of line :return: tuple (header dict, stolen chars)

if header is detected, reads 2 lines of stream and returns (dict, None) else reads couple of chars and return (None, couple-of-chars)
astwro.starlist.daofiles.parse_dao_hdr(hdr, val, line_prefix='')[source]

creates dao header dict form two lines of file header :param str hdr: first line :param str val: second line :param line_prefix: expected line prefix :return: dict with dao header compatible with StarList.DAO_header

IO of ds9 files

astwro.starlist.ds9.read_ds9_regions(file)[source]

Reads ds9 region :param file: filename or open input stream :return: StarList object

Returned object has columns id, x, y, auto_id

Boolean column auto_id indicates weather id for item is read from file (#id=xxx comment) or generated by function.

astwro.starlist.ds9.write_ds9_regions(starlist, filename, color='green', width=1, size=None, font=None, label='{id:.0f}', exclude=None, indexes=None, colors=None, sizes=None, labels=None, color_column=None, size_column=None, comment=None, add_global=None, WCS=False)[source]

Writes ds9 region file. Some regions can be visually distinguish by providing additional indexes to select those regions with specific attributes :param StarList starlist: StarList object to dump :param str filename: output filename or stream open for writing :param str color: default color :param int width: default line width :param int size: default radius (default 8px or 2”) :param str font: ds9 font specification e.g. “times 12 bold italic” :param str label: format expression for label, use col names :param pd.Index exclude: index of disabled regions, if None all are enabled :param [pd.Index] indexes: additional indexes to include specific color and size attributes :param [str] colors: specific colors for indexes :param [int] sizes: specific sizes for indexes :param [str] labels: specific labels for indexes :param str color_column: column of starlist with color values :param str size_column: column of starlist with size values :param str add_global: content of additional ‘global’ if not None :param str comment: content of additional comment line if not None :param bool or str WCS: If true, columns ra and dec will be used and coord system set to ICRS

If nonepmpty string, string will be used as system description If None, False or ‘’, columns ‘x’,’y’ will be used and system set to IMAGE

Example: write_ds9_regions(sl, ‘i.reg’, color=’blue’,

indexes=[saturated, psf], colours=[‘yellow’, ‘red’], sizes=[12, None], labels=[None, ‘PDF:{id}’], exclude=faint)

Generates regions file i.reg of blue circles, radius 8, objects present in index saturated will have larger yellow circles objects present in index psf will be red and labeled with prefix PSF: objects present in index faint will be disabled by ‘-‘ sign and not displayed by ds9, but can be parsed back