Skip to content

Commit a04ffa5

Browse files
committed
[EJP] some greensurge fix
1 parent b3ee795 commit a04ffa5

File tree

3 files changed

+21
-85
lines changed

3 files changed

+21
-85
lines changed

bluemath_tk/additive/greensurge.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,12 @@ def plot_GS_vs_dynamic_windsetup_swath(
413413
Maximum value for the color scale. Default is None.
414414
figsize : tuple, optional
415415
Figure size. Default is (10, 8).
416+
Returns
417+
-------
418+
fig : Figure
419+
The figure object containing the plots.
420+
axs : list of Axes
421+
List of Axes objects for the two subplots.
416422
"""
417423

418424
warnings.filterwarnings("ignore", message="All-NaN slice encountered")
@@ -477,6 +483,7 @@ def plot_GS_vs_dynamic_windsetup_swath(
477483

478484
for ax in axs:
479485
ax.set_extent([lon_min, lon_max, lat_min, lat_max])
486+
return fig, axs
480487

481488

482489
def GS_windsetup_reconstruction_with_postprocess(

bluemath_tk/topo_bathy/mesh_utils.py

Lines changed: 0 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,10 @@ def plot_mesh_vals(
9494
The axes with the plot.
9595
"""
9696

97-
# Copy coordinates to avoid modifying original mesh
9897
crd = np.array(msh_t.vert2["coord"], copy=True)
9998
cnn = msh_t.tria3["index"]
10099
val = msh_t.value.flatten()
101100

102-
# Transform to geographic coordinates if needed
103101
if to_geo is not None:
104102
crd[:, 0], crd[:, 1] = to_geo(crd[:, 0], crd[:, 1])
105103

@@ -426,17 +424,6 @@ def simply_polygon(base_shape: Polygon, simpl_UTM: float, project) -> Polygon:
426424
-------
427425
Polygon
428426
The simplified polygon in geographic coordinates.
429-
430-
Examples
431-
--------
432-
>>> from shapely.geometry import Polygon
433-
>>> from pyproj import Transformer
434-
>>> from shapely.ops import transform
435-
>>> base_shape = Polygon([(0, 0), (1, 1), (1, 0), (0, 0)])
436-
>>> project = Transformer.from_crs("EPSG:4326", "EPSG:32630").transform
437-
>>> simpl_UTM = 100.0 # Simplification tolerance in meters
438-
>>> simplified_shape = simply_polygon(base_shape, simpl_UTM, project)
439-
>>> print(simplified_shape)
440427
"""
441428

442429
base_shape_utm = transform(project, base_shape)
@@ -471,17 +458,6 @@ def remove_islands(base_shape: Polygon, threshold_area: float, project) -> Polyg
471458
-------
472459
Polygon
473460
The polygon with small interior rings removed, transformed back to geographic coordinates.
474-
475-
Examples
476-
--------
477-
>>> from shapely.geometry import Polygon
478-
>>> from pyproj import Transformer
479-
>>> from shapely.ops import transform
480-
>>> base_shape = Polygon([(0, 0), (1, 1), (1, 0), (0, 0)])
481-
>>> project = Transformer.from_crs("EPSG:4326", "EPSG:32630").transform
482-
>>> threshold_area = 100.0 # Minimum area for interior rings in square meters
483-
>>> simplified_shape = remove_islands(base_shape, threshold_area, project)
484-
>>> print(simplified_shape)
485461
"""
486462

487463
base_shape_utm = transform(project, base_shape)
@@ -552,17 +528,6 @@ def calculate_edges(Elmts: np.ndarray) -> np.ndarray:
552528
np.ndarray
553529
A 2D array of shape (n_edges, 2) containing the unique edges,
554530
each represented by a pair of node indices.
555-
556-
Examples
557-
--------
558-
>>> Elmts = np.array([[0, 1, 2], [1, 2, 3], [2, 0, 3]])
559-
>>> edges = calculate_edges(Elmts)
560-
>>> print(edges)
561-
[[0 1]
562-
[0 2]
563-
[1 2]
564-
[1 3]
565-
[2 3]]
566531
"""
567532

568533
perc = 0
@@ -901,15 +866,6 @@ def compute_circumcenter(p0: np.ndarray, p1: np.ndarray, p2: np.ndarray) -> np.n
901866
-------
902867
np.ndarray
903868
2D coordinates of the circumcenter.
904-
905-
Examples
906-
--------
907-
>>> p0 = np.array([0, 0])
908-
>>> p1 = np.array([1, 0])
909-
>>> p2 = np.array([0, 1])
910-
>>> center = compute_circumcenter(p0, p1, p2)
911-
>>> print(center)
912-
[0.5 0.5]
913869
"""
914870

915871
A = p1 - p0
@@ -943,13 +899,6 @@ def build_edge_to_cells(elements: np.ndarray) -> Dict[Tuple[int, int], List[int]
943899
-------
944900
edge_to_cells : Dict[Tuple[int, int], List[int]]
945901
Dictionary mapping edges to the list of adjacent element indices.
946-
947-
Examples
948-
--------
949-
>>> elements = np.array([[0, 1, 2], [1, 2, 3], [2, 0, 3]])
950-
>>> edge_to_cells = build_edge_to_cells(elements)
951-
>>> print(edge_to_cells)
952-
{(0, 1): [0], (0, 2): [0, 2], (1, 2): [0, 1], (1, 3): [1], (2, 3): [1]}
953902
"""
954903

955904
edge_to_cells = defaultdict(list)
@@ -985,15 +934,6 @@ def detect_circumcenter_too_close(
985934
-------
986935
bad_elements_mask : np.ndarray
987936
Boolean mask indicating which elements are problematic (True if bad).
988-
989-
Examples
990-
--------
991-
>>> X = np.array([0, 1, 0, 1])
992-
>>> Y = np.array([0, 0, 1, 1])
993-
>>> elements = np.array([[0, 1, 2], [1, 3, 2]])
994-
>>> bad_elements = detect_circumcenter_too_close(X, Y, elements, aj_threshold=0.1)
995-
>>> print(bad_elements)
996-
[False False]
997937
"""
998938

999939
nodes = np.column_stack((X, Y))
@@ -1155,15 +1095,3 @@ def get_raster_resolution_meters(lon_center, lat_center, raster_resolution, proj
11551095
]
11561096
)
11571097
return raster_resolution_meters
1158-
1159-
1160-
if __name__ == "__main__":
1161-
# Example usage
1162-
from pyproj import Transformer
1163-
from shapely.geometry import Polygon
1164-
1165-
base_shape = Polygon([(0, 0), (1, 1), (1, 0), (0, 0)])
1166-
project = Transformer.from_crs("EPSG:4326", "EPSG:32630").transform
1167-
simpl_UTM = 100.0 # Simplification tolerance in meters
1168-
simplified_shape = simply_polygon(base_shape, simpl_UTM, project)
1169-
print(simplified_shape)

bluemath_tk/wrappers/delft3d/delft3d_wrapper.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,21 @@
1717
#SBATCH --mem=4gb # Memory per node in GB (see also --mem-per-cpu)
1818
#SBATCH --time=24:00:00
1919
20+
source /home/grupos/geocean/faugeree/miniforge3/etc/profile.d/conda.sh
21+
conda activate GreenSurge
22+
2023
case_dir=$(ls | awk "NR == $SLURM_ARRAY_TASK_ID")
2124
launchDelft3d.sh --case-dir $case_dir
2225
2326
output_file="${case_dir}/dflowfmoutput/GreenSurge_GFDcase_map.nc"
2427
output_file_compressed="${case_dir}/dflowfmoutput/GreenSurge_GFDcase_map_compressed.nc"
2528
output_file_compressed_tmp="${case_dir}/dflowfmoutput/GreenSurge_GFDcase_map_compressed_tmp.nc"
2629
27-
ncap2 -s 'mesh2d_s1=float(mesh2d_s1)' -v -O "$output_file" "$output_file_compressed_tmp"
28-
ncks -4 -L 4 "$output_file_compressed_tmp" "$output_file_compressed"
29-
30-
rm "$output_file_compressed_tmp"
31-
if [[ "$SLURM_ARRAY_TASK_ID" -ne 1 ]]; then
32-
rm "$output_file"
33-
fi
30+
ncap2 -s 'mesh2d_s1=float(mesh2d_s1)' -v -O "$output_file" "$output_file_compressed_tmp" && {
31+
ncks -4 -L 4 "$output_file_compressed_tmp" "$output_file_compressed"
32+
rm "$output_file_compressed_tmp"
33+
[[ "$SLURM_ARRAY_TASK_ID" -ne 1 ]] && rm "$output_file"
34+
}
3435
"""
3536

3637

@@ -149,14 +150,14 @@ def monitor_cases(
149150
)
150151

151152

152-
def format_matrix(mat):
153-
return "\n".join(
154-
" ".join(f"{x:.1f}" if abs(x) > 0.01 else "0" for x in line) for line in mat
155-
)
153+
# def format_matrix(mat):
154+
# return "\n".join(
155+
# " ".join(f"{x:.1f}" if abs(x) > 0.01 else "0" for x in line) for line in mat
156+
# )
156157

157158

158-
def format_zeros(mat_shape):
159-
return "\n".join("0 " * mat_shape[1] for _ in range(mat_shape[0]))
159+
# def format_zeros(mat_shape):
160+
# return "\n".join("0 " * mat_shape[1] for _ in range(mat_shape[0]))
160161

161162

162163
def actualize_grid_info(

0 commit comments

Comments
 (0)