eph.jpl package¶
Submodules¶
eph.jpl.exceptions module¶
Defines Jpl Horizons related exceptions.
-
exception
eph.jpl.exceptions.
JplBadParamError
¶ Bases:
eph.jpl.exceptions.JplError
A
JplBadParamError
is raised when aJplReq
tries to set a parameter that do not match with Jpl Horizons specifications.
-
exception
eph.jpl.exceptions.
JplBadReqError
¶ Bases:
eph.jpl.exceptions.JplError
A
JplBadReqError
exceptions is raised when a request (JplReq
) to the Horizons service cannot be interpreted by the Horizons system.
-
exception
eph.jpl.exceptions.
JplError
¶ Bases:
Exception
Base class for Horizons service related errors.
-
exception
eph.jpl.exceptions.
JplParserError
¶ Bases:
eph.jpl.exceptions.JplError
A
JplParserError
exception is raised when problems are found in parsing a response (JplRes
) from Horizons service.
eph.jpl.horizons module¶
Defines variables and functions used to interfacing with Jpl Horizons system.
-
eph.jpl.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.jpl.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.jpl.horizons.
format_time
(t)¶ Modify time data
t
so thatstr(t)
can be interpreted by Jpl.Parameters: t – the time data. It can be a str
, anastropy.time.Time
object or an object such asstr(t)
can be understood by Jpl.Returns: the final object.
-
eph.jpl.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.jpl.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.jpl.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.jpl.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.jpl.horizons.
transform_value
(key, value)¶ 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)
can be interpreted by Jpl.
Returns: the transofrmed value.
Return type: str
eph.jpl.interface module¶
Contains classes and functions useful to interact with the Jpl Horizons service from NASA.
-
class
eph.jpl.interface.
JplReq
(*args, **kwargs)¶ Bases:
eph.jpl.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='jplparams')¶ 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.jpl.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.jpl.models module¶
eph.jpl.parsers module¶
Defines parsing functions to read Jpl Horizons ephemeris.
-
eph.jpl.parsers.
check_csv
(source)¶
-
eph.jpl.parsers.
get_sections
(source)¶ Split a Jpl Horizons ephemeris in header, data and footer.
Parameters: 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.jpl.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.jpl.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.jpl.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.jpl.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.jpl.parsers.
parse_jplparams
(source)¶
-
eph.jpl.parsers.
parse_meta
(header)¶
-
eph.jpl.parsers.
parse_units
(meta)¶
eph.jpl.shortcuts module¶
Defines shortcut functions useful to ease the access of Jpl Horizons data.
-
eph.jpl.shortcuts.
raw_data_from_req_file
(req_file)¶ It returns a raw Jpl Horizons response from a request built from a config ini file.
Parameters: req_file (str) – the filename from which the request has to be load. Returns: the raw text output from Jpl. Return type: str
Module contents¶
jpl
package contains modules related to retrieve and parse ephemeris from the Jpl Horizons service.
The main classes defined by jpl
package are
JplReq
: this class represents a Jpl request to the Horizons service. AJplReq
object is like adict
containing Jpl service parameters used to specify an ephemeris.JplRes
: this represents a Jpl response from the Horizons service. AJplRes
object contains the http response obtained from the Horizons service through a query performed by aJplReq
instance. TheJplRes
object can parse the response in an astropy table or return the raw text response.