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

Remove error and add a warning for gravmag.transform.upcontinue when height <= 0#337

Merged
leouieda merged 4 commits into
fatiando:masterfrom
rafaelmds:upward-continuation-warning
Nov 25, 2016
Merged

Remove error and add a warning for gravmag.transform.upcontinue when height <= 0#337
leouieda merged 4 commits into
fatiando:masterfrom
rafaelmds:upward-continuation-warning

Conversation

@rafaelmds

@rafaelmds rafaelmds commented Nov 24, 2016

Copy link
Copy Markdown
Contributor

Fixes #235

Change the behavior of gravmag.transform.upcontinue. Now, instead of an error its gives a warnings.warn when height <= 0.
This change is mainly for educational purposes (you can test what happen if you calculate for it for height <= 0).

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, 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)

@leouieda

Copy link
Copy Markdown
Member

@rafaelmds thanks for the PR! Could you please add the following code to fatiando/gravmag/tests/test_transform.py? The function should go below the test_upcontinue function and the import at the top. This will test if the warning is being raised properly.

import pytest


def test_upcontinue_warning():
    "gravmag.transform upward continuation raises warning if height <= 0"
    model = [Prism(-1000, 1000,-500, 500, 0, 1000, {'density': 1000})]
    shape = (100, 100)
    x, y, z = gridder.regular([-5000, 5000, -5000, 5000], shape, z=-500)
    data = prism.gz(x, y, z, model)
    with pytest.warns(UserWarning):
        up = transform.upcontinue(x, y, data, shape, height=0)
    with pytest.warns(UserWarning):
        up = transform.upcontinue(x, y, data, shape, height=-100)

@rafaelmds

Copy link
Copy Markdown
Contributor Author

@leouieda Sure! I thought that was necessary but I wasn't sure about it.

@leouieda

Copy link
Copy Markdown
Member

No problem. This is the part that always gets newcomers.

Could you also please change the warning message to "Using 'height' <= 0 means downward continuation, which is known to be unstable." That might be more informative.

@leouieda

Copy link
Copy Markdown
Member

After that, you can add the changelog entry for this PR in doc/changelog.rst and you're done 👍

@leouieda leouieda merged commit 061fb44 into fatiando:master Nov 25, 2016
@leouieda

Copy link
Copy Markdown
Member

@rafaelmds merged! Thanks

@rafaelmds rafaelmds deleted the upward-continuation-warning branch November 25, 2016 15:22
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants