Exemplo n.º 1
0
 def test_parse_collection_arg(self):
     """ Collection given. """
     coll = autils.parse_collection_arg({'collection': 'XXX'},
                                        required=True)
     assert coll is not None
     assert coll == 'XXX'
     coll2 = autils.parse_collection_arg({'collection': 'horde'},
                                         required=True)
     assert coll2 is not None
     assert coll2 == 'horde'
Exemplo n.º 2
0
def query_coordinates (args):
    """
    Return some metadata for images which contain the given point.
    """
    co_args = au.parse_cutout_args(args)        # get coordinates
    collection = au.parse_collection_arg(args)  # optional collection restriction
    filt = au.parse_filter_arg(args)            # optional filter restriction
    return jsonify(imgr.query_coordinates(co_args, collection=collection, filt=filt))
Exemplo n.º 3
0
def fetch_cutout_by_filter (args):
    """ Make and return an image cutout for a filtered image.
        The band is specified by the required 'filter' argument. """

    # parse the parameters for the cutout
    co_args = au.parse_cutout_args(args)
    filt = au.parse_filter_arg(args, required=True)  # test for required filter
    collection = au.parse_collection_arg(args)
    return imgr.get_image_or_cutout(co_args, filt=filt, collection=collection)
Exemplo n.º 4
0
def fetch_cutout (args):
    """
    Return an image cutout. if cutout size is not specified, return the entire image.
    """
    # parse the parameters for the cutout
    co_args = au.parse_cutout_args(args)
    collection = au.parse_collection_arg(args)
    filt = au.parse_filter_arg(args)
    return imgr.get_image_or_cutout(co_args, filt=filt, collection=collection)
Exemplo n.º 5
0
def fetch_image_by_filter (args):
    """ Fetch a specific image by filter/collection. """
    filt = au.parse_filter_arg(args, required=True)  # get required filter or error
    collection = au.parse_collection_arg(args)
    istream = imgr.fetch_image_by_filter(filt, collection=collection)
    if (istream is not None):
        return istream
    else:
        coll = f"and collection '{collection}'" if (collection) else ''
        errMsg = f"Image with filter '{filt}' {coll} not found in database"
        current_app.logger.error(errMsg)
        raise exceptions.ImageNotFound(errMsg)
Exemplo n.º 6
0
def image_metadata_by_collection (args):
    """ Return image metadata for all images in a specific collection. """
    collection = au.parse_collection_arg(args, required=True)  # get required collection or error
    return jsonify(imgr.image_metadata_by_collection(collection))
Exemplo n.º 7
0
def query_image (args):
    """ List images which meet the given filter and collection criteria. """
    collection = au.parse_collection_arg(args)    # optional collection restriction
    filt = au.parse_filter_arg(args)              # optional filter restriction
    return jsonify(imgr.query_image(collection=collection, filt=filt))
Exemplo n.º 8
0
 def test_parse_collection_arg_none(self):
     """ None given, but not required. """
     coll = autils.parse_collection_arg({'collection': None})
     assert coll is None
Exemplo n.º 9
0
def list_filters (args):
    """ List image filters found in the image metadata table. """
    collection = au.parse_collection_arg(args)    # optional collection restriction
    return jsonify(imgr.list_filters(collection=collection))
Exemplo n.º 10
0
 def test_parse_collection_arg_empty_req2(self):
     """ Empty collection given and collection required. """
     with pytest.raises(RequestException, match=self.coll_emsg) as reqex:
         autils.parse_collection_arg({'coll': '  '}, required=True)
Exemplo n.º 11
0
 def test_parse_collection_arg_none_req(self):
     """ None given and collection required. """
     with pytest.raises(RequestException, match=self.coll_emsg) as reqex:
         autils.parse_collection_arg({'collection': None}, required=True)
Exemplo n.º 12
0
 def test_parse_collection_arg_nocoll_req(self):
     """ No collection argument and collection required. """
     with pytest.raises(RequestException, match=self.coll_emsg) as reqex:
         autils.parse_collection_arg({}, required=True)
Exemplo n.º 13
0
 def test_parse_collection_arg_empty2(self):
     """ Empty coll given, but not required. """
     coll = autils.parse_collection_arg({'coll': '  '})
     assert coll is None
Exemplo n.º 14
0
def image_metadata_by_filter (args):
    """ Return image metadata for all images with a specific filter/collection. """
    filt = au.parse_filter_arg(args, required=True)  # get required filter or error
    collection = au.parse_collection_arg(args)       # optional collection restriction
    return jsonify(imgr.image_metadata_by_filter(filt, collection=collection))
Exemplo n.º 15
0
def list_image_paths (args):
    """ List paths to FITS images from the image metadata table. """
    collection = au.parse_collection_arg(args)    # optional collection restriction
    return jsonify(imgr.list_image_paths(collection=collection))
Exemplo n.º 16
0
def image_metadata_by_path (args):
    """ Return image metadata for all images with a specific image path. """
    ipath = au.parse_ipath_arg(args, required=True)  # get required image path or error
    collection = au.parse_collection_arg(args)       # optional collection restriction
    return jsonify(imgr.image_metadata_by_path(ipath, collection=collection))
Exemplo n.º 17
0
 def test_parse_collection_arg_nocoll(self):
     """ No collection given, but not required. """
     coll = autils.parse_collection_arg({})
     assert coll is None