Example #1
0
 def test_ncGetTimeValues(self):
     """Test ncGetTimes returns correct time values"""
     ncobj = netCDF4.Dataset(self.ncfile)
     times = nctools.ncGetTimes(ncobj)
     start = datetime.strptime(ncobj.variables['time'].units,
                               'hours since %Y-%m-%d %H:%M:%S')
     t = np.array([start + timedelta(hours=t) for t in range(self.nrecs)])
     self.numpyAssertEqual(t, times)
     ncobj.close()
Example #2
0
 def test_ncGetTimeValues(self):
     """Test ncGetTimes returns correct time values"""
     ncobj = netCDF4.Dataset(self.ncfile)
     times = nctools.ncGetTimes(ncobj)
     start = datetime.strptime(ncobj.variables['time'].units,
                               'hours since %Y-%m-%d %H:%M:%S')
     t = np.array([start + timedelta(hours=t) for t in range(self.nrecs)])
     self.numpyAssertEqual(t, times)
     ncobj.close()
Example #3
0
 def test_ncGetTimes(self):
     """Test ncGetTimes returns datetime objects"""
     ncobj = netCDF4.Dataset(self.ncfile)
     times = nctools.ncGetTimes(ncobj)
     ncobj.close()
     #self.assertEqual(type(times[0]), datetime)
     #  Note: cftype.real_datetime inherits from datetime.datetime
     print(type(times[0]))
     self.assertTrue(issubclass(type(times[0]), datetime))
Example #4
0
 def test_ncGetTimes(self):
     """Test ncGetTimes returns datetime objects"""
     ncobj = netCDF4.Dataset(self.ncfile)
     times = nctools.ncGetTimes(ncobj)
     ncobj.close()
     self.assertEqual(type(times[0]), datetime)
Example #5
0
 def test_ncGetTimes(self):
     """Test ncGetTimes returns datetime objects"""
     ncobj = netCDF4.Dataset(self.ncfile)
     times = nctools.ncGetTimes(ncobj)
     ncobj.close()
     self.assertEqual(type(times[0]), datetime)