test_MAGL1bGEOF.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:ncagg 作者: 5tefan 项目源码 文件源码
def test_strict_time(self):
        """Make sure the time array looks ok. Evenly spaced, bounds are correct."""
        numeric_times = self.output.variables["OB_time"][:].flatten()
        np.set_printoptions(threshold=np.inf)
        # logger.debug(numeric_times)
        # logger.debug(np.diff(numeric_times)[9:].reshape(-1, 10))
        self.assertAlmostEqual(np.mean(np.diff(numeric_times)), 0.1, delta=0.002)
        self.assertAlmostEqual(np.min(np.diff(numeric_times)), 0.1, delta=0.002)
        self.assertAlmostEqual(np.max(np.diff(numeric_times)), 0.1, delta=0.002)

        datetimes = nc.num2date(numeric_times, self.output.variables["OB_time"].units)
        # since we have records of size 10 and we don't want any coming in before start time
        # the start time may be up to 0.9 after the aggregation start time,
        self.assertLess(abs((datetimes[0]-self.start_time).total_seconds()), 0.91)

        # similarly for the aggregation end, we aren't chopping off in the middle of a records,
        # so even if the first one is before the end, up to 0.91 may be after.
        self.assertLess(abs((datetimes[-10]-self.end_time).total_seconds()), 0.91)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号