コード例 #1
0
    def _get_coverage(self):
        """
        Returns the coverage to be used for the importer
        """
        gdal_dataset = GDALGmlUtil.open_gdal_dataset_from_any_file(self.session.get_files())
        crs = gdal_dataset.get_crs()

        general_recipe = GeneralRecipe(self.session)
        global_metadata_fields = general_recipe._global_metadata_fields()
        local_metadata_fields = general_recipe._local_metadata_fields()

        sentence_evaluator = SentenceEvaluator(ExpressionEvaluatorFactory())

        gdal_coverage_converter = GdalToCoverageConverter(self.resumer, self.session.get_default_null_values(),
                                                          self.recipe_type, sentence_evaluator,
                                                          self.session.get_coverage_id(),
                                                          None, self.session.get_files(),
                                                          crs, None, None,
                                                          global_metadata_fields, local_metadata_fields,
                                                          None, None, general_recipe._metadata_type(),
                                                          None, None)

        coverage_slices = self._get_coverage_slices(crs, gdal_coverage_converter)
        fields = GdalRangeFieldsGenerator(gdal_dataset, self.options['band_names']).get_range_fields()

        global_metadata = None
        if len(coverage_slices) > 0:
            global_metadata = gdal_coverage_converter._generate_global_metadata(coverage_slices[0], self.evaluator_slice)

        coverage = Coverage(self.session.get_coverage_id(), coverage_slices, fields, gdal_dataset.get_crs(),
                            gdal_dataset.get_band_gdal_type(), self.options['tiling'], global_metadata)

        return coverage
コード例 #2
0
ファイル: recipe.py プロジェクト: christophenoel/rasdaman
    def _get_grib_coverage(self, recipe_type):
        """
        Returns a coverage that uses the grib slicer
        :param: string recipe_type the type of grib
        :rtype: master.importer.coverage.Coverage
        """
        crs = self._resolve_crs(self.options['coverage']['crs'])
        sentence_evaluator = SentenceEvaluator(ExpressionEvaluatorFactory())
        pixel_is_point = False
        if 'pixelIsPoint' in self.options['coverage']['slicer'] and self.options['coverage']['slicer']['pixelIsPoint']:
            pixel_is_point = True

        coverage = GRIBToCoverageConverter(self.resumer, self.session.default_null_values,
                                           recipe_type,
                                           sentence_evaluator, self.session.get_coverage_id(),
                                           self._read_bands(),
                                           self.session.get_files(), crs, self._read_axes(crs),
                                           self.options['tiling'], self._global_metadata_fields(),
                                           self._bands_metadata_fields(),
                                           self._local_metadata_fields(),
                                           self._axes_metadata_fields(),
                                           self._metadata_type(),
                                           self.options['coverage']['grid_coverage'], pixel_is_point,
                                           self.options['import_order']).to_coverage()

        return coverage
コード例 #3
0
ファイル: recipe.py プロジェクト: kalxas/rasdaman
    def _get_gdal_coverages(self, recipe_type):
        """
        Returns a list of coverage that uses the gdal slicer
        :param string: recipe_type the type of recipe
        :rtype: master.importer.coverage.Coverage
        """
        crs = self._resolve_crs(self.options['coverage']['crs'])
        sentence_evaluator = SentenceEvaluator(ExpressionEvaluatorFactory())

        input_files = self.session.get_files()
        user_axes = self._read_axes(crs)
        DEFAULT_NUMBER_GDAL_DIMENSIONS = 2
        self.__validate_data_bound_axes(user_axes, DEFAULT_NUMBER_GDAL_DIMENSIONS)

        coverages = GdalToCoverageConverter(self.resumer, self.session.default_null_values,
                                           recipe_type, sentence_evaluator, self.session.get_coverage_id(),
                                           self._read_bands(),
                                            input_files, crs, user_axes,
                                           self.options['tiling'], self._global_metadata_fields(),
                                           self._local_metadata_fields(),
                                           self._bands_metadata_fields(),
                                           self._axes_metadata_fields(),
                                           self._metadata_type(),
                                           self.options['coverage']['grid_coverage'],
                                           self.options['import_order'],
                                           self.session).to_coverages()
        return coverages
コード例 #4
0
ファイル: recipe.py プロジェクト: kalxas/rasdaman
    def _create_convertor(self, convertors, cov_id, crs_code, level, res):
        recipe_type = GdalToCoverageConverter.RECIPE_TYPE
        sentence_evaluator = SentenceEvaluator(ExpressionEvaluatorFactory())
        files = []
        crs = self._get_crs(crs_code)
        bands_metadata_fields = {}
        axis_metadata_fields = {}

        default_null_values = [self.DEFAULT_NULL_VALUE]

        return GdalToCoverageConverter(self.resumer,
                                       default_null_values,
                                       recipe_type, 
                                       sentence_evaluator, 
                                       cov_id, 
                                       self.BANDS[level][res],
                                       files, 
                                       crs,
                                       self._read_axes(crs),
                                       self.options['tiling'],
                                       self._global_metadata_fields(),
                                       self._local_metadata_fields(),
                                       bands_metadata_fields,
                                       axis_metadata_fields,
                                       self._metadata_type(),
                                       self.grid_cov,
                                       self.import_order,
                                       self.session)
コード例 #5
0
 def __init__(self):
     """
     The registry contains all the recipes available for the wcst import
     To add one please register it in the _init_registry method
     """
     self.registry = {}
     self._init_registry()
     self.sentence_evaluator = SentenceEvaluator(ExpressionEvaluatorFactory())
コード例 #6
0
    def _get_coverages(self):
        """
        Returns the list of coverages to be used for the importer
        """
        gdal_dataset = GDALGmlUtil.open_gdal_dataset_from_any_file(
            self.session.get_files())
        crs = CRSUtil.get_compound_crs(
            [self.options['time_crs'],
             gdal_dataset.get_crs()])

        general_recipe = GeneralRecipe(self.session)
        global_metadata_fields = general_recipe._global_metadata_fields()
        local_metadata_fields = general_recipe._local_metadata_fields()

        sentence_evaluator = SentenceEvaluator(ExpressionEvaluatorFactory())

        gdal_coverage_converter = GdalToCoverageConverter(
            self.resumer, self.session.get_default_null_values(),
            self.recipe_type,
            sentence_evaluator, self.session.get_coverage_id(), None,
            self.session.get_files(), crs, None, None,
            global_metadata_fields, local_metadata_fields, None, None,
            general_recipe._metadata_type(), None, None, self.session)

        coverage_slices_dict = self._get_coverage_slices(
            crs, gdal_coverage_converter)
        fields = GdalRangeFieldsGenerator(
            gdal_dataset, self.options['band_names']).get_range_fields()

        global_metadata = None
        if len(coverage_slices_dict["base"]) > 0:
            global_metadata = gdal_coverage_converter._generate_global_metadata(
                coverage_slices_dict["base"][0], self.evaluator_slice)

        results = []
        base_coverage_id = self.session.get_coverage_id()
        for key, value in coverage_slices_dict.items():
            if key == "base":
                # base coverage
                coverage = Coverage(base_coverage_id,
                                    coverage_slices_dict[key], fields, crs,
                                    gdal_dataset.get_band_gdal_type(),
                                    self.options['tiling'], global_metadata)
            else:
                # overview coverage (key = overview_index)
                coverage_id = create_coverage_id_for_overview(
                    base_coverage_id, key)
                coverage = Coverage(coverage_id, coverage_slices_dict[key],
                                    fields, crs,
                                    gdal_dataset.get_band_gdal_type(),
                                    self.options['tiling'], global_metadata,
                                    base_coverage_id, key)

            results.append(coverage)

        return results
コード例 #7
0
ファイル: recipe.py プロジェクト: javyxu/rasdaman
 def _get_gdal_coverage(self, recipe_type):
     """
     Returns a coverage that uses the gdal slicer
     :param string: recipe_type the type of recipe
     :rtype: master.importer.coverage.Coverage
     """
     crs = self._resolve_crs(self.options['coverage']['crs'])
     sentence_evaluator = SentenceEvaluator(ExpressionEvaluatorFactory())
     coverage = GdalToCoverageConverter(recipe_type, sentence_evaluator, self.session.get_coverage_id(),
                                        self._read_bands(),
                                        self.session.get_files(), crs, self._read_axes(crs),
                                        self.options['tiling'], self._global_metadata_fields(),
                                        self._local_metadata_fields(), self._bands_metadata_fields(),
                                        self._axes_metadata_fields(),
                                        self._metadata_type(),
                                        self.options['coverage']['grid_coverage']).to_coverage()
     return coverage
コード例 #8
0
    def _create_convertor(self, cov_id):
        recipe_type = GdalToCoverageConverter.RECIPE_TYPE
        sentence_evaluator = SentenceEvaluator(ExpressionEvaluatorFactory())
        files = []
        bands_metadata_fields = {}
        axis_metadata_fields = {}

        default_null_values = []

        if self.product == self.DEFAULT_PRODUCT:
            default_null_values = [self.DEFAULT_NULL_VALUE]

        return GdalToCoverageConverter(
            self.resumer, default_null_values, recipe_type,
            sentence_evaluator, cov_id, [self.BAND], files, self.crs,
            self._read_axes(self.crs), self.options['tiling'],
            self._global_metadata_fields(), self._local_metadata_fields(),
            bands_metadata_fields, axis_metadata_fields, self._metadata_type(),
            self.grid_cov, self.import_order)
コード例 #9
0
ファイル: recipe.py プロジェクト: javyxu/rasdaman
    def _get_netcdf_coverage(self, recipe_type):
        """
        Returns a coverage that uses the netcdf slicer
        :param: string recipe_type the type of netcdf
        :rtype: master.importer.coverage.Coverage
        """
        crs = self._resolve_crs(self.options['coverage']['crs'])
        sentence_evaluator = SentenceEvaluator(ExpressionEvaluatorFactory())
        # by default pixelIsPoint is not set to true in ingredient file
        pixel_is_point = False
        if 'pixelIsPoint' in self.options['coverage']['slicer'] and self.options['coverage']['slicer']['pixelIsPoint']:
            pixel_is_point = True

        coverage = NetcdfToCoverageConverter(recipe_type, sentence_evaluator, self.session.get_coverage_id(),
                                             self._read_bands(),
                                             self.session.get_files(), crs, self._read_axes(crs),
                                             self.options['tiling'], self._netcdf_global_metadata_fields(),
                                             self._local_metadata_fields(),
                                             self._netcdf_bands_metadata_fields(),
                                             self._netcdf_axes_metadata_fields(),
                                             self._metadata_type(),
                                             self.options['coverage']['grid_coverage'], pixel_is_point).to_coverage()
        return coverage
コード例 #10
0
ファイル: recipe.py プロジェクト: kalxas/rasdaman
    def _get_netcdf_coverage(self, recipe_type):
        """
        Returns a coverage that uses the netcdf slicer
        :param: string recipe_type the type of netcdf
        :rtype: master.importer.coverage.Coverage
        """
        crs = self._resolve_crs(self.options['coverage']['crs'])
        sentence_evaluator = SentenceEvaluator(ExpressionEvaluatorFactory())
        # by default pixelIsPoint is not set to true in ingredient file
        pixel_is_point = False
        if 'pixelIsPoint' in self.options['coverage']['slicer'] and self.options['coverage']['slicer']['pixelIsPoint']:
            pixel_is_point = True

        input_files = self.session.get_files()
        user_axes = self._read_axes(crs)
        bands = self._read_bands()
        first_band = bands[0]
        first_band_variable_identifier = first_band.identifier

        netCDF4 = import_netcdf4()
        # Get the number of dimensions of band variable to validate with number of axes specified in the ingredients file
        number_of_dimensions = len(netCDF4.Dataset(input_files[0], 'r').variables[first_band_variable_identifier].dimensions)
        self.__validate_data_bound_axes(user_axes, number_of_dimensions)

        coverage = NetcdfToCoverageConverter(self.resumer, self.session.default_null_values,
                                             recipe_type, sentence_evaluator, self.session.get_coverage_id(),
                                             bands,
                                             input_files, crs, user_axes,
                                             self.options['tiling'], self._global_metadata_fields(),
                                             self._local_metadata_fields(),
                                             self._netcdf_bands_metadata_fields(),
                                             self._netcdf_axes_metadata_fields(),
                                             self._metadata_type(),
                                             self.options['coverage']['grid_coverage'], pixel_is_point,
                                             self.options['import_order'],
                                             self.session).to_coverages()
        return coverage