satpy.tests.reader_tests.test_netcdf_utils module

Module for testing the satpy.readers.netcdf_utils module.

class satpy.tests.reader_tests.test_netcdf_utils.FakeNetCDF4FileHandler(filename, filename_info, filetype_info, auto_maskandscale=False, xarray_kwargs=None, cache_var_size=0, cache_handle=False, extra_file_content=None)[source]

Bases: NetCDF4FileHandler

Swap-in NetCDF4 File Handler for reader tests to use.

Get fake file content from ‘get_test_content’.

get_test_content(filename, filename_info, filetype_info)[source]

Mimic reader input file content.

Parameters:
  • filename (str) – input filename

  • filename_info (dict) – Dict of metadata pulled from filename

  • filetype_info (dict) – Dict of metadata from the reader’s yaml config for this file type

Returns: dict of file content with keys like:

  • ‘dataset’

  • ‘/attr/global_attr’

  • ‘dataset/attr/global_attr’

  • ‘dataset/shape’

  • ‘dataset/dimensions’

  • ‘/dimension/my_dim’

class satpy.tests.reader_tests.test_netcdf_utils.TestNetCDF4FileHandler(methodName='runTest')[source]

Bases: TestCase

Test NetCDF4 File Handler Utility class.

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

setUp()[source]

Create a test NetCDF4 file.

tearDown()[source]

Remove the previously created test file.

test_all_basic()[source]

Test everything about the NetCDF4 class.

test_caching()[source]

Test that caching works as intended.

test_filenotfound()[source]

Test that error is raised when file not found.

test_get_and_cache_npxr_data_is_cached()[source]

Test that the data are cached when get_and_cache_npxr() is called.

test_get_and_cache_npxr_is_xr()[source]

Test that get_and_cache_npxr() returns xr.DataArray.

test_listed_variables()[source]

Test that only listed variables/attributes area collected.

test_listed_variables_with_composing()[source]

Test that composing for listed variables is performed.

class satpy.tests.reader_tests.test_netcdf_utils.TestNetCDF4FsspecFileHandler[source]

Bases: object

Test the remote reading class.

test_default_to_netcdf4_lib()[source]

Test that the NetCDF4 backend is used by default.

test_use_h5netcdf_for_file_not_accessible_locally()[source]

Test that h5netcdf is used for files that are not accesible locally.