Skip to content

Commit 081d2ce

Browse files
authored
Issue#150 gpcp (#152)
* Fix CF-1 Conventions for GPCP * Fix GPCP and break other tests * Check dimension of coords and pep8 dataset.py * Add GPCP test * Delete fvariable default missing_value * change test for DRS * temporarly disable tests * create rectangular grid for axis of length 1 * fix GPCP grid * fix fill_value comparison to N/A * fix array comparison issue * remove space * add BaseException to try statement
1 parent 7d4e3ab commit 081d2ce

File tree

5 files changed

+28
-9
lines changed

5 files changed

+28
-9
lines changed

Lib/axis.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,6 @@ def mapLinearIntersection(xind, yind, iind,
188188
aMinusEps, aPlusEps, bPlusEps, bMinusEps,
189189
boundLeft, nodeSubI, boundRight):
190190
"""
191-
192191
Return true iff the coordinate interval (a,b) intersects the node
193192
nodeSubI or cell bounds [boundLeft,boundRight], where the interval
194193
(a,b) is defined by:

Lib/dataset.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1238,8 +1238,13 @@ def __init__(self, path, mode, hostObj=None, mpiBarrier=False):
12381238
grid = FileCurveGrid(
12391239
lat, lon, gridname, parent=self, maskvar=maskvar)
12401240
else:
1241-
grid = FileGenericGrid(
1242-
lat, lon, gridname, parent=self, maskvar=maskvar)
1241+
try:
1242+
grid = FileGenericGrid(
1243+
lat, lon, gridname, parent=self, maskvar=maskvar)
1244+
except BaseException:
1245+
if(lat.rank() == 1 and lon.rank() == 1):
1246+
grid = FileRectGrid(self, gridname, lat, lon, gridkey[2], gridtype)
1247+
12431248
self.grids[grid.id] = grid
12441249
self._gridmap_[gridkey] = grid
12451250

Lib/fvariable.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ def __init__(self, parent, varname, cdunifobj=None):
2727
if '_FillValue' in self.__dict__.keys():
2828
self.__dict__['missing_value'] = self.__dict__['_FillValue']
2929
self.attributes['missing_value'] = self.__dict__['_FillValue']
30-
if self.__dict__['missing_value'] is None:
31-
self.__dict__[
32-
'missing_value'] = numpy.ma.default_fill_value(self)
33-
self.attributes['missing_value'] = numpy.ma.default_fill_value(
34-
self)
30+
# if self.__dict__['missing_value'] is None:
31+
# self.__dict__[
32+
# 'missing_value'] = numpy.ma.default_fill_value(self)
33+
# self.attributes['missing_value'] = numpy.ma.default_fill_value(
34+
# self)
3535

3636
val = self.__cdms_internals__ + ['name_in_file', ]
3737
self.___cdms_internals__ = val

share/test_data_files.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ bae6d4d96aeb7faafee00f2a906392a5 era40_tas_sample.nc
3434
a58748f192e02ae1ec2cf9375a1141cc 161122_RobertPincus_multiple_input4MIPs_radiation_RFMIP_UColorado-RFMIP-20161122_none.nc
3535
fe00a043c990b2cfd8ff1e2f9e9c4cc0 tas_GFDL-ESM2G_Amon_historical_r1i1p1_198501-200512-clim.nc
3636
4f8e5dcfe78e4be26af2c2440971bee5 stereographic.nc
37+
6c5bcd38ce3f77954e4353d2b9cba2f4 gpcp_cdr_v23rB1_y2016_m08.nc
3738
f515f21f4a62d182617f0ae24f60e495 20160520.A_WCYCL1850.ne30_oEC.edison.alpha6_01_ANN_climo_Q.nc
3839
c85f1abcd5769f4056209413e64d894a MERRA_ANN_climo_SHUM.nc
3940
43d54b60e1b7b46b9dd0720c85e4a3a3 vmro3_input4MIPs_ozone_DAMIP_CCMI-hist-stratO3-1-0_gr_185001_nco.nc

tests/test_all_formats.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ def testHDF(self):
1717
def testDRS(self):
1818
f = self.getDataFile("dvtest1.dic")
1919
data = f['a']
20-
self.assertEqual(data.missing_value, 1e20)
20+
# self.assertEqual(data.missing_value, 1e20)
21+
self.assertEqual(data.time, '15:17:00')
2122

2223
def testDAP(self):
2324
f = cdms2.open(
@@ -48,6 +49,19 @@ def testGRIB2(self):
4849
data = f['wvhgtsfc']
4950
self.assertEqual(data.missing_value, 9.999e20)
5051

52+
def testnetCDF(self):
53+
f = self.getDataFile("stereographic.nc")
54+
data = f('seaice_conc_cdr')
55+
self.assertAlmostEqual(data.mean(), 0.143803220111, 10)
56+
self.assertEqual(data.max(), 1.0)
57+
58+
def testGPCP(self):
59+
f = self.getDataFile("gpcp_cdr_v23rB1_y2016_m08.nc")
60+
data = f('precip')
61+
self.assertAlmostEqual(data.mean(), 2.40109777451, 8)
62+
self.assertAlmostEqual(data.max(), 30.859095, 5)
63+
self.assertEqual(data.min(), 0.0)
64+
5165

5266
if __name__ == "__main__":
5367
basetest.run()

0 commit comments

Comments
 (0)