examples.encoders.plugins package
Submodules
examples.encoders.plugins.astropy_tables module
Encoder and Decoder for Astropy Table Data via Wrapyfi.
This script provides a mechanism to encode and decode Astropy table data using Wrapyfi. It makes use of base64 encoding to transform binary data into ASCII strings.
The script contains a class, AstropyData, registered as a plugin to handle the conversion of Astropy data (if available) between its original and encoded forms.
- Requirements:
Wrapyfi: Middleware communication wrapper (refer to the Wrapyfi documentation for installation instructions)
- Astropy: A library for Astronomy computations and data handling in Python.
Note: If Astropy is not available, HAVE_ASTROPY will be set to False and the plugin will be registered with no types.
- You can install the necessary packages using pip:
pip install astropy
- class examples.encoders.plugins.astropy_tables.AstropyData(**kwargs)[source]
Bases:
Plugin- __init__(**kwargs)[source]
Initialize the AstropyData plugin for encoding and decoding Astropy table data.
This class provides methods to convert Astropy table data to an encoded form and decode it back to its original form. The data is encoded using base64 to transform binary data into ASCII strings.
- encode(obj, *args, **kwargs)[source]
Encode Astropy table data into a base64 ASCII string.
- Parameters:
obj – Table: The Astropy table data to encode
args – tuple: Additional arguments (not used)
kwargs – dict: Additional keyword arguments (not used)
- Returns:
Tuple[bool, dict]: A tuple containing: - bool: Always True, indicating that the encoding was successful - dict: A dictionary containing:
’__wrapyfi__’: A tuple containing the class name and the encoded data string
- decode(obj_type, obj_full, *args, **kwargs)[source]
Decode a base64 ASCII string back into Astropy table data.
- Parameters:
obj_type – type: The expected type of the decoded object (not used)
obj_full – tuple: A tuple containing the encoded data string
args – tuple: Additional arguments (not used)
kwargs – dict: Additional keyword arguments (not used)
- Returns:
Tuple[bool, astropy.Table]: A tuple containing: - bool: Always True, indicating that the decoding was successful - Table: The decoded Astropy table data