You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have SICDs from all over the place (inland, littoral, ocean, ...). When doing geolocation, we want the best possible accuracy and specify a DEM source for image_to_ground operations. When our imagery is not near land we get a ton of warnings from the below code as there is not DEM data available.
msg='Missing expected DEM files for squares with lower left lat/lon corner {}'.format(missing_boxes)
For us this is a totally expected situation. There appears to be a missing_error option in DTEDList to specify that you want this elevated to an error, but we'd like the opposite, for it to be silenced.
Would it be reasonable to change missing_error to missing_action with options of ('error', 'warning', 'silent') with the default being the existing warning?
The text was updated successfully, but these errors were encountered:
Thanks for writing this up! I too find the presence of missing_error in the interface and its behavior a bit odd. That said, I would be hesitant to change/complicate an interface if there is a workable resolution that is possibly extensible to other logging records throughout SarPy. Is filtering the logging a feasible approach for your use case?
filter logging stubs
# module_with_warning.pyimportlogginglogger=logging.getLogger(__name__)
deffunc(msg):
logger.warning(f'Missing expected DEM files for squares with lower left\n{msg}\n')
# main.pyimportcontextlibimportloggingimportmodule_with_warning@contextlib.contextmanagerdeftemp_filter(logger, filt):
try:
logger.addFilter(filt)
yieldloggerfinally:
logger.removeFilter(filt)
defsuppress_missing_dem_warning(rec):
returnnot (rec.levelname=='WARNING'andrec.msg.startswith('Missing expected DEM files for squares'))
module_with_warning.func('This warning is not suppressed')
withtemp_filter(logging.getLogger('module_with_warning'), suppress_missing_dem_warning):
module_with_warning.func('This warning IS suppressed')
module_with_warning.func('This warning is back to not being suppressed')
python main.py
Missing expected DEM files for squares with lower left
This warning is not suppressed
Missing expected DEM files for squares with lower left
This warning is back to not being suppressed
Moving forward, we may also consider using warnings.warn which are easier to temporarily suppress
We have SICDs from all over the place (inland, littoral, ocean, ...). When doing geolocation, we want the best possible accuracy and specify a DEM source for
image_to_ground
operations. When our imagery is not near land we get a ton of warnings from the below code as there is not DEM data available.sarpy/sarpy/io/DEM/DTED.py
Line 248 in 11d19a0
For us this is a totally expected situation. There appears to be a
missing_error
option inDTEDList
to specify that you want this elevated to an error, but we'd like the opposite, for it to be silenced.Would it be reasonable to change
missing_error
tomissing_action
with options of ('error', 'warning', 'silent') with the default being the existing warning?The text was updated successfully, but these errors were encountered: