Closed mpkay closed 6 years ago
Looks like the package versions got filtered out.
In my 1.5.1 environment:
pynio 1.5.1 py27h36f4ed2_2 conda-forge
In the 1.5.0 environment:
pynio 1.5.0 py27h10838b4_5 conda-forge
Sorry about not catching that earlier.
The numpy API behavior must have changed under the hood when PyNIO was ported to the newer 1.7 API in 1.5.1. Working on a fix for it.
Hi @mpkay, we just created a new PyNIO 1.5.2 release on conda-forge; if you continue to experience the same problem with the new build, please reopen this issue and let us know. Thanks!
Hi @khallock -
Thanks for the quick turnaround! I created a test environment with the new package and my tests all pass now.
In the current (1.5.1) release of PyNIO, accessed through the conda package (see below), we can no longer update data arrays retrieved from PyNIO variables in place with code like the following:
x = nc.variables["skintemp"][:] x *= 2.0
This raises an exception: ValueError: output array is read-only
Somehow the arrays have their writeable flag set to False.
You can set x to be writeable though and the operation will succeed: x = nc.variables["skintemp"][:] x.setflags(write=True) x *= 2.0
This behavior is consistent across any variables created for all files we've thrown at it (GRIB-2, NetCDF versions 3 and 4).
A sample program to illustrate the issue where we print the flags for the data arrays retrieved from all variables in a file:
!/usr/bin/env python
from future import print_function import sys import Nio
nc = Nio.open_file(sys.argv[1]) for v in nc.variables.keys(): arr = nc.variables[v][:] print(v) print(arr.flags) nc.close()
Below are some tests using one of NCAR's sample NetCDF files: https://www.unidata.ucar.edu/software/netcdf/examples/test_echam_spectral.nc
The operation fails in a conda environment created with the current release:
The above works if we fall back to the 1.5.0: