コード例 #1
0
 def test_caching_profile(self):
     with tempfile.TemporaryDirectory() as testcachedir:
         with argopy.set_options(cachedir=testcachedir, local_ftp=self.local_ftp):
             loader = ArgoDataFetcher(src=self.src, cache=True).profile(2901623, 1)
             # 1st call to load and save to cachedir:
             loader.to_xarray()
             # 2nd call to load from cached file
             ds = loader.to_xarray()
             assert isinstance(ds, xr.Dataset)
             assert is_list_of_strings(loader.fetcher.uri)
             assert is_list_of_strings(loader.fetcher.cachepath)
コード例 #2
0
 def test_caching_region(self):
     with tempfile.TemporaryDirectory() as testcachedir:
         with argopy.set_options(cachedir=testcachedir):
             fetcher = (ArgoDataFetcher(src=self.src, cache=True).region(
                 self.requests['region'][1]).fetcher)
             # 1st call to load and save to cachedir:
             fetcher.to_xarray()
             # 2nd call to load from cached file
             ds = fetcher.to_xarray()
             assert isinstance(ds, xr.Dataset)
             assert is_list_of_strings(fetcher.uri)
             assert is_list_of_strings(fetcher.cachepath)
コード例 #3
0
 def test_caching_region(self):
     with tempfile.TemporaryDirectory() as testcachedir:
         with argopy.set_options(cachedir=testcachedir, local_ftp=self.local_ftp):
             loader = ArgoDataFetcher(src=self.src, cache=True).region(
                 [-60, -40, 40., 60., 0., 100., '2007-08-01', '2007-09-01']
             )
             # 1st call to load and save to cachedir:
             loader.to_xarray()
             # 2nd call to load from cached file
             ds = loader.to_xarray()
             assert isinstance(ds, xr.Dataset)
             assert is_list_of_strings(loader.fetcher.uri)
             assert is_list_of_strings(loader.fetcher.cachepath)
コード例 #4
0
    def test_load(self):
        with argopy.set_options(local_ftp=self.local_ftp):
            f, fetcher = self.__get_fetcher(pt='float')

            fetcher.load()
            assert is_list_of_strings(fetcher.uri)
            assert isinstance(fetcher.data, xr.Dataset)
            assert isinstance(fetcher.index, pd.core.frame.DataFrame)

            # Change the access point:
            new_fetcher = f.profile(fetcher._AccessPoint_data['wmo'], 1)
            new_fetcher.load()
            assert is_list_of_strings(new_fetcher.uri)
            assert isinstance(new_fetcher.data, xr.Dataset)
            assert isinstance(new_fetcher.index, pd.core.frame.DataFrame)
コード例 #5
0
 def __testthis_profile(self, dataset):
     with argopy.set_options(local_ftp=self.local_ftp):
         fetcher_args = {"src": self.src, 'ds': dataset}
         for arg in self.args['profile']:
             f = ArgoDataFetcher(**fetcher_args).profile(*arg)
             assert isinstance(f.to_xarray(), xr.Dataset)
             assert is_list_of_strings(f.fetcher.uri)
コード例 #6
0
 def test_chunks_region(self):
     with argopy.set_options(local_ftp=self.local_ftp):
         fetcher_args = {"src": self.src, "parallel": True, 'chunks': {'lon': 1, 'lat': 2, 'dpt': 1, 'time': 2}}
         for access_arg in self.requests["region"]:
             f = ArgoDataFetcher(**fetcher_args).region(access_arg)
             assert isinstance(f.to_xarray(), xr.Dataset)
             assert is_list_of_strings(f.fetcher.uri)
コード例 #7
0
 def __test_region(self, bk):
     """ Test float for a given backend """
     for arg in self.args["region"]:
         for mode in self.mode:
             f = ArgoDataFetcher(src=bk, mode=mode).region(arg)
             assert isinstance(f.to_xarray(), xr.Dataset)
             assert is_list_of_strings(f.uri)
コード例 #8
0
 def __test_float(self, bk, **ftc_opts):
     """ Test float for a given backend """
     for arg in self.args["float"]:
         for mode in self.mode:
             options = {**self.fetcher_opts, **ftc_opts}
             f = ArgoDataFetcher(src=bk, mode=mode, **options).float(arg)
             assert isinstance(f.to_xarray(), xr.Dataset)
             assert is_list_of_strings(f.uri)
コード例 #9
0
 def test_chunks_wmo(self):
     with argopy.set_options(local_ftp=self.local_ftp):
         fetcher_args = {"src": self.src, "parallel": True, "chunks_maxsize": {'wmo': 1}}
         for access_arg in self.requests["wmo"]:
             # f = ArgoDataFetcher(**fetcher_args).float(access_arg)
             f = ArgoDataFetcher(**fetcher_args).profile(access_arg, 1)
             assert isinstance(f.to_xarray(), xr.Dataset)
             assert is_list_of_strings(f.fetcher.uri)
             assert len(f.fetcher.uri) == len(access_arg)
コード例 #10
0
 def test_chunks_wmo(self):
     for access_arg in self.requests["wmo"]:
         fetcher_args = {
             "src": self.src,
             "parallel": True,
             "chunks_maxsize": {
                 "wmo": 1
             },
         }
         f = ArgoDataFetcher(**fetcher_args).profile(access_arg, 12).fetcher
         assert isinstance(f.to_xarray(), xr.Dataset)
         assert is_list_of_strings(f.uri)
         assert len(f.uri) == len(access_arg)
コード例 #11
0
 def test_chunks_region(self):
     for access_arg in self.requests["region"]:
         fetcher_args = {
             "src": self.src,
             "parallel": True,
             "chunks": {
                 "lon": 1,
                 "lat": 2,
                 "dpt": 1,
                 "time": 2
             },
         }
         f = ArgoDataFetcher(**fetcher_args).region(access_arg).fetcher
         assert isinstance(f.to_xarray(), xr.Dataset)
         assert is_list_of_strings(f.uri)
         assert len(f.uri) == np.prod(
             [v for k, v in fetcher_args["chunks"].items()])
コード例 #12
0
 def __testthis_region(self, dataset):
     fetcher_args = {"src": self.src, "ds": dataset}
     for arg in self.args["region"]:
         f = ArgoDataFetcher(**fetcher_args).region(arg)
         assert isinstance(f.fetcher.to_xarray(), xr.Dataset)
         assert is_list_of_strings(f.fetcher.uri)
コード例 #13
0
 def __assert_fetcher(self, f):
     # Standard loading of measurements:
     f.load()
     assert is_list_of_strings(f.uri)
     assert isinstance(f.data, xr.Dataset)
     assert isinstance(f.index, pd.core.frame.DataFrame)
コード例 #14
0
def test_list_multiprofile_file_variables():
    assert is_list_of_strings(list_multiprofile_file_variables())