eph package¶
Submodules¶
eph.config module¶
-
eph.config.
create_config_file
(out_filename='/home/docs/.ephrc')¶
-
eph.config.
get_config_dir
()¶
-
eph.config.
get_config_file
()¶
-
eph.config.
get_default_config_file
()¶
-
eph.config.
read_config
(filename=None, section=None)¶
eph.exceptions module¶
Defines eph
package related exceptions.
-
exception
eph.exceptions.
ConfigError
¶ Bases:
eph.exceptions.EphError
Base class for configuration related errors.
-
exception
eph.exceptions.
ConfigNotFoundError
¶ Bases:
eph.exceptions.ConfigError
A
ConfigNotFoundError
is raised when config file is not found.
-
exception
eph.exceptions.
ConfigParserError
¶ Bases:
eph.exceptions.ConfigError
A
ConfigParser
is raised when problems are encountered parsing a config file.
-
exception
eph.exceptions.
JplBadParamError
¶ Bases:
eph.exceptions.JplError
A
JplBadParamError
is raised when aJplReq
tries to set a parameter that do not match with Jpl Horizons specifications.
-
exception
eph.exceptions.
JplBadReqError
¶ Bases:
eph.exceptions.JplError
A
JplBadReqError
exceptions is raised when a request to the Horizons service cannot be interpreted by the Horizons system.
-
exception
eph.exceptions.
JplError
¶ Bases:
eph.exceptions.EphError
Base class for JPL Horizons service related errors.
-
exception
eph.exceptions.
ParserError
¶ Bases:
eph.exceptions.EphError
A
ParserError
exception is raised when problems are found in parsing a response from the Horizons service.
eph.horizons module¶
Defines variables and functions used to interfacing with JPL Horizons system.
-
eph.horizons.
codify_obj
(name)¶ Tries to translate a human readable celestial object name to the corresponding Jpl Horizons code. If the name is not known the name itself will be returned.
Parameters: name (str) – the name to be translated. Returns: the code of the object (stringified version of the id). Return type: str
-
eph.horizons.
codify_site
(name)¶ Tries to translate a human readable celestial object name to the corresponding Jpl Horizons site code.
If the name is not known the name itself will be returned preceded by a @ sign if @ is not already present in the name.
Parameters: name (str) – the name to be translated. Returns: the code of the site. Return type: str
-
eph.horizons.
format_time
(t)¶ Modify time data t so that str(t) can be interpreted by Jpl.
Parameters: - t – the time data. It can be a str, an astropy.time.Time object
- an object such as str (or) –
Returns: the final object.
-
eph.horizons.
get_col_dim
(col)¶ Get the physical dimension of a column by its name.
Parameters: col (str) – the name of the column. Returns: the physical dimensions of the given column. Return type: str
-
eph.horizons.
humanify
(code)¶ Tries to interpret a Jpl object or site code as a human readable celestial object name.
Parameters: code (str) – the code to be translated. Returns: the corresponding human readable name. Return type: str
-
eph.horizons.
is_jpl_param
(key)¶ Checks if a key is a Jpl Horizons parameter or a defined alias.
Parameters: key (str) – the parameter to be checked. Returns: Whether key is or not a Jpl parameter. Return type: boolean
-
eph.horizons.
transform
(key, value)¶ Transforms an input key-value pair in a Jpl-compatible one.
Parameters: - key (str) – the key to be interpreted or translated.
- value – a
str
to be translated or the object such asstr(value)
is Jpl-compatible.
Returns: the final key-value pair.
Return type: tuple
-
eph.horizons.
transform_key
(key)¶ Tranforms an input key to a Jpl-compatible parameter key.
Parameters: key (str) – the key to be interpreted and translated. Returns: the interpreted Jpl-compatible key. Return type: str Raises: JplBadParamError
-
eph.horizons.
transform_value
(key, value)¶ Tries to transforms an input value into a Jpl-compatible one or it leaves as is.
Parameters: - key (str) – the Jpl-compatible key.
- value – a
str
to be translated or an object such asstr(value)
- be interpreted by Jpl. (can) –
Returns: the transofrmed value.
Return type: str
eph.interface module¶
Contains classes and functions useful to interact with the Jpl Horizons service from NASA.
-
class
eph.interface.
JplReq
(*args, **kwargs)¶ Bases:
eph.models.BaseMap
A requests to Jpl Horizons service.
It can be thought as a
dict
where key-value pairs represents Jpl Horizons parameters. Jpl parameters can be also set as attributes of theJplReq
instance. Furthermore, keys and values are adjusted to match Jpl Horizons interface in order to enhance readability and usability.-
query
()¶ Performs the query to the Jpl Horizons service.
Returns: the response from Jpl Horizons service. Return type: JplRes
Raises: ConnectionError
-
read
(filename, section='DEFAULT')¶ Reads configurations parameters from an ini file.
Reads the section section of the ini config file filename and set all parameters for the Jpl request.
Parameters: - filename (str) – the config file to be read.
- section (str) – the section of the ini config file to be read.
Returns: the object itself.
Return type:
-
-
class
eph.interface.
JplRes
(http_response)¶ Bases:
object
A response from the Jpl Horizons service.
-
get_data
()¶
-
get_header
()¶
-
parse
(target=<class 'astropy.table.table.QTable'>)¶ Parse the http response from Jpl Horizons and return, according to target.
- an astropy.table.Table object.
- an astropy.table.QTable object.
-
raw
()¶ Returns the content of the Jpl Horizons http response as is.
-
eph.models module¶
eph.parsers module¶
Defines parsing functions to read Jpl Horizons ephemeris.
-
eph.parsers.
check_csv
(source)¶
-
eph.parsers.
get_sections
(source)¶ Split a Jpl Horizons ephemeris in header, data and footer.
Args: source (str): the content of the Jpl Horizons ephemeris data output.
Returns: a tuple of strings containing header, data and footer sections respectively. Return type: tuple
-
eph.parsers.
get_subsections
(source)¶ Split a source string in a list of sections separated by one or more *.
Parameters: source (str) – the source string to be splitted. Returns: the lists of subsections. Return type: list
-
eph.parsers.
parse
(source, target=<class 'astropy.table.table.QTable'>)¶ Parses an entire Jpl Horizons ephemeris and build an astropy table out of it.
Parameters: - source (str) – the content of the Jpl Horizons data file.
- target – the type of table to produce (Table or QTable).
Returns: the table containing data from Jpl Horizons source ephemeris.
Return type: table
-
eph.parsers.
parse_cols
(header)¶ Finds and parses ephemeris column names in a Jpl Horizons ephemeris.
Parameters: header (str) – the header of a Jpl Horizons ephemeris. Returns: a tuple with the names of columns. Return type: tuple
-
eph.parsers.
parse_data
(data, **kwargs)¶ Parses the data section of a Jpl Horizons ephemeris in a list of lists table.
Parameters: data (str) – the section containing data of a Jpl Horizons ephemeris. Returns: the list of lists representing a data table. Return type: list
-
eph.parsers.
parse_meta
(header)¶
-
eph.parsers.
parse_params
(source)¶
-
eph.parsers.
parse_units
(meta)¶
eph.shortcuts module¶
Defines shortcut functions useful to ease the access of Jpl Horizons data.
-
eph.shortcuts.
altaz
(objs, site_coord='0, 0, 0', dates=datetime.datetime(2019, 7, 20, 16, 50, 2, 436434), **kwargs)¶ Shortcut function to directly obtain an astropy QTable with ALT/AZ data.
Parameters: - objs – The celestial objects to be targeted.
- dates – start and stop (optional) time.
- site_coord – comma separated value for longitude, latidute, altitude of a site.
Returns: The data structure containing ephemeris data.
Return type: astropy.table.Qtable
-
eph.shortcuts.
elem
(objs, dates=datetime.datetime(2019, 7, 20, 16, 50, 2, 436431), **kwargs)¶ Shortcut function to directly obtain an astropy QTable with orbital elements.
Parameters: - objs – The celestial objects to be targeted.
- dates – start and stop (optional) time.
Returns: The data structure containing ephemeris data.
Return type: astropy.table.Qtable
-
eph.shortcuts.
get
(objs, dates=datetime.datetime(2019, 7, 20, 16, 50, 2, 436417), **kwargs)¶ Shortcut function to directly obtain an astropy QTable from Jpl Horizons parameters without building a JplReq and get a JplRes out of it to be parsed.
Parameters: - objs – The celestial objects to be targeted.
- dates – start and stop (optional) time.
Returns: The data structure containing ephemeris data.
Return type: astropy.table.Qtable
-
eph.shortcuts.
obs
(objs, dates=datetime.datetime(2019, 7, 20, 16, 50, 2, 436432), **kwargs)¶ Shortcut function to directly obtain an astropy QTable with observable quantities.
Parameters: - objs – The celestial objects to be targeted.
- dates – start and stop (optional) time.
Returns: The data structure containing ephemeris data.
Return type: astropy.table.Qtable
-
eph.shortcuts.
pos
(objs, dates=datetime.datetime(2019, 7, 20, 16, 50, 2, 436430), **kwargs)¶ Shortcut function to directly obtain an astropy QTable with position- only vector data.
Parameters: - objs – The celestial objects to be targeted.
- dates – start and stop (optional) time.
Returns: The data structure containing ephemeris data.
Return type: astropy.table.Qtable
-
eph.shortcuts.
radec
(objs, dates=datetime.datetime(2019, 7, 20, 16, 50, 2, 436433), **kwargs)¶ Shortcut function to directly obtain an astropy QTable with RA/DEC data.
Parameters: - objs – The celestial objects to be targeted.
- dates – start and stop (optional) time.
Returns: The data structure containing ephemeris data.
Return type: astropy.table.Qtable
-
eph.shortcuts.
vec
(objs, dates=datetime.datetime(2019, 7, 20, 16, 50, 2, 436428), center='@0', **kwargs)¶ Shortcut function to directly obtain an astropy QTable with vector data.
Parameters: - objs – The celestial objects to be targeted.
- dates – start and stop (optional) time.
Returns: The data structure containing ephemeris data.
Return type: astropy.table.Qtable
-
eph.shortcuts.
vel
(objs, dates=datetime.datetime(2019, 7, 20, 16, 50, 2, 436430), **kwargs)¶ Shortcut function to directly obtain an astropy QTable with velocity- only vector data.
Parameters: - objs – The celestial objects to be targeted.
- dates – start and stop (optional) time.
Returns: The data structure containing ephemeris data.
Return type: astropy.table.Qtable
eph.util module¶
-
eph.util.
addparams2url
(url, params)¶
-
eph.util.
clean_row
(row)¶
-
eph.util.
is_vector
(obj)¶
-
eph.util.
numberify
(data)¶
-
eph.util.
parse_row
(raw, cols_del=', ')¶
-
eph.util.
parse_table
(raw, cols_del=', ', rows_del='\\r?\\n')¶
-
eph.util.
path
(filename)¶
-
eph.util.
transpose
(data)¶
-
eph.util.
wrap
(s, wrapper="'", to_strip='"')¶
-
eph.util.
yes_or_no
(value, yes='YES', no='NO')¶
Module contents¶
eph package aims to provide useful classes, functions and tools to retrieve, represent and manipulate ephemerides.