src.api.utils.output_utils module

src.api.utils.output_utils.format_date(date)[source]

Format a datetime object into a standardized string format.

Parameters:

date – A datetime object to format, or None

Returns:

MM:SS TZ’ if date is provided, otherwise returns None

Return type:

A formatted date string in the format ‘YYYY-MM-DD HH

Example

>>> format_date(datetime(2024, 1, 1, 12, 0, 0, tzinfo=timezone.utc))
'2024-01-01 12:00:00 UTC'
src.api.utils.output_utils.fov_data_to_json(results: list[dict[str, Any]], points_in_fov: int, performance_metrics: dict[str, Any], api_source: str, api_version: str, group_by: str, precision_angles=8, precision_date=8) dict[str, Any][source]

Convert FOV results to JSON format with optional grouping by satellite.

Parameters:
  • results – List of satellite position results

  • points_in_fov – Total number of position points in field of view

  • performance_metrics – Dictionary of performance measurements

  • api_source – Source of the API

  • api_version – Version of the API

  • group_by – Grouping strategy (‘satellite’ or ‘time’, time by default)

  • precision_angles – Decimal precision for angle values

  • precision_date – Decimal precision for dates

Returns:

Formatted results either grouped by satellite or chronologically

Return type:

dict

src.api.utils.output_utils.position_data_to_json(name, intl_designator, catalog_id, date_collected, tle_epoch_date, data_source, results, api_source, api_version, precision_angles=8, precision_date=8, precision_range=6, precision_velocity=12)[source]

Convert API output to JSON format

Parameters:
  • name (str) – Name of the target satellite

  • intl_designator (str) – International Designator/COSPAR ID of the satellite

  • catalog_id (str) – Catalog ID of the satellite

  • date_collected (datetime) – Date when the data was collected

  • tle_epoch_date (datetime) – Date when the TLE was created

  • data_source (str) – Source of the data

  • results (list) – List of results from the API

  • api_source (str) – Source of the API

  • version (str) – Version of the API

  • precision_angles (int, optional) – Number of digits for angles to be rounded to (default: 8)

  • precision_date (int, optional) – Number of digits for Julian Date to be rounded to (default: 8)

  • precision_range (int, optional) – Number of digits for range to be rounded to (default: 6)

  • precision_velocity (int, optional) – Number of digits for velocity to be rounded to (default: 12)

Returns:

JSON dictionary of the above quantities

Return type:

dict

src.api.utils.output_utils.satellite_data_to_json(satellites: list, api_source: str, api_version: str) dict[source]

Convert satellite data to JSON format

Parameters:
  • satellites – List of satellites

  • api_source – Source of the API

  • api_version – Version of the API

Returns:

JSON dictionary of the satellite data

Return type:

dict