def test_select_gridded_task_generator_from_extenal_geojson(tmpdir):
    shapefile = tmpdir.join('myfile.geojson')
    shapefile.write(json.dumps(TEST_GEOJSON))
    input_region = {'from_file': str(shapefile)}
    task_generator = select_task_generator(input_region, EXAMPLE_STORAGE, None)

    assert isinstance(task_generator, GriddedTaskGenerator)
def test_non_gridded_task_generator_when_specifying_spatial_extents():
    input_region = {
        'crs': 'EPSG:4326',
        'latitude': [-33, -34],
        'longitude': [147.1, 147.9]
    }
    task_generator = select_task_generator(input_region, None, None)

    assert isinstance(task_generator, NonGriddedTaskGenerator)
Esempio n. 3
0
    def __init__(self, config, index=None):
        """
        Create a StatsApp to run a processing job, based on a configuration dict.
        """
        config = normalize_config(config)

        #: Dictionary containing the configuration
        self.config_file = config

        #: Description of output file format
        self.storage = config['storage']

        #: Definition of source products, including their name, which variables to pull from them, and
        #: a specification of any masking that should be applied.
        self.sources = config['sources']

        #: List of filenames and statistical methods used, describing what the outputs of the run will be.
        self.output_product_specs = config['output_products']

        #: Base directory to write output files to.
        #: Files may be created in a sub-directory, depending on the configuration of the
        #: :attr:`output_driver`.
        self.location = config['location']

        #: How to slice a task up spatially to to fit into memory.
        self.computation = config['computation']

        #: Define filter product to accept all derive product attributes
        self.filter_product = config['filter_product']

        #: An iterable of date ranges.
        self.date_ranges = _configure_date_ranges(config, index=index)

        #: Generates tasks to compute statistics. These tasks should be :class:`StatsTask` objects
        #: and will define spatial and temporal boundaries, as well as statistical operations to be run.
        self.task_generator = select_task_generator(config['input_region'],
                                                    self.storage,
                                                    self.filter_product)

        #: A class which knows how to create and write out data to a permanent storage format.
        #: Implements :class:`.output_drivers.OutputDriver`.
        self.output_driver = _prepare_output_driver(self.storage)

        self.global_attributes = config['global_attributes']
        self.var_attributes = config['var_attributes']

        self.validate()
def test_gridded_task_generation_when_inline_geojson():
    input_region = {'geometry': TEST_GEOJSON['features'][0]['geometry']}
    task_generator = select_task_generator(input_region, EXAMPLE_STORAGE, None)

    assert isinstance(task_generator, GriddedTaskGenerator)
def test_gridded_task_generation_when_empty_input_region():
    input_region = {}
    task_generator = select_task_generator(input_region, EXAMPLE_STORAGE, None)

    assert isinstance(task_generator, GriddedTaskGenerator)