Skip to content
This repository has been archived by the owner on Dec 22, 2021. It is now read-only.

Finite-difference wave modeling with an object-oriented API (2nd attempt) #308

Closed
wants to merge 10 commits into from

Conversation

leouieda
Copy link
Member

@leouieda leouieda commented Aug 26, 2016

Fixes #70

This is a retry at PR #137. I'll start fresh and take the best code and lessons learned from that PR to make this.

Defines a new API for the fatiando.seismic.wavefd module. You now interact with simulation classes instead of generator functions. The simulation data that was thrown away before is now kept in an HDF5 file. This adds the dependency of h5py but it's worth it. The class also knows how to produce an animation of the simulation. The video animation can be embedded into the Jupyter notebook.

As an added bonus, replaces the Cython time-stepping functions with numba equivalents without loss
in speed.

TODO

  • Option to set the sampling frequency. Would need to keep 2 frames (one before and one after) the desired sample time and do a linear interpolation to get the wavefield at that time. Possible implementation is to see how many iterations are required between each sample and keep the frames around the required number. This won't add to the cost of storage because I'm already keeping 2 frames at a time anyway.

Checklist:

  • Make tests for new code (at least 80% coverage)
  • Create/update docstrings
  • Include relevant equations and citations in docstrings
  • Docstrings follow the style conventions
  • Code follows PEP8 style conventions
  • Code and docs have been spellchecked
  • Include new dependencies in doc/install.rst, requirements.txt, environment.yml, ci/requirements-conda.txt and ci/requirements-pip.txt.
  • Documentation builds properly (run cd doc; make locally)
  • Changelog entry (leave for last to avoid conflicts)

This removes the compilation step and gives the same speed results.
Split into multiple files. Should work right now. Will populate with the
new classes later.
@leouieda leouieda changed the title Replace Cython timesteppers with numba Finite-difference wave modeling with an object-oriented API (2nd attempt) Aug 27, 2016
@leouieda
Copy link
Member Author

leouieda commented Sep 1, 2016

A possible way of not relying on h5py is to optionally use memory-mapped numpy arrays for the cache. It seems that HDF5 has it's problems and numpy.memmap arrays can be faster (but also larger on disk).

Update: using numpy memmaps might be a problem because they are difficult to resize when running the simulation a second time. Would have to implement it and see what the performance is like.

As given in the paper by Di Bartolo et al (2012).
Brought over the old classes and functions.
Adapted the Equivalent Staggered Grid of Di Bartolo et al. (2012) that
was implemented for the SH waves.
@eusoubrasileiro
Copy link
Contributor

eusoubrasileiro commented Sep 9, 2016

uow!!! I'm really going back to this ... esg acoustic, I think I can help on that I have done that for 3D here...

@leouieda
Copy link
Member Author

@eusoubrasileiro yep! I'm reusing a lot of your functions from the previous PRs. I have separated things a bit more. The wavelets go into a seismic/wavelet.py module and the FD stuff is in a seismic/wavefd package. All public classes are imported into seismic/__init__.py.

Here is an example that I'm using for my geophysics class: http:https://mybinder.org/repo/leouieda/geofisica2/notebooks/notebooks/1-ondas-sismicas.ipynb

I'm hopping to get this finished in October when I'll have some time off from work.

@eusoubrasileiro
Copy link
Contributor

interesting about the hdf5 problems... some of the suggestions on your link is to use numpy format *.npy I will try to take a deeper look in this soon.

The progressbar uses the stdout stream, which can't be pickled. So can't
use it with multiprocessing. Setting verbose=False should completely
bypass the progressbar.
leouieda added a commit that referenced this pull request Dec 16, 2016
Calculate lambda and mu Lamé parameters from the P and S velocities and
density. Functions transported from #308 with tests and added
documentation.
leouieda added a commit that referenced this pull request Dec 16, 2016
Calculate lambda and mu Lamé parameters from the P and S velocities and
density. Functions transported from #308 with tests and added
documentation.
leouieda added a commit that referenced this pull request Dec 17, 2016
The classes set basic attributes of the wavelets and can be called (like
functions) to evaluate the wavelet at a given time. They also have a
`sample` method to sample with a given time interval.

For example:

    wavelet = RickerWavelet(f=10)
    value = wavelet(time=0.1)
    values = wavelet(time=np.linspace(0, 1, 100))
    samples = wavelet.sample(dt=0.001)

These classes can be used in the finite difference modeling as sources
and to generate samples of a wavelet for convolutional modeling.

Ports code over from #308
Defaults to mp4 and adds extra options for avconv.
Copy link
Contributor

@eusoubrasileiro eusoubrasileiro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new ipython API?! nice!

It's available as a conda package.
@leouieda leouieda closed this Jun 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make wavefd API Object Oriented
2 participants