Skip to content

Instantly share code, notes, and snippets.

@cpelley
Created March 31, 2015 12:48
Show Gist options
  • Save cpelley/2da0b8dd347f7a4772e0 to your computer and use it in GitHub Desktop.
Save cpelley/2da0b8dd347f7a4772e0 to your computer and use it in GitHub Desktop.
Lazy NetCDF save bug
{
"metadata": {
"name": "",
"signature": "sha256:1ccaf1d6efde449dc4d273823364434c19bdd068d41587570ffde0a5be796216"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "code",
"collapsed": false,
"input": [
"import iris"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 1
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"import numpy as np\n",
"cube = iris.cube.Cube(np.ma.array(np.arange(4), mask=[False, True, True, False], fill_value=-1))\n",
"cube.add_dim_coord(iris.coords.DimCoord(np.arange(4), long_name='bla'), 0)\n",
"print cube"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"unknown / (unknown) (bla: 4)\n",
" Dimension coordinates:\n",
" bla x\n"
]
}
],
"prompt_number": 2
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"iris.save(cube, 'tmp.nc', unlimited_dimensions=[])\n",
"ncube = iris.load_cube('tmp.nc')\n",
"print ncube.lazy_data().fill_value"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"-1\n"
]
}
],
"prompt_number": 5
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"iris.save(ncube, 'tmp2.nc', unlimited_dimensions=[])"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 6
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"%%bash\n",
"ncdump -h 'tmp2.nc'"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"netcdf tmp2 {\n",
"dimensions:\n",
"\tbla = 4 ;\n",
"variables:\n",
"\tint64 unknown(bla) ;\n",
"\t\tunknown:units = \"1\" ;\n",
"\tint64 bla(bla) ;\n",
"\t\tbla:units = \"1\" ;\n",
"\t\tbla:long_name = \"bla\" ;\n",
"\n",
"// global attributes:\n",
"\t\t:Conventions = \"CF-1.5\" ;\n",
"}\n"
]
}
],
"prompt_number": 8
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"ncube2 = iris.load_cube('tmp2.nc')\n",
"ncube2.data.fill_value"
],
"language": "python",
"metadata": {},
"outputs": [
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 13,
"text": [
"-9223372036854775806"
]
}
],
"prompt_number": 13
}
],
"metadata": {}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment