astro.util package

Submodules

astro.util.BinaryFitsTable module

astro.util.CalibratePhotometryToGaia module

astro.util.CanonicalName module

CanonicalName

Implements a filename convention

class astro.util.CanonicalName.CanonicalName

Bases: object

Implements a filename convention

chip_name = '-'
date = '-'
extension = 'fits'
file_basetype = '-'
file_subtype = '-'
filter_name = '-'
get_uid()
instrument_name = '-'
mode = '-'
owner = '-'
process_level = '-'
project = '-'
set_owner()

Read the user from the environment and set the property owner

strategy = '-'
to_string()

Return the contents of the CanonicalName object as a string.

astro.util.CanonicalName.replace_reserved(word)

Replace any occurance of a reserved character (e.g., ‘/’ for a filename) with a non-reserved character (e.g., ‘_’ or URL encoded equivalent).

astro.util.CatalogAssociation module

astro.util.CosmologicalDistance module

A class to calculate cosmological distances The procedure by Hoggs 2000 and Peebles 1993 are followed http://arxiv.org/abs/astro-ph/9905116

class astro.util.CosmologicalDistance.CosmologicalDistance(omega_m=0.3, omega_l=0.7, h0=0.7)

Bases: object

A class to calculate cosmological distances The procedure by Hoggs 2000 and Peebles 1993 are followed http://arxiv.org/abs/astro-ph/9905116

The cosmological parameters of interest are h0 ~0.7 = dimensionless constant: hubble parameter / (100 (km/s)/Mpc) omega_m ~ 0.3 = matter content of the universe omega_l ~ 0.7 dark energy omega_k = 1 - omega_m - omega_l = curvature

Other parameters: redshift = the redshift of the source(s) for which distance is

being measured
angular_diameter_distance(redshift)

Returns the angular diameter distance: the ratio of an object’s physical transverse size to its angular size. Hogg 2000, chapter 6, equation 18.

angular_separation(ra0, dec0, ra1, dec1)

Calculates the angular separation between two points using the haversine formula. Input and output in radians.

c = 299792.458
comoving_distance(redshift)

Returns the comoving distance of an object of given redshift Hogg 2000, chapter 5, equation 15.

comoving_volume(redshift)

Returns the comoving volume within radius redshift for the entire sky in Mpc^3.

comoving_volume_element(redshift)

Returns the comoving volume element in Mpc^3. Hogg 2000, chapter 9, equation 28.

comoving_volume_slice(redshiftmin, redshiftmax, solidangle)

Returns the comoving volume in Mpc^3of a slice of angulare size ‘solidangle’ (in sterradian) between redshifts ‘redshiftmin’ and ‘redshiftmax’.

ee(redshift)

Hogg 2000, equation 14. Peebles 1993, pp 310-321.

eei(redshift)

The inverse of ee, used for integration

eeii(redshift)

The integration of the inverse of ee.

flat = 5e-05
h0(h0=nan)

read or set the Hubble Parameter in units of (100 km/s/Mpc)

hubble_distance()

Returns the Hubble distance. Hogg 2000 eqn. 4

inverse_comoving_distance(comoving_distance)

Returns the redshift from the comoving distance.

luminosity_distance(redshift)

Returns the luminosity distance. Hogg 2000, chapter 7, equation 21.

omega_k = 0.0
omega_l = 0.7
omega_m = 0.3
proper_motion_distance(redshift)

Returns the propermotion distance at distance redshift. Hogg 2000, chapter 5, equation 16.

set_omega_k()

You cannot set the curvature of the universe directly.

set_omega_l(omega_l)

Set the vacuum/dark energy/lambda content of the universe.

set_omega_m(omega_m)

Set the matter content of the universe (dark and baryonic).

transverse_comoving_distance(redshift, arc)

Returns the comoving distance between two points at a distance ‘redshift’ seperated by an angular separation arc Hogg 2000, chapter 5.

astro.util.CosmologicalDistance.integrate_simple(func, a, b, tolerance=1e-06)

Integrate func from a to b with tolerance tolerance.

Closed Simpson’s rule for
int_a^b f(x) dx

Divide [a,b] iteratively into h, h/2, h/4, h/8, ... step sizes; and, for each step size, evaluate f(x) at a+h, a+3h, a+5h, a+7h, .., b-3h, b-h, noting that other points have already been sampled.

At each iteration step, data are sampled only where necessary so that the total data is represented by adding sampled points from all previous steps:

step 1: h a—————b step 2: h/2 a——-^——-b step 3: h/4 a—^——-^—b step 4: h/8 a-^—^—^—^-b total: a-^-^-^-^-^-^-^-b

So, for step size of h/n, there are n intervals, and the data are sampled at the boundaries including the 2 end points.

If old = Trapezoid formula for an old step size 2h, then Trapezoid formula for the new step size h is obtained by

new = old/2 + h{f(a+h) + f(a+3h) + f(a+5h) +...+ f(b-3h)
  • f(b-h)}
Also, Simpson formula for the new step size h is given by
simpson = (4 new - old)/3
astro.util.CosmologicalDistance.newton(func, funcd, x, tolerance=1e-06)

f(x)=func(x), f’(x)=funcd(x)

Ubiquitous Newton-Raphson algorithm for solving
f(x) = 0
where a root is repeatedly estimated by
x = x - f(x)/f’(x)

until |dx|/(1+|x|) < tolerance is achieved. This termination condition is a compromise between

|dx| < tolerance, if x is small |dx|/|x| < tolerance, if x is large
astro.util.CosmologicalDistance.quad(func, a, b, tolerance=1e-06)

Integrate func from a to b with tolerance tolerance.

Closed Simpson’s rule for
int_a^b f(x) dx

Divide [a,b] iteratively into h, h/2, h/4, h/8, ... step sizes; and, for each step size, evaluate f(x) at a+h, a+3h, a+5h, a+7h, .., b-3h, b-h, noting that other points have already been sampled.

At each iteration step, data are sampled only where necessary so that the total data is represented by adding sampled points from all previous steps:

step 1: h a—————b step 2: h/2 a——-^——-b step 3: h/4 a—^——-^—b step 4: h/8 a-^—^—^—^-b total: a-^-^-^-^-^-^-^-b

So, for step size of h/n, there are n intervals, and the data are sampled at the boundaries including the 2 end points.

If old = Trapezoid formula for an old step size 2h, then Trapezoid formula for the new step size h is obtained by

new = old/2 + h{f(a+h) + f(a+3h) + f(a+5h) +...+ f(b-3h)
  • f(b-h)}
Also, Simpson formula for the new step size h is given by
simpson = (4 new - old)/3

astro.util.ExportDict module

class astro.util.ExportDict.ExportAction(eid='', name='')

Bases: object

class astro.util.ExportDict.ExportObject

Bases: object

Class used to export objects through SAMP.

get_property(name, nr=None)
sampdict()

Returns a dictionary to be used over SAMP.

txt(d=0)
class astro.util.ExportDict.ExportProperty(name='', eclass='', description='', value='', readonly=True)

Bases: object

Class used to export properties through SAMP.

sampdict()

astro.util.GlobalPhotometry module

astro.util.HeaderExtractor module

astro.util.Image module

astro.util.LVFrame module

astro.util.LVRecipe module

astro.util.LVtoBaseFrame module

astro.util.MakePointings module

astro.util.NameResolver module

Resolve names to coordinates using Simbad web service

Usage :

from astro.util.NameResolver import resolve result = resolve(‘M51’)

result is a dictionary with all info from Simbad ra and dec should always be present

Throws exception when Simbad does not return data

ra and dec will be None when the object is unknown

exception astro.util.NameResolver.SimbadError

Bases: Exception

class astro.util.NameResolver.SimbadSoapXmlHandler

Bases: xml.sax.handler.ContentHandler

class for parsing (Soap) xml from simbad

characters(content)
class astro.util.NameResolver.SimbadXmlHandler(result)

Bases: xml.sax.handler.ContentHandler

class for parsing xml from simbad

characters(content)

a set of character data in the xml

endElement(name)

end of element in xml

startElement(name, attrs)

element is started in xml

astro.util.NameResolver.resolve(search_term, force_encoding='')

resolve the search_term to coordinates (optional) use force_encoding to force the use of an encoding (example UTF-8)

astro.util.OldDataFinder module

astro.util.OverlapImage module

astro.util.Pars module

astro.util.PlateSystem module

PlateSystem — 7 June 2006 KIDS with eye on second decimal in field —- plots produce contours of fieldsize_ra and fieldsize_dec — 1 June 2006 KIDS adaptations — for KIDS different overlap in RA and DEC 1 june 2006 — SMOOTHING DISABLED- not needed FOR SUCH SMALL OVERLAP — overlap defined at BOTTOM of fields -> more fields/ more overlap Define a platesystem, a collection fields (“plates”) of a constant size covering the entire sky. Edwin Valentijn - —- 7 March 2004 —- version with smooth grid - more advanced than PAE

class astro.util.PlateSystem.PlateSystem(fieldsizera=1.0127, fieldsizedec=1.02451, overlapra=1.186, overlapdec=4, efflimit=0.96)

Bases: object

Define a plate system

The plate system is defined by a set of fields covering the sky. Each field has a size in ra and dec, a centre and a requested amount of overlap with neighbouring fields in both ra and dec and a minimun allowed overlap in ra The fields are arranged in strips perpendicular to the meredian. This means that with increasing declination there are less fields per strip. Script optimizes for continuity form one dec strip to the next; therfor the positions in various dec stips are dependent on each other.

get_field_centre(rain, decin)

get nearest ra fieldcenters, needs dec too

get_numberra_centers(log)

log - print log to screen

get_ra(decin)

get seq of ra’s for a single decin

nearest_dec(decin)

get nearest fieldcenter dec for any dec

plot_it(rastart=-1.0, raend=360.0, decstart=0.0, decend=90.0, title=' ')

plots the grid in range can be used as survey preparation tool selects fields within rectangle on sky returns ra,dec of selected fields in self autoscaling implemented

print_grid()

print grid properties in file

astro.util.PlotTiles module

astro.util.Polygon module

class astro.util.Polygon.Point(x, y)

Bases: object

inside(polygon)

# http://www.ariel.com.au/a/python-point-int-poly.html

# determine if a point is inside a given polygon or not # Polygon is a list of (x,y) pairs.

class astro.util.Polygon.Polygon(vertices=None, edges=None)

Bases: object

check_self_intersection()
check_unique_vertices()
edges
find_union_edges(other)

Finds the edges that form the union between self and other.

First loops over all edges of ‘self’, then over all edges of ‘other’ and adds those parts that are outside the other polygon. Both polygons have to be oriented in the same way.

orientation()

http://stackoverflow.com/questions/1165647/how-to-determine-if-a-list-of-polygon-points-are-in-clockwise-order

overlapping_bounding_boxes(other)
reorient()
shuffle(r=0.1)
union(other)
vertices
volume_bounding_box()
xmax
xmean
xmin
xs()
ymax
ymean
ymin
ys()
class astro.util.Polygon.Segment(start, end)

Bases: object

extend_end(factor=1.0)
extend_start(factor=1.0)
intersection(other)

# http://stackoverflow.com/questions/4543506/algorithm-for-intersection-of-2-lines

intersects(other)

#http://stackoverflow.com/questions/3838329/how-can-i-check-if-two-segments-intersect

length()
xs()
ys()
astro.util.Polygon.lazyproperty(fn)

astro.util.RatioImage module

astro.util.SetRelations module

A SetRelations object describes a specific logical relation between d sets as a Boolean matrix of size 2^d.

class astro.util.SetRelations.SetRelations(relation='t', labels=None)

Bases: object

A SetRelations object describes a specific logical relation between d sets as a Boolean matrix of size 2^d.

Every relation has a unique number that is created by flattening the matrix and interpretting it as a binary number after prepending a 1 to it.

The ordering of the dimensions of the matrix represents the ordering of the sets. Dimensions are labeled with uppercase letters alphabetically.

add(label=None, equalto=None)

Creates a list of all SetRelations that have an extra set.

add_alias(label, label1)

Adds an alias of an a set.

Nothing is done if the original set is not present.

add_crosssection(label, label1, label2)

Adds a new dimension to the matrix that is the cross section of another. This is still experimental.

add_disjoint(label)

Adds a set that has no points in common with any other sets. E.g. a SourceList.

add_disjoint_set(name)

Deprecated, use add_disjoint.

add_element(name=None, equalto=None)

Deprecated, use add()

add_element_alias(oldname, newname)

Deprecated, use add_alias

add_empty(label)

Adds an empty set.

add_empty_set(label)

Deprecated, use add_empty.

add_equal(label=None, equalto=None, name=None)

Adds a new dimension to the matrix that is equal to another. This function should only be called internally.

Use the add_element function with an equalto argument to add an element that is equal to another element manually.

add_union(label, label1, label2)

Adds a new dimension to the matrix that is the cross section of another. This is still experimental.

all_labels()

Returns a list with all the labels.

static bin_from_num(n)

Convert denary integer n to binary list.

combine(other)

Combines two relations. This function could do something smart in case specific relations are added.

combine_raw(other)

Combines two relations in most simplistic form by adding all the other sets one by one and filtering the relations. Returns a set of SetRelation objects that are consistent with self and other.

copy()

Creates a new copy of this relation.

dimension_from_label(label)

Returns the dimension that corresponds to the given label.

dimension_from_name(name)

Deprecated, use dimension_from_label

dimension_matrix()

Returns the dimension of the matrix.

find_equals(label)
flatten()

Splits up all labels.

from_number(number)

Create the matrix from a number.

from_symbol(symbol)

Create the matrix from a symbol.

isequal(label1, label2)

Conveniance function to determine whether two sets are equal. Much faster than using ‘relation’.

msum(dim)

Sums the matrix in order to remove a dimension and the corresponding sets. This is a separate function for profiling reasons. Use .remove() to remove a set/dimension properly.

new_label()

Returns a new label that is not yet used. It is preferred to set labels manually.

number()

Returns the number that corresponds to this relation. This is only sensible if the order of the sets is known.

number_from_symbol(symbol)

Get the number from a symbol.

order_labels()

The order of the labels is arbitrary. Relations can only be compared if the order of their relations is the same.

relabel(old, new)

Relabels one set.

relation(relation)

Determines the relation between a group of sets.

remove(label=None, element=None)

Removes either a set by label, or all sets belonging to a dimension. The ‘element’ argument is deprecated in favor of ‘label’.

split(label)

If the dimension that belongs to label is shared with other sets, split it.

symbol()

Returns the number that corresponds to this relation. This is only sensible if the order of the sets is known.

class astro.util.SetRelations.SetRelationsSet(infinite_points=False)

Bases: object

A list of SetRelations that meet the proposed criteria.

add(label=None, equalto=None, name=None)

Add one set to the relations.

add_alias(label, label1)

Adds an alias to one of the sets.

add_crosssection(label, label1, label2)
add_disjoint(label)
add_disjoint_set(name)

Deprecated, use add_disjoint

add_element(label=None, equalto=None, name=None)

Deprecated, use add.

add_element_alias(oldname, newname)

Deprecated, use add_alias

add_empty(label)
add_equal(label=None, equalto=None, name=None)
add_inbetween(label, label1, label2)

Adds set name that is larger or equal than p1 but smaller or equal then p2.

add_subset(label, label1)

It is not possible to do this quickly

add_super(label, label1)
add_union(label, label1, label2)
all_labels()
assure_same_labels()
combine(other)

Creates .relations that is consistent with both self and other.

combine_equal()
combine_equals()

If two dimensions are equal in all relations, we can sum them away.

copy()

Returns a copy of this SetRelationsSet.

debug = 0
ensure_points_left()

We remove all relations that do not have points left.

equal_identifier(label, set_labels=None, equal_elements=None)

Given an identifier to the label such that every label with the same identifier represents the same set.

filter(sets, allowed)

Filter all set relations that are not allowed. sets is a list of dimensions, allowed a list of allowed symbols (todo: also numbers)

TODO MT M: [SETRELATIONS] Implement more ways of defining the allowed relations.

filterequal(label1, label2)

First test for equality before filtering.

find_equals(label1)

Returns a list of set labels that are the same set as the given set.

find_supers(label1, strict=False)

Returns a list of set labels that are the same set as the given set or a superset. If strict=True, the sets must be strict supersets. However, this is not recommended, since for most sets it will be unknown whether it is a strict superset.

get_equal_elements()
get_equal_sets()

Returns a list of lists of sets that are equal.

isequal(label1, label2)

Determines wether two sets are equal.

relabel(old, new)
relation(labels=None, elements=None)
relation_holds(labels=None, relations=None, elements=None)

Tests whether the relation holds for the elements.

remove(label)
split(name)
class astro.util.SetRelations.TestSetRelations(methodName='runTest')

Bases: unittest.case.TestCase

Test SetRelations.

setUp()
static test_Ccontiguous()

Do not give this error in Python 3: ValueError: ndarray is not C-contiguous

static test_adding_disjoint()
static test_adding_empty()
static test_adding_inbetween()
static test_combine()
static test_crosssection()
static test_crosssection_new()
static test_crosssection_triple()
static test_numberlabels()
static test_order()
static test_sdss_relations()
static test_transitivity()
static test_transitivity2()
static test_union_new()

astro.util.StellarLocusRegression module

astro.util.TableConverter module

astro.util.UCD module

UCD.py map AWE-table-attributes to VO Unified Code Descriptors (UCD)

class astro.util.UCD.UcdXmlHandler

Bases: xml.sax.handler.ContentHandler

class to handle xml returned from web services (http://cdsweb.u-strasbg.fr/cdsws/ucdClient.gml)

characters(content)
endDocument()
endElement(name)
startDocument()
startElement(name, attrs)
astro.util.UCD.do_service(service_path)

call web service and extract result

class astro.util.UCD.ucd

Bases: dict

the ucd class is a dictionary setting the relation between column names in AW and ucds

assign(descr)
assign_path = '/axis/services/UCD?method=assign&ucd=%s'
base_url = 'cdsws.u-strasbg.fr'
explain(ucd)
explain_path = '/axis/services/UCD?method=explain&ucd=%s'
find(ucd)

find column names with same ucd

find_types(ucd)

find all types which have an attribute of ucd type

translate(ucd)
translate_path = '/axis/services/UCD?method=translate&ucd=%s'
validate(ucd)
validate_path = '/axis/services/UCD?method=validate&ucd=%s'

astro.util.Unit module

UNIT.py map AWE-table-attributes to units

********* OBSOLETE ********* Use the [] in the doc string of persistent attributes to define units ! ********* OBSOLETE ********* This class will be removed !!!! ********* OBSOLETE *********

astro.util.Unit.Unit = {}

see sites :

http://vizier.u-strasbg.fr/viz-bin/Unit?%3f

http://vizier.u-strasbg.fr/doc/catstd-3.2.htx

class astro.util.Unit.unit

Bases: dict

the unit class is a dictionary defining the unit of columns in AW

astro.util.Unit.units = {}

‘RA’ : ‘deg’, ‘DEC’ : ‘deg’, ‘A’ : ‘pixel’, ‘B’ : ‘pixel’, ‘BackGr’ : ‘count’, ‘Corr’ : ‘pixel**2’, ‘DEC’ : ‘deg’, ‘ERRA_IMAGE’ : ‘pixel’, ‘ERRB_IMAGE’ : ‘pixel’, ‘ERRTHETA_IMAGE’ : ‘deg’, ‘ERRX2_IMAGE’ : ‘pixel**2’, ‘ERRXY_IMAGE’ : ‘pixel**2’, ‘ERRY2_IMAGE’ : ‘pixel**2’, ‘FLUXERR_APER’ : ‘count’, ‘FLUXERR_AUTO’ : ‘count’, ‘FLUXERR_ISO’ : ‘count’, ‘FLUXERR_ISOCOR’ : ‘count’, ‘FLUX_APER’ : ‘count’, ‘FLUX_AUTO’ : ‘count’, ‘FLUX_ISO’ : ‘count’, ‘FLUX_ISOCOR’ : ‘count’, ‘FLUX_RADIUS’ : ‘pixel’, ‘FWHM_IMAGE’ : ‘pixel’, ‘Level’ : ‘count’, ‘MAGERR_APER’ : ‘mag’, ‘MAGERR_ISO’ : ‘mag’, ‘MAGERR_ISOCOR’ : ‘mag’, ‘MAG_APER’ : ‘mag’, ‘MAG_AUTO’ : ‘mag’, ‘MAG_ISO’ : ‘mag’, ‘MAG_ISOCOR’ : ‘mag’, ‘MU_MAX’ : ‘mag * arcsec**(-2)’, ‘MU_THRESHOLD’ : ‘mag * arcsec**(-2)’, ‘NPIX’ : ‘pixel**2’, ‘POSANG’ : ‘deg’, ‘RA’ : ‘deg’, ‘XM2’ : ‘pixel**2’, ‘Xpos’ : ‘pixel’, ‘YM2’ : ‘pixel**2’, ‘Ypos’ : ‘pixel’, ‘CRVAL1’ : ‘deg’, ‘CRVAL2’ : ‘deg’

astro.util.XSD module

Functionality to transform xsds

This module contains function to help transform xsds and can be used as a script to generate an xml template from a set of xsds for a given xsd type.

class astro.util.XSD.XSDType(xsd, item)

Bases: object

Map xml xsd type to a Python class

fmt()
fulltype()
isatomic()
isvalid()
astro.util.XSD.capitalize(s)
astro.util.XSD.expand_complextype(xsd, item, outelem, prefix, XSD)

Expand a complexType

astro.util.XSD.expand_sequence(xsd, item, outelem, prefix)

Expand the xs:sequence part of an xml element

astro.util.XSD.prettyxml(elem)
astro.util.XSD.read_all_xsds(dictionarydir=None)

Parse all xsd files inside a directory tree

astro.util.XSD.with_appinfo(elem, name, attr)

These are exceptions if the appinfo tag is present.

astro.util.XSD.without_appinfo(elem, name)

These are exceptions if the appinfo tag is missing.

astro.util.XsdMapping module

astro.util.angsep module

astro.util.angsep.angsep(ra1deg, dec1deg, ra2deg, dec2deg)

Determine separation in degrees between two celestial objects arguments are RA and Dec in decimal degrees.

astro.util.bwsm module

Biweight location and scale estimator.

Implemented from bwsm subroutine by Naples KiDS-CAT (La Barbera et al.).

astro.util.bwsm.bin_mat(nx, num_per_bin_min, num_per_bin, x, y, plot=None)

Do binned trend, in each bin calculating average of edges, median, and standard deviation.

Implemented from bin_mat subroutine by Naples KiDS-CAT (La Barbera et al.).

Argument plot is set by KidsCatCompl to run additional steps for that plot.

Loop through x, which has length nx, and make bins with num_per_bin or at least num_per_bin_min.

Keep in the xb list the average of the edges of the bin. Keep in the yb list the numpy medians of the bins. Keep in the eyb list the numpy standard deviation of the median. Count the number of sources and store in nb.

Return xb, yb, nb, eyb.

Should be called by child classes.

astro.util.bwsm.bwsm(xx, num_sigma)

Calculates the biweight location and scale estimator.

Implemented from bwsm subroutine by Naples KiDS-CAT (La Barbera et al.).

The argument xx is the list of numbers. The argument num_sigma is a float to indicate the number of standard deviations from the location that we want to keep.

Return list of floats with biweight location and scale.

Should be called by method bin_mat.

astro.util.bwsm.bwsm_loop(n, x, num_sigma, par_2, t1, s1)

Loop used by method bwsm.

Implemented from bwsm subroutine by Naples KiDS-CAT (La Barbera et al.).

Return list of floats with biweight location and scale.

Should be called by method bwsm.

astro.util.bwsm.chi(diff, num_sigma)

Calculates part of the biweight scale.

Implemented from chi subroutine by Naples KiDS-CAT (La Barbera et al.).

The argument diff is the value to compare. The argument num_sigma is a float to indicate the number of standard deviations from the MAD that we want to keep.

Return float.

Should be called by method bwsm_loop.

astro.util.bwsm.integrate_par2(num_sigma)

Calculates par2 through integration.

astro.util.bwsm.psi(diff)

Calculates part of the biweight location.

Implemented from psi subroutine by Naples KiDS-CAT (La Barbera et al.).

The argument diff is the value to compare.

Return float.

Should be called by method bwsm_loop.

astro.util.bwsm.really_integrate_par2(num_sigma)

Calculates par2 of bwsm.

Values calculated by bwsm.f and this function: num_sigma/CC par_2 1 0.258029384450943 0.2579972183544455 2.5 0.488780198167117 0.48878747011089507 0 0.000000000000000 0.0

astro.util.bwsm.std_fast(x)

The std() function of bwsm in KiDSCAT calculates something else than the standard deviation. What KiDSCAT calculates is the same as the standard deviation for a Gaussian distribution. Which could be justified since the validity of using this std assumes an almost Gaussian distribution:

astro.util.epoco module

astro.util.epoco.epoco(a1, d1, t1=1950.0, t2=2000.0)

epoco transforms equatorial coordinates from one epoch to another epoch.

input: a1 R.A. of input coordinate
d1 Dec. of input coordinate t1 Epoch of input coordinates [1950.0] t2 Epoch of output coordiantes [2000.0]

output: tuple of two containing R.A. and Dec. at epoch t2.

astro.util.extinction module

astro.util.extra_parameters module

astro.util.extra_parameters.get_extra_parameters(params, name=None)
astro.util.extra_parameters.put_extra_parameters(object, params={})
astro.util.extra_parameters.set_extra_parameter(object, key, val, skiplist=[])
astro.util.extra_parameters.set_extra_parameters(object, skiplist=[])

astro.util.htmsafe module

astro.util.idllib module

astro.util.match module

astro.util.match.matchids(id1, id2)

Match two sets of ids. Returns:

ibest – array of indices of i1 that match i2; -1 if no match
astro.util.match.matchidsorted(ids, targetid)

Find id matches, return index in i1 that matches targetid; -1 if no match.

astro.util.match.matchjoin(si1, si2, ibest, sep=[], dict1={}, dict2={})

Keep only elements that match in both catalogs. Arguments:

si1 – object with data arrays as attributes (e.g. si1.mag_auto, si1.id) si2 – object with data arrays as attributes ibest – indices of si1 that match si2 (in order of si2)
Keyword Arguments:
sep – array of separations, will be added as an attribute to second object dict1 – dictionary of attributes for si1 (e.g. {‘mag_auto’:0,’id’:1} ) dict2 – dictionary of attributes for si2

The objects si1 and si2 would normally be sextractor objects returned by sextutils.sextractor(). In that case, the column names are stored in si1._d and si2._d. If the objects are not sextractor objects, the user can provide separate dictionaries whose keys are the object attributes that correspond to the numpy data arrays.

Returns:
s1, s2 – object arrays that include only the matching objects contained
in both s1 and s2.
astro.util.match.matchpos(ra1, dec1, ra2, dec2, tol)

Match two sets of ra,dec within a tolerance. Longer catalog should go first Arguments:

ra1 - Right Ascension decimal degrees (numpy array) dec1 - Declination decimal degrees (numpy array) ra2 - Right Ascension decimal degrees (numpy array) dec2 - Declination decimal degrees (numpy array) tol - Matching tolerance in decimal degrees.
Returns:
ibest - indices of the best matches within tol; -1 if no match within tol sep - separations (defaults to tol if no match within tol)
astro.util.match.matchsorted(ra, dec, ra1, dec1, tol)

Find closest ra,dec within tol to a target in an ra-sorted list of ra,dec. Arguments:

ra - Right Ascension decimal degrees (numpy sorted in ascending order) dec - Declination decimal degrees (numpy array) ra1 - RA to match (scalar, decimal degrees) ra1 - Dec to match (scalar, decimal degrees) tol - Matching tolerance in decimal degrees.
Returns:
ibest - index of the best match within tol; -1 if no match within tol sep - separation (defaults to tol if no match within tol)

astro.util.projections module

class astro.util.projections.car(cdelt1=None, cdelt2=None, crpix1=None, crpix2=None, crota2=0.0, crval1=None, crval2=None, CD=None, PV=None, ctype1=None, ctype2=None, astrom=None)

Bases: astro.util.projections.flt

proj_type = 'CAR'
astro.util.projections.degrad(x)

Converts radians -> degrees

astro.util.projections.distance(ra1, dec1, ra2, dec2)

Calculates distance in degrees

class astro.util.projections.flt(cdelt1=None, cdelt2=None, crpix1=None, crpix2=None, crota2=0.0, crval1=None, crval2=None, CD=None, PV=None, ctype1=None, ctype2=None, astrom=None)

Bases: astro.util.projections.projections

gg_to_ss(x, y)
proj_type = 'FLT'
ss_to_gg(a, d)
class astro.util.projections.gnomonic(cdelt1=None, cdelt2=None, crpix1=None, crpix2=None, crota2=0.0, crval1=None, crval2=None, CD=None, PV=None, ctype1=None, ctype2=None, astrom=None)

Bases: astro.util.projections.projections

do_PV(l, m)
do_inverse_PV(l, m)
gg_to_ss(x, y)
proj_type = 'TAN'
ss_to_gg(a, d)
class astro.util.projections.ncp(cdelt1=None, cdelt2=None, crpix1=None, crpix2=None, crota2=0.0, crval1=None, crval2=None, CD=None, PV=None, ctype1=None, ctype2=None, astrom=None)

Bases: astro.util.projections.projections

gg_to_ss(x, y)
proj_type = 'NCP'
ss_to_gg(a, d)
astro.util.projections.posang(ra1, dec1, ra2, dec2)
class astro.util.projections.projections(cdelt1=None, cdelt2=None, crpix1=None, crpix2=None, crota2=0.0, crval1=None, crval2=None, CD=None, PV=None, ctype1=None, ctype2=None, astrom=None)

Bases: object

cdelt1 = 0.0
cdelt2 = 0.0
cosd0 = 1.0
cosrho = 1.0
crota2 = 0.0
crpix1 = 0.0
crpix2 = 0.0
crval1 = 0.0
crval2 = 0.0
gg_to_ss(x, y)
gs_to_sg(x, d)
lm_to_xy(l, m)
proj_type = '???'
sg_to_gs(a, y)
sind0 = 0.0
sinrho = 0.0
ss_to_gg(a, d)
xy_to_lm(x, y)
astro.util.projections.raddeg(x)

Converts degrees -> radians

class astro.util.projections.sin(cdelt1=None, cdelt2=None, crpix1=None, crpix2=None, crota2=0.0, crval1=None, crval2=None, CD=None, PV=None, ctype1=None, ctype2=None, astrom=None)

Bases: astro.util.projections.projections

gg_to_ss(x, y)
proj_type = 'SIN'
ss_to_gg(a, d)
class astro.util.projections.zpn(cdelt1=None, cdelt2=None, crpix1=None, crpix2=None, crota2=0.0, crval1=None, crval2=None, CD=None, PV=None, ctype1=None, ctype2=None, astrom=None)

Bases: astro.util.projections.projections

proj_type = 'ZPN'

astro.util.skyco module

astro.util.skyco.arc2deg(xxx_todo_changeme, xxx_todo_changeme1)

convert the ra and dec coordinates in (hour,minute,second) and (degrees,minutes,seconds) to degrees

astro.util.skyco.deg2arc(ra, dec)

convert degrees (ra,dec) to (hour,minute,second) and (degrees,minutes,seconds)

astro.util.skyco.deg2arc_dec(dec)

convert dec in degrees to degrees,minutes,seconds

astro.util.skyco.deg2arc_ra(ra)

convert ra in degrees to hour,minute,second

astro.util.skyco.degrad(x)
astro.util.skyco.dist_on_sky(p1, p2)

Calculate the distance in arcseconds between two positions on the sky; p1 and p2. These are tuples containing the equatorial coordinates in decimal degrees of the two positions.

astro.util.skyco.raddeg(x)
astro.util.skyco.skyco(x, y)

astro.util.utilities module

astro.util.utilities.group_objects_by_chip(objects)
astro.util.utilities.group_objects_by_date_obs(objects)
astro.util.utilities.group_objects_by_filter(objects)
astro.util.utilities.group_objects_by_mag_id(objects)
astro.util.utilities.group_unique_objects_by_chip(objects)
astro.util.utilities.group_unique_objects_by_filter(objects)

astro.util.votable module

Class to handle VOTable Created: 2005-05-31 by Shui Hung Kwok, shkwok at computer.org Edited: 2007-02-12 by Noel Winstanley, noel.winstanley at manchester.ac.uk

  • added ability to parse strings as votable-xml

See http://www.ivoa.net/Documents/latest/VOT.html .

class astro.util.votable.VONode(tagname=('', ''))

Bases: object

Class representing an XML node of a VOTable

addAttribute(attr)
addAttributes(attrs)
addNode(node)
buildName(tname)

Returns a name with namespace as prefix or just name if no namespace Note that the prefix is the real namespace and not the abbreviation used in the original XML

getAttribute(name)

Returns attribute by name or ‘’ if not found

getAttributes()

Returns all attributes.

getContent()

Returns all strings of the node.

getNamePart()
getNode(path)

Returns a node for a given path. Path is of the form /tag1/tag2/tag3. Path can include array index, like /tag1/tag2[3]/tag4.

getNodeList()

Returns a list of nodes that are of type VONode

getNodesByName(look4)

Returns a list of nodes whose tagname = look4

getNodesByPath(path)

Returns an array of VONodes for a given path. Path is of the form /tag1/tag2/tag3. Path can include array index, like /tag1/tag2[3]/tag4.

printAllNodes(func=<bound method Myfile.write of <common.config.startup.Myfile object at 0x7f6205cce080>>, prefix='')

Recursive method to visit all nodes of the tree and calls the provided function to output the content.

class astro.util.votable.VOTable(source=None, vonode=<class 'astro.util.votable.VONode'>)

Bases: astro.util.votable.VOXML

Implementation of VOTable

append(vot)

Appends votable vot to the end of this VOTable. No tests to see if fields are the same. vot must have the same fields.

getColumnIdx(val)

Returns the column index for the given name Will return any attribute value matching val.

getData(row)

row is a VONode <TR> parent of a list of <TD>. Returns a list of values.

getDataRows()

Returns a list of VONodes representing rows of the table. Use getData () to extract data from each row. for x in getDataRows ():

data = getData (x) #data = [values ...]
getDataType()
getFields()

Returns a list of VONode representing all the fields

getFieldsAttrs()

Returns a list of maps that contains attributes. Returned list looks like this: [{},{},...]

getFits()
getParams()

Returns a list of VONode representing all PARAMS

output2CSV(write=<bound method Myfile.write of <common.config.startup.Myfile object at 0x7f6205cce080>>)

Outputs the content in CSV format with fields names as column heads.

class astro.util.votable.VOXML(source=None, vonode=<class 'astro.util.votable.VONode'>)

Bases: object

Class to implement XML parser

getContent(path)

Returns the content of a node. Only strings are returned.

getNode(path)

Returns a VONode of the given path.

parse(source)

Invokes XML parser and stores VOXML in self.root as VONode.

parseText(text)

Invokes XML parser on inlined xml text

printAllNodes(func=<bound method Myfile.write of <common.config.startup.Myfile object at 0x7f6205cce080>>)

Output entire content as XML. func is the output method, defined as:

func (outString)
class astro.util.votable.VOXMLHandler(vonode=<class 'astro.util.votable.VONode'>)

Bases: xml.sax.handler.ContentHandler

Class implementing callbacks for the SAX parser.

characters(chunk)
endElementNS(urn_name, qname)
parse(source)

Main entry point. Source can be URL or file name.

parseText(t)

Alternate entry point. Text is some xml to be parsed

startElementNS(urn_name, qname, attrs)

astro.util.xsdsupport module

Module contents

util