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'
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))
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)
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)
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)
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))
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))
def test_parse_collection_arg_none(self): """ None given, but not required. """ coll = autils.parse_collection_arg({'collection': None}) assert coll is None
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))
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)
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)
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)
def test_parse_collection_arg_empty2(self): """ Empty coll given, but not required. """ coll = autils.parse_collection_arg({'coll': ' '}) assert coll is None
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))
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))
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))
def test_parse_collection_arg_nocoll(self): """ No collection given, but not required. """ coll = autils.parse_collection_arg({}) assert coll is None