Reference/API#
Utility Functions/Classes#
astropy.utils.codegen Module#
Utilities for generating new Python code at runtime.
Functions#
|
Make a new function from an existing function but with the desired signature. |
astropy.utils.collections Module#
A module containing specialized collection classes.
Classes#
|
A subclass of list that contains only elements of a given type or types. |
astropy.utils.console Module#
Utilities for console input and output.
Functions#
|
Returns |
|
Prints colors and styles to the terminal uses ANSI escape sequences. |
|
Returns a human-friendly time string that is always exactly 6 characters long. |
|
Returns a human-friendly string representing a file size that is 2-4 characters long. |
|
Prints a line of source code, highlighting a particular character position in the line. |
|
Returns a tuple (height, width) containing the height and width of the terminal. |
Classes#
|
A class to display a progress bar in the terminal. |
|
A class to display a spinner in the terminal. |
|
A class that displays either a |
astropy.utils.data_info Module#
This module contains functions and methods that relate to the DataInfo class which provides a container for informational attributes as well as summary info methods.
A DataInfo object is attached to the Quantity, SkyCoord, and Time classes in astropy. Here it allows those classes to be used in Tables and uniformly carry table column attributes such as name, format, dtype, meta, and description.
Functions#
|
Factory to create a function that can be used as an |
|
Return a human-oriented string name of the |
Classes#
|
Base info class for anything that can be a column in an astropy Table. |
|
Descriptor that data classes use to add an |
|
|
|
Mixin that gets info.dtype from parent. |
astropy.utils.decorators Module#
Sundry function and class decorators.
Functions#
|
Used to mark a function or class as deprecated. |
|
Used to mark a public attribute as deprecated. |
|
Deprecate a _renamed_ or _removed_ function argument. |
|
Replaces the docstring of the decorated object and then formats it. |
Classes#
|
Similar to |
|
Works similarly to property(), but computes the value only once. |
This is a method decorator that allows both an instancemethod and a |
astropy.utils.diff Module#
Functions#
|
Diff two scalar values. |
|
Write a diff report between two values to the specified file-like object. |
|
A version of |
astropy.utils.exceptions Module#
This module contains errors/exceptions and warnings of general use for astropy. Exceptions that are specific to a given subpackage should not be here, but rather in the particular subpackage.
Classes#
The base warning class from which all Astropy warnings should inherit. |
|
The primary warning class for Astropy. |
|
A warning class to indicate a deprecated feature. |
|
A warning class to indicate a soon-to-be deprecated feature. |
|
A warning class indicating a change in astropy that is incompatible with previous versions. |
|
A warning class indicating a representation name was already registered. |
astropy.utils.iers Package#
Classes#
|
Configuration parameters for |
|
Generic IERS table class, defining interpolation functions. |
IERS time conversion has degraded accuracy normally due to setting |
|
Any error for when dates are outside of the valid range for IERS. |
|
Downloaded IERS table may be stale. |
|
Generic warning class for IERS. |
|
|
IERS Table class targeted to IERS A, provided by USNO. |
|
Provide most-recent IERS data and automatically handle downloading of updated values as necessary. |
|
IERS Table class targeted to IERS B, provided by IERS itself. |
|
Leap seconds class, holding TAI-UTC differences. |
Default IERS table for Earth rotation and reference systems service. |
astropy.utils.introspection Module#
Functions related to Python runtime introspection.
Functions#
|
Resolve a name like |
|
Returns |
|
Determines the module/package from which this function is called. |
|
Returns |
astropy.utils.metadata Package#
This module contains helper functions and classes for handling metadata.
Functions#
|
Context manager to temporarily enable one or more custom metadata merge strategies. |
|
Merge the |
|
Use numpy to find the common dtype for a list of ndarrays. |
Classes#
|
A descriptor for classes that have a |
|
Descriptor to define custom attribute which gets stored in the object |
|
Metaclass that registers MergeStrategy subclasses into the MERGE_STRATEGIES registry. |
Base class for defining a strategy for merging metadata from two sources, left and right, into a single output. |
|
Merge |
|
Merge |
|
astropy.utils.misc Module#
A “grab bag” of relatively small general-purpose utilities that don’t have a clear module/package to live in.
Functions#
|
Returns |
|
A context manager that silences sys.stdout and sys.stderr. |
|
Fill in information about the exception that occurred. |
|
Determines the URL of the API page for the specified object, and optionally open that page in a web browser. |
|
Deprecated since version 6.0. |
|
Deprecated since version 6.0. |
|
Indent a block of text. |
|
Parse the number out of a dtype.str value like '<U5' or '<f8'. |
Classes#
|
A context manager (for use with the |
|
Support for data types that JSON default encoder does not do. |
astropy.utils.parsing Module#
Wrappers for PLY to provide thread safety.
Functions#
|
Create a lexer from local variables. |
|
Create a parser from local variables. |
Classes#
|
Wrap a parser produced by |
astropy.utils.state Module#
A simple class to manage a piece of global science state. See Adding New Configuration Items for more details.
Classes#
Science state subclasses are used to manage global items that can affect science results. |
astropy.utils.shapes Module#
The ShapedLikeNDArray mixin class and shape-related functions.
Functions#
|
Determines whether two or more Numpy arrays can be broadcast with each other based on their shape tuple alone. |
|
Given a Numpy basic index, return a tuple of integers and slice objects with no default values ( |
|
Given an array, return a new array that is the smallest subset of the original array that can be re-broadcasted back to the original array. |
Classes#
Mixin class to provide shape-changing methods. |
|
Mixin class to provide shape-changing methods. |
|
|
File Downloads#
astropy.utils.data Module#
Functions for accessing, downloading, and caching data files.
Functions#
|
Downloads a URL and optionally caches the result. |
|
Download multiple files in parallel from the given URLs. |
|
Yield a readable, seekable file-like object from a file or URL. |
|
Retrieves a data file from the standard locations for the package and provides the file as a file-like object that reads bytes. |
|
Retrieves a data file from the standard locations for the package and provides a local filename for the data. |
|
Retrieves a data file from the standard locations and returns its contents as a bytes object. |
|
Returns readable file objects for all of the data files in a given directory that match a given glob pattern. |
|
Returns the path of all of the data files in a given directory that match a given glob pattern. |
|
Get path from source-included data directories. |
|
Test whether a string is a valid URL for |
|
Check if a download for |
|
Get the list of URLs in the cache. |
|
Return the total size in bytes of all files in the cache. |
|
Obtain a dict mapping cached URLs to filenames. |
|
Exports the cache contents as a ZIP file. |
|
Imports the contents of a ZIP file into the cache. |
|
Import the on-disk file specified by filename to the cache. |
|
Do a consistency check on the cache. |
|
Clears the data file cache by deleting the local file(s). |
|
Computes the MD5 hash for a file. |
|
Given a path to a directory, returns the amount of free space on that filesystem. |
|
Determines if a given directory has enough space to hold a file of a given size. |
|
Retrieves the contents of a filename or file-like object. |
Classes#
|
Configuration parameters for |
This warning indicates the standard cache directory is not accessible, with the first argument providing the warning message. |
|
|
Record the URL or file that was a problem. |
XML#
The astropy.utils.xml.*
modules provide various
XML processing tools.
astropy.utils.xml.check Module#
A collection of functions for checking various XML-related strings for standards compliance.
Functions#
|
Returns |
|
Returns |
|
Returns |
|
Returns |
|
Given an arbitrary string, create one that can be used as an xml id. |
astropy.utils.xml.iterparser Module#
This module includes a fast iterator-based XML parser.
Functions#
|
Returns an iterator over the elements of an XML file. |
|
Determine the encoding of an XML file by reading its header. |
|
Get the lines from a given XML file. |
astropy.utils.xml.unescaper Module#
URL unescaper functions.
Functions#
|
Recursively unescape a given URL. |
astropy.utils.xml.validate Module#
Functions to do XML schema and DTD validation. At the moment, this makes a subprocess call to xmllint. This could use a Python-based library at some point in the future, if something appropriate could be found.
Functions#
|
Validates an XML file against a schema or DTD. |
astropy.utils.xml.writer Module#
Contains a class that makes it simple to stream out well-formed and nicely-indented XML.
Classes#
|
A class to write well-formed and nicely indented XML. |