### Install PyBufrKit from source Source: https://pybufrkit.readthedocs.io/en/latest/index.html Install PyBufrKit from its source code. ```bash python setup.py install ``` -------------------------------- ### Install PyBufrKit using pip Source: https://pybufrkit.readthedocs.io/en/latest/index.html Install the PyBufrKit package from PyPi using pip. ```bash pip install pybufrkit ``` -------------------------------- ### Query Template Data Examples Source: https://pybufrkit.readthedocs.io/en/latest/index.html Illustrates various valid query expressions for template data, demonstrating different ways to select descriptors, subsets, and specific instances using EBNF syntax. ```text 008042 ``` ```text @[0] > 008042 ``` ```text /008042 ``` ```text /008042[0] ``` ```text 303051/008042 ``` ```text 103000.031001 ``` ```text 021062.A21062 ``` -------------------------------- ### get_or_compile() Source: https://pybufrkit.readthedocs.io/en/latest/genindex.html Gets or compiles a template. This method is part of the pybufrkit.templatecompiler.CompiledTemplateManager class. ```APIDOC ## get_or_compile() ### Description Gets or compiles a template. ### Method (Not specified in source) ### Endpoint (Not specified in source) ### Parameters (Not specified in source) ### Request Example (Not specified in source) ### Response (Not specified in source) ``` -------------------------------- ### Query BUFR Metadata Source: https://pybufrkit.readthedocs.io/en/latest/index.html Queries metadata from a BUFR message using a MetadataQuerent and MetadataExprParser. Example queries the number of subsets. ```python from pybufrkit.mdquery import MetadataExprParser, MetadataQuerent n_subsets = MetadataQuerent(MetadataExprParser()).query(bufr_message, '%n_subsets') ``` -------------------------------- ### get_pos() Source: https://pybufrkit.readthedocs.io/en/latest/genindex.html Gets the current position. This method is available in pybufrkit.bitops.BitStringBitReader and pybufrkit.bitops.BitStringBitWriter. ```APIDOC ## get_pos() ### Description Gets the current position. ### Method (Not specified in source) ### Endpoint (Not specified in source) ### Parameters (Not specified in source) ### Request Example (Not specified in source) ### Response (Not specified in source) ``` -------------------------------- ### get_section_index_and_edition() Source: https://pybufrkit.readthedocs.io/en/latest/genindex.html Gets the section index and edition. This is a static method of the pybufrkit.bufr.SectionConfigurer class. ```APIDOC ## get_section_index_and_edition() ### Description Gets the section index and edition. ### Method (Not specified in source) ### Endpoint (Not specified in source) ### Parameters (Not specified in source) ### Request Example (Not specified in source) ### Response (Not specified in source) ``` -------------------------------- ### BUFR Query Expression Syntax Source: https://pybufrkit.readthedocs.io/en/latest/index.html This EBNF defines the syntax for querying metadata sections in BUFR messages. Use '%' to start a query, optionally followed by a section index and parameter name. ```ebnf = '%'[.] ``` -------------------------------- ### get_value_for_delayed_replication_factor() Source: https://pybufrkit.readthedocs.io/en/latest/genindex.html Gets the value for a delayed replication factor. This method is available in pybufrkit.coder.Coder, pybufrkit.decoder.Decoder, pybufrkit.encoder.Encoder, and pybufrkit.templatecompiler.TemplateCompiler. ```APIDOC ## get_value_for_delayed_replication_factor() ### Description Gets the value for a delayed replication factor. ### Method (Not specified in source) ### Endpoint (Not specified in source) ### Parameters (Not specified in source) ### Request Example (Not specified in source) ### Response (Not specified in source) ``` -------------------------------- ### Implement custom JSON encoding Source: https://pybufrkit.readthedocs.io/en/latest/api.html Subclasses should implement this method to return a serializable object for 'o', or call the base implementation to raise a TypeError. For example, to support arbitrary iterators, you could implement default like this. ```python def default(self, o): try: iterable = iter(o) except TypeError: pass else: return list(iterable) # Let the base class default method raise the TypeError return JSONEncoder.default(self, o) ``` -------------------------------- ### pybufrkit.commands.command_info Source: https://pybufrkit.readthedocs.io/en/latest/api.html Command to show metadata information of given files from command line. ```APIDOC ## pybufrkit.commands.command_info ### Description Command to show metadata information of given files from command line. ### Parameters #### Path Parameters - **ns** (any) - Required - Namespace object containing command-line arguments. ``` -------------------------------- ### SectionConfigurer Class Source: https://pybufrkit.readthedocs.io/en/latest/api.html Responsible for loading section configuration JSON files and initializing/configuring sections. ```APIDOC ## class pybufrkit.bufr.SectionConfigurer ### Description This class is responsible for loading the section config JSON files. It also initialise and configure a requested Section. ### Methods #### configure_section(bufr_message: BufrMessage, section_index: int, configuration_transformers=()) Initialise and Configure a section for the give section index and version. Parameters: - **bufr_message** (BufrMessage) – The Bufr Message object to configure - **section_index** (int) – (Zero-based) index of the section - **configuration_transformers** (collection) – A collection of configuration transformation functions. These functions make it possible to use the same set of JSON files while still dynamically providing different coder behaviours. Returns: The configured section or `None` if not present #### configure_section_with_values(bufr_message: BufrMessage, section_index: int, values: list, overrides=None) Initialise and Configure a section for the give section index and version and also populate the value of each section parameter with the given list of values. Used by the encoder. Parameters: - **bufr_message** (BufrMessage) – The BUFR message object to configure - **section_index** (int) – The zero-based section index - **values** (list) – A list of values for the parameters. - **overrides** (dict) – Optional overrides for configuration. Returns: The configured section or `None` if the section is not present #### static get_section_index_and_edition(fname: str) Get Section Index and version from file name of a configuration file. Parameters: - **fname** (str) – The base file name Returns: The index and edition numbers. #### static ignore_value_expectation(config: dict) Remove any expectation value check. Parameters: - **config** (dict) – The config JSON object loaded from a configuration file. #### static info_configuration(config: dict) This is a configuration transformation function to make the decoder work only for the part of message before the template data. Parameters: - **config** (dict) – The config JSON object loaded from a configuration file. ``` -------------------------------- ### info_configuration() Source: https://pybufrkit.readthedocs.io/en/latest/genindex.html Provides information about the configuration. This is a static method of the pybufrkit.bufr.SectionConfigurer class. ```APIDOC ## info_configuration() ### Description Provides information about the configuration. ### Method (Not specified in source) ### Endpoint (Not specified in source) ### Parameters (Not specified in source) ### Request Example (Not specified in source) ### Response (Not specified in source) ``` -------------------------------- ### pybufr.bitops.get_bit_writer Source: https://pybufrkit.readthedocs.io/en/latest/api.html Initializes and returns a BitWriter. ```APIDOC ## get_bit_writer ### Description Initialise and return a BitWriter. ### Returns - **BitWriter** - A BitWriter instance. ``` -------------------------------- ### Compile BUFR Template from descriptors Source: https://pybufrkit.readthedocs.io/en/latest/index.html Compile a BUFR Template from a comma-separated list of descriptors. ```bash pybufrkit compile 309052,205060 ``` -------------------------------- ### Query BUFR Data Source: https://pybufrkit.readthedocs.io/en/latest/index.html Queries specific data from a BUFR message using a DataQuerent and NodePathParser. Example queries data with node ID '001002'. ```python from pybufrkit.dataquery import NodePathParser, DataQuerent query_result = DataQuerent(NodePathParser()).query(bufr_message, '001002') ``` -------------------------------- ### process Source: https://pybufrkit.readthedocs.io/en/latest/api.html The main entry point for the encoding process, converting a JSON formatted message into a BUFR message. ```APIDOC ## process(s, file_path=' ', wire_template_data=True) ### Description Entry point for the encoding process. The process encodes a JSON format message to BUFR message. ### Parameters * **s** - A JSON or its string serialized form. * **file_path** - The file path to the JSON file. * **wire_template_data** (bool) - Whether to wire the template data to construct a fully hierarchical structure from the flat lists. ### Returns A bitstring object of the encoded message. ``` -------------------------------- ### descend_and_proceed() Source: https://pybufrkit.readthedocs.io/en/latest/genindex.html Descends into the data structure and proceeds. This method is part of the pybufrkit.dataquery.DataQuerent class. ```APIDOC ## descend_and_proceed() ### Description Descends into the data structure and proceeds. ### Method (Not specified in source) ### Endpoint (Not specified in source) ### Parameters (Not specified in source) ### Request Example (Not specified in source) ### Response (Not specified in source) ``` -------------------------------- ### define_bitmap() Source: https://pybufrkit.readthedocs.io/en/latest/genindex.html Defines a bitmap. This method is available in pybufrkit.coder.Coder, pybufrkit.decoder.Decoder, pybufrkit.encoder.Encoder, and pybufrkit.templatecompiler.TemplateCompiler. ```APIDOC ## define_bitmap() ### Description Defines a bitmap. ### Method (Not specified in source) ### Endpoint (Not specified in source) ### Parameters (Not specified in source) ### Request Example (Not specified in source) ### Response (Not specified in source) ``` -------------------------------- ### Format integer to fixed width string Source: https://pybufrkit.readthedocs.io/en/latest/api.html Formats an integer to a string of a specified width, padding with spaces or asterisks as needed. Ensure the result string has the exact width. ```python def fixed_width_repr_of_int(value, width, pad_left=True): ``` -------------------------------- ### build_template() Source: https://pybufrkit.readthedocs.io/en/latest/genindex.html Builds a template for a BufrMessage. This method is part of the pybufrkit.bufr.BufrMessage class. ```APIDOC ## build_template() ### Description Builds a template for a BufrMessage. ### Method (Not specified in source) ### Endpoint (Not specified in source) ### Parameters (Not specified in source) ### Request Example (Not specified in source) ### Response (Not specified in source) ``` -------------------------------- ### build_bitmapped_descriptors Source: https://pybufrkit.readthedocs.io/en/latest/api.html Builds bitmapped descriptors based on a given bitmap and also constructs back-referenced descriptors if they are not already defined. ```APIDOC ## build_bitmapped_descriptors ### Description Build the bitmapped descriptors based on the given bitmap. Also build the back referenced descriptors if it is not already defined. ### Parameters: * **bitmap** - ``` -------------------------------- ### pybufrkit.commands.command_compile Source: https://pybufrkit.readthedocs.io/en/latest/api.html Command to compile the given descriptors. ```APIDOC ## pybufrkit.commands.command_compile ### Description Command to compile the given descriptors. ### Parameters #### Path Parameters - **ns** (any) - Required - Namespace object containing command-line arguments. ``` -------------------------------- ### Subset BUFR file Source: https://pybufrkit.readthedocs.io/en/latest/index.html Create a new BUFR file by subsetting specific descriptors from a given BUFR file. ```bash pybufrkit subset 0,3,6,9 BUFR_FILE ``` -------------------------------- ### Decode a BUFR file using the library Source: https://pybufrkit.readthedocs.io/en/latest/index.html Basic library usage for decoding a BUFR file. Requires opening the file in binary read mode and processing its content. ```python from pybufrkit.decoder import Decoder decoder = Decoder() with open(SOME_BUFR_FILE, 'rb') as ins: bufr_message = decoder.process(ins.read()) ``` -------------------------------- ### BUFR Configuration File Structure Source: https://pybufrkit.readthedocs.io/en/latest/index.html Defines the structure for BUFR message configuration files, including section metadata and parameter definitions. ```json { "index": 0, # zero-based section index "description": "Indicator section", "default": true, # use this config if an edition-specific one is not available "optional": false, # whether this section is optional "end_of_message": false, # whether this is the last section "parameters": [ # a list of parameter configs { "name": "start_signature", # parameter name "nbits": 32, # number of bits "type": "bytes", # parameter type determines how the value can be processed from the input bits "expected": "BUFR", # expected value for this parameter (will be validated if not None) "as_property": false # whether this parameter can be accessed from the parent message object }, ... ] } ``` -------------------------------- ### pybufrkit.commands.command_query Source: https://pybufrkit.readthedocs.io/en/latest/api.html Command to query given BUFR files. ```APIDOC ## pybufrkit.commands.command_query ### Description Command to query given BUFR files. ### Parameters #### Path Parameters - **ns** (any) - Required - Namespace object containing command-line arguments. ``` -------------------------------- ### Encoder Class Initialization Source: https://pybufrkit.readthedocs.io/en/latest/api.html Initializes the Encoder class with optional parameters for definition directories, table roots, and caching behavior. ```APIDOC ## Encoder(definitions_dir=None, tables_root_dir=None, ignore_declared_length=True, compiled_template_cache_max=None, master_table_number=None, master_table_version=None) ### Description The encoder takes a JSON object or string and encoded it to a BUFR message. ### Parameters * **ignore_declared_length** (bool) - If set, ignore the section_length declared in the input JSON message and always calculated it. ``` -------------------------------- ### pybufrkit.commands.command_script Source: https://pybufrkit.readthedocs.io/en/latest/api.html Command to execute script against given BUFR files. ```APIDOC ## pybufrkit.commands.command_script ### Description Command to execute script against given BUFR files. ### Parameters #### Path Parameters - **ns** (any) - Required - Namespace object containing command-line arguments. ``` -------------------------------- ### Filter BUFR files using script support Source: https://pybufrkit.readthedocs.io/en/latest/index.html Use script support to filter through multiple BUFR files based on conditions, such as the number of subsets. ```bash pybufrkit script 'if ${%n_subsets} > 1: print(PBK_FILENAME)' DIRECTORY/*.bufr ``` -------------------------------- ### Query metadata from BUFR sections Source: https://pybufrkit.readthedocs.io/en/latest/index.html Query values from the metadata sections (0, 1, 2, 3) of a BUFR file. ```bash pybufrkit query %n_subsets BUFR_FILE ``` -------------------------------- ### command_info() Source: https://pybufrkit.readthedocs.io/en/latest/genindex.html Provides information about a command. This function is located in the pybufrkit.commands module. ```APIDOC ## command_info() ### Description Provides information about a command. ### Method (Not specified in source) ### Endpoint (Not specified in source) ### Parameters (Not specified in source) ### Request Example (Not specified in source) ### Response (Not specified in source) ``` -------------------------------- ### pybufrkit.commands.command_lookup Source: https://pybufrkit.readthedocs.io/en/latest/api.html Command to lookup the given descriptors from command line. ```APIDOC ## pybufrkit.commands.command_lookup ### Description Command to lookup the given descriptors from command line. ### Parameters #### Path Parameters - **ns** (any) - Required - Namespace object containing command-line arguments. ``` -------------------------------- ### command_script() Source: https://pybufrkit.readthedocs.io/en/latest/genindex.html Executes a script command. This function is located in the pybufrkit.commands module. ```APIDOC ## command_script() ### Description Executes a script command. ### Method (Not specified in source) ### Endpoint (Not specified in source) ### Parameters (Not specified in source) ### Request Example (Not specified in source) ### Response (Not specified in source) ``` -------------------------------- ### command_compile() Source: https://pybufrkit.readthedocs.io/en/latest/genindex.html Compiles a command. This function is located in the pybufrkit.commands module. ```APIDOC ## command_compile() ### Description Compiles a command. ### Method (Not specified in source) ### Endpoint (Not specified in source) ### Parameters (Not specified in source) ### Request Example (Not specified in source) ### Response (Not specified in source) ``` -------------------------------- ### NodePathParser Class Source: https://pybufrkit.readthedocs.io/en/latest/api.html Provides a parser for handling path query strings in BUFR data. ```APIDOC ## class pybufrkit.dataquery.NodePathParser ### Description This class provides a parser for parsing path query string. ### Parameters * **bare_id_matches_all** (bool) - By default, a path component with bare ID, i.e. with no slicing part, means match all occurrences, i.e. [::]. If set to False, it only matches the first occurence. ``` -------------------------------- ### switch_subset_context Source: https://pybufrkit.readthedocs.io/en/latest/api.html Switches the subset context, which is primarily useful for uncompressed data. ```APIDOC ## switch_subset_context ### Description This function is only useful for uncompressed data. ### Parameters: * **idx_subset** - ``` -------------------------------- ### pybufr.renderer.Renderer.render Source: https://pybufrkit.readthedocs.io/en/latest/api.html Renders the given object into a string representation. ```APIDOC ## render ### Description Render the given object as string. ### Parameters #### Path Parameters - **obj** (object) - Required - The object to render ### Returns - **str** - A string representation of the given object. ``` -------------------------------- ### pybufr.bitops.get_bit_reader Source: https://pybufrkit.readthedocs.io/en/latest/api.html Initializes and returns a BitReader for the given byte string. ```APIDOC ## get_bit_reader ### Description Initialise and return a BitReader the given string. This function is intended to shield the actual implementation of BitReader away from the caller. ### Parameters #### Path Parameters - **s** - Required - The byte string to read from. ### Returns - **BitReader** - A BitReader instance. ``` -------------------------------- ### pybufrkit.commands.command_split Source: https://pybufrkit.readthedocs.io/en/latest/api.html Command to split given files from command line into one file per BufrMessage. ```APIDOC ## pybufrkit.commands.command_split ### Description Command to split given files from command line into one file per BufrMessage. ### Parameters #### Path Parameters - **ns** (any) - Required - Namespace object containing command-line arguments. ``` -------------------------------- ### command_subset() Source: https://pybufrkit.readthedocs.io/en/latest/genindex.html Creates a subset of a command. This function is located in the pybufrkit.commands module. ```APIDOC ## command_subset() ### Description Creates a subset of a command. ### Method (Not specified in source) ### Endpoint (Not specified in source) ### Parameters (Not specified in source) ### Request Example (Not specified in source) ### Response (Not specified in source) ``` -------------------------------- ### configure_section() Source: https://pybufrkit.readthedocs.io/en/latest/genindex.html Configures a section using a SectionConfigurer. This method is part of the pybufrkit.bufr.SectionConfigurer class. ```APIDOC ## configure_section() ### Description Configures a section using a SectionConfigurer. ### Method (Not specified in source) ### Endpoint (Not specified in source) ### Parameters (Not specified in source) ### Request Example (Not specified in source) ### Response (Not specified in source) ``` -------------------------------- ### Query root level descriptor Source: https://pybufrkit.readthedocs.io/en/latest/index.html Query for a specific descriptor at the root level of the BUFR Template. ```bash pybufrkit query /001002 BUFR_FILE ``` -------------------------------- ### pybufr.bitops.BitStringBitReader Source: https://pybufrkit.readthedocs.io/en/latest/api.html A BitReader implementation using the bitstring module for reading bits from a stream. ```APIDOC ## BitStringBitReader ### Description A BitReader implementation using the bitstring module. ### Parameters #### Path Parameters - **s** (bitstring.BitStream) - Required - Bit stream created from the input string ### Methods - **get_pos()** - Retrieve the bit position for next read - **read_bin(nbits)** - Read number of bits as bytes representation of binary number - **read_bool()** - Read one bit for value of boolean - **read_bytes(nbytes)** - Read number of bytes for value of bytes type - **read_int(nbits)** - Read number of bits as integer - **read_uint(nbits)** - Read number of bites for value of unsigned integer ``` -------------------------------- ### pybufrkit.templatecompiler.CompiledTemplateManager Source: https://pybufrkit.readthedocs.io/en/latest/api.html Manages compiled templates, handling caching and lookup. ```APIDOC ## CompiledTemplateManager(cache_max) ### Description A management class for compiled templates that handles caching and lookup. ### Parameters * **cache_max** (integer) - The maximum number of compiled templates to cache. ### Methods * **get_or_compile(template, table_group)**: Retrieves a compiled template from the cache or compiles it if not found. ### Parameters for Methods: * **get_or_compile**: * **template** (descriptors.BufrTemplate) - The BUFR template to compile * **table_group** (tables.TableGroup) - The Table Group used to instantiate the Template. ### Returns * **get_or_compile**: CompiledTemplate ``` -------------------------------- ### Query all descriptors of the first subset Source: https://pybufrkit.readthedocs.io/en/latest/index.html Query for all occurrences of a descriptor within the first subset of a BUFR message. ```bash pybufr query '@[0] > 001002' BUFR_FILE ``` -------------------------------- ### create_values_from_nodes() Source: https://pybufrkit.readthedocs.io/en/latest/genindex.html Creates values from data nodes. This method is part of the pybufrkit.dataquery.DataQuerent class. ```APIDOC ## create_values_from_nodes() ### Description Creates values from data nodes. ### Method (Not specified in source) ### Endpoint (Not specified in source) ### Parameters (Not specified in source) ### Request Example (Not specified in source) ### Response (Not specified in source) ``` -------------------------------- ### command_query() Source: https://pybufrkit.readthedocs.io/en/latest/genindex.html Queries a command. This function is located in the pybufrkit.commands module. ```APIDOC ## command_query() ### Description Queries a command. ### Method (Not specified in source) ### Endpoint (Not specified in source) ### Parameters (Not specified in source) ### Request Example (Not specified in source) ### Response (Not specified in source) ``` -------------------------------- ### build_bitmapped_descriptors() Source: https://pybufrkit.readthedocs.io/en/latest/genindex.html Builds bitmapped descriptors within the CoderState. This method is part of the pybufrkit.coder.CoderState class. ```APIDOC ## build_bitmapped_descriptors() ### Description Builds bitmapped descriptors within the CoderState. ### Method (Not specified in source) ### Endpoint (Not specified in source) ### Parameters (Not specified in source) ### Request Example (Not specified in source) ### Response (Not specified in source) ``` -------------------------------- ### Filter Files Using BUFR Template - Python Source: https://pybufrkit.readthedocs.io/en/latest/index.html Filters files based on a BUFR Template ID. Uses `${%unexpanded_descriptors}` to check for the template and `PBK_FILENAME` to print the current file's name. Requires the function version of `print` due to `__future__` import. ```python if 309052 in ${%unexpanded_descriptors}: print(PBK_FILENAME) ``` -------------------------------- ### Query child descriptor Source: https://pybufrkit.readthedocs.io/en/latest/index.html Query for a descriptor that is a direct child of another descriptor within the BUFR Template. ```bash pybufrkit query /301001/001002 BUFR_FILE ``` -------------------------------- ### minmax Source: https://pybufrkit.readthedocs.io/en/latest/api.html A static method that finds the minimum and maximum values in a list, ignoring any None values. ```APIDOC ## static minmax ### Description Give a list of values, find out the minimum and maximum, ignore any Nones. ### Parameters: * **values** - ``` -------------------------------- ### command_split() Source: https://pybufrkit.readthedocs.io/en/latest/genindex.html Splits a command. This function is located in the pybufrkit.commands module. ```APIDOC ## command_split() ### Description Splits a command. ### Method (Not specified in source) ### Endpoint (Not specified in source) ### Parameters (Not specified in source) ### Request Example (Not specified in source) ### Response (Not specified in source) ``` -------------------------------- ### MetadataQuerent Class Source: https://pybufrkit.readthedocs.io/en/latest/api.html Provides an interface for querying metadata expressions. ```APIDOC ## class pybufrkit.mdquery.MetadataQuerent ### Description This class provides an interface for querying metadata expressions. ### Parameters * **metadata_expr_parser** (MetadataExprParser) – Parser for metadata expression ``` -------------------------------- ### define_bitmap Source: https://pybufrkit.readthedocs.io/en/latest/api.html Defines a bitmap for compressed data, ensuring that bitmap and back-referenced descriptors are identical for effective compression. ```APIDOC ## define_bitmap(state, reuse) ### Description For compressed data, bitmap and back referenced descriptors must be identical Otherwise it makes no sense in compressing different bitmapped descriptors into one slot. ### Parameters * **reuse** (bool) - Is this bitmap for reuse? ``` -------------------------------- ### Query data for a specific descriptor Source: https://pybufrkit.readthedocs.io/en/latest/index.html Query all values for a specific descriptor (e.g., 001002) from the data section of a BUFR file. ```bash pybufrkit query 001002 BUFR_FILE ``` -------------------------------- ### SectionNamespace Class Source: https://pybufrkit.readthedocs.io/en/latest/api.html An ordered dictionary that stores decoded parameters with their names as keys. ```APIDOC ## class pybufrkit.bufr.SectionNamespace ### Description A Section Namespace is an ordered dictionary that store the decoded parameters with their names as the keys. ``` -------------------------------- ### pybufrkit.commands.command_subset Source: https://pybufrkit.readthedocs.io/en/latest/api.html Command to subset and save the given BUFR file. ```APIDOC ## pybufrkit.commands.command_subset ### Description Command to subset and save the given BUFR file. ### Parameters #### Path Parameters - **ns** (any) - Required - Namespace object containing command-line arguments. ``` -------------------------------- ### from_element_descriptor() Source: https://pybufrkit.readthedocs.io/en/latest/genindex.html Creates a MarkerDescriptor from an ElementDescriptor. This is a static method of the pybufrkit.descriptors.MarkerDescriptor class. ```APIDOC ## from_element_descriptor() ### Description Creates a MarkerDescriptor from an ElementDescriptor. ### Method (Not specified in source) ### Endpoint (Not specified in source) ### Parameters (Not specified in source) ### Request Example (Not specified in source) ### Response (Not specified in source) ``` -------------------------------- ### add_bitmap_link Source: https://pybufrkit.readthedocs.io/en/latest/api.html Must be called before a descriptor is processed, likely to establish a link for bitmap-related descriptors. ```APIDOC ## add_bitmap_link ### Description Must be called before the descriptor is processed ``` -------------------------------- ### command_lookup() Source: https://pybufrkit.readthedocs.io/en/latest/genindex.html Looks up a command. This function is located in the pybufrkit.commands module. ```APIDOC ## command_lookup() ### Description Looks up a command. ### Method (Not specified in source) ### Endpoint (Not specified in source) ### Parameters (Not specified in source) ### Request Example (Not specified in source) ### Response (Not specified in source) ``` -------------------------------- ### pybufrkit.commands.command_decode Source: https://pybufrkit.readthedocs.io/en/latest/api.html Command to decode given files from command line. ```APIDOC ## pybufrkit.commands.command_decode ### Description Command to decode given files from command line. ### Parameters #### Path Parameters - **ns** (any) - Required - Namespace object containing command-line arguments. ``` -------------------------------- ### pybufr.bitops.BitStringBitWriter Source: https://pybufrkit.readthedocs.io/en/latest/api.html A BitWriter implementation using the bitstring module for writing bits to a stream. ```APIDOC ## BitStringBitWriter ### Description A BitWriter implementation using the bitstring module. ### Methods - **get_pos()** - Retrieve the bit position for next write - **set_uint(value, nbits, bitpos)** - Set an unsigned integer value of given number of bits at the bit position and replace the old value. - **skip(nbits)** - Skip ahead for the given number of nbits - **to_bytes()** - dump all content to bytes type - **write_bin(value)** - Write a binary number represented by the given value. The length is determined by the value. - **write_bool(value)** - Write one bit for value of boolean type - **write_bytes(value, nbytes=None)** - Write given number of bits value of bytes type. If nbytes is none, use the length of the given bytes value - **write_int(value, nbits)** - Write given number of bits for value of signed integer - **write_uint(value, nbits)** - Write given number of bits value of unsigned integer type ``` -------------------------------- ### generate_quiet() Source: https://pybufrkit.readthedocs.io/en/latest/genindex.html Generates output quietly. This function is in the pybufrkit.utils module. ```APIDOC ## generate_quiet() ### Description Generates output quietly. ### Method (Not specified in source) ### Endpoint (Not specified in source) ### Parameters (Not specified in source) ### Request Example (Not specified in source) ### Response (Not specified in source) ``` -------------------------------- ### Descriptor Source: https://pybufrkit.readthedocs.io/en/latest/api.html The base class for all BUFR descriptors, providing common machinery. It requires a descriptor ID. ```APIDOC ## Descriptor ### Description This class is the base class of all BUFR descriptors. It provides common machinery for Descriptors. ### Parameters - **id** (int) - Required - The descriptor ID. ### Attributes - **F** - The F value of the descriptor. - **X** - The X value of the descriptor. - **Y** - The Y value of the descriptor. ``` -------------------------------- ### Split BUFR file into individual messages Source: https://pybufrkit.readthedocs.io/en/latest/index.html Split a BUFR file into multiple files, with each file containing a single BUFR message. ```bash pybufrkit split BUFR_FILE ``` -------------------------------- ### process_string Source: https://pybufrkit.readthedocs.io/en/latest/api.html Processes a descriptor that contains a string value. It requires the descriptor and the number of bytes to process. ```APIDOC ## process_string ### Description Process a descriptor that has string value ### Parameters: * **descriptor** - The BUFR descriptor * **nbytes** - Number of BYTES to process for the descriptor. * **state** - * **bit_operator** - ``` -------------------------------- ### Decode and re-encode BUFR using pipes Source: https://pybufrkit.readthedocs.io/en/latest/index.html Decode a BUFR file and pipe the output to the encoder to convert it back to BUFR format. ```bash pybufrkit decode BUFR_FILE | pybufrkit encode - ``` -------------------------------- ### Decode a BUFR file to flat text Source: https://pybufrkit.readthedocs.io/en/latest/index.html Decode a BUFR file and output its content in the default flat text format. ```bash pybufrkit decode BUFR_FILE ``` -------------------------------- ### DataQuerent Class Source: https://pybufrkit.readthedocs.io/en/latest/api.html Offers an interface to query the data section of a BUFR message. ```APIDOC ## class pybufrkit.dataquery.DataQuerent ### Description This class provides interface to query the BUFR Data section. ### Parameters * **path_parser** - Parser for the path query string. ``` ```APIDOC ## create_values_from_nodes ### Description Process through the nested matching node list and create an values list of identical structure. This method is recursive. ### Parameters * **nodes** – A nested list of matching nodes. * **decoded_values** – ### Returns A nested values list corresponding to the given nodes. ``` ```APIDOC ## descend_and_proceed ### Description Processing through the given list of nodes, for any nodes that are not a direct match of the path component, descent to its sub-nodes for further matching. Once a match is found, it then proceed through the path component till all the component is matched or zero match is encountered. ### Parameters * **nodes** – A list of nodes to descend into its sub-nodes * **path_components** – The path components used for matching. ``` ```APIDOC ## filter_for_attribute_sub_nodes ### Description This method is a specific version of the filter_for_sub_nodes method. It first filters through the attribute nodes of the given node and then goes depth first till all the path components are matched or zero match is found. ``` ```APIDOC ## filter_for_child_sub_nodes ### Description This method is a specific version of the filter_for_sub_nodes method. It first filters through the child nodes of the given node and then goes depth first till all the path components are matched or zero match is found. ``` ```APIDOC ## filter_for_descendant_sub_nodes ### Description This method is a specific version of the filter_for_sub_nodes method. It filter through all descendant nodes in a depth first fashion of the given node. A descendant node could be either a child, attribute or factor node all the way to the leaf node. It then process through path components till every component is matched or zero match is encountered. ``` ```APIDOC ## filter_for_nodes ### Description Filter the given list of nodes using the path component. Note this method is different from the filter_for_sub_nodes method in that it filters the given nodes themselves, NOT their sub-nodes. The return value will be a selection of the given nodes. ### Parameters * **nodes** – A list of nodes to be filtered * **path_component** – The path component used for the filtering. ### Returns A list of nodes that qualified by the path component. ``` ```APIDOC ## filter_for_sub_nodes ### Description For the given node, filter through its sub-nodes, which could be child, attribute, factor or descendant nodes depending on the separator value of the first member of path components. Note that the filtering will be performed in a depth first fashion, i.e. the filtering is continued with the direct sub-nodes down to the leaves of the node tree or the end of path components, whichever encounters first. ### Parameters * **node** – The node for which the sub-nodes will be filtered * **path_components** – A list of path components used to filter the nodes. ### Returns A list of qualified nodes matching through the entire path components. ``` ```APIDOC ## node_matches ### Description Check whether the given node is qualified with the path component. If the path component’s separator is descendant, any sub-nodes containing node is qualified. ### Parameters * **node** – * **path_component** – ### Returns True or False ``` ```APIDOC ## proceed_next_path_component ### Description Proceed further down the path components. ### Parameters * **nodes** – * **path_components** – ### Returns ``` ```APIDOC ## query ### Description Entry method of the class. Query the data section of the given BUFR message with the query string. ### Parameters * **bufr_message** – A BufrMessage object with wired nodes * **path_expr** – A query string for data. ### Returns A QueryResult object ``` -------------------------------- ### Decoder.process_unexpanded_descriptors Source: https://pybufrkit.readthedocs.io/en/latest/api.html Decodes a list of unexpanded descriptors. ```APIDOC ## Decoder.process_unexpanded_descriptors(bit_reader, section) ### Description Decode for the list of unexpanded descriptors. ### Parameters * **bit_reader** - Bit reader object. * **section** (Section) - The BUFR section object. ### Returns * list - The unexpanded descriptors as a list. ``` -------------------------------- ### Decoder.define_bitmap Source: https://pybufrkit.readthedocs.io/en/latest/api.html Defines a bitmap for compressed data, handling identical bitmaps and back-referenced descriptors. ```APIDOC ## Decoder.define_bitmap(state, reuse) ### Description For compressed data, bitmap and back referenced descriptors must be identical Otherwise it makes no sense in compressing different bitmapped descriptors into one slot. ### Parameters * **state** - State object. * **reuse** (bool) - Is this bitmap for reuse? ### Returns * list[int] - The bitmap as a list of 0 and 1. ``` -------------------------------- ### Decoder.process_section Source: https://pybufrkit.readthedocs.io/en/latest/api.html Decodes a given configured BUFR section. ```APIDOC ## Decoder.process_section(bufr_message, bit_reader, section) ### Description Decode the given configured Section. ### Parameters * **bufr_message** (BufrMessage) - The BUFR message object. * **bit_reader** - Bit reader object. * **section** (Section) - The BUFR section object. ### Returns * int - Number of bits decoded for this section. ``` -------------------------------- ### pybufrkit.utils.subsets_flat_text_to_flat_json Source: https://pybufrkit.readthedocs.io/en/latest/api.html Convert all subsets data from flat text output to all subsets data of flat JSON. ```APIDOC ## pybufrkit.utils.subsets_flat_text_to_flat_json ### Description Convert all subsets data from flat text output to all subsets data of flat JSON. ### Parameters #### Path Parameters - **lines** (list) - Required - The lines of text output. - **idxline** (int) - Required - The current line index. ``` -------------------------------- ### UndefinedSequenceDescriptor Source: https://pybufrkit.readthedocs.io/en/latest/api.html Represents an undefined sequence descriptor. ```APIDOC ## class pybufrkit.descriptors.UndefinedSequenceDescriptor ### Parameters - **_id__** (any) - Description ``` -------------------------------- ### configure_section_with_values() Source: https://pybufrkit.readthedocs.io/en/latest/genindex.html Configures a section with specific values. This method is part of the pybufrkit.bufr.SectionConfigurer class. ```APIDOC ## configure_section_with_values() ### Description Configures a section with specific values. ### Method (Not specified in source) ### Endpoint (Not specified in source) ### Parameters (Not specified in source) ### Request Example (Not specified in source) ### Response (Not specified in source) ``` -------------------------------- ### pybufrkit.utils.fixed_width_repr_of_int Source: https://pybufrkit.readthedocs.io/en/latest/api.html Format the given integer and ensure the result string is of the given width. The string will be padded space on the left if the number is small or replaced as a string of asterisks if the number is too big. ```APIDOC ## pybufrkit.utils.fixed_width_repr_of_int ### Description Format the given integer and ensure the result string is of the given width. The string will be padded space on the left if the number is small or replaced as a string of asterisks if the number is too big. ### Parameters #### Path Parameters - **value** (int) - Required - An integer number to format - **width** (int) - Required - The result string must have the exact width ### Returns - A string representation of the given integer. ``` -------------------------------- ### Query associated field Source: https://pybufrkit.readthedocs.io/en/latest/index.html Query for an associated field of a given descriptor. ```bash pybufrkit query 021062.A21062 BUFR_FILE ``` -------------------------------- ### process_constant_compressed Source: https://pybufrkit.readthedocs.io/en/latest/api.html Handles the processing of constant values, specifically for cases like '0' for descriptor 222000, in a compressed format. ```APIDOC ## process_constant_compressed(state, bit_writer, descriptor, value) ### Description This method is used for pop out value 0 for 222000, etc. ``` -------------------------------- ### get_metadata() Source: https://pybufrkit.readthedocs.io/en/latest/genindex.html Retrieves metadata from a BufrSection. This method is part of the pybufrkit.bufr.BufrSection class. ```APIDOC ## get_metadata() ### Description Retrieves metadata from a BufrSection. ### Method (Not specified in source) ### Endpoint (Not specified in source) ### Parameters (Not specified in source) ### Request Example (Not specified in source) ### Response (Not specified in source) ``` -------------------------------- ### add_bitmap_link() Source: https://pybufrkit.readthedocs.io/en/latest/genindex.html Adds a bitmap link to the CoderState. This method is part of the pybufrkit.coder.CoderState class. ```APIDOC ## add_bitmap_link() ### Description Adds a bitmap link to the CoderState. ### Method (Not specified in source) ### Endpoint (Not specified in source) ### Parameters (Not specified in source) ### Request Example (Not specified in source) ### Response (Not specified in source) ``` -------------------------------- ### Encode JSON to BUFR file Source: https://pybufrkit.readthedocs.io/en/latest/index.html Encode data from a flat JSON file into a BUFR file. ```bash pybufrkit encode -j JSON_FILE BUFR_FILE ``` -------------------------------- ### Print Latitude and Longitude - Python Source: https://pybufrkit.readthedocs.io/en/latest/index.html Prints latitude and longitude values from BUFR files using embedded data queries. The output format (nesting level) can be controlled. ```python print(${005001}, ${006001}) ``` -------------------------------- ### UndefinedElementDescriptor Source: https://pybufrkit.readthedocs.io/en/latest/api.html Represents an undefined element descriptor. ```APIDOC ## class pybufrkit.descriptors.UndefinedElementDescriptor ### Parameters - **_id__** (any) - Description ``` -------------------------------- ### CoderState Source: https://pybufrkit.readthedocs.io/en/latest/api.html Represents the state of the Coder during encoding or decoding. It keeps track of variables and allows for multiple decoding/encoding tasks using a single Coder instance. ```APIDOC ## class pybufrkit.coder.CoderState ### Description The state of Coder for keeping track of variables when a Coder is working. The use of a new state for each run makes it possible to use a single Coder to run multiple decoding/encoding tasks. ### Parameters: * **is_compressed** - * **n_subsets** - * **decoded_values_all_subsets** - This is only for Encoder use. ``` -------------------------------- ### BufrMessageQuerent Class Source: https://pybufrkit.readthedocs.io/en/latest/api.html A convenient class for querying both metadata and data sections of a BUFR message. ```APIDOC ## class pybufrkit.query.BufrMessageQuerent ### Description This is a convenient class for querents of metadata and data sections. It provides an uniform interface for querying the BufrMessage object. ``` -------------------------------- ### ReplacementNode Class Source: https://pybufrkit.readthedocs.io/en/latest/api.html Represents a replacement node within the hierarchical data structure. ```APIDOC ## class pybufrkit.templatedata.ReplacementNode(_descriptor_, _index_) ``` -------------------------------- ### default() Source: https://pybufrkit.readthedocs.io/en/latest/genindex.html Provides a default representation for an entity. This method is part of the pybufrkit.utils.EntityEncoder class. ```APIDOC ## default() ### Description Provides a default representation for an entity. ### Method (Not specified in source) ### Endpoint (Not specified in source) ### Parameters (Not specified in source) ### Request Example (Not specified in source) ### Response (Not specified in source) ``` -------------------------------- ### UndefinedDescriptor Source: https://pybufrkit.readthedocs.io/en/latest/api.html Represents undefined descriptors, useful when loading incomplete BUFR tables. ```APIDOC ## class pybufrkit.descriptors.UndefinedDescriptor ### Description Undefined Descriptors are only useful when loading BUFR tables that are NOT completely defined. For an example, an element descriptor is used by one of the sequence descriptor but the element descriptor itself is not defined in Table B. In this case, an Undefined descriptor is created in place of the actual element descriptor to allow tables to be loaded normally. As long as the Undefined descriptor is not used in the actual decoding (the Template of a BUFR message may not contain the descriptor at all), it is harmless to stay in the loaded Table Group. Ideally this is not necessary if all tables are well defined. However, in practice, this is needed so some not-well-defined local tables can be used. ### Parameters - **_id__** (any) - Description ``` -------------------------------- ### SkippedLocalDescriptor Source: https://pybufrkit.readthedocs.io/en/latest/api.html A placeholder for descriptors followed by operator descriptor 206YYY. ```APIDOC ## class pybufrkit.descriptors.SkippedLocalDescriptor ### Description The skipped local descriptor is a placeholder for any descriptors followed by operator descriptor 206YYY. ### Parameters - **_id__** (any) - Description - **_nbits_** (any) - Description ``` -------------------------------- ### command_encode() Source: https://pybufrkit.readthedocs.io/en/latest/genindex.html Encodes a command. This function is located in the pybufrkit.commands module. ```APIDOC ## command_encode() ### Description Encodes a command. ### Method (Not specified in source) ### Endpoint (Not specified in source) ### Parameters (Not specified in source) ### Request Example (Not specified in source) ### Response (Not specified in source) ``` -------------------------------- ### Lookup BUFR descriptor information Source: https://pybufrkit.readthedocs.io/en/latest/index.html Look up information about a BUFR Element Descriptor, including its code table. ```bash pybufrkit lookup -l 020003 ``` -------------------------------- ### Decoder Class Source: https://pybufrkit.readthedocs.io/en/latest/api.html The Decoder class is used to decode BUFR messages from a bytes string. It can be initialized with optional directories for definitions and tables, and a cache size for compiled templates. ```APIDOC ## class pybufrkit.decoder.Decoder ### Description The decoder takes a bytes type string and decode it to a BUFR Message object. ### Parameters * **definitions_dir** (str, optional) - Directory for definitions. * **tables_root_dir** (str, optional) - Root directory for tables. * **compiled_template_cache_max** (int, optional) - Maximum size for the compiled template cache. ``` -------------------------------- ### Decoder.process Source: https://pybufrkit.readthedocs.io/en/latest/api.html Decodes a given BUFR message string into a BufrMessage object. ```APIDOC ## Decoder.process(s, file_path=' ', start_signature='BUFR', info_only=False, ignore_value_expectation=False, wire_template_data=True) ### Description Decoding the given message string. ### Parameters * **s** (bytes) - Message string that contains the BUFR Message. * **file_path** (str, optional) - The file where this string is read from. Defaults to ' '. * **start_signature** (str, optional) - Locate the starting position of the message string with the given signature. Defaults to 'BUFR'. * **info_only** (bool, optional) - Only show information up to template data (exclusive). Defaults to False. * **ignore_value_expectation** (bool, optional) - Do not validate the expected value. Defaults to False. * **wire_template_data** (bool, optional) - Whether to wire the template data to construct a fully hierarchical structure from the flat lists. Only takes effect when it is NOT info_only. Defaults to True. ### Returns * BufrMessage - A BufrMessage object that contains the decoded information. ``` -------------------------------- ### pybufrkit.templatecompiler.loads_compiled_template Source: https://pybufrkit.readthedocs.io/en/latest/api.html Loads a compiled template object from its JSON string representation. ```APIDOC ## loads_compiled_template(s) ### Description Load a compiled template object from its JSON string representation. ### Parameters * **s** (string) - A JSON string represents the compiled template. ### Returns * The compiled template ``` -------------------------------- ### Decode BUFR file with hierarchical structure Source: https://pybufrkit.readthedocs.io/en/latest/index.html Decode a BUFR file and represent its data in a hierarchical structure, associating attribute descriptors with their corresponding descriptors. ```bash pybufrkit decode -a BUFR_FILE ``` -------------------------------- ### Decode BUFR file to JSON Source: https://pybufrkit.readthedocs.io/en/latest/index.html Decode a BUFR file and output the data in JSON format. ```bash pybufrkit decode -j BUFR_FILE ``` -------------------------------- ### process_string Source: https://pybufrkit.readthedocs.io/en/latest/api.html Processes a descriptor containing a string value, specifying the number of bytes to process. ```APIDOC ## process_string(state, bit_writer, descriptor, nbytes) ### Description Process a descriptor that has string value ### Parameters * **descriptor** - The BUFR descriptor. * **nbytes** (int) - Number of BYTES to process for the descriptor. ``` -------------------------------- ### ReplicationDescriptor Source: https://pybufrkit.readthedocs.io/en/latest/api.html Represents a Replication Descriptor, which can store a group of descriptors to be replicated. It provides the number of items and members to be replicated. ```APIDOC ## ReplicationDescriptor ### Description The replication factor member stores only the replication factor descriptor NOT the actual value. So it is OK as it should be reusable for the same sequence descriptor. That is to say, when a Sequence Descriptor, e.g. 309052, is reused, the Replication Descriptor inside it should always have the same replication factor descriptor. Although these replication factor descriptor can have different values in different reuses of 309052, it does not matter as it does not store the actual values. When the replication descriptor is reused as naked descriptor, i.e. not part of a Sequence Descriptor but directly under a Template, the associated replication factor descriptor could be different. But since the replication descriptor is NOT cached when used as naked. Every time a new Replication Descriptor is spawn thus there is no risk on the associated replication factor descriptor gets mixed up. ### Parameters - **members** (list[Descriptor]) - Optional - The group of descriptors to be replicated ### Attributes - **n_items** (int) - Number of descriptors to be replicated. This value is decoded from the ID of the descriptor. - **n_members** (int) ``` -------------------------------- ### Convert flat text to flat JSON Source: https://pybufrkit.readthedocs.io/en/latest/api.html Converts flat text output to the flat JSON output format. This is useful for standardizing data representation. ```python def flat_text_to_flat_json(flat_text): ```