PDS_VERSION_ID = PDS3 DATA_SET_ID = "S1-L/X-AMIE-2-EDR-EEP-V1.1" PRODUCT_ID = UNPACKING PRODUCT_CREATION_TIME = 2021-02-26T14:08:11 RECORD_TYPE = STREAM OBJECT = TEXT NOTE = "Description of the software used to unpack the telemetry data and to create PDS compatible files" PUBLICATION_DATE = 2008-06-30 END_OBJECT = TEXT END Description of the unpacking software Virgile Dougnac 2008-06-30 #****************************************************************************# #- Table of contents ##TOC #****************************************************************************# #- 1 Acronyms #- 2 Software purpose #- 3 Command files #- 4 DDS file #- 5 PDS file #- 6 Processing steps #- 6.1 DDS Unpacking #- 6.2 Matching commands/times #- 6.3 Processing #- 6.3.1 Image Decompression #- 6.3.2 Image Splitting #- 6.3.3 PDS Computation and formating #****************************************************************************# #- 1 ## Acronyms #****************************************************************************# # AMIE Advanced Moon Imaging Experiment # APO Apogee # DDS Data Dissemination System # DOR Direct Operation Request # EAICD Experiment to Archive Interface Control Document # ET Ephemeris Time # ICU Image Compression Unit # JPL Jet Propulsion Laboratory # PDS Planetary Data System # POR Payload Operation Request # UTC Coordinated universal time #****************************************************************************# #- 2 ## Software purpose #****************************************************************************# The program is designed to extract, form telemetric file in DDS format, telemetric data and images taken by the AMIE camera and presents the images in PDS format whose the header contains all information needed for archiving and scientific purposes. The process involves several steps: images are decompressed, split following filters area and presented within a PDS format. #****************************************************************************# #- 3 ## Command files #****************************************************************************# To control the AMIE camera, a command file was sent to the spacecraft every week. This file contains all commands the camera had to execute during the week, their corresponding time and if needed their parameters. There are 6 families of commands executing different functions as follow: - Switch on/off camera/ICU; - Take picture either in camera bank or unit bank with or without cleaning, taking or not the temperature; - Set the compression type, ratio; - Compress picture; - Download picture either from the camera bank to unit bank or from unit bank to spacecraft; - Diagnostic, Reset or Take temperature. When the command is for taking a picture the following parameters are also written: - Exposure time with the unit in millisecond written either in decimal or hexadecimal (the indicator is D or H); - Compression type/ratio. During the mission, there were 3 different command files. 1. At the very beginning of the mission, the command file was a DOR file. 2. Then during all the Earth Escape Phase, a POR file was used whose the command times were specified in UTC time. 3. Once the spacecraft was orbiting around the Moon the POR file used a relative time. This time is an offset of the UTC APO time (in SMART1, the APO corresponds to the North Pole) which was reset to 0 each time the spacecraft crossed this point so that the orbit number is also mentioned as reference. The UTC Apogee time for each orbit is referenced in the ORMS_MERGED_00233.ORB file. It is important to note that in the ORMS_MERGED_00233.ORB file the time covered by the orbit n lies from UTC APO No. n to UTC APO No. n+1. To know the exact time a command was requested to be executed, both files are needed. The link between them is the orbit number. For convenience, a reformatted version of command files has been created. Each line represents a command with the following data: YYYY-MM-DDThh:mm:ss/command/orbit/number within the sequence/exposure The orbit is only present during the orbit phase. The number winthin the sequence and exposure time are only present for command used to take a picture. #****************************************************************************# #- 4 ## DDS file #****************************************************************************# For each command the camera has executed, it returns an acknowledgement to the spacecraft with the length of the executed command. The spacecraft tags the command acknowledgement with the spacecraft timestamp and stores it in its mass memory. When the camera takes an image, this image is also sent to the spacecraft mass memory without tagging. The camera also returns the temperature if a command for it is executed. All those data are sent by packet. When the spacecraft has the possibility, it sends the data stored into its mass memory to Earth which are saved in a file in DDS format. At the end, the DDS contains: - command acknowledgments with the spacecraft time when the command was executed and the command length, - temperatures, - images. #****************************************************************************# #- 5 ## PDS file #****************************************************************************# The PDS file is the file containing the image. There is a PDS file for each filter. Each PDS file is presented with a header describing all information about the image. The header is supposed to be 256 lines with 78 characters long usable. After the header comes the browse image with a size of 128x128 pixels which display the full image with filter boundaries. Finally, follows the image of the corresponding filter. The information about the image PDS header contains either computed by CSpice routines in case it is positionnal or geomtrical paramter, otherwise are retrieved from the command files or DDS file. In the DDS file, is written the executed time whereas the command files contain all other information such as time, temperature, exposure time, orbit number, image number within the day or orbit, compression type and ratio. The way to match information from those 2 files is not obvious. Both files contain a time which is not exactly the same. Indeed, in the POR file, the time is the requested time whereas in the DDS file it is the effective time the command was executed. The command name can be helpful to constrain the matching since the commands are sequentially executed; finding one matching gives the whole matching. The command acknowledgement gives only information about the length of the command and several commands have the same length. Using a tolerance of few second on the difference between requested and executed time and correspondence between the command name found in the POR file and it length, it is possible to correctly match the 2 files and retrieve information needed for the PDS header. #****************************************************************************# #- 6 ## Processing steps #****************************************************************************# The program is written in C/C++ and uses the CSpice library provided by JPL for its routines to make PDS computation. #============================================================================# #- 6.1 ### DDS Unpacking #============================================================================# The DDS file is read and unpacked to retrieve original data from the different packets. A more human readable file is generated which will be used later on for the matching process. Each image contained in the DDS file is stored in a separate file. #============================================================================# #- 6.2 ### Matching commands/times #============================================================================# The matching is an interactive process. The DDS file (actually the new file originally from the unpacking process) is sequentially read. For each command acknowledgement, the ET is computed from the spacecraft time (using CSpice routines and kernels) and the length of the command is read. Then the POR file is read and for each requested command in the POR file, the ET is computed and the command length is derived form the command name. If the time difference is smaller than a tolerance of few seconds and the command length in both file are identical, then the command matches the command acknowledgement which allows to retrieve information such as executed time, exposure time, compression type and ratio in case it is a command to take a picture. It can be summarized by the following pseudo-algorithm: the process starts at the beginning of each file. # for the following command acknowledgement in DDS do # extract the spacecraft time and compute ET -> ETack # extract command length -> Lack # for each command from the last POR command read do # extract UTC time and compute ET -> ETcom # extract command name and derive its length -> Lcom # if abs(ETack - ETcom) < ETtol and Lack = Lcom # the matching is found! # store the result in a log file # stop the loop for the POR # end if # end do # end do #============================================================================# #- 6.3 ### Processing #============================================================================# The previous log file is sequentialy read and interpreted. Each time a command to take an image appears, information about the image contained in POR dans DDS file are collected. #----------------------------------------------------------------------------# #- 6.3.1 #### Image Decompression #----------------------------------------------------------------------------# The image is then decompressed. The decompression algorithm was provided by Y. Langevin and introduced in the source code as it was. #----------------------------------------------------------------------------# #- 6.3.2 #### Image Splitting #----------------------------------------------------------------------------# Once the image is decompressed it is cut with respect to the filters boundaries. # Filter name | start position x,y pixel | size WxH pixel # VIS_Y | 0,768 | 512x256 # FeL_Y | 0,512 | 512x256 # NONE | 512,512 | 512x512 # FeH_Y | 0,256 | 512x256 # LASER | 0,0 | 256x256 # FeL_X | 512,0 | 256x512 # VIS_X | 768,0 | 256x512 # FeH_X | 256,0 | 256x512 # 0 # 0.---------------------------------------. # | | | | | # | | | | | # | o LAS| | | | # | | | | | # | | FeH_X | FeL_X | VIS_X | # |---------. o | o | o | # | | | | # | | | | # | o FeH_Y | | | # | | | | # | | | | # |-------------------o--CCD--------------| # | | | # | | | # | o FeL_Y | | # | | | # | | | # |-------------------| o NONE | # | | | # | | | # | o VIS_Y | | # | | | # | | | # .---------------------------------------. 1024 # 1024 #----------------------------------------------------------------------------# #- 6.3.3 #### PDS Computation and formating #----------------------------------------------------------------------------# For each image filter, a PDS label is computed. This computation is carried out using functions from the CSpice library and Spice kernels provided by ESA which use the comnand acknowledge time. In the case the comnand acknowledgement time is not found, the time found in the command file is used. The temperature corresponding to an image is suppose to be the last one read in the DDS file since the last 5 minutes, otherwise the temperature is considered as unknown. Spice Meta-Kernel used for the processing: KPL/MK This is the meta-kernel used in the solution of the ``Time Conversion'' task in the SMART-1 SPICE hands-on tutorial. # \begindata # # PATH_VALUES = ( '/AMIE/kernels' ) # # PATH_SYMBOLS = ( 'KERN' ) # # KERNELS_TO_LOAD = ( # '$KERN/lsk/NAIF0008.tls', # # '$KERN/sclk/SMART1_070227_STEP.TSC', # # '$KERN/spk/DE405S.BSP', # '$KERN/spk/SMART1_STRUCT_V01.BSP', # '$KERN/spk/ORES_______________00125.BSP', # '$KERN/spk/ORMS_041111020517_00206.BSP', # '$KERN/spk/ORMS_______________00233.BSP', # # '$KERN/fk/SMART1_V1.TF', # '$KERN/fk/EARTHFIXEDITRF93.TF', # # '$KERN/pck/EARTH_000101_070729_070507.BPC', # '$KERN/pck/PCK00008.TPC', # # '$KERN/ck/ATNS_P030929010023_00188.BC', # '$KERN/ck/ATNS_P050930150947_00220.BC', # '$KERN/ck/ATNS_P060301004212_00233.BC', # # '$KERN/ik/SMART1_AMIE_V01.TI' # ) # \begintext When the command to take a picture carries out a cleaning before effectively taking the picture, the cleaning time (1.136s) is added to the command acknowledge time. This is referred in the PDS header by the label START_TIME for the real UTC time the picture was taken (corrected from the cleaning time) whereas UNCORRECTED_START_TIME is simply the UTC command acknowledge time. The PDS header is written to the file according to the PDS standard presented in the EAICD.