Exemplo n.º 1
0
    def __init__(self, catalog_id, bbox=None):
        self._interface = Auth()
        self.catalog_id = catalog_id
        self._get_image()
        self.metadata = self._get_metadata()
        self.shape = self.image.shape
        self.geom = self._get_geometry()
        self.xmin, self.ymin, self.xmax, self.ymax = self.geom.bounds
        self.cell_width = (self.xmax - self.xmin) / self.shape[1]
        self.cell_height = (self.ymax - self.ymin) / self.shape[0]
        self.bbox = bbox

        if self.bbox is not None:
            # find which cells intersect the bbox
            bbox_xmin, bbox_ymin, bbox_xmax, bbox_ymax = self.bbox
            window_xmin = int(
                np.floor((bbox_xmin - self.xmin) / self.cell_width))
            window_xmax = int(
                np.ceil((bbox_xmax - self.xmin) / self.cell_width))
            window_ymax = self.shape[0] - int(
                np.floor((bbox_ymin - self.ymin) / self.cell_height))
            window_ymin = self.shape[0] - int(
                np.ceil((bbox_ymax - self.ymin) / self.cell_height))
            self.window = ((window_ymin, window_ymax), (window_xmin,
                                                        window_xmax))
        else:
            self.window = None
Exemplo n.º 2
0
    def __init__(self, **kwargs):
        interface = Auth(**kwargs)
        self.gbdx_connection = interface.gbdx_connection
        self.root_url = interface.root_url
        self.logger = interface.logger

        # create and store an instance of the GBDX s3 client
        self.s3 = S3()

        # create and store an instance of the GBDX Ordering Client
        self.ordering = Ordering()

        # create and store an instance of the GBDX Catalog Client
        self.catalog = Catalog()

        # create and store an instance of the GBDX Workflow Client
        self.workflow = Workflow()

        # create and store an instance of the Idaho Client
        self.idaho = Idaho()

        self.vectors = Vectors()

        self.catalog_image = CatalogImage
        self.idaho_image = IdahoImage
        self.landsat_image = LandsatImage
        self.sentinel2 = Sentinel2
        self.tms_image = TmsImage
        self.dem_image = DemImage
        self.wv03_vnir = WV03_VNIR
        self.wv02 = WV02
        self.ge01 = GE01
        self.s3_image = S3Image

        self.task_registry = TaskRegistry()
Exemplo n.º 3
0
    def __init__(self, **kwargs):
        interface = Auth(**kwargs)
        self.gbdx_connection = interface.gbdx_connection
        self.root_url = interface.root_url
        self.logger = interface.logger

        # create and store an instance of the GBDX s3 client
        self.s3 = S3()

        # create and store an instance of the GBDX Ordering Client
        self.ordering = Ordering()

        # create and store an instance of the GBDX Catalog Client
        self.catalog = Catalog()

        # create and store an instance of the GBDX Workflow Client
        self.workflow = Workflow()

        # create and store an instance of the Idaho Client
        self.idaho = Idaho()

        self.vectors = Vectors()

        self.catalog_image = CatalogImage
        self.idaho_image = IdahoImage

        self.task_registry = TaskRegistry()
Exemplo n.º 4
0
    def __init__(self,
                 cat_id,
                 band_type="MS",
                 node="toa_reflectance",
                 **kwargs):
        self.interface = Auth()
        self.vectors = Vectors()
        self._gid = cat_id
        self._band_type = band_type
        self._pansharpen = kwargs.get('pansharpen', False)
        self._acomp = kwargs.get('acomp', False)
        if self._pansharpen:
            self._node_id = 'pansharpened'
        else:
            self._node_id = node
        self._level = kwargs.get('level', 0)
        if 'proj' in kwargs:
            self._proj = kwargs['proj']
        if '_ipe_graphs' in kwargs:
            self._ipe_graphs = kwargs['_ipe_graphs']
        else:
            self._ipe_graphs = self._init_graphs()

        super(CatalogImage, self).__init__(self._ipe_graphs,
                                           cat_id,
                                           node=self._node_id,
                                           **kwargs)
Exemplo n.º 5
0
 def __init__(self, graph_id, node_id=None, **kwargs):
     assert graph_id is not None
     self._rda_id = graph_id
     self._node_id = node_id
     self._interface = Auth()
     self._rda_meta = None
     self._graph = None
     self._nid = None
Exemplo n.º 6
0
    def __init__(self, **kwargs):
        '''Instantiate the GBDX Ordering Interface

           Returns:
               An instance of the Ordering interface.
        '''
        interface = Auth(**kwargs)
        self.base_url = '%s/orders/v2' % interface.root_url
        self.gbdx_connection = interface.gbdx_connection
        self.logger = interface.logger
Exemplo n.º 7
0
    def __init__(self, **kwargs):
        ''' Construct the Catalog interface class

        Returns:
            An instance of the Catalog interface class.
        '''
        interface = Auth(**kwargs)
        self.base_url = '%s/catalog/v2' % interface.root_url
        self.gbdx_connection = interface.gbdx_connection
        self.logger = interface.logger
Exemplo n.º 8
0
 def __init__(self, name, node_id=None, **kwargs):
     self._template_name = name
     self._template_id = None
     self._rda_id = None
     self._params = kwargs
     self._node_id = node_id
     self._interface = Auth()
     self._rda_meta = None
     self._rda_stats = None
     self._graph = None
     self._nid = None
Exemplo n.º 9
0
    def __init__(self, **kwargs):
        """ Construct the Idaho interface class.

            Returns:
                An instance of the Idaho interface class.
        """
        interface = Auth(**kwargs)
        self.base_url = '%s/catalog/v2' % interface.root_url
        self.gbdx_connection = interface.gbdx_connection
        self.catalog = Catalog()
        self.logger = interface.logger
Exemplo n.º 10
0
 def __init__(self, template_id, node_id=None, **kwargs):
     assert template_id is not None
     self._template_id = template_id
     self._rda_id = template_id
     self._params = kwargs
     self._node_id = node_id
     self._interface = Auth()
     self._rda_meta = None
     self._rda_stats = None
     self._graph = None
     self._nid = None
Exemplo n.º 11
0
    def __init__(self, **kwargs):
        interface = Auth(**kwargs)
        self._base_url = '%s/workflows/v1/tasks' % interface.root_url

        # store a reference to the GBDX Connection
        self.gbdx_connection = interface.gbdx_connection

        # store a ref to the s3 interface
        self.s3 = S3()

        # the logger
        self.logger = interface.logger
Exemplo n.º 12
0
    def __init__(self, **kwargs):
        ''' Construct the Vectors interface class

        Returns:
            An instance of the Vectors interface class.
        '''
        interface = Auth(**kwargs)
        self.gbdx_connection = interface.gbdx_connection
        self.logger = interface.logger
        self.query_url = 'https://vector.geobigdata.io/insight-vector/api/vectors/query/paging'
        self.page_url = 'https://vector.geobigdata.io/insight-vector/api/vectors/paging'
        self.get_url = 'https://vector.geobigdata.io/insight-vector/api/vector/%s/'
        self.create_url = 'https://vector.geobigdata.io/insight-vector/api/vectors'
Exemplo n.º 13
0
def is_ordered(cat_id):
    """
      Checks to see if a CatalogID has been ordered or not.

      Args:
        catalogID (str): The catalog ID from the platform catalog.
      Returns:
        ordered (bool): Whether or not the image has been ordered
    """
    url = 'https://rda.geobigdata.io/v1/stripMetadata/{}'.format(cat_id)
    auth = Auth()
    r = _req_with_retries(auth.gbdx_connection, url)
    if r is not None:
        return r.status_code == 200
    return False
Exemplo n.º 14
0
    def __init__(self, **kwargs):
        '''
        Construct an instance of an AnswerFactory Recipe

        Args:
            **kwargs

        Returns:
            An instance of a Recipe.

        '''
        interface = Auth(**kwargs)
        self.base_url = 'https://vector.geobigdata.io/answer-factory-recipe-service/api'
        self.gbdx_connection = interface.gbdx_connection
        self.logger = interface.logger
Exemplo n.º 15
0
 def __init__(self, ipe_graph, gid, node="toa_reflectance", **kwargs):
     self.interface = Auth()
     self._gid = gid
     self._node_id = node
     self._dtype = kwargs.get("dtype", "float32")
     if self._node_id == "pansharpened":
         self._dtype = "uint16"
     if "proj" in kwargs:
         self._proj = kwargs["proj"]
     self._ipe_graphs = ipe_graph
     self._tile_size = kwargs.get("tile_size", 256)
     self._cfg = self._config_dask()
     super(IpeImage, self).__init__(**self._cfg)
     bounds = self._parse_geoms(**kwargs)
     if bounds is not None:
         _cfg = self._aoi_config(bounds)
         super(IpeImage, self).__init__(**_cfg)
Exemplo n.º 16
0
def can_acomp(cat_id):
    """
      Checks to see if a CatalogID can be atmos. compensated or not.

      Args:
        catalogID (str): The catalog ID from the platform catalog.
      Returns:
        available (bool): Whether or not the image can be acomp'd
    """
    url = 'https://rda.geobigdata.io/v1/stripMetadata/{}/capabilities'.format(cat_id)
    auth = Auth()
    r = _req_with_retries(auth.gbdx_connection, url)
    try: 
        data = r.json()
        return data['acompVersion'] is not None
    except:
        return False
Exemplo n.º 17
0
    def __init__(self, **kwargs):
        '''Instantiate the s3 interface

        Returns:
            An instance of gbdxtools.S3.

        '''
        interface = Auth(**kwargs)
        self.base_url = '%s/s3creds/v1' % interface.root_url

        # store a ref to the GBDX connection
        self.gbdx_connection = interface.gbdx_connection

        # store a ref to the logger
        self.logger = interface.logger

        self._info = None
Exemplo n.º 18
0
    def __init__(self, **kwargs):
        """Construct the Workflow instance

        Returns:
            An instance of the Workflow class.
        """
        interface = Auth(**kwargs)
        self.base_url = '%s/workflows/v1' % interface.root_url
        self.workflows_url = '%s/workflows' % self.base_url

        # store a reference to the GBDX Connection
        self.gbdx_connection = interface.gbdx_connection

        # store a ref to the s3 interface
        self.s3 = S3()

        # the logger
        self.logger = interface.logger
Exemplo n.º 19
0
def is_available(cat_id):
    """
      Checks to see if a CatalogID is ingested in RDA and available to GBDXtools

      Args:
        catalogID (str): The catalog ID from the platform catalog.
      Returns:
        (bool): Whether or not the image is available in RDA
    """
    # checking for RDA metadata is the most authorative way to make
    # sure an image is available from RDA

    # TODO align with metadata fetch

    url = 'https://rda.geobigdata.io/v1/stripMetadata/{}'.format(cat_id)
    auth = Auth()
    r = _req_with_retries(auth.gbdx_connection, url)
    if r is not None:
        return r.status_code == 200
    return False
Exemplo n.º 20
0
def can_acomp(cat_id):
    """
    Checks to see if a CatalogID can be atmos. compensated or not.
    :cat_id (str): The catalog ID from the platform catalog.
    :return: available (bool): Whether or not the image can be acomp'd
    """
    url = 'https://rda.geobigdata.io/v1/stripMetadata/{}/capabilities'.format(
        cat_id)
    auth = Auth()
    r = _req_with_retries(auth.gbdx_connection, url)
    try:
        data = r.json()
        try:
            return data['acompVersion'] is not None
        except KeyError:
            if 'error' in data:
                if data['error'].startswith('Metadata not found'):
                    raise MissingMetadata(data['error'])
                raise Exception(data['error'])
    except Exception as e:
        # may need to handle some other errors
        raise e
Exemplo n.º 21
0
 def __getattr__(self, name):
     return Op(name=name, interface=Auth())
Exemplo n.º 22
0
 def __getattr__(self, name, **kwargs):
     return Op(name=name, interface=Auth(), **kwargs)