astro.util package

Submodules

astro.util.BinaryFitsTable module

Write a SourceList as binary Fits table.

Write the Fits file per incoming SourceList row. This is useful for web services that do not need to have the whole SourceList in memory before writing out the binary Fits table to the client.

Example :

# this can also be a socket for example, as long as it has a write method f = open(‘test.fits’) sl = (SourceList.SLID==414761)[0] from astro.util.BinaryFitsTable import write_binary_fits_table write_binary_fits_table(f, sl)

WJ Vriend

astro.util.BinaryFitsTable.test()

method uses a ‘fake’ sourcelist for testing write_binary_fits_table

class astro.util.BinaryFitsTable.test_sourcelist

Bases: object

“fake” SourceList for testing purposes

static get_attributes_on_sources()
number_of_sources = 4
sources = [{'col4': 312.0, 'col2': 312, 'col3': 312, 'col1': 'NGC1'}, {'col4': 334.0, 'col2': 334, 'col3': 334, 'col1': 'NGC2'}, {'col4': 308.0, 'col2': 308, 'col3': 308, 'col1': 'NGC3'}, {'col4': 317.0, 'col2': 317, 'col3': 317, 'col1': 'NGC4'}]
astro.util.BinaryFitsTable.translate_attr(attr_type)

tranlsate the attribute type

astro.util.BinaryFitsTable.write_binary_fits_table(f, sl)

write SourceList as binary fits table

astro.util.BinaryFitsTable.write_primary(f)

write the primary fits hdu

astro.util.CalibratePhotometryToGaia module

astro.util.CanonicalName module

astro.util.CatalogAssociation module

astro.util.CosmologicalDistance module

A class to calculate cosmological distances The procedure by Hogg 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 Hogg 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.

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’.

eei(redshift)

The inverse of ee, used for integration

eeii(redshift)

The integration of the inverse of ee.

eez(redshift)

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

flat = 5e-05
h0 = 0.7
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 proper motion distance at distance redshift. Hogg 2000, chapter 5, equation 16.

set_h0(h0=nan)

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

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’ separated 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.main(show=True)

Testing cosmological distances, this should plot images from Hogg 2000.

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

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 minimum allowed overlap in ra. The fields are arranged in strips perpendicular to the meridian. This means that with increasing declination there are less fields per strip. Script optimizes for continuity form one dec strip to the next; therefore the positions in various dec strips are dependent on each other.

get_field_centre(rain, decin)

get nearest ra fieldcenters, needs dec too

get_numberra_centers(log)

determine number of fields for each dec

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

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 interpreting it as a binary number after prefixing 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)

Add a new set.

label : str
Label of the new set.
equalto : str
Optional, label of an existing set that is equal to the new set.
add_alias(label, label1)

Add an alias to one of the sets.

label : str
Original label.
label1 : str
New label.
add_crosssection(label, label1, label2)

Add a set that is a cross section of two other sets.

label : str
Label of the new set.
label1 : str
Label of the first set of the cross section.
label2 : str
Label of the second set of the cross section.
add_disjoint(label)

Add a new set that is disjoint with all existing sets.

label : str
Label of the new set.
add_empty(label)

Add an empty set.

label : str
Label of the new set.
add_equal(label=None, equalto=None)

Add a set that is equal to another set.

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.

label : str
Label of the set.
equalto : str
Label of the set that the new set is equal to.
add_union(label, label1, label2)

Add a set that is a union of two other sets.

label : str
Label of the new set.
label1 : str
Label of the first set of the union.
label2 : str
Label of the second set of the union.
all_labels()

Get labels of all sets.

list of str
Labels of all sets.
static bin_from_num(n)

Convert denary integer n to binary list.

n : int

list of int
Binary digits of n.
combine(other)

Combine this SetRelations with another.

other : SetRelations
The other SetRelations to combine.
set of SetRelations
SetRelations that are consistent with self and other.
combine_raw(other)

Combines two relations in most simplistic form.

All sets from the other relation are added one by one and the corresponding SetRelations are filtered.

other : SetRelations
The other SetRelations to combine.
set of SetRelations
SetRelations that are consistent with self and other.
copy()

Creates a new copy of this relation.

SetRelations
A copy of self.
dimension_from_label(label)

Get the dimension that corresponds to the given label.

label : str
Set label.
int
Dimension corresponding to the label.
dimension_matrix()

Get the dimension of the matrix.

int
Dimension of the matrix.
find_equals(label)

Find sets that are equal to the set with the given label.

label : str
Label of the set to find equals from
list of str
List of labels of sets that are equal to set with given label.
flatten()

Split all dimensions that correspond to multiple sets.

from_number(number)

Create the matrix from a number.

number : int
The number corresponding to the matrix.
from_symbol(symbol)

Create the matrix from a symbol.

symbol : str
The symbol.
isequal(label1, label2)

Determine whether two sets are equal.

Much faster than using relation().

label1 : str or int
Label of the first set to check for equality.
label2 : str or int
Label of the second set to check for equality.
msum(dim)

Sums the matrix to remove a dimension and the corresponding sets.

This is a separate function for profiling reasons because it is slow. Use remove() to remove a set/dimension properly.

dim : int
The dimension to sum over.
numpy.ndarray
The summed array.
new_label()

Returns a new label that is not yet used.

It is preferred to set labels explicitly.

str
A new, unused label.
number()

Get the number that corresponds to this relation.

This is only sensible if the order of the sets is known.

int
The number corresponding to this relation.
number_from_symbol(symbol)

Get the number from a symbol.

symbol : str
The symbol.
int
The number corresponding to the symbol.
order_labels()

Sort the labels of the sets.

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

relabel(old, new)

Relabel a set.

old : str
Old label of the set.
new : str
New label of the set.
relation(relation)

Determines the relation between a group of sets.

relation : list of str
Labels of sets to find the relation between. TODO: Rename
SetRelations
The relation between the labels.
remove(label=None)

Remove a set identified by label or dimension.

All sets matching the dimension are removed when a dimension is given.

label : str or int
Label of the set or dimension.
split(label)

Split the dimension corresponding to label if it is shared with other sets.

label : str
The label of the set.
symbol()

Get the number that corresponds to this relation.

str
Symbol corresponding to this relation.
class astro.util.SetRelations.SetRelationsSet(infinite_points=False)

Bases: object

A list of SetRelations that meet the proposed criteria.

add(label=None, equalto=None)

Add a new set.

label : str
Label of the new set.
equalto : str
Optional, label of an existing set that is equal to the new set.
add_alias(label, label1)

Add an alias to one of the sets.

label : str
Original label.
label1 : str
New label.
add_crosssection(label, label1, label2)

Add a set that is a cross section of two other sets.

label : str
Label of the new set.
label1 : str
Label of the first set of the cross section.
label2 : str
Label of the second set of the cross section.
add_disjoint(label)

Add a new set that is disjoint with all existing sets.

label : str
Label of the new set.
add_empty(label)

Add an empty set.

label : str
Label of the new set.
add_equal(label=None, equalto=None)

Add a set that is equal to another set.

label : str
Label of the set.
equalto : str
Label of the set that the new set is equal to.
add_inbetween(label, label1, label2)

Add a set that is larger or equal than label1 but smaller or equal then label2.

label : str
Label of the new set.
label1 : str
Label of the set that is a subset of the new set.
label2 : str
Label of the set that is a superset of the new set.
add_subset(label, label1)

Add a new set that is a subset of an existing set.

label : str
Label of the new set.
label1 : str
Label of the set that is a superset of the new set.
add_super(label, label1)

Add a superset of an existing set.

label : str
Label of the new set.
label1 : str
Label of the existing set that is a subset of the new set.
add_union(label, label1, label2)

Add a set that is a union of two other sets.

label : str
Label of the new set.
label1 : str
Label of the first set of the union.
label2 : str
Label of the second set of the union.
all_labels()

Get labels of all sets.

list of str
Labels of all sets.
assure_same_labels()

Assure that all subrelations have the same labels.

bool
Whether all subrelations have the same labels.
combine(other)

Ensure this SetRelationsSet is consistent with another one.

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

other : SetRelationsSet
The other SetRelationsSet to be compatible with.
combine_equal()

Find and combine two sets that are equal in all subrelations.

bool
Whether two previously uncombined equal sets where found.
combine_equals()

Combine all sets that are equal.

copy()

Make a copy of this SetRelationsSet.

SetRelationsSet
Copy of this SetRelationsSet.
debug = 0
ensure_points_left()

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 : list of str or list of int
List of labels of sets to filter on.
allowed : list
List of allowed symbols. [TODO: also numbers]

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

filterequal(label1, label2)

Ensure that two sets are equal.

label1 : str
Label of the first set.
label2 : str
Label of the second set.
find_equals(label1)

Find sets that are equal to the set with the given label.

label1 : str
Label of the set to find equals from. TODO: Rename
list of str
List of labels of sets that are equal to set with given label.
find_supers(label1, strict=False)

Find sets that are equal to a given set or a superset.

label1 : str
Label of the set to find supersets of.
strict : bool
Whether the found sets should be strict supersets (not equal).
list of str
Labels of sets that are equal to the given set or a superset.
get_equal_sets()

Find equal sets.

list of list of str
List of lists of labels of sets that are equal.
isequal(label1, label2)

Determine whether two sets are equal.

label1 : str or int
Label of the first set to check for equality.
label2 : str or int
Label of the second set to check for equality.
relabel(old, new)

Relabel a set.

old : str
Old label of the set.
new : str
New label of the set.
relation(labels=None)

Determines the relation between a group of sets.

labels : list of str
Labels of sets to find the relation between.
set of SetRelations
The possible relations between the labels.
relation_holds(labels=None, relations=None)

Test whether a relation holds for the elements.

labels : list of str
Labels of sets to find the relation between.
relations : list of SetRelations.
Relation between sets indicated by labels.
bool
Whether the relation holds.
remove(label)

Remove a set.

label : str
Label of the set.
split(name)

Split the dimension corresponding to label if it is shared with other sets.

name : str
The label of the set.
class astro.util.SetRelations.TestSetRelations(methodName='runTest')

Bases: unittest.case.TestCase

Test SetRelations.

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()
static test_zero_labels()

Test 0 labels.

astro.util.StellarLocusRegression module

astro.util.TableConverter module

astro.util.UCD module

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.extinction module

astro.util.extra_parameters module

astro.util.htmsafe module

Safe usage of the htm module.

The bare htm module might cause the awe-prompt to hang or segfault. This wrapper module ensures that an exception is raised instead of passing dangerous values to the htm module itself.

Improvements w.r.t. to the normal htm module: - Prevents get_depth() from segfaulting by providing native Python

implementation.
  • Prevents NaN valued arguments from hanging/aborting/crashing the awe-prompt through a wrapper.

Possible improvements to add: - Prevent segfaults when passing invalid values (e.g. a dec > 90).

Possible improvements to this module itself: - Maintain docstring etc. through proper decorator? (This information

is not available in the htm module anyway.)
  • Put this functionality directly in the SWIG wrapper?

Tests for this module can be found in astro/test/functional/htmsafe_test.py

astro.util.htmsafe.area(*args, **kwargs)
astro.util.htmsafe.get_circle_indices(*args, **kwargs)
astro.util.htmsafe.get_circle_indices_dummy(*args, **kwargs)
astro.util.htmsafe.get_depth(trixel)
astro.util.htmsafe.get_distance(*args, **kwargs)
astro.util.htmsafe.get_edges_dec(*args, **kwargs)
astro.util.htmsafe.get_edges_ra(*args, **kwargs)
astro.util.htmsafe.get_nearest_indices(*args, **kwargs)
astro.util.htmsafe.get_ranges_3(*args, **kwargs)
astro.util.htmsafe.get_ranges_4(*args, **kwargs)
astro.util.htmsafe.get_ranges_4_test(*args, **kwargs)
astro.util.htmsafe.get_ranges_circle(*args, **kwargs)
astro.util.htmsafe.get_ranges_ellipse(*args, **kwargs)
astro.util.htmsafe.get_shortest_side(*args, **kwargs)
astro.util.htmsafe.htm_get_edges(*args, **kwargs)
astro.util.htmsafe.lookup(*args, **kwargs)
astro.util.htmsafe.lookup_(level, ra, dec)
astro.util.htmsafe.nan_checker(func)
astro.util.htmsafe.ok(*args, **kwargs)

astro.util.idllib module

exception astro.util.idllib.IDLLibError

Bases: Exception

astro.util.idllib.bprecess(ra, dec, mu_radec=None, parallax=None, rad_vel=None, epoch=None)
astro.util.idllib.glactc(ra, dec, year, degree=False, fk4=False, SuperGalactic=False, eqtogal=True)
astro.util.idllib.jprecess(ra, dec, mu_radec=None, parallax=None, rad_vel=None, epoch=None)
astro.util.idllib.precess(ra, dec, equinox1, equinox2, fk4=False, radian=False)
astro.util.idllib.premat(equinox1, equinox2, fk4=False)
astro.util.idllib.total(a, b)

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=None, dict1=None, dict2=None)

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

astro.util.skyco module

sky coordinates adapted by DB from part of Gipsy skyco_c EPOCH 1950 to 2000

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)

Compute radians from degrees.

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)

Compute radians from degrees.

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)
static 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=<built-in method write of _io.TextIOWrapper object>, 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.

static 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=<built-in method write of _io.TextIOWrapper object>)

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=<built-in method write of _io.TextIOWrapper object>)

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