{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Description" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This notebook gather basic tests of the OEM and AEM writers. These tests are not automatized yet, their purposes is to generate CCSDS and CIC files, and the user has to visually check that the files look valid." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "originator = 'GorgiAstro'\n", "samples_folder = 'samples'\n", "generated_folder = 'generated-ccsds-cic'\n", "from odmadmpy.core import Oem, Aem" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# OEM" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## CCSDS" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "import os\n", "df = pd.read_csv(os.path.join(samples_folder, 'sample_oem.txt'), delimiter=' ', parse_dates=['datetime'])\n", "df[['x', 'y', 'z', 'vx', 'vy', 'vz', 'ax', 'ay', 'az']] = 1e3 * df[['x', 'y', 'z', 'vx', 'vy', 'vz', 'ax', 'ay', 'az']]\n", "display(df)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "meta_mandat_oem = Oem.sample_meta_mandat()\n", "display(meta_mandat_oem)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "meta_opt_oem = Oem.sample_meta_opt()\n", "display(meta_opt_oem)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "oem = Oem(originator)\n", "segments = []\n", "segments += oem.format_segment(df, meta_mandat_oem, meta_opt_oem, \n", " comments_meta=['Comment in metadata section'], \n", " comments_data=['Comment before data section'])\n", "segments += oem.format_segment(df, meta_mandat_oem)\n", "oem.write_file(segments, os.path.join(generated_folder, 'OEM_CCSDS_sample.txt'), \n", " comments=['This is a file comment', 'It can also be multi-line'])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## CIC" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "df_oem_cic = pd.read_csv(os.path.join(samples_folder, 'sample_oem_cic.txt'), delimiter=' ')\n", "df_oem_cic['MJD'] = df_oem_cic['mjd_day'] + df_oem_cic['mjd_seconds'] / 86400\n", "df_oem_cic[['x', 'y', 'z', 'vx', 'vy', 'vz']] = 1e3 * df_oem_cic[['x', 'y', 'z', 'vx', 'vy', 'vz']]\n", "display(df_oem_cic)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "meta_mandat_oem_cic = {\n", " 'OBJECT_NAME': 'MARS',\n", " 'OBJECT_ID': 'MARS',\n", " 'CENTER_NAME': 'SUN',\n", " 'REF_FRAME': 'ICRF',\n", " 'TIME_SYSTEM': 'TAI'\n", "}" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "oem = Oem(originator, standard='CIC')\n", "segments = []\n", "segments += oem.format_segment(df_oem_cic, meta_mandat_oem_cic)\n", "oem.write_file(segments, os.path.join(generated_folder, 'OEM_CIC_sample.txt'))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# AEM" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## CCSDS" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "meta_mandat_aem = Aem.sample_meta_mandat()\n", "display(meta_mandat_aem)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "meta_opt_aem = Aem.sample_meta_opt()\n", "display(meta_opt_aem)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "df_aem = pd.read_csv(os.path.join(samples_folder, 'sample_aem.txt'), delimiter=' ', parse_dates=['datetime'])\n", "display(df_aem)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "aem = Aem(originator)\n", "segments = []\n", "segments += aem.format_segment(df_aem, meta_mandat_aem, meta_opt_aem, \n", " comments_meta=['Comment in metadata section'], \n", " comments_data=['Comment before data section'])\n", "segments += aem.format_segment(df_aem, meta_mandat_aem, \n", " comments_data=['Here, no QUATERNION_TYPE parameter was given, therefore quaternion is given in scalar-first'])\n", "aem.write_file(segments, os.path.join(generated_folder, 'AEM_CCSDS_sample.txt'), \n", " comments=['This is a file comment', 'It can also be multi-line'])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## CIC" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "meta_mandat_aem_cic = {\n", " 'OBJECT_NAME': 'MARS',\n", " 'OBJECT_ID': 'MARS',\n", " 'REF_FRAME_A': 'ICRF',\n", " 'REF_FRAME_B': 'BODY',\n", " 'ATTITUDE_DIR': 'A2B',\n", " 'TIME_SYSTEM': 'TAI',\n", " 'ATTITUDE_TYPE': 'QUATERNION'\n", "}\n", "meta_opt_aem_cic = {\n", " 'QUATERNION_TYPE': 'FIRST'\n", "}" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "df_aem_cic = pd.read_csv(os.path.join(samples_folder, 'sample_aem_cic.txt'), delimiter=' ')\n", "df_aem_cic['MJD'] = df_aem_cic['mjd_day'] + df_aem_cic['mjd_seconds'] / 86400\n", "display(df_aem_cic)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "aem = Aem(originator, standard='CIC')\n", "segments = []\n", "segments += aem.format_segment(df_aem_cic, meta_mandat_aem_cic, meta_opt_aem_cic)\n", "aem.write_file(segments, os.path.join(generated_folder, 'AEM_CIC_sample.txt'))" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.6" } }, "nbformat": 4, "nbformat_minor": 4 }