Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrap blockmedian #349

Merged
merged 3 commits into from
Apr 21, 2020
Merged

Conversation

weiji14
Copy link
Member

@weiji14 weiji14 commented Oct 20, 2019

Wrapping the blockmedian function!

Description of proposed changes

Current implementation can take a pandas.DataFrame as input and produce a pandas.DataFrame output filtered accordingly.

import pygmt
dataframe = pygmt.datasets.load_sample_bathymetry()
output = pygmt.blockmedian(table=dataframe, spacing="5m", region=[245, 255, 20, 30])
print(f"Original: {len(dataframe)}, Filtered: {len(output)}")
print(output.head())
Original: 82970, Filtered: 5849
   longitude  latitude  bathymetry
0  245.88819  29.97895      -385.0
1  246.96821  29.97529       -96.0
2  245.87456  29.92130      -426.0
3  245.94120  29.89000      -430.0
4  246.95780  29.92900       -96.0

Fixes #348

Reminders

  • Run make format and make check to make sure the code follows the style guide.
  • Add tests for new features or tests that would have caught the bug that you're fixing.
  • Add new public functions/methods/classes to doc/api/index.rst.
  • Write detailed docstrings for all functions/methods.
  • If adding new functionality, add an example to docstrings or tutorials.

@weiji14 weiji14 added this to the 0.1.0 milestone Oct 20, 2019
@weiji14 weiji14 self-assigned this Oct 20, 2019
@weiji14 weiji14 force-pushed the filtering/blockmedian branch from e72203e to 8f326cb Compare October 25, 2019 23:21
@weiji14 weiji14 force-pushed the filtering/blockmedian branch from 8f326cb to 2579be1 Compare November 1, 2019 09:20
Initial commit for wrapping the blockmedian function for #348, to be implemented under filtering.py. Original GMT `blockmedian` documentation can be found at https://docs.generic-mapping-tools.org/latest/blockmedian.html.

Storing sample test cases under test_blockmedian.py. Current implementation only allows for pandas.DataFrame or ASCII file name inputs, and correspondingly outputs the same type. Tests currently use the load_sample_bathymetry dataset, and we check for a variety of cases that the blockmedian filtered output is valid. Also aliased required arguments spacing (I) and region (R).
weiji14 added 2 commits April 17, 2020 20:49
Trim docstring length to 79 characters, and change 'L1 norm' to 'median estimation'.
@weiji14 weiji14 requested a review from leouieda April 17, 2020 09:24
@weiji14 weiji14 merged commit a3887ab into GenericMappingTools:master Apr 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wrapper for blockmedian
1 participant