How to use the siphon.cdmr.ncStream_pb2.Attribute function in siphon

To help you get started, we’ve selected a few siphon examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Unidata / siphon / siphon / cdmr / ncstream.py View on Github external
data = var.data
        else:
            # Always sent big endian
            data = np.frombuffer(var.data, dtype=dt.newbyteorder('>'))
    else:
        data = None

    return data, dt, type_name


_attr_converters = {stream.Attribute.BYTE: np.dtype('>b'),
                    stream.Attribute.SHORT: np.dtype('>i2'),
                    stream.Attribute.INT: np.dtype('>i4'),
                    stream.Attribute.LONG: np.dtype('>i8'),
                    stream.Attribute.FLOAT: np.dtype('>f4'),
                    stream.Attribute.DOUBLE: np.dtype('>f8')}


def unpack_attribute(att):
    """Unpack an embedded attribute into a python or numpy object."""
    if att.unsigned:
        log.warning('Unsupported unsigned attribute!')

    # TDS 5.0 now has a dataType attribute that takes precedence
    if att.len == 0:  # Empty
        val = None
    elif att.dataType == stream.STRING:  # Then look for new datatype string
        val = att.sdata
    elif att.dataType:  # Then a non-zero new data type
        val = np.frombuffer(att.data,
                            dtype='>' + _dtype_lookup[att.dataType], count=att.len)
    elif att.type:  # Then non-zero old-data type0
github Unidata / siphon / siphon / cdmr / ncstream.py View on Github external
type_name = dt.name

    if var.data:
        log.debug('Storing variable data: %s %s', dt, var.data)
        if var.dataType == stream.STRING:
            data = var.data
        else:
            # Always sent big endian
            data = np.frombuffer(var.data, dtype=dt.newbyteorder('>'))
    else:
        data = None

    return data, dt, type_name


_attr_converters = {stream.Attribute.BYTE: np.dtype('>b'),
                    stream.Attribute.SHORT: np.dtype('>i2'),
                    stream.Attribute.INT: np.dtype('>i4'),
                    stream.Attribute.LONG: np.dtype('>i8'),
                    stream.Attribute.FLOAT: np.dtype('>f4'),
                    stream.Attribute.DOUBLE: np.dtype('>f8')}


def unpack_attribute(att):
    """Unpack an embedded attribute into a python or numpy object."""
    if att.unsigned:
        log.warning('Unsupported unsigned attribute!')

    # TDS 5.0 now has a dataType attribute that takes precedence
    if att.len == 0:  # Empty
        val = None
    elif att.dataType == stream.STRING:  # Then look for new datatype string
github Unidata / siphon / siphon / cdmr / ncstream.py View on Github external
if var.data:
        log.debug('Storing variable data: %s %s', dt, var.data)
        if var.dataType == stream.STRING:
            data = var.data
        else:
            # Always sent big endian
            data = np.frombuffer(var.data, dtype=dt.newbyteorder('>'))
    else:
        data = None

    return data, dt, type_name


_attr_converters = {stream.Attribute.BYTE: np.dtype('>b'),
                    stream.Attribute.SHORT: np.dtype('>i2'),
                    stream.Attribute.INT: np.dtype('>i4'),
                    stream.Attribute.LONG: np.dtype('>i8'),
                    stream.Attribute.FLOAT: np.dtype('>f4'),
                    stream.Attribute.DOUBLE: np.dtype('>f8')}


def unpack_attribute(att):
    """Unpack an embedded attribute into a python or numpy object."""
    if att.unsigned:
        log.warning('Unsupported unsigned attribute!')

    # TDS 5.0 now has a dataType attribute that takes precedence
    if att.len == 0:  # Empty
        val = None
    elif att.dataType == stream.STRING:  # Then look for new datatype string
        val = att.sdata
    elif att.dataType:  # Then a non-zero new data type
github Unidata / siphon / siphon / cdmr / ncstream.py View on Github external
log.debug('Storing variable data: %s %s', dt, var.data)
        if var.dataType == stream.STRING:
            data = var.data
        else:
            # Always sent big endian
            data = np.frombuffer(var.data, dtype=dt.newbyteorder('>'))
    else:
        data = None

    return data, dt, type_name


_attr_converters = {stream.Attribute.BYTE: np.dtype('>b'),
                    stream.Attribute.SHORT: np.dtype('>i2'),
                    stream.Attribute.INT: np.dtype('>i4'),
                    stream.Attribute.LONG: np.dtype('>i8'),
                    stream.Attribute.FLOAT: np.dtype('>f4'),
                    stream.Attribute.DOUBLE: np.dtype('>f8')}


def unpack_attribute(att):
    """Unpack an embedded attribute into a python or numpy object."""
    if att.unsigned:
        log.warning('Unsupported unsigned attribute!')

    # TDS 5.0 now has a dataType attribute that takes precedence
    if att.len == 0:  # Empty
        val = None
    elif att.dataType == stream.STRING:  # Then look for new datatype string
        val = att.sdata
    elif att.dataType:  # Then a non-zero new data type
        val = np.frombuffer(att.data,
github Unidata / siphon / siphon / cdmr / ncstream.py View on Github external
if var.dataType == stream.STRING:
            data = var.data
        else:
            # Always sent big endian
            data = np.frombuffer(var.data, dtype=dt.newbyteorder('>'))
    else:
        data = None

    return data, dt, type_name


_attr_converters = {stream.Attribute.BYTE: np.dtype('>b'),
                    stream.Attribute.SHORT: np.dtype('>i2'),
                    stream.Attribute.INT: np.dtype('>i4'),
                    stream.Attribute.LONG: np.dtype('>i8'),
                    stream.Attribute.FLOAT: np.dtype('>f4'),
                    stream.Attribute.DOUBLE: np.dtype('>f8')}


def unpack_attribute(att):
    """Unpack an embedded attribute into a python or numpy object."""
    if att.unsigned:
        log.warning('Unsupported unsigned attribute!')

    # TDS 5.0 now has a dataType attribute that takes precedence
    if att.len == 0:  # Empty
        val = None
    elif att.dataType == stream.STRING:  # Then look for new datatype string
        val = att.sdata
    elif att.dataType:  # Then a non-zero new data type
        val = np.frombuffer(att.data,
                            dtype='>' + _dtype_lookup[att.dataType], count=att.len)
github Unidata / siphon / siphon / cdmr / ncstream.py View on Github external
if var.data:
        log.debug('Storing variable data: %s %s', dt, var.data)
        if var.dataType == stream.STRING:
            data = var.data
        else:
            # Always sent big endian
            data = np.frombuffer(var.data, dtype=dt.newbyteorder('>'))
    else:
        data = None

    return data, dt, type_name


_attr_converters = {stream.Attribute.BYTE: np.dtype('>b'),
                    stream.Attribute.SHORT: np.dtype('>i2'),
                    stream.Attribute.INT: np.dtype('>i4'),
                    stream.Attribute.LONG: np.dtype('>i8'),
                    stream.Attribute.FLOAT: np.dtype('>f4'),
                    stream.Attribute.DOUBLE: np.dtype('>f8')}


def unpack_attribute(att):
    """Unpack an embedded attribute into a python or numpy object."""
    if att.unsigned:
        log.warning('Unsupported unsigned attribute!')

    # TDS 5.0 now has a dataType attribute that takes precedence
    if att.len == 0:  # Empty
        val = None
    elif att.dataType == stream.STRING:  # Then look for new datatype string
        val = att.sdata