Exemple #1
0
 def test_processing_of_no_files(self):
     temp_file = NamedTemporaryFile()
     with pytest.raises(ValidTimeStampError):
         hatpro.hatpro2nc(file_path,
                          temp_file.name,
                          self.site_meta,
                          date="2020-10-24")
Exemple #2
0
 def test_handling_of_corrupted_files(self):
     temp_dir = TemporaryDirectory()
     copy_tree(self.file_path, temp_dir.name)
     with open(f'{temp_dir.name}/foo.LV1', 'w') as f:
         f.write('kissa')
     _, files = hatpro.hatpro2nc(temp_dir.name, self.temp_file.name, self.site_meta,
                                 date='2021-01-23')
     assert len(files) == 2
Exemple #3
0
 def test_processing_of_one_file(self):
     temp_file = NamedTemporaryFile()
     date = "2020-07-23"
     uuid, files = hatpro.hatpro2nc(file_path,
                                    temp_file.name,
                                    self.site_meta,
                                    date=date)
     assert len(files) == 1
Exemple #4
0
 def test_handling_of_corrupted_files(self):
     temp_dir = TemporaryDirectory()
     copy_tree(file_path, temp_dir.name)
     with open(f"{temp_dir.name}/foo.LV1", "w") as f:
         f.write("kissa")
     temp_file = NamedTemporaryFile()
     _, files = hatpro.hatpro2nc(temp_dir.name,
                                 temp_file.name,
                                 self.site_meta,
                                 date="2021-01-23")
     assert len(files) == 2
Exemple #5
0
 def test_processing_of_several_files(self):
     test_uuid = "abc"
     temp_file = NamedTemporaryFile()
     uuid, files = hatpro.hatpro2nc(file_path,
                                    temp_file.name,
                                    self.site_meta,
                                    date="2021-01-23",
                                    uuid=test_uuid)
     assert len(files) == 2
     assert uuid == test_uuid
     nc = netCDF4.Dataset(temp_file.name)
     time = nc.variables["time"]
     assert "hours since" in time.units
     assert max(time[:]) < 24
     for ind, t in enumerate(time[:-1]):
         assert time[ind + 1] > t
     assert "lwp" in nc.variables
     assert "g m-2" in nc.variables["lwp"].units
     nc.close()
Exemple #6
0
 def test_processing_of_no_files(self):
     _, files = hatpro.hatpro2nc(self.file_path, self.temp_file.name, self.site_meta,
                                 date='2020-10-24')
     assert len(files) == 0
Exemple #7
0
 def test_processing_of_one_file(self):
     _, files = hatpro.hatpro2nc(self.file_path, self.temp_file.name, self.site_meta,
                                 date='2020-07-23')
     assert len(files) == 1
Exemple #8
0
 def test_processing_of_several_files(self):
     test_uuid = 'abc'
     uuid, files = hatpro.hatpro2nc(self.file_path, self.temp_file.name, self.site_meta,
                                 date='2021-01-23', uuid=test_uuid)
     assert len(files) == 2
     assert uuid == test_uuid
Exemple #9
0
 def test_default_processing(self):
     uuid, files = hatpro.hatpro2nc(self.file_path, self.temp_file.name, self.site_meta)
     assert len(files) == 3
     assert len(uuid) == 32
Exemple #10
0
 def test_default_processing(self):
     temp_file = NamedTemporaryFile()
     uuid, files = hatpro.hatpro2nc(file_path, temp_file.name,
                                    self.site_meta)
     assert len(files) == 4
     assert len(uuid) == 36
Exemple #11
0
class TestHatpro2nc(Check):
    site_meta = {
        "name": "the_station",
        "altitude": 50,
        "latitude": 23.0,
        "longitude": 123
    }
    date = "2020-07-23"
    temp_file = NamedTemporaryFile()
    uuid, valid_files = hatpro.hatpro2nc(file_path,
                                         temp_file.name,
                                         site_meta,
                                         date=date)

    def test_default_processing(self):
        temp_file = NamedTemporaryFile()
        uuid, files = hatpro.hatpro2nc(file_path, temp_file.name,
                                       self.site_meta)
        assert len(files) == 4
        assert len(uuid) == 36

    def test_processing_of_several_files(self):
        test_uuid = "abc"
        temp_file = NamedTemporaryFile()
        uuid, files = hatpro.hatpro2nc(file_path,
                                       temp_file.name,
                                       self.site_meta,
                                       date="2021-01-23",
                                       uuid=test_uuid)
        assert len(files) == 2
        assert uuid == test_uuid
        nc = netCDF4.Dataset(temp_file.name)
        time = nc.variables["time"]
        assert "hours since" in time.units
        assert max(time[:]) < 24
        for ind, t in enumerate(time[:-1]):
            assert time[ind + 1] > t
        assert "lwp" in nc.variables
        assert "g m-2" in nc.variables["lwp"].units
        nc.close()

    def test_processing_of_one_file(self):
        temp_file = NamedTemporaryFile()
        date = "2020-07-23"
        uuid, files = hatpro.hatpro2nc(file_path,
                                       temp_file.name,
                                       self.site_meta,
                                       date=date)
        assert len(files) == 1

    def test_processing_of_no_files(self):
        temp_file = NamedTemporaryFile()
        with pytest.raises(ValidTimeStampError):
            hatpro.hatpro2nc(file_path,
                             temp_file.name,
                             self.site_meta,
                             date="2020-10-24")

    def test_handling_of_corrupted_files(self):
        temp_dir = TemporaryDirectory()
        copy_tree(file_path, temp_dir.name)
        with open(f"{temp_dir.name}/foo.LV1", "w") as f:
            f.write("kissa")
        temp_file = NamedTemporaryFile()
        _, files = hatpro.hatpro2nc(temp_dir.name,
                                    temp_file.name,
                                    self.site_meta,
                                    date="2021-01-23")
        assert len(files) == 2