sixty-north / segpy

A Python package for reading and writing SEG Y files.
Other
102 stars 54 forks source link

Progress bar #47

Closed pareantoine closed 7 years ago

pareantoine commented 7 years ago

Hi there,

Is the progress bar really implemented for the reader and writer? I've looked at the code and it doesn't seem to be much in there.

Thanks.

rob-smallshire commented 7 years ago

Segpy doesn't implement a progress "bar" as such. It's up to you to pass a function to the progress argument which segpy will call back with a number between 0.0 and 1.0 as work proceeds. Whether the function you pass displays a progress-bar, or doesn't something else, is up to you.

This has been implemented for the create_reader() function – you can try it by passing progress=print as a argument to create_reader(). The writer current accepts a progress argument, but doesn't yet invoke the callback. That's a legitimate shortcoming, so I'll leave this issue open to track it.

rob-smallshire commented 7 years ago

The documentation on the writer is also misleading, as it mentions "progress bar", so I understand the confusion this might cause. This also needs to be addressed.

rob-smallshire commented 7 years ago

Fixed in 03eece6a9cc9f44b51. I've improved the documentation, implemented progress callbacks for the writer, and added example usage in examples/loadsave.py.

pareantoine commented 7 years ago

Hi Rob,

The progress bar is returning an error if using a delegating dataset in write_segy:

File ".../writer.py", line 54, in write_segy num_traces = dataset.num_traces() File ".../dataset.py", line 125, in num_traces raise self._source.num_traces() TypeError: exceptions must derive from BaseException

I wonder if it's because in line 125 of dataset.py you wrote raise and not return?

Definitely works with "return" !

rob-smallshire commented 7 years ago

Ugh! Yes. That should definitely be return. That's what you get for late-night fixes! Sorry.