Skip to content

Update cdms2 to deal with all common datatypes (uint8, uint16, char, str etc) #63

@chaosphere2112

Description

@chaosphere2112

It appears that UV-CDAT 2.0 beta doesn't play nicely with the unsigned integer data types, and it would appear this is a hangover from numeric data types a long time ago:

Taking a look in https://github.com/UV-CDAT/cdms/blob/master/Lib/cdmsNode.py#L23-65 do not include these unsigned types:

# Data types

CdChar = CDML.CdChar
CdByte = CDML.CdByte
CdShort = CDML.CdShort
CdInt = CDML.CdInt
CdLong = CDML.CdLong
CdInt64 = CDML.CdInt64
CdFloat = CDML.CdFloat
CdDouble = CDML.CdDouble
CdString = CDML.CdString
CdFromObject = CDML.CdFromObject
CdAny = CDML.CdAny
CdDatatypes = [CdChar,CdByte,CdShort,CdInt,CdLong,CdInt64,CdFloat,CdDouble,CdString]

CdScalar = CDML.CdScalar
CdArray = CDML.CdArray

NumericToCdType = {numpy.sctype2char(numpy.float32):CdFloat,
                   numpy.sctype2char(numpy.float):CdDouble,
                   numpy.sctype2char(numpy.int16):CdShort,
                   numpy.sctype2char(numpy.int32):CdInt,
                   numpy.sctype2char(numpy.int):CdLong,
                   numpy.sctype2char(numpy.int64):CdInt64,
                   numpy.sctype2char(numpy.intc):CdLong,
                   numpy.sctype2char(numpy.int8):CdByte,
                   'c':CdChar,
                   'B':'B',
                   'H':'H',
                   'L':'L',
                   'q':CdInt64,
                   'Q':'Q',
                   'S':'S'
                   }

CdToNumericType = {CdChar:'c',
                   CdByte:numpy.int8,
                   CdShort:numpy.int16,
                   CdInt:numpy.int32,
                   CdLong:numpy.int,
                   CdInt64:numpy.int64,
                   CdFloat:numpy.float32,
                   CdDouble:numpy.float}

It would be great to include these, as netcdf 4 also includes these types as NC_ubyte (uint8; unsigned byte), NC_ushort (uint16; unsigned short), NC_uint (uint32; unsigned int), NC_uint64 (uint64; unsigned long long)

Migrated from: CDAT/cdat#537

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions