-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
missing_value = 'N/A' led to fail (#84)
* missing_value = 'N/A' led to fail * added test to make sure reading in var with ASCII missing val will work * fix for mac
- Loading branch information
1 parent
28e5996
commit 8ad09a2
Showing
2 changed files
with
65 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import basetest | ||
import subprocess | ||
import cdms2 | ||
import os | ||
|
||
class TestMissingASCII(basetest.CDMSBaseTest): | ||
def testMissingASCII(self): | ||
nc_dump = """ | ||
netcdf tmp_test { | ||
dimensions: | ||
axis_0 = 2 ; | ||
axis_1 = 2 ; | ||
variables: | ||
double axis_0(axis_0) ; | ||
double axis_1(axis_1) ; | ||
double var(axis_0, axis_1) ; | ||
var:missing_value = "N/A" ; | ||
// global attributes: | ||
:Conventions = "CF-1.0" ; | ||
data: | ||
axis_0 = 0, 1 ; | ||
axis_1 = 0, 1 ; | ||
var = | ||
1, 1, | ||
1, 1 ; | ||
} | ||
""" | ||
|
||
f=open("tmp_test.asc","w") | ||
f.write(nc_dump) | ||
f.close() | ||
|
||
subprocess.call("ncgen -b tmp_test.asc".split()) | ||
|
||
f=cdms2.open("tmp_test.nc") | ||
v=f("var") | ||
f.close() | ||
|
||
self.assertEqual(v.missing_value,1.e20) | ||
|
||
os.remove("tmp_test.asc") | ||
os.remove("tmp_test.nc") | ||
|
||
|
||
if __name__ == "__main__": | ||
basetest.run() |