Skip to content

Problems writing netcdf data - _FillValue error #1479

@durack1

Description

@durack1

@doutriaux1 this error has appeared, which doesn't seem obviously wrong (user error) - I'm curious if this is related to #1470:

#!/bin/env python

# -*- coding: utf-8 -*-
"""
Created on Tue Aug  4 11:24:35 2015

@author: durack1
"""
import os
import cdms2 as cdm

# Set outfile criteria
on = 0
cdm.setNetcdfShuffleFlag(on)
cdm.setNetcdfDeflateFlag(on)
cdm.setNetcdfDeflateLevelFlag(on)

# Read data
path = '/work/cmip5/historical/atm/mo/ts/'
inFile = 'cmip5.CCSM4.historical.r1i1p1.mo.atm.Amon.ts.ver-v20120604.latestX.xml'
inFile = os.path.join(path,inFile)
fIn = cdm.open(inFile)
time = fIn.getAxis('time')
slab = fIn('ts',time=('1850','1900'))
print 'slab _FillValue:',slab._FillValue,type(slab._FillValue)
print 'slab type:',slab.dtype

# Write data
outFile = './testGemma.nc'
if os.path.exists(outfile):
  os.remove(outFile)
  print 'outFile removed..'
fOut = cdm.open(outFile,'w')
fOut.write(slab.astype('float32'))
fOut.close()
fIn.close()

Yields the following output:

[durack1@crunchy ~/Desktop]$ testGemma.py
slab _FillValue: 1e+20 <type 'float'>
slab type: float32
cdunif: NetCDF: Not a valid data type or _FillValue type mismatch
If you are trying to write a NetCDF4 type (e.g. int64) please do not turn off cdms_shuffle and cdms_deflate
Traceback (most recent call last):
  File ".//testGemma.py", line 32, in <module>
    fOut.write(slab.astype('float32'))
  File "/usr/local/uvcdat/2015-07-09/lib/python2.7/site-packages/cdms2/dataset.py", line 1796, in write
    id=varid, extend=extend, fill_value=fill_value, index=index)
  File "/usr/local/uvcdat/2015-07-09/lib/python2.7/site-packages/cdms2/dataset.py", line 1721, in createVariableCopy
    setattr(newvar, attname, attval)
  File "/usr/local/uvcdat/2015-07-09/lib/python2.7/site-packages/cdms2/fvariable.py", line 145, in __setattr__
    setattr(self._obj_, name, value)
IOError: cdunif: NetCDF: Not a valid data type or _FillValue type mismatch
If you are trying to write a NetCDF4 type (e.g. int64) please do not turn off cdms_shuffle and cdms_deflate

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions