Adding progress bar to forward gravity calculation of prisms
See original GitHub issueDescription of the desired feature:
During a call to prism.gravity
(or prism_layer.gravity
) it would be great to have a progress bar which updates as the calculations advance through the gravity observation points (coordinates
) . @LL-Geo suggested the numba_progress
package, which seems to be a good fit. Looking through harmonica.forward.prisms.py
, I assume implementing this feature would be done within the jit_prism_gravity
function, and when calling the function, users would use something along the lines of:
with ProgressBar(total=max_iter) as numba_progress:
topo_prisms.prism_layer.gravity(
coordinates=(df_grav.x, df_grav.y, df_grav.z),
field = 'g_z',
progress=numba_progress)
Are you willing to help implement and maintain this feature?
Yes I’m willing to try, but will likely need some assistance since it’s my first code contribution, and I’m unfamiliar with numba_progress.
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:7 (7 by maintainers)
Top Results From Across the Web
How to Make a Progress Bar - Gravity Forms - YouTube
Need a multi-step form? Gravity Forms can do that! Here's a link to purchase Gravity Forms for the best WordPress forms builder!
Read more >Gravity Forms Progress Text and Progress Bar - Tutorial
With the calculation and progress bar options in GFChart you can do that or with using the Count Add-on.
Read more >How to Make a Gravity Forms Progress Bar
Learn how to create a visually-appealing, animated Gravity Forms progress bar in WordPress the easy way using Gravity Perks.
Read more >gform_progress_bar - Gravity Forms Documentation
Description. Use this filter to modify or replace the default Gravity Forms progress bar (for multi-page forms).
Read more >GM-SYS User's Guide
Because gravity and magnetic calculations are non-linear, the calculations use an iterative process. The forward calculation equations are ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks for the suggestions! I have it working and everything seems alright, except if called with
parallel=False
then the progress bar only gives 0% and 100%, with no intermediate progress. Not sure why this is happening, but sinceparallel
defaults toTrue
then maybe it’s no big deal.Here is an example without the progress bar, which took 1m 28.2s :
And an example with
progressbar=True
, which took 1min 34.6s:In the
prism.py
file, I’ve added the following before the dispatcher call:And the following after the dispacher call:
And this is the updated function:
Is the next step to open a pull request to implement this?
This looks great! Thanks @mdtanker for the idea! 🥇
Actually I was thinking that we don’t need to expose the
ProgressBar
to the user, nor ask them to pass aProgressBar
instance as argument. Instead we can add aprogressbar
flag toprism_gravity
(like the one we have inpooch.retrieve
https://www.fatiando.org/pooch/latest/api/generated/pooch.retrieve.html#pooch.retrieve) and initialize aProgressBar
inside the function, which will be passed to the jitted functions down the road.So, your last example would look like this:
Since
numba-progress
will be an optional dependency, theprogressbar
should beFalse
by default and the jitted functions should be able to work even if noProgressBar
is being passed to them.