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

Refactor mean_pressure_weighted #1674

Closed
dopplershift opened this issue Jan 27, 2021 · 0 comments · Fixed by #1914
Closed

Refactor mean_pressure_weighted #1674

dopplershift opened this issue Jan 27, 2021 · 0 comments · Fixed by #1914
Labels
Area: Calc Pertains to calculations Type: Maintenance Updates and clean ups (but not wrong)
Milestone

Comments

@dopplershift
Copy link
Member

Right now this looks like:

    ret = []  # Returned variable means in layer
    layer_arg = get_layer(pressure, *args, height=height,
                          bottom=bottom, depth=depth)
    layer_p = layer_arg[0]
    layer_arg = layer_arg[1:]
    # Taking the integral of the weights (pressure) to feed into the weighting
    # function. Said integral works out to this function:
    pres_int = 0.5 * (layer_p[-1]**2 - layer_p[0]**2)
    for i, _datavar in enumerate(args):
        arg_mean = np.trapz((layer_arg[i] * layer_p),
                            x=layer_p) / pres_int
        ret.append(arg_mean)

So it's iterating over an enumeration but not actually using what it's looping over, so that could be better. I think this could probably be reduced to returning a list comprehension, but not completely sure. We should also double check any other places that are using enumerate.

@dopplershift dopplershift added the Type: Maintenance Updates and clean ups (but not wrong) label Jan 27, 2021
@dopplershift dopplershift added this to the 1.1.0 milestone Jan 27, 2021
@dopplershift dopplershift added the Area: Calc Pertains to calculations label Jun 15, 2021
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: Maintenance Updates and clean ups (but not wrong)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant