Skip to content

error in default value with write_sids() #45

@mbauer288

Description

@mbauer288

In sidecar.py the default fill_value is -1, but the datatype for SIDs is unit64, which can't have negative values. This results is a netcdf write error.

def write_sids(self, sids, nom_res=None, group=None, fill_value=-1):
    i = sids.shape[0]
    j = sids.shape[1]
    varname = 'STARE_index'.format(nom_res=nom_res)
    i_name = 'i'
    j_name = 'j'
    if nom_res:
        varname += '_{nom_res}'.format(nom_res=nom_res)
        i_name += '_{nom_res}'.format(nom_res=nom_res)
        j_name += '_{nom_res}'.format(nom_res=nom_res)   
    with netCDF4.Dataset(self.file_path, 'a', format="NETCDF4") as rootgrp:
        if group:
            grp = rootgrp.createGroup(group)
        else:
            grp = rootgrp
        sids_netcdf = grp.createVariable(varname=varname,
                                         datatype='u8', 
                                         dimensions=(i_name, j_name),
                                         chunksizes=[i, j],
                                         shuffle=self.shuffle,
                                         zlib=self.zlib,
                                         fill_value=fill_value)
        print("HERE")
        sids_netcdf.long_name = 'SpatioTemporal Adaptive Resolution Encoding (STARE) index'
        sids_netcdf[:, :] = sids

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions