Skip to content

Potential bug in 4-d variable output for standard memory mode #56

@anewman89

Description

@anewman89

When running vic2netcdf, an error occurs when outputting 4-d variables (e.g. soil moisture) using the standard memory mode.

I used the "standard" option and got an error. If I tried to include soil moisture in the configuration file I got the following error when the code tries to write to the netcdf files after it loads all the files in the current chunk:

Traceback (most recent call last):
File "./bin/vic_utils", line 5, in
pkg_resources.run_script('tonic==0.0.0.dev-2bf5167', 'vic_utils')
File "/glade/apps/opt/python/2.7.7/gnu-westmere/4.8.2/lib/python2.7/site-packages/pkg_resources.py", line 534, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/glade/apps/opt/python/2.7.7/gnu-westmere/4.8.2/lib/python2.7/site-packages/pkg_resources.py", line 1441, in run_script
exec(script_code, namespace, namespace)
File "./lib/python2.7/site-packages/tonic-0.0.0.dev_2bf5167-py2.7.egg/EGG-INFO/scripts/vic_utils", line 221, in
File "./lib/python2.7/site-packages/tonic-0.0.0.dev_2bf5167-py2.7.egg/EGG-INFO/scripts/vic_utils", line 197, in main
File "build/bdist.linux-x86_64/egg/tonic/models/vic/vic2netcdf.py", line 546, in _run
File "build/bdist.linux-x86_64/egg/tonic/models/vic/vic2netcdf.py", line 896, in vic2nc
File "build/bdist.linux-x86_64/egg/tonic/models/vic/vic2netcdf.py", line 459, in nc_add_data_standard
File "netCDF4.pyx", line 3267, in netCDF4.Variable.setitem (netCDF4.c:39658)
ValueError: total size of new array must be unchanged

I traced it back to line ~448:

self.f.variables[name][:, i, ys, xs]

is looking for something that is 2-dimensional while

p.df[sn].values[self.slice]

is only 1 dimensional with a length set at the number of time steps going into the current netcdf file. If I removed soil moisture in the configuration file, I got this option to output properly, so it is an issue with 4-d variables.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions