[Scipy-tickets] [SciPy] #1720: io.netcdf outputs garbage variable values in Windows XP

SciPy Trac scipy-tickets@scipy....
Fri Mar 15 02:12:45 CDT 2013


#1720: io.netcdf outputs garbage variable values  in Windows XP
----------------------+-----------------------------------------------------
 Reporter:  mtrauts   |       Owner:  somebody
     Type:  defect    |      Status:  new     
 Priority:  high      |   Milestone:  0.12.0  
Component:  scipy.io  |     Version:  0.11.0  
 Keywords:  netcdf    |  
----------------------+-----------------------------------------------------
Changes (by eelsirhc):

 * cc: lee@… (added)
  * priority:  normal => high
  * version:  devel => 0.11.0
  * milestone:  Unscheduled => 0.12.0


Comment:

 This problem affects all platforms using version 0.11.0, and all versions
 since June 2012, not just windows XP.

 The problem is caused by the change made in commit
 76a983ec625556bcc7a1f8ba76339399e8af68a4 (Ralf Gommers,    Sun Jun 3
 18:16:08 2012 +0200 ).

 Prior to that commit, all data types that are passed into the
 createVariable function were converted to big Endian as required by the
 NetCDF v3 specification (e.g.
 [http://www.unidata.ucar.edu/support/help/MailArchives/netcdf/msg11257.html
 here]), after that commit the conversion no longer occurs.

 The pupynere library doesn't have this piece of code either
 ([https://bitbucket.org/robertodealmeida/pupynere/src/8bf915cab498b5b10e7c09fafd8633df2ed1980c/pupynere.py?at=default#cl-280
 pupynere.py line 280]) , but does have extra protection when the data is
 written to ensure that it's big endian
 ([https://bitbucket.org/robertodealmeida/pupynere/src/8bf915cab498b5b10e7c09fafd8633df2ed1980c/pupynere.py?at=default#cl-414
 pupynere.py line 414]). The scipy version retains some of this protection
 in the case of record variables
 ([https://github.com/eelsirhc/scipy/blob/master/scipy/io/netcdf.py#L435
 netcdf.py line 435]) but lacks the non-record variable protection.

 A (bad, hacky) work-around is to explicitly define the datatype as big-
 endian, even if the incoming data is not. This will correctly initialize
 the data array in createVariable.

 There are 'unit' tests in tests/test_netcdf.py that are passed by this
 buggy version of netcdf.py simply because the unit test that might be
 affected "test_dtype_specifiers" doesn't ever write data to the netcdf
 file, or check the data written. The time variable in make_simple might
 have caught the error, but is defined as a byte (int8) so is never
 affected by endian-ness issues.

-- 
Ticket URL: <http://projects.scipy.org/scipy/ticket/1720#comment:3>
SciPy <http://www.scipy.org>
SciPy is open-source software for mathematics, science, and engineering.


More information about the Scipy-tickets mailing list