Skip to content

vic2netcdf standard memory mode error #62

@ghost

Description

I'm using vic2netcf to convert the ascii data files into a netcdf file. However, there is an error when using standard memory mode, where the data cannot be inserted into the NetCDF variable.

Traceback (most recent call last):
File "/home/scott/venv/tonic/bin/vic_utils", line 4, in
import('pkg_resources').run_script('tonic===0.0.0.dev-190aca2', 'vic_utils')
File "/home/scott/venv/tonic/lib/python3.5/site-packages/pkg_resources/init.py", line 743, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/home/scott/venv/tonic/lib/python3.5/site-packages/pkg_resources/init.py", line 1505, in run_script
exec(script_code, namespace, namespace)
File "/home/scott/venv/tonic/lib/python3.5/site-packages/tonic-0.0.0.dev_190aca2-py3.5.egg/EGG-INFO/scripts/vic_utils", line 221, in
File "/home/scott/venv/tonic/lib/python3.5/site-packages/tonic-0.0.0.dev_190aca2-py3.5.egg/EGG-INFO/scripts/vic_utils", line 197, in main
File "/home/scott/venv/tonic/lib/python3.5/site-packages/tonic-0.0.0.dev_190aca2-py3.5.egg/tonic/models/vic/vic2netcdf.py", line 512, in _run
File "/home/scott/venv/tonic/lib/python3.5/site-packages/tonic-0.0.0.dev_190aca2-py3.5.egg/tonic/models/vic/vic2netcdf.py", line 861, in vic2nc
File "/home/scott/venv/tonic/lib/python3.5/site-packages/tonic-0.0.0.dev_190aca2-py3.5.egg/tonic/models/vic/vic2netcdf.py", line 462, in nc_add_data_standard
File "netCDF4/_netCDF4.pyx", line 4074, in netCDF4._netCDF4.Variable.setitem (netCDF4/_netCDF4.c:46416)
ValueError: cannot reshape array of size 70858 into shape (35429,2,2)

The problem is coming from Segment.nc_add_data_standard() when assinging the 2d array to the variable on line 462 as it's iterating over all combinations of (ys,xs) which is not the same size as data.

self.f.variables[name][:, ys, xs] = data

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