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

Respelling of v_vorticity and h_divergence #684

Merged
merged 2 commits into from Dec 18, 2017

Conversation

jrleeman
Copy link
Contributor

A few respellings that are clearer instead of shorter. These could be up for debate, but it's more in line with the ethos we're working around here.

  • v_vorticity -> vertical_vorticity
  • h_divergence -> divergence (with options for 3D post X-array integration)

I still need to add some skeletons for the old names telling users that those have been renamed.

@jrleeman jrleeman added this to the 0.7 milestone Dec 12, 2017
@jrleeman
Copy link
Contributor Author

Safe to ignore codacy

@dopplershift
Copy link
Member

@deeplycloudy @kgoebber @ktyle If you guys have any opinion on this (especially the h_convergence to convergence), I’d love to hear it now.

@dopplershift dopplershift added Area: Calc Pertains to calculations Type: Enhancement Enhancement to existing functionality labels Dec 13, 2017
@deeplycloudy
Copy link
Collaborator

deeplycloudy commented Dec 13, 2017 via email

@jrleeman
Copy link
Contributor Author

Are these just vorticity and divergence that in the future will work in 2D or 3D depending on the input? 🤔

@kgoebber
Copy link
Collaborator

I generally agree with @deeplycloudy and would prefer vorticity and divergence for the names of the functions. As he stated the 2D vorticity can be calculated for any plane from the function we have (the most common one would likely be the vertical) and similar with divergence (the vertical part is simply the negative of the horizontal part). When a 3D version of vorticity is written that would compute all of the components and retain its vector form, then it could be named vorticity3D (or something similar).

@dopplershift
Copy link
Member

Ok, I think I see where you're coming from @kgoebber @deeplycloudy -- which is why it's great to get input on issues like this.

@jrleeman I think the extensions for these two functions are going to be done differently in the future, owing to differences in the way they extend to additional dimensions.

For now, let's do this:

  1. h_divergence -> divergence
  2. v_vorticity -> vorticity

In the future, should we actually have the need, we can add vector_vorticity. We can defer designs on extending divergence to 3D and vorticity to other planes until we actually can see what we're doing with xarray.

@dopplershift dopplershift added the Type: API Change Changes to how existing functionality works label Dec 13, 2017
from metpy.calc import (advection, divergence_vorticity, frontogenesis, geostrophic_wind,
get_wind_components, h_divergence, montgomery_streamfunction,
from metpy.calc import (advection, divergence, divergence_vorticity, frontogenesis,
geostrophic_wind, get_wind_components, montgomery_streamfunction,

Choose a reason for hiding this comment

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

E241 multiple spaces after ','

a = np.arange(3)
u = np.c_[a, a, a] * units('m/s')
with pytest.raises(NameError):
v = v_vorticity(u, u.T, 1 * units.meter, 1 * units.meter, dim_order='xy')

Choose a reason for hiding this comment

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

F841 local variable 'v' is assigned to but never used

get_wind_components, h_divergence, montgomery_streamfunction,
from metpy.calc import (advection, convergence, convergence_vorticity, divergence,
divergence_vorticity, frontogenesis,
geostrophic_wind, get_wind_components, montgomery_streamfunction,

Choose a reason for hiding this comment

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

E241 multiple spaces after ','

true_c = np.ones_like(u) / units.sec
true_v = np.ones_like(u) / units.sec
assert_array_equal(c, true_c)
assert_array_equal(v, true_v)

Choose a reason for hiding this comment

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

W292 no newline at end of file

@jrleeman
Copy link
Contributor Author

Safe to ignore code climate. Had to add dim_order='xy' on the wrappers. Ugly, but should preserve functionality. Just ported a single test over for each.

Copy link
Member

@dopplershift dopplershift left a comment

Choose a reason for hiding this comment

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

Generally 👍

I don't like the dim_order, but I see no way around it.

@deprecated('0.7', addendum=' This function has been renamed vorticity.',
pending=False)
def v_vorticity(u, v, dx, dy, dim_order='xy'):
r"""Calculate the vertical vorticity of the horizontal wind.
Copy link
Member

Choose a reason for hiding this comment

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

Could we just do:

v_vorticity.__doc__ = vorticity.__doc__?



def test_convergence_vorticity():
"""TTest that convergence_vorticity wrapper works (deprecated in 0.7)."""
Copy link
Member

Choose a reason for hiding this comment

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

You stuttered here. 😁

Copy link
Contributor Author

Choose a reason for hiding this comment

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

pending=False)
def v_vorticity(u, v, dx, dy, dim_order='xy'):
return vorticity(u, v, dx, dy, dim_order=dim_order)
v_vorticity.__doc__ = vorticity.__doc__

Choose a reason for hiding this comment

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

E305 expected 2 blank lines after class or function definition, found 0

pending=False)
def convergence(u, v, dx, dy, dim_order='xy'):
return divergence(u, v, dx, dy, dim_order=dim_order)
convergence.__doc__ = divergence.__doc__

Choose a reason for hiding this comment

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

E305 expected 2 blank lines after class or function definition, found 0

pending=False)
def convergence_vorticity(u, v, dx, dy, dim_order='xy'):
return divergence_vorticity(u, v, dx, dy, dim_order=dim_order)
convergence_vorticity.__doc__ = divergence_vorticity.__doc__

Choose a reason for hiding this comment

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

E305 expected 2 blank lines after class or function definition, found 0

@jrleeman jrleeman force-pushed the respelling branch 3 times, most recently from f09501c to 3a1d973 Compare December 15, 2017 15:31
@jrleeman
Copy link
Contributor Author

Should be ready to go @dopplershift

@dopplershift dopplershift merged commit db9f582 into Unidata:master Dec 18, 2017
@jrleeman jrleeman deleted the respelling branch April 24, 2018 14:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Calc Pertains to calculations Type: API Change Changes to how existing functionality works Type: Enhancement Enhancement to existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants