コード例 #1
0
    def test_missing_requirements(self, *mocks):
        """Test warnings and exceptions in case of missing requirements."""
        from satpy.readers import load_readers

        # Filenames from a single scan
        epi_pro_miss = [
            'H-000-MSG4__-MSG4________-IR_108___-000006___-201809050900-__'
        ]
        epi_miss = epi_pro_miss + [
            'H-000-MSG4__-MSG4________-_________-PRO______-201809050900-__'
        ]
        pro_miss = epi_pro_miss + [
            'H-000-MSG4__-MSG4________-_________-EPI______-201809050900-__'
        ]
        for filenames in [epi_miss, pro_miss, epi_pro_miss]:
            self.assertRaises(ValueError,
                              load_readers,
                              reader='seviri_l1b_hrit',
                              filenames=filenames)

        # Filenames from multiple scans
        at_least_one_complete = [
            # 09:00 scan is ok
            'H-000-MSG4__-MSG4________-IR_108___-000006___-201809050900-__',
            'H-000-MSG4__-MSG4________-_________-PRO______-201809050900-__',
            'H-000-MSG4__-MSG4________-_________-EPI______-201809050900-__',
            # 10:00 scan is incomplete
            'H-000-MSG4__-MSG4________-IR_108___-000006___-201809051000-__',
        ]
        try:
            load_readers(filenames=at_least_one_complete,
                         reader='seviri_l1b_hrit')
        except ValueError:
            self.fail('If at least one set of filenames is complete, no '
                      'exception should be raised')
コード例 #2
0
ファイル: test_readers.py プロジェクト: lamby/satpy
 def test_almost_all_filtered(self):
     """Test behaviour if only one reader has datasets."""
     from satpy.readers import load_readers
     import datetime
     filenames = {
         'viirs_sdr': [
             'SVI01_npp_d20120225_t1801245_e1802487_b01708_c20120226002130255476_noaa_ops.h5'
         ],
         'abi_l1b': [
             'OR_ABI-L1b-RadF-M3C01_G16_s20172631730408_e20172631741175_c20172631741218.nc'
         ],
     }
     filter_params = {
         'start_time': datetime.datetime(2012, 2, 25),
         'end_time': datetime.datetime(2012, 2, 26)
     }
     # viirs has data that matches the request, abi doesn't
     readers = load_readers(
         filenames=filenames,
         reader_kwargs={'filter_parameters': filter_params})
     self.assertIn('viirs_sdr', readers)
     # abi_l1b reader was created, but no datasets available
     self.assertIn('abi_l1b', readers)
     self.assertEqual(len(list(readers['abi_l1b'].available_dataset_ids)),
                      0)
コード例 #3
0
ファイル: test_readers.py プロジェクト: lamby/satpy
 def test_filenames_only(self):
     """Test with filenames specified"""
     from satpy.readers import load_readers
     ri = load_readers(filenames=[
         'SVI01_npp_d20120225_t1801245_e1802487_b01708_c20120226002130255476_noaa_ops.h5'
     ])
     self.assertListEqual(list(ri.keys()), ['viirs_sdr'])
コード例 #4
0
ファイル: test_readers.py プロジェクト: davidh-ssec/satpy
 def test_filenames_only(self):
     """Test with filenames specified"""
     from satpy.readers import load_readers
     ri = load_readers(filenames=[
         'SVI01_npp_d20120225_t1801245_e1802487_b01708_c20120226002130255476_noaa_ops.h5',
     ])
     self.assertListEqual(list(ri.keys()), ['viirs_sdr'])
コード例 #5
0
ファイル: test_readers.py プロジェクト: lamby/satpy
    def test_no_args(self):
        """Test no args provided.

        This should check the local directory which should have no files.
        """
        from satpy.readers import load_readers
        ri = load_readers()
        self.assertDictEqual(ri, {})
コード例 #6
0
ファイル: test_readers.py プロジェクト: shepherdmeng/satpy
 def test_filenames_as_dict(self):
     """Test loading readers where filenames are organized by reader"""
     from satpy.readers import load_readers
     filenames = {
         'viirs_sdr': ['SVI01_npp_d20120225_t1801245_e1802487_b01708_c20120226002130255476_noaa_ops.h5'],
     }
     ri = load_readers(filenames=filenames)
     self.assertListEqual(list(ri.keys()), ['viirs_sdr'])
コード例 #7
0
ファイル: test_readers.py プロジェクト: davidh-ssec/satpy
 def test_filenames_as_dict(self):
     """Test loading readers where filenames are organized by reader"""
     from satpy.readers import load_readers
     filenames = {
         'viirs_sdr': ['SVI01_npp_d20120225_t1801245_e1802487_b01708_c20120226002130255476_noaa_ops.h5'],
     }
     ri = load_readers(filenames=filenames)
     self.assertListEqual(list(ri.keys()), ['viirs_sdr'])
コード例 #8
0
ファイル: test_readers.py プロジェクト: davidh-ssec/satpy
 def test_no_args(self):
     """Test no args provided.
     
     This should check the local directory which should have no files.
     """
     from satpy.readers import load_readers
     ri = load_readers()
     self.assertDictEqual(ri, {})
コード例 #9
0
 def create_reader_instances(self,
                             filenames=None,
                             reader=None,
                             reader_kwargs=None):
     """Find readers and return their instances."""
     return load_readers(filenames=filenames,
                         reader=reader,
                         reader_kwargs=reader_kwargs,
                         ppp_config_dir=self.ppp_config_dir)
コード例 #10
0
ファイル: test_readers.py プロジェクト: shepherdmeng/satpy
    def test_filenames_as_dict_with_reader(self):
        """Test loading from a filenames dict with a single reader specified.

        This can happen in the deprecated Scene behavior of passing a reader
        and a base_dir.

        """
        from satpy.readers import load_readers
        filenames = {
            'viirs_sdr': ['SVI01_npp_d20120225_t1801245_e1802487_b01708_c20120226002130255476_noaa_ops.h5'],
        }
        ri = load_readers(reader='viirs_sdr', filenames=filenames)
        self.assertListEqual(list(ri.keys()), ['viirs_sdr'])
コード例 #11
0
    def test_empty_filenames_as_dict(self):
        """Test passing filenames as a dictionary with an empty list of filenames."""
        # only one reader
        from satpy.readers import load_readers
        filenames = {
            'viirs_sdr': [],
        }
        self.assertRaises(ValueError, load_readers, filenames=filenames)

        # two readers, one is empty
        filenames = {
            'viirs_sdr': ['SVI01_npp_d20120225_t1801245_e1802487_b01708_c20120226002130255476_noaa_ops.h5'],
            'viirs_l1b': [],
        }
        ri = load_readers(filenames)
        self.assertListEqual(list(ri.keys()), ['viirs_sdr'])