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
The function TerrainAttribute prints references to the screen when run. E.g. for the slope:
A Slope calculation (degrees)
C Horn, B.K.P., 1981. Hill shading and the reflectance map. Proceedings of the IEEE 69, 14–47. doi:10.1109/PROC.1981.11918
I understand the idea behind it, but it can become annoying when looping over many items, and trying to add a progress bar. I could not find any option to silent that print. Please let me know if there is a way, otherwise would it be possible to include this as an option?
Since the print is called from the C++ function, it does not seem possible to catch the stdout in Python directly. I tried for example this option and this option, without success. It works with a pure Python function though. So I don't think there is any way on my end to capture that output that comes from the C++ function.
The text was updated successfully, but these errors were encountered:
importosclassSilence:
"""A context manager that prevents shared C libraries from printing to console. Specifically, this was built to silence richdem."""def__init__(self):
self.stderr_fd=sys.stderr.fileno()
self.orig_fd=os.dup(self.stderr_fd)
self.null_fd=os.open(os.devnull, os.O_WRONLY)
def__enter__(self):
os.dup2(self.null_fd, self.stderr_fd)
def__exit__(self, type, value, traceback):
os.dup2(self.orig_fd, self.stderr_fd)
# Instantiating this once helps with performance.silence=Silence()
withsilence:
rd.TerrainAttribute()
The function
TerrainAttribute
prints references to the screen when run. E.g. for the slope:I understand the idea behind it, but it can become annoying when looping over many items, and trying to add a progress bar. I could not find any option to silent that print. Please let me know if there is a way, otherwise would it be possible to include this as an option?
Since the print is called from the C++ function, it does not seem possible to catch the stdout in Python directly. I tried for example this option and this option, without success. It works with a pure Python function though. So I don't think there is any way on my end to capture that output that comes from the C++ function.
The text was updated successfully, but these errors were encountered: