Giter Club home page Giter Club logo

bdc-collectors's Introduction

Collectors Extension for Brazil Data Cube Applications and Services

Software License

Documentation Status

Software Life Cycle

Release

Join us at Discord

About

BDC-Collectors is a Flask extension for Brazil Data Cube to collect data from multiple providers.

Other applications can also define custom collectors using Python entry point in setup.py. See the usage documentation on how to take advantage of this package.

Installation

See INSTALL.rst.

Usage

See USAGE.rst.

Developer Documentation

See https://bdc-collectors.readthedocs.io/en/latest.

License

Copyright (C) 2022 INPE.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

bdc-collectors's People

Contributors

queirozws avatar raphaelrpl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

bdc-collectors's Issues

Fix landsat SR collections path

Currently, its points to Collection/Year-Month/PathRow/Scene_id. It should use the following syntax: Collection/Version/path/row/year/scene_id

Bug in parser Landsat-4 scenes

The following error occurs when trying to parse Landsat-4 (LANDSAT_TM_C1):

File "/home/user/bdc-collectors/bdc_collectors/usgs/parser.py", line 29, in __init__
  raise RuntimeError(f'Invalid Landsat scene {scene_id}')
RuntimeError: Invalid Landsat scene LT04_L1TP_220068_19880927_20170205_01_T1

Add function to list assets of a collection

Right now, we have get_files which returns all raster files in dir. We should have a function which results other essential files:

Landsat - MTL, ANG, etc.
Sentinel - MTD, AOT, etc.

Drop flask requirement

Since this module does not strict require Flask, we should consider to remove it from install_requires.

Improve description for custom collector/provider

We should improve the documentation in how to create custom providers and attach it into collectors. It should contain the following entries:

  • Add example for module initialization and class for this
  • brief entrypoint management and how it is loaded by bdc-collectors

For example, consider an extension of current provider SciHub named MyProvider which uses different api location. You may have few ways to use this

  • Change runtime parameter api_url:
from bdc_collectors.scihub import SciHub

catalog = SciHub(username="user", password="pass", api_url="https://my-url-provider-hub")
catalog.search(...)

# or
# from bdc_collectors.ext import CollectorExtension
# ext = CollectorExtension(app)  # flask_app
# catalog = ext.get_provider("SciHub")(username="user", password="pass", api_url="https://my-url-provider-hub")
  • Custom Provider named MyProvider (in bdc-collectors bdc_collectors/my_provider/__init__.py or in other github repo):
from typing import Type

from ..base import BaseCollection
from ..scihub import SciHub

def init_provider():
    return dict(MyProvider=MyProviderAPI)


class MyProviderAPI(SciHub):
    def __init__(self, *args, **kwargs):
        kwargs.setdefault("api_url", "https://my-url-provider-hub")
        super(MyProviderAPI, self).__init__(*args, **kwargs)
    def get_collector(self, collection: str) -> Type[BaseCollection]:
        # ... logic for custom data collection
        return super().get_collector(collection) # optional

Register in setup.py the entrypoint for loading this provider:

entry_points={
        ...,
        'bdc_collectors.providers': [
            ...  # other providers
            'my_provider = bdc_collectors.my_provider'
        ]
}

and use it with:

from bdc_collectors.ext import CollectorExtension
ext = CollectorExtension(app)  # flask_app
catalog = ext.get_provider("MyProvider")(username="user", password="pass")

Bug related day/night indicator in provider USGS - landsat c2 l2

We have noticed that the EarthExplorer API not providing anymore the filter Day/Night indicator flag for Landsat C2 L2. I think we should consider to set as optional and set it only if its provided by default.

def _check_day_indicator(self, query, options, **kwargs):
"""Check the dataset Day/Night Indicator.
By default, the new USGS API display the products day/night indicate as All.
For Brazil Data Cube Context, it should only display the 'Day'.
You can skip this step just giving the parameter::
# Using BDC Alias (Same values supported by USGS API - Day/Night/All)
dict(day_night_indicator='Day')
# or the entire USGS API request
dict(
sceneFilter=dict(
metadataFilter(
# ... field criteria
)
)
)
"""
day_night_indicator = kwargs.get('day_night_indicator', 'Day')
day_night_filter_id = self._get_filter(dataset=query, context='Day/Night Indicator')
# When no filter specified or no meta filter for Day/Night indicator, use day only.
if len(options['sceneFilter']['metadataFilter']['childFilters']) == 0 or \
not any([_filter for _filter in options['sceneFilter']['metadataFilter']['childFilters'] if
_filter['filterId'] == day_night_filter_id]):
day_night_filter = self._criteria(day_night_indicator, filter_type='value', field_id=day_night_filter_id)
options['sceneFilter']['metadataFilter']['childFilters'].append(day_night_filter)
return options

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.