From 7e371004f9dbba284a4b06b493a32f4944a35258 Mon Sep 17 00:00:00 2001 From: Jesse Mapel <jmapel@usgs.gov> Date: Fri, 25 Oct 2019 16:31:53 -0700 Subject: [PATCH] Added verbose for creating a csm sensor --- knoten/csm.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/knoten/csm.py b/knoten/csm.py index d4c80ae..e210558 100644 --- a/knoten/csm.py +++ b/knoten/csm.py @@ -74,7 +74,7 @@ def create_camera(label, url='http://pfeffer.wr.usgs.gov/api/1.0/pds/'): model = plugin.constructModelFromISD(isd, model_name) return model -def create_csm(image): +def create_csm(image, verbose=False): """ Given an image file create a Community Sensor Model. @@ -82,6 +82,8 @@ def create_csm(image): ---------- image : str The image filename to create a CSM for + verbose : bool + Print information about which plugins and models were attempted Returns ------- @@ -91,11 +93,26 @@ def create_csm(image): isd = csmapi.Isd(image) plugins = csmapi.Plugin.getList() for plugin in plugins: + if verbose: + print(f'Trying plugin {plugin.getPluginName()}') num_models = plugin.getNumModels() for model_index in range(num_models): model_name = plugin.getModelName(model_index) - if plugin.canModelBeConstructedFromISD(isd, model_name): + warnings = csmapi.WarningList() + if verbose: + print(f'Trying model {plugin.getModelName(model_index)}') + if plugin.canModelBeConstructedFromISD(isd, model_name, warnings): + camera_warnings = csmapi.WarningList() + camera = plugin.constructModelFromISD(isd, model_name, camera_warnings) + if verbose: + for warning in camera_warnings: + print(f'Warning in function {warning.getFunction()}: "{warning.getMessage()}"') + print('Success!') return plugin.constructModelFromISD(isd, model_name) + elif verbose: + for warning in warnings: + print(f'Warning in function {warning.getFunction()}: "{warning.getMessage()}"') + print('Failed!') @singledispatch def generate_ground_point(dem, image_pt, camera): -- GitLab