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

Other types of mean using volume_average #307

Open
shashwat97 opened this issue Mar 2, 2023 · 2 comments
Open

Other types of mean using volume_average #307

shashwat97 opened this issue Mar 2, 2023 · 2 comments

Comments

@shashwat97
Copy link

Hi,

I want to calculate the harmonic mean for a tree mesh based on an input tensor mesh. Just like the volume_average function, just a different kind of average.

I am doing it like this:

avg_df = pd.DataFrame([tree_mesh.point2index(fine_mesh.gridCC), df[prop].values]).T
harmonic_means = avg_df.groupby(0)[1].apply(hmean)

The problem is, this is much slower than the volume_average. Is there any way to use the volume_average code to find the harmonic average of the overlapping cells?

Thanks for your assistance!
@jcapriot

@jcapriot
Copy link
Member

jcapriot commented Mar 2, 2023

I would look at how volume_average finds intersecting cells.

@jcapriot
Copy link
Member

jcapriot commented Mar 2, 2023

The relevant code is inside cython at

def _vol_avg_to_tens(self, out_tens_mesh, values=None, output=None):
, so it is compiled.

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

No branches or pull requests

2 participants