file_io.ADESXMLReader

Reader for MPC ADES observation files in XML form (issue #44).

ADES XML wraps each observation in an <optical> (or <radar>) element whose child tags are the ADES field names – the same fields the CSV/PSV reader consumes, e.g. provID, stn, obsTime, ra, dec, mag. Both the “flat” form (<ades><optical>...</optical></ades>) and the <obsBlock>-wrapped form are handled: we collect every <optical>/ <radar> element anywhere under the root.

Each record becomes one row; the union of all field tags becomes the columns (missing fields are filled, exactly as a mixed CSV would be). Field text is coerced to numeric where possible, while the primary-id and station columns are kept as strings – mirroring CSVDataReader so downstream code sees an identical structured array regardless of whether the input was CSV, PSV, or XML.

Attributes

logger

_RECORD_TAGS

Classes

ADESXMLDataReader

Read MPC ADES observation data stored as XML into a structured array.

Functions

_localname(tag)

Strip any XML namespace from a tag: {ns}optical -> optical.

parse_ades_xml(filename[, record_tags])

Parse an ADES XML file into a list of per-observation dicts.

Module Contents

logger[source]
_RECORD_TAGS = ('optical', 'radar')[source]
_localname(tag)[source]

Strip any XML namespace from a tag: {ns}optical -> optical.

parse_ades_xml(filename, record_tags=_RECORD_TAGS)[source]

Parse an ADES XML file into a list of per-observation dicts.

Uses streaming iterparse so large files do not load the whole DOM at once. Each returned dict maps ADES field name -> stripped text value for one observation record.

class ADESXMLDataReader(filename, sep=None, **kwargs)[source]

Bases: layup.utilities.file_io.ObjectDataReader.ObjectDataReader

Read MPC ADES observation data stored as XML into a structured array.

filename[source]
_records = None[source]
_id_map_built = False[source]
obj_id_counts[source]
get_reader_info()[source]

Return a string identifying the reader and its input file.

_parse()[source]

Parse (once) and cache the observation records.

get_row_count()[source]

Return the total number of observation records in the file.

_get_fixed_dtypes()[source]

Columns forced to str (identifiers, not numbers).

Mirrors CSVDataReader._get_fixed_dtypes() so the primary-id and station columns are never coerced to numeric (e.g. station "024" must stay a string, not become 24).

_records_to_array(records)[source]

Convert a list of record dicts into a numpy structured array.

_read_rows_internal(block_start=0, block_size=None, **kwargs)[source]

Read a contiguous block of observation rows.

_build_id_map()[source]

Populate obj_id_counts (rows per object id) for create_chunks.

_read_objects_internal(obj_ids, **kwargs)[source]

Read all rows belonging to the given object ids.

_process_and_validate_input_table(input_table, **kwargs)[source]

Run the shared validation and strip whitespace from column names.