src/pys5p/s5p_xarray.py
def __get_attrs(dset, field: str) -> dict:
    """
    Return attributes of the HDF5 dataset

    Parameters
    ----------
    dset :  h5py.Dataset
       h5py dataset from which the attributes are read
    field : str
       Name of field in compound dataset

    Returns
    -------
    dict with numpy arrays
    """
    _field = None
    if field is not None:
        try:
            _field = {'name': field,
                      'oneof': len(dset.dtype.names),
                      'index': dset.dtype.names.index(field)}
        except Exception as exc:
            raise RuntimeError(
                f'field {field} not found in dataset {dset.name}') from exc
        # print('_field ', _field)

    attrs = {}
    for key in dset.attrs:
        if key in ('CLASS', 'DIMENSION_LIST', 'NAME', 'REFERENCE_LIST',
                   '_Netcdf4Dimid'):
            continue

        attr_value = dset.attrs[key]
        # print('# ----- ', key, type(attr_value), attr_value)
        if isinstance(attr_value, np.ndarray):
            if len(attr_value) == 1:
                attr_value = attr_value[0]
                # print('# ----- ', key, type(attr_value), attr_value)
            elif _field is not None:
                if len(attr_value) == _field['oneof']:
                    attr_value = attr_value[_field['index']]
                # elif isinstance(attr_value, np.void):
                #    attr_value = attr_value[0]

        attrs[key] = (attr_value.decode('ascii')
                      if isinstance(attr_value, bytes) else attr_value)

    return attrs

    Return attributes of the HDF5 dataset

    Parameters
    ----------
    dset :  h5py.Dataset
       h5py dataset from which the attributes are read
    field : str
       Name of field in compound dataset

    Returns
    -------
    dict with numpy arrays
    
Return attributes of the HDF5 dataset
Parameters

dset :  h5py.Dataset
h5py dataset from which the attributes are read
field : str
Name of field in compound dataset

Returns

dict with numpy arrays
Return attributes of the HDF5 dataset Parameters dset : h5py . Dataset h5py dataset from which the attributes are read field : str Name of field in compound dataset Returns dict with numpy arrays
def __get_attrs(dset, field: str) -> dict:
    _field = None
    if field is not None:
        try:
            _field = {'name': field,
                      'oneof': len(dset.dtype.names),
                      'index': dset.dtype.names.index(field)}
        except Exception as exc:
            raise RuntimeError(
                f'field {field} not found in dataset {dset.name}') from exc
    attrs = {}
    for key in dset.attrs:
        if key in ('CLASS', 'DIMENSION_LIST', 'NAME', 'REFERENCE_LIST',
                   '_Netcdf4Dimid'):
            continue
        attr_value = dset.attrs[key]
        if isinstance(attr_value, np.ndarray):
            if len(attr_value) == 1:
                attr_value = attr_value[0]
            elif _field is not None:
                if len(attr_value) == _field['oneof']:
                    attr_value = attr_value[_field['index']]
        attrs[key] = (attr_value.decode('ascii')
                      if isinstance(attr_value, bytes) else attr_value)
    return attrs
def __get_attrs ( dset , field : str ) -> dict : _field = None if field is not None : try : _field = { 'name' : field , 'oneof' : len ( dset . dtype . names ) , 'index' : dset . dtype . names . index ( field ) } except Exception as exc : raise RuntimeError ( f'field {field} not found in dataset {dset.name}' ) from exc attrs = { } for key in dset . attrs : if key in ( 'CLASS' , 'DIMENSION_LIST' , 'NAME' , 'REFERENCE_LIST' , '_Netcdf4Dimid' ) : continue attr_value = dset . attrs [ key ] if isinstance ( attr_value , np . ndarray ) : if len ( attr_value ) == 1 : attr_value = attr_value [ 0 ] elif _field is not None : if len ( attr_value ) == _field [ 'oneof' ] : attr_value = attr_value [ _field [ 'index' ] ] attrs [ key ] = ( attr_value . decode ( 'ascii' ) if isinstance ( attr_value , bytes ) else attr_value ) return attrs
Return attributes of the HDF5 dataset
Parameters
Return attributes of the HDF5 dataset Parameters
"""
    Return attributes of the HDF5 dataset

    Parameters
    ----------
    dset :  h5py.Dataset
       h5py dataset from which the attributes are read
    field : str
       Name of field in compound dataset

    Returns
    -------
    dict with numpy arrays
    """ # print('_field ', _field) # print('# ----- ', key, type(attr_value), attr_value) # print('# ----- ', key, type(attr_value), attr_value) # elif isinstance(attr_value, np.void): #    attr_value = attr_value[0]
dset
field
str