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.
originator = 'GorgiAstro'
samples_folder = 'samples'
generated_folder = 'generated-ccsds-cic'
from odmadmpy.core import Oem, Aem
import pandas as pd
import os
df = pd.read_csv(os.path.join(samples_folder, 'sample_oem.txt'), delimiter=' ', parse_dates=['datetime'])
df[['x', 'y', 'z', 'vx', 'vy', 'vz', 'ax', 'ay', 'az']] = 1e3 * df[['x', 'y', 'z', 'vx', 'vy', 'vz', 'ax', 'ay', 'az']]
display(df)
meta_mandat_oem = Oem.sample_meta_mandat()
display(meta_mandat_oem)
meta_opt_oem = Oem.sample_meta_opt()
display(meta_opt_oem)
oem = Oem(originator)
segments = []
segments += oem.format_segment(df, meta_mandat_oem, meta_opt_oem,
comments_meta=['Comment in metadata section'],
comments_data=['Comment before data section'])
segments += oem.format_segment(df, meta_mandat_oem)
oem.write_file(segments, os.path.join(generated_folder, 'OEM_CCSDS_sample.txt'),
comments=['This is a file comment', 'It can also be multi-line'])
df_oem_cic = pd.read_csv(os.path.join(samples_folder, 'sample_oem_cic.txt'), delimiter=' ')
df_oem_cic['MJD'] = df_oem_cic['mjd_day'] + df_oem_cic['mjd_seconds'] / 86400
df_oem_cic[['x', 'y', 'z', 'vx', 'vy', 'vz']] = 1e3 * df_oem_cic[['x', 'y', 'z', 'vx', 'vy', 'vz']]
display(df_oem_cic)
meta_mandat_oem_cic = {
'OBJECT_NAME': 'MARS',
'OBJECT_ID': 'MARS',
'CENTER_NAME': 'SUN',
'REF_FRAME': 'ICRF',
'TIME_SYSTEM': 'TAI'
}
oem = Oem(originator, standard='CIC')
segments = []
segments += oem.format_segment(df_oem_cic, meta_mandat_oem_cic)
oem.write_file(segments, os.path.join(generated_folder, 'OEM_CIC_sample.txt'))
meta_mandat_aem = Aem.sample_meta_mandat()
display(meta_mandat_aem)
meta_opt_aem = Aem.sample_meta_opt()
display(meta_opt_aem)
df_aem = pd.read_csv(os.path.join(samples_folder, 'sample_aem.txt'), delimiter=' ', parse_dates=['datetime'])
display(df_aem)
aem = Aem(originator)
segments = []
segments += aem.format_segment(df_aem, meta_mandat_aem, meta_opt_aem,
comments_meta=['Comment in metadata section'],
comments_data=['Comment before data section'])
segments += aem.format_segment(df_aem, meta_mandat_aem,
comments_data=['Here, no QUATERNION_TYPE parameter was given, therefore quaternion is given in scalar-first'])
aem.write_file(segments, os.path.join(generated_folder, 'AEM_CCSDS_sample.txt'),
comments=['This is a file comment', 'It can also be multi-line'])
meta_mandat_aem_cic = {
'OBJECT_NAME': 'MARS',
'OBJECT_ID': 'MARS',
'REF_FRAME_A': 'ICRF',
'REF_FRAME_B': 'BODY',
'ATTITUDE_DIR': 'A2B',
'TIME_SYSTEM': 'TAI',
'ATTITUDE_TYPE': 'QUATERNION'
}
meta_opt_aem_cic = {
'QUATERNION_TYPE': 'FIRST'
}
df_aem_cic = pd.read_csv(os.path.join(samples_folder, 'sample_aem_cic.txt'), delimiter=' ')
df_aem_cic['MJD'] = df_aem_cic['mjd_day'] + df_aem_cic['mjd_seconds'] / 86400
display(df_aem_cic)
aem = Aem(originator, standard='CIC')
segments = []
segments += aem.format_segment(df_aem_cic, meta_mandat_aem_cic, meta_opt_aem_cic)
aem.write_file(segments, os.path.join(generated_folder, 'AEM_CIC_sample.txt'))