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

Weighted Average #833

Open
wants to merge 37 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
e496054
boilerplate
philipc2 Jul 2, 2024
23c7a7b
update boilerplate
philipc2 Jul 2, 2024
3094cfc
fix boilerplate
philipc2 Jul 3, 2024
af8b865
Merge branch 'main' into weighted-mean
philipc2 Jul 3, 2024
23a6422
add quad hexagon to tests
philipc2 Jul 5, 2024
bd3248c
Merge branch 'weighted-mean' of https://github.com/UXARRAY/uxarray in…
philipc2 Jul 5, 2024
98c1c90
Merge branch 'main' into weighted-mean
philipc2 Jul 5, 2024
1ecb633
Merge branch 'main' into weighted-mean
philipc2 Jul 5, 2024
ae4a13e
Merge branch 'main' into weighted-mean
philipc2 Jul 8, 2024
e8e01a5
Merge branch 'main' into weighted-mean
philipc2 Jul 15, 2024
5dbaf5d
write tests, work on api design
philipc2 Jul 16, 2024
4c3290b
asv benchmark
philipc2 Jul 17, 2024
7e5ceca
Merge branch 'main' into weighted-mean
philipc2 Jul 17, 2024
6553163
update asv benchmark
philipc2 Jul 17, 2024
659cfe9
Merge branch 'weighted-mean' of https://github.com/UXARRAY/uxarray in…
philipc2 Jul 17, 2024
70bf239
Merge branch 'main' into weighted-mean
philipc2 Jul 26, 2024
0032870
Committing weighted mean modifications from rtam/weighted mean to uxa…
rytam2 Jul 26, 2024
8a2ecb3
Merge branch 'main' into weighted-mean
philipc2 Aug 12, 2024
02dc504
merge main
philipc2 Oct 10, 2024
f9a4d19
some cleanup
philipc2 Oct 10, 2024
efce996
fix tests
philipc2 Oct 10, 2024
87e6543
Merge branch 'main' into weighted-mean
philipc2 Oct 22, 2024
7999c43
Merge branch 'main' into weighted-mean
philipc2 Nov 13, 2024
7722698
Merge branch 'main' into weighted-mean
philipc2 Nov 19, 2024
8c36fa0
add initial dask test cases
philipc2 Nov 19, 2024
a3c87b8
use parametrize
philipc2 Nov 19, 2024
7056451
add boilerplate for example in docstring
philipc2 Nov 19, 2024
944b42b
update docstring
philipc2 Nov 19, 2024
9a1d746
Merge branch 'weighted-mean' of https://github.com/UXARRAY/uxarray in…
rytam2 Nov 22, 2024
48273fb
added examples to weighted mean API, userguide and test case
rytam2 Nov 22, 2024
c16f192
Merge branch 'main' into weighted-mean
philipc2 Dec 3, 2024
a5f0d3c
cleaned userguide output
rytam2 Dec 3, 2024
97cdf92
restarted kernel
rytam2 Dec 3, 2024
70a2b3f
removed duplicate notebook
rytam2 Dec 5, 2024
d7a6d18
run pre-commit
philipc2 Dec 5, 2024
1613a2d
re-run notebook
philipc2 Dec 5, 2024
b5ae01a
Merge branch 'main' into weighted-mean
aaronzedwick Dec 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
147 changes: 76 additions & 71 deletions benchmarks/mpas_ocean.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

import uxarray as ux

import numpy as np

current_path = Path(os.path.dirname(os.path.realpath(__file__)))

data_var = 'bottomDepth'
Expand All @@ -29,74 +27,120 @@
"120km": [current_path / grid_filename_120, current_path / data_filename_120]}


class Gradient:

class DatasetBenchmark:
"""Class used as a template for benchmarks requiring a ``UxDataset`` in
this module across both resolutions."""
param_names = ['resolution',]
params = [['480km', '120km'],]
param_names = ['resolution']
params = ['480km', '120km']

def setup(self, resolution, *args, **kwargs):

def setup(self, resolution):
self.uxds = ux.open_dataset(file_path_dict[resolution][0], file_path_dict[resolution][1])

def teardown(self, resolution, *args, **kwargs):
def teardown(self, resolution):
del self.uxds

class GridBenchmark:
"""Class used as a template for benchmarks requiring a ``Grid`` in this
module across both resolutions."""
param_names = ['resolution', ]
params = [['480km', '120km'], ]

def setup(self, resolution, *args, **kwargs):
self.uxgrid = ux.open_grid(file_path_dict[resolution][0])

def teardown(self, resolution, *args, **kwargs):
del self.uxgrid


class Gradient(DatasetBenchmark):
def time_gradient(self, resolution):
self.uxds[data_var].gradient()

def peakmem_gradient(self, resolution):
grad = self.uxds[data_var].gradient()

class Integrate(DatasetBenchmark):
class Integrate:

param_names = ['resolution']
params = ['480km', '120km']


def setup(self, resolution):
self.uxds = ux.open_dataset(file_path_dict[resolution][0], file_path_dict[resolution][1])

def teardown(self, resolution):
del self.uxds

def time_integrate(self, resolution):
self.uxds[data_var].integrate()

def peakmem_integrate(self, resolution):
integral = self.uxds[data_var].integrate()

class GeoDataFrame:

param_names = ['resolution', 'exclude_antimeridian']
params = [['480km', '120km'],
[True, False]]

class GeoDataFrame(DatasetBenchmark):
param_names = DatasetBenchmark.param_names + ['exclude_antimeridian']
params = DatasetBenchmark.params + [[True, False]]

def setup(self, resolution, exclude_antimeridian):
self.uxds = ux.open_dataset(file_path_dict[resolution][0], file_path_dict[resolution][1])

def teardown(self, resolution, exclude_antimeridian):
del self.uxds

def time_to_geodataframe(self, resolution, exclude_antimeridian):
self.uxds[data_var].to_geodataframe(exclude_antimeridian=exclude_antimeridian)

def peakmem_to_geodataframe(self, resolution, exclude_antimeridian):
gdf = self.uxds[data_var].to_geodataframe(exclude_antimeridian=exclude_antimeridian)


class ConnectivityConstruction:

param_names = ['resolution']
params = ['480km', '120km']


def setup(self, resolution):
self.uxds = ux.open_dataset(file_path_dict[resolution][0], file_path_dict[resolution][1])


def teardown(self, resolution):
del self.uxds

class ConnectivityConstruction(DatasetBenchmark):
def time_n_nodes_per_face(self, resolution):
self.uxds.uxgrid.n_nodes_per_face

def time_face_face_connectivity(self, resolution):
ux.grid.connectivity._populate_face_face_connectivity(self.uxds.uxgrid)


class MatplotlibConversion(DatasetBenchmark):
param_names = DatasetBenchmark.param_names + ['periodic_elements']
params = DatasetBenchmark.params + [['include', 'exclude', 'split']]
class WeightedMean:

param_names = ['resolution']
params = ['480km', '120km']

def setup(self, resolution):
self.uxds = ux.open_dataset(file_path_dict[resolution][0], file_path_dict[resolution][1])
_ = self.uxds.uxgrid.face_areas
_ = self.uxds.uxgrid.edge_node_distances

def teardown(self, resolution):
del self.uxds

def time_weighted_mean_face_centered(self, resolution):
self.uxds['bottomDepth'].weighted_mean()

class MatplotlibConversion:
param_names = ['resolution', 'periodic_elements']
params = (['480km', '120km'], ['include', 'exclude', 'split'])

def setup(self, resolution, periodic_elements):
self.uxds = ux.open_dataset(file_path_dict[resolution][0], file_path_dict[resolution][1])

def teardown(self, resolution, periodic_elements):
del self.uxds

def time_dataarray_to_polycollection(self, resolution, periodic_elements):
self.uxds[data_var].to_polycollection()

class ConstructTreeStructures:
param_names = ['resolution']
params = ['480km', '120km']

class ConstructTreeStructures(DatasetBenchmark):
def setup(self, resolution):
self.uxds = ux.open_dataset(file_path_dict[resolution][0], file_path_dict[resolution][1])

def teardown(self, resolution):
del self.uxds

def time_kd_tree(self, resolution):
self.uxds.uxgrid.get_kd_tree()
Expand Down Expand Up @@ -135,42 +179,3 @@ def time_nearest_neighbor_remapping(self):

def time_inverse_distance_weighted_remapping(self):
self.uxds_480["bottomDepth"].remap.inverse_distance_weighted(self.uxds_120.uxgrid)

class HoleEdgeIndices(DatasetBenchmark):
def time_construct_hole_edge_indices(self, resolution):
ux.grid.geometry._construct_hole_edge_indices(self.uxds.uxgrid.edge_face_connectivity)


class DualMesh(DatasetBenchmark):
def time_dual_mesh_construction(self, resolution):
self.uxds.uxgrid.get_dual()

class ConstructFaceLatLon(GridBenchmark):
def time_welzl(self, resolution):
self.uxgrid.construct_face_centers(method='welzl')

def time_cartesian_averaging(self, resolution):
self.uxgrid.construct_face_centers(method='cartesian average')


class CheckNorm:
param_names = ['resolution']
params = ['480km', '120km']

def setup(self, resolution):
self.uxgrid = ux.open_grid(file_path_dict[resolution][0])

def teardown(self, resolution):
del self.uxgrid

def time_check_norm(self, resolution):
from uxarray.grid.validation import _check_normalization
_check_normalization(self.uxgrid)


class CrossSections(DatasetBenchmark):
param_names = DatasetBenchmark.param_names + ['n_lat']
params = DatasetBenchmark.params + [[1, 2, 4, 8]]
def time_constant_lat_fast(self, resolution, n_lat):
for lat in np.linspace(-89, 89, n_lat):
self.uxds.uxgrid.constant_latitude_cross_section(lat, method='fast')
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading