|
15 | 15 |
|
16 | 16 | from uxarray.grid.coordinates import _populate_node_latlon, _lonlat_rad_to_xyz, _xyz_to_lonlat_rad_scalar |
17 | 17 |
|
18 | | -from uxarray.constants import INT_FILL_VALUE, ERROR_TOLERANCE, INT_DTYPE |
| 18 | +from uxarray.constants import INT_FILL_VALUE, ERROR_TOLERANCE |
19 | 19 |
|
20 | 20 | from uxarray.grid.arcs import extreme_gca_latitude |
21 | 21 |
|
@@ -746,3 +746,39 @@ def test_dual_duplicate(): |
746 | 746 | dataset = ux.open_dataset(gridfile_geoflow, gridfile_geoflow) |
747 | 747 | with pytest.raises(RuntimeError): |
748 | 748 | dataset.get_dual() |
| 749 | + |
| 750 | + |
| 751 | +def test_normalize_existing_coordinates_non_norm_initial(): |
| 752 | + gridfile_mpas = current_path / "meshfiles" / "mpas" / "QU" / "mesh.QU.1920km.151026.nc" |
| 753 | + from uxarray.grid.validation import _check_normalization |
| 754 | + uxgrid = ux.open_grid(gridfile_mpas) |
| 755 | + |
| 756 | + uxgrid.node_x.data = 5 * uxgrid.node_x.data |
| 757 | + uxgrid.node_y.data = 5 * uxgrid.node_y.data |
| 758 | + uxgrid.node_z.data = 5 * uxgrid.node_z.data |
| 759 | + assert not _check_normalization(uxgrid) |
| 760 | + |
| 761 | + uxgrid.normalize_cartesian_coordinates() |
| 762 | + assert _check_normalization(uxgrid) |
| 763 | + |
| 764 | + |
| 765 | +def test_normalize_existing_coordinates_norm_initial(): |
| 766 | + gridfile_CSne30 = current_path / "meshfiles" / "ugrid" / "outCSne30" / "outCSne30.ug" |
| 767 | + from uxarray.grid.validation import _check_normalization |
| 768 | + uxgrid = ux.open_grid(gridfile_CSne30) |
| 769 | + |
| 770 | + assert _check_normalization(uxgrid) |
| 771 | + |
| 772 | + |
| 773 | + |
| 774 | +def test_from_topology(): |
| 775 | + node_lon = np.array([-20.0, 0.0, 20.0, -20, -40]) |
| 776 | + node_lat = np.array([-10.0, 10.0, -10.0, 10, -10]) |
| 777 | + face_node_connectivity = np.array([[0, 1, 2, -1], [0, 1, 3, 4]]) |
| 778 | + |
| 779 | + uxgrid = ux.Grid.from_topology( |
| 780 | + node_lon=node_lon, |
| 781 | + node_lat=node_lat, |
| 782 | + face_node_connectivity=face_node_connectivity, |
| 783 | + fill_value=-1, |
| 784 | + ) |
0 commit comments