def test_time_extraction(self):
        extractor = TimeInformationExtractor()
        startTime, endTime = extractor.extractTimeInformation('MER_RR__2PRACR20071224_131046_000026212064_00296_30410_0000.nc')

        expectedStartDate = datetime(2007, 12, 24, 13, 10, 46)
        expectedEndDate = datetime(2007, 12, 24, 13, 54, 27)

        self.assertEquals(expectedStartDate, startTime)
        self.assertEquals(expectedEndDate, endTime)
Exemplo n.º 2
0
    def addTimeInformation(self, filepath):
        filename = os.path.basename(filepath)
        try:
            start_time, stop_time = TimeInformationExtractor().extractTimeInformation(filename)
        except ValueError:
            print("Unable to parse time information from filename '" + filename + "'. Skipping file.")

        dataset = Dataset(filepath, mode='a')

        pattern = '%Y-%m-%d %H:%M:%S'
        dataset.start_time = start_time.strftime(pattern)
        dataset.stop_time = stop_time.strftime(pattern)

        dataset.close()
 def testTimeExtraction_fail(self):
     extractor = TimeInformationExtractor()
     self.assertRaises(ValueError, lambda : extractor.extractTimeInformation('completely_wrong_but_at_least_long_filename'))