@@ -251,6 +251,12 @@ def swan_current(
251251def swan_ice (file_out , ice , STR_START , STR_END , factor : float , ice_path : str ) -> None :
252252 """Writes ice information to SWAN input file"""
253253
254+ if ice is None :
255+ msg .info (
256+ "No ice object provided. Ice information will NOT be written to SWAN input file!"
257+ )
258+ return
259+
254260 delta_Xf = np .round (np .diff (ice .edges ("lon" )), 5 )[0 ]
255261 delta_Yf = np .round (np .diff (ice .edges ("lat" )), 5 )[0 ]
256262 for i in range (len (ice_path )):
@@ -298,6 +304,8 @@ def swan_structures(file_out, structures: list[dict]) -> None:
298304 trans = None
299305 refl = 0.0
300306 closed = False
307+ if structures :
308+ file_out .write ("$ Define obstacles (structures) \n " )
301309 for structure in structures :
302310 trans = structure .get ("trans" ) or trans
303311 if trans is None :
@@ -323,11 +331,12 @@ def swan_structures(file_out, structures: list[dict]) -> None:
323331 file_out .write ("\n " )
324332
325333
326- def swan_spectral_output_points (file_out , grid , STR_START : str ) -> None :
334+ def swan_spectral_output_points (file_out , grid , STR_START : str , homog : bool ) -> None :
327335 """Writes a list of spectral output points set in grid"""
328336 spec_lon , spec_lat = grid .output_points ()
329337 if len (spec_lon ) == 0 :
330338 return
339+ file_out .write ("$ Generate spectral output \n " )
331340 file_out .write ("POINTS 'pkt' &\n " )
332341 for slon , slat in zip (spec_lon , spec_lat ):
333342 file_out .write (str (slon ) + " " + str (slat ) + " &\n " )
@@ -337,7 +346,9 @@ def swan_spectral_output_points(file_out, grid, STR_START: str) -> None:
337346 + "_"
338347 + STR_START .split ("." )[0 ]
339348 + "_spec"
340- + ".nc"
341- + "' & \n "
349+ + ".nc'"
342350 )
343- file_out .write ("OUTPUT " + STR_START + " 1 HR \n " )
351+ if not homog :
352+ file_out .write (" & \n OUTPUT " + STR_START + " 1 HR" )
353+
354+ file_out .write (" \n " )
0 commit comments