satpy.tests.test_scene module

Unit tests for scene.py.

class satpy.tests.test_scene.TestFinestCoarsestArea[source]

Bases: object

Test the Scene logic for finding the finest and coarsest area.

test_coarsest_finest_area_different_shape(coarse_area, fine_area)[source]

Test ‘coarsest_area’ and ‘finest_area’ methods for upright areas.

test_coarsest_finest_area_same_shape(area_def, shifted_area)[source]

Test that two areas with the same shape are consistently returned.

If two geometries (ex. two AreaDefinitions or two SwathDefinitions) have the same resolution (shape) but different coordinates, which one has the finer resolution would ultimately be determined by the semi-random ordering of the internal container of the Scene (a dict) if only pixel resolution was compared. This test makes sure that it is always the same object returned.

class satpy.tests.test_scene.TestScene[source]

Bases: object

Test the scene class.

setup_method()[source]

Set config_path to point to test ‘etc’ directory.

teardown_method()[source]

Restore previous ‘config_path’ setting.

test_all_dataset_names_no_readers()[source]

Test all dataset names with no reader.

test_all_datasets_no_readers()[source]

Test all datasets with no reader.

test_available_dataset_names_no_readers()[source]

Test the available dataset names without a reader.

test_available_dataset_no_readers()[source]

Test the available datasets without a reader.

test_bad_setitem()[source]

Test setting an item wrongly.

test_contains()[source]

Test contains.

test_create_multiple_reader_different_kwargs()[source]

Test passing different kwargs to different readers.

test_create_reader_instances_with_filenames()[source]

Test creating a reader providing filenames.

test_create_reader_instances_with_reader()[source]

Test createring a reader instance providing the reader name.

test_create_reader_instances_with_reader_kwargs()[source]

Test creating a reader instance with reader kwargs.

test_crop()[source]

Test the crop method.

test_crop_epsg_crs()[source]

Test the crop method when source area uses an EPSG code.

test_crop_rgb()[source]

Test the crop method on multi-dimensional data.

test_delitem()[source]

Test deleting an item.

test_getitem()[source]

Test __getitem__ with names only.

test_getitem_modifiers()[source]

Test __getitem__ with names and modifiers.

test_getitem_slices()[source]

Test __getitem__ with slices.

test_init()[source]

Test scene initialization.

test_init_alone()[source]

Test simple initialization.

test_init_no_files()[source]

Test that providing an empty list of filenames fails.

test_init_preserve_reader_kwargs()[source]

Test that the initialization preserves the kwargs.

test_init_str_filename()[source]

Test initializing with a single string as filenames.

test_init_with_empty_filenames()[source]

Test initialization with empty filename list.

test_init_with_fsfile()[source]

Test initialisation with FSFile objects.

test_iter()[source]

Test iteration over the scene.

test_iter_by_area_swath()[source]

Test iterating by area on a swath.

test_sensor_names_added_datasets(include_reader, added_sensor, exp_sensors)[source]

Test that Scene sensor_names handles contained sensors properly.

test_sensor_names_readers(reader, filenames, exp_sensors)[source]

Test that Scene sensor_names handles different cases properly.

test_setitem()[source]

Test setting an item.

test_start_end_times()[source]

Test start and end times for a scene.

test_storage_options_from_reader_kwargs_no_options()[source]

Test getting storage options from reader kwargs.

Case where there are no options given.

test_storage_options_from_reader_kwargs_per_reader()[source]

Test getting storage options from reader kwargs.

Case where each reader have their own storage options.

test_storage_options_from_reader_kwargs_per_reader_and_global()[source]

Test getting storage options from reader kwargs.

Case where each reader have their own storage options and there are global options to merge.

test_storage_options_from_reader_kwargs_single_dict(reader_kwargs)[source]

Test getting storage options from reader kwargs.

Case where a single dict is given for all readers with some common storage options.

test_storage_options_from_reader_kwargs_single_dict_no_options()[source]

Test getting storage options from reader kwargs for remote files.

Case where a single dict is given for all readers without storage options.

class satpy.tests.test_scene.TestSceneAggregation(methodName='runTest')[source]

Bases: TestCase

Test the scene’s aggregate method.

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.

test_aggregate()[source]

Test the aggregate method.

test_aggregate_with_boundary()[source]

Test aggregation with boundary argument.

class satpy.tests.test_scene.TestSceneAvailableDatasets[source]

Bases: object

Test the Scene’s handling of various dependencies.

setup_method()[source]

Set config_path to point to test ‘etc’ directory.

teardown_method()[source]

Restore previous ‘config_path’ setting.

test_all_datasets_multiple_reader()[source]

Test all datasets for multiple readers.

test_all_datasets_one_reader()[source]

Test all datasets for one reader.

test_available_composite_ids_missing_available()[source]

Test available_composite_ids when a composites dep is missing.

test_available_composites_known_versus_all()[source]

Test available_composite_ids when some datasets aren’t available.

test_available_datasets_one_reader()[source]

Test the available datasets for one reader.

class satpy.tests.test_scene.TestSceneConversions(methodName='runTest')[source]

Bases: TestCase

Test Scene conversion to geoviews, xarray, etc.

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.

test_geoviews_basic_with_area()[source]

Test converting a Scene to geoviews with an AreaDefinition.

test_geoviews_basic_with_swath()[source]

Test converting a Scene to geoviews with a SwathDefinition.

test_to_xarray_dataset_with_empty_scene()[source]

Test converting empty Scene to xarray dataset.

class satpy.tests.test_scene.TestSceneLoading[source]

Bases: object

Test the Scene objects .load method.

setup_method()[source]

Set config_path to point to test ‘etc’ directory.

teardown_method()[source]

Restore previous ‘config_path’ setting.

test_available_comps_no_deps()[source]

Test Scene available composites when composites don’t have a dependency.

test_available_when_sensor_none_in_preloaded_dataarrays()[source]

Test Scene available composites when existing loaded arrays have sensor set to None.

Some readers or composites (ex. static images) don’t have a sensor and developers choose to set it to None. This test makes sure this doesn’t break available composite IDs.

test_chunk_pass_through()[source]

Test pass through of xarray chunk.

test_compute_pass_through()[source]

Test pass through of xarray compute.

test_load_comp1()[source]

Test loading a composite with one required prereq.

test_load_comp10()[source]

Test loading a composite that depends on a modified dataset.

test_load_comp11()[source]

Test loading a composite that depends all wavelengths.

test_load_comp11_and_23()[source]

Test loading two composites that depend on similar wavelengths.

test_load_comp12()[source]

Test loading a composite that depends all wavelengths that get modified.

test_load_comp13()[source]

Test loading a composite that depends on a modified dataset where the resolution changes.

test_load_comp14()[source]

Test loading a composite that updates the DataID during generation.

test_load_comp15()[source]

Test loading a composite whose prerequisites can’t be loaded.

Note that the prereq exists in the reader, but fails in loading.

test_load_comp16()[source]

Test loading a composite whose opt prereq can’t be loaded.

Note that the prereq exists in the reader, but fails in loading

test_load_comp17()[source]

Test loading a composite that depends on a composite that won’t load.

test_load_comp18()[source]

Test loading a composite that depends on a incompatible area modified dataset.

test_load_comp18_2()[source]

Test loading a composite that depends on a incompatible area modified dataset.

Specifically a modified dataset where the modifier has optional dependencies.

test_load_comp19()[source]

Test loading a composite that shares a dep with a dependency.

More importantly test that loading a dependency that depends on the same dependency as this composite (a sibling dependency) and that sibling dependency includes a modifier. This test makes sure that the Node in the dependency tree is the exact same node.

test_load_comp20()[source]

Test loading composite with optional modifier dependencies.

test_load_comp21()[source]

Test loading composite with bad optional modifier dependencies.

test_load_comp22()[source]

Test loading composite with only optional modifier dependencies.

test_load_comp4()[source]

Test loading a composite that depends on a composite.

test_load_comp5()[source]

Test loading a composite that has an optional prerequisite.

test_load_comp6()[source]

Test loading a composite that has an optional composite prerequisite.

test_load_comp8()[source]

Test loading a composite that has a non-existent prereq.

test_load_comp9()[source]

Test loading a composite that has a non-existent optional prereq.

test_load_dataset_after_composite()[source]

Test load composite followed by other datasets.

test_load_dataset_after_composite2()[source]

Test load complex composite followed by other datasets.

test_load_ds1_load_twice()[source]

Test loading one dataset with no loaded compositors.

test_load_ds1_no_comps()[source]

Test loading one dataset with no loaded compositors.

test_load_ds1_unknown_modifier()[source]

Test loading one dataset with no loaded compositors.

test_load_ds4_cal()[source]

Test loading a dataset that has two calibration variations.

test_load_ds5_best_resolution()[source]

Test loading a dataset has multiple resolutions available.

test_load_ds5_empty_modifiers()[source]

Test loading a dataset has multiple resolutions available with different resolutions.

test_load_ds5_missing_best_resolution()[source]

Test loading a dataset that has multiple resolutions but the best isn’t available.

test_load_ds5_multiple_resolution()[source]

Test loading a dataset has multiple resolutions available with different resolutions.

test_load_ds5_resolution_list()[source]

Test loading a dataset has multiple resolutions available with different resolutions.

test_load_ds6_wl()[source]

Test loading a dataset by wavelength.

test_load_ds9_fail_load()[source]

Test loading a dataset that will fail during load.

test_load_green()[source]

Test loading ahi_green.

test_load_modified()[source]

Test loading a modified dataset.

test_load_modified_with_load_kwarg()[source]

Test loading a modified dataset using the Scene.load keyword argument.

test_load_multiple_comps()[source]

Test loading multiple composites.

test_load_multiple_comps_separate()[source]

Test loading multiple composites, one at a time.

test_load_multiple_modified()[source]

Test loading multiple modified datasets.

test_load_multiple_resolutions()[source]

Test loading a dataset has multiple resolutions available with different resolutions.

test_load_no_exist()[source]

Test loading a dataset that doesn’t exist.

test_load_no_exist2()[source]

Test loading a dataset that doesn’t exist then another load.

test_load_same_subcomposite()[source]

Test loading a composite and one of it’s subcomposites at the same time.

test_load_str()[source]

Test passing a string to Scene.load.

test_load_too_many()[source]

Test dependency tree if too many reader keys match.

test_load_when_sensor_none_in_preloaded_dataarrays()[source]

Test Scene loading when existing loaded arrays have sensor set to None.

Some readers or composites (ex. static images) don’t have a sensor and developers choose to set it to None. This test makes sure this doesn’t break loading.

test_modified_with_wl_dep()[source]

Test modifying a dataset with a modifier with modified deps.

More importantly test that loading the modifiers dependency at the same time as the original modified dataset that the dependency tree nodes are unique and that DataIDs.

test_no_generate_comp10()[source]

Test generating a composite after loading.

test_persist_pass_through()[source]

Test pass through of xarray persist.

class satpy.tests.test_scene.TestSceneResampling[source]

Bases: object

Test resampling a Scene to another Scene object.

setup_method()[source]

Set config_path to point to test ‘etc’ directory.

teardown_method()[source]

Restore previous ‘config_path’ setting.

test_comp_loading_after_resampling_existing_sensor()[source]

Test requesting a composite after resampling.

test_comp_loading_after_resampling_new_sensor()[source]

Test requesting a composite after resampling when the sensor composites weren’t loaded before.

test_comp_loading_multisensor_composite_created_user()[source]

Test that multisensor composite can be created manually.

Test that if the user has created datasets “manually”, that multi-sensor composites provided can still be read.

test_comps_need_resampling_optional_mod_deps()[source]

Test that a composite with complex dependencies.

This is specifically testing the case where a compositor depends on multiple resolution prerequisites which themselves are composites. These sub-composites depend on data with a modifier that only has optional dependencies. This is a very specific use case and is the simplest way to present the problem (so far).

The general issue is that the Scene loading creates the “ds13” dataset which already has one modifier on it. The “comp27” composite requires resampling so its 4 prerequisites + the requested “ds13” (from the reader which includes mod1 modifier) remain. If the DependencyTree is not copied properly in this situation then the new Scene object will have the composite dependencies without resolution in its dep tree, but have the DataIDs with the resolution in the dataset dictionary. This all results in the Scene trying to regenerate composite dependencies that aren’t needed which fail.

test_no_generate_comp10(rs)[source]

Test generating a composite after loading.

test_resample_ancillary()[source]

Test that the Scene reducing data does not affect final output.

test_resample_multi_ancillary()[source]

Test that multiple ancillary variables are retained after resampling.

This test corresponds to GH#2329

test_resample_reduce_data()[source]

Test that the Scene reducing data does not affect final output.

test_resample_reduce_data_toggle(rs)[source]

Test that the Scene can be reduced or not reduced during resampling.

test_resample_scene_copy(rs, datasets)[source]

Test that the Scene is properly copied during resampling.

The Scene that is created as a copy of the original Scene should not be able to affect the original Scene object.

test_resample_scene_preserves_requested_dependencies(rs)[source]

Test that the Scene is properly copied during resampling.

The Scene that is created as a copy of the original Scene should not be able to affect the original Scene object.

class satpy.tests.test_scene.TestSceneSaving(methodName='runTest')[source]

Bases: TestCase

Test the Scene’s saving method.

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 temporary directory to save files to.

tearDown()[source]

Remove the temporary directory created for a test.

test_save_dataset_default()[source]

Save a dataset using ‘save_dataset’.

test_save_datasets_bad_writer()[source]

Save a dataset using ‘save_datasets’ and a bad writer.

test_save_datasets_by_ext()[source]

Save a dataset using ‘save_datasets’ with ‘filename’.

test_save_datasets_default()[source]

Save a dataset using ‘save_datasets’.

test_save_datasets_missing_wishlist()[source]

Calling ‘save_datasets’ with no valid datasets.

class satpy.tests.test_scene.TestSceneSerialization[source]

Bases: object

Test the Scene serialization.

setup_method()[source]

Set config_path to point to test ‘etc’ directory.

teardown_method()[source]

Restore previous ‘config_path’ setting.

test_serialization_with_readers_and_data_arr()[source]

Test that dask can serialize a Scene with readers.