eebit.bitmask ============= .. py:module:: eebit.bitmask .. autoapi-nested-parse:: Bitmask module. Classes ------- .. autoapisummary:: eebit.bitmask.Bit eebit.bitmask.BitGroup eebit.bitmask.BitMask Module Contents --------------- .. py:class:: Bit(position, positive, negative = None) Initialize a Bit. :param position: position of the bit. :param positive: positive bit description. :param negative: negative bit description. If None, it uses "no {positive}". .. py:method:: is_negative(value) Check if a value is negative for this bit. :param value: the value to check. :returns: True if the value is negative for this bit, False otherwise. .. py:method:: is_positive(value) Check if a value is positive for this bit. :param value: the value to check. :returns: True if the value is positive for this bit, False otherwise. .. py:method:: negative_values(n_bits = None) Get the negative values of the bit. :param n_bits: number of bits to consider. If None, it uses the bit position + 1. .. py:method:: positive_values(n_bits = None) Get the positive values of the bit. :param n_bits: number of bits to consider. If None, it uses the bit position + 1. .. py:method:: to_bit_group(description) Convert a Bit to a BitGroup. :param description: description of the bit group. :returns: A BitGroup object. .. py:property:: max_value :type: int Get the maximum value of the bit. .. py:property:: min_value :type: int Get the minimum value of the bit. .. py:attribute:: negative :value: 'no Uninferable' .. py:attribute:: positive .. py:property:: value_map :type: dict[Literal['0', '1'], str] Get the value map of the bit. .. py:class:: BitGroup(description, min_position, max_position, value_map) Initialize a bit group. :param min_position: minimum position of the bit group. :param max_position: maximum position of the bit group. :param value_map: a dict with the bit positions as keys and the bit descriptions as values. {bit-key: bit-value} :param description: description of the bit group. Different from each bit descriptions in the value_map. .. py:method:: _get_key_for_bit_value(value) Get the key for a given bit value. :param value: the bit value to get the key for. .. py:method:: _get_value_for_bit_key(key) Get the bit value for a given bit key. .. py:method:: decode_to_columns(table, column) Decode a column in a FeatureCollection into multiple columns. :param table: the FeatureCollection to decode. :param column: the column to decode. :returns: A new FeatureCollection with one column per bit value in the group. .. py:method:: decode_value(value) Decode a value into its description. :param value: the value to decode. :returns: The description of the value, or None if not found. .. py:method:: from_dict(bit_info) :classmethod: Create a BitGroup from a dict. :param bit_info: a dict with the bit positions as keys and the bit descriptions as values. :returns: A BitGroup object. .. py:method:: get_mask_by_bit_value(image, value) Get a mask for a given bit value in the group. :param image: the image to get the mask from. :param value: the bit value to get the mask for. :returns: A binary image with 1 for pixels that have the description, and 0 otherwise. .. py:method:: get_mask_by_position(image, position) Get a mask for a given bit position in the group. :param image: the image to get the mask from. :param position: the position of the bit in the group. :returns: A binary image with 1 for pixels that have the bit set, and 0 otherwise. .. py:method:: get_masks(image) Get masks for all bit values in the group. :param image: the image to get the masks from. :returns: An image with one band per bit value in the group. .. py:method:: is_positive(value, key = None, description = None) Check if a value is positive for this bit group. :param value: the value to check. :param key: the key to check. :param description: the description to check. :returns: True if the value is positive for the passed key or description, False otherwise. .. py:method:: is_positive_by_description(value, description) Check if a value is positive for this description. :param value: the value to check. :param description: the description to check. :returns: True if the value is positive for the passed description, False otherwise. .. py:method:: is_positive_by_description_gee(value, description) Check if a value is positive for this description using GEE. :param value: the value to check. :param description: the description to check. :returns: True if the value is positive for the passed description, False otherwise. .. py:method:: is_positive_by_key(value, key) Check if a value is positive for this key. :param value: the value to check. :param key: the key to check. :returns: True if the value is positive for the passed key, False otherwise. .. py:method:: is_positive_by_key_gee(value, key) Check if a value is positive for this key using GEE. :param value: the value to check. :param key: the key to check. :returns: True if the value is positive for the passed key, False otherwise. .. py:method:: is_positive_gee(value, key = None, description = None) Check if a value is positive for this bit group using GEE. :param value: the value to check. :param key: the key to check. :param description: the description to check. :returns: True if the value is positive for the passed key or description, False otherwise. .. py:method:: to_dict() Convert a bit group to a dict. .. py:attribute:: BAND_NAME_PATTERN :value: '{description} - {value}' .. py:attribute:: _reverse_value_map .. py:property:: bit_values :type: list[str] Get the list of bit values in the value map. .. py:attribute:: description .. py:property:: group_mask :type: int Get the mask for the entire group. .. py:attribute:: max_position .. py:attribute:: min_position .. py:attribute:: n_values .. py:attribute:: value_map .. py:class:: BitMask(bits, total = None) Initialize a bitmask. :param bits: a list of BitGroup. :param total: total number of bits. If None, it uses the maximum position of the last group + 1. .. py:method:: bit_values() Get the list of bit values in the bitmask. .. py:method:: decode_to_columns(table, column) Decode a column in a FeatureCollection into multiple columns. :param table: the FeatureCollection to decode. :param column: the column to decode. :returns: A new FeatureCollection with one column per bit value in the bitmask. .. py:method:: decode_value(value) Decode a value into its descriptions. :param value: the value to decode. :returns: A dict with the descriptions of the value, or None if not found. .. py:method:: from_dict(bits_info) :classmethod: Create a BitMask from a dict. .. py:method:: get_group_by_description(description) Get the BitGroup that match a given description. :param description: the description to search for. :returns: The BitGroup that match the given description. .. py:method:: get_masks(image) Get masks for all bit values in the bitmask. :returns: An image with one band per bit value in the bitmask. .. py:method:: to_dict() Convert a Bitmask into a dict. .. py:attribute:: bits :value: [] .. py:attribute:: total