3535from webbrowser import UnixBrowser
3636import numpy as np
3737from matplotlib import pyplot as plt
38+ from scipy .io import savemat
3839
3940# package modules
4041from aeolis .utils import *
@@ -493,14 +494,17 @@ def visualize_spatial(s, p):
493494 fig , axs = plt .subplots (5 , 3 )
494495 pcs = [[None for _ in range (3 )] for _ in range (5 )]
495496
497+ # In the plotting below, prevent the UserWarning: The input coordinates to pcolormesh are interpreted as cell centers, but are not monotonically increasing or decreasing (...)
498+ import warnings
499+ warnings .filterwarnings ("ignore" , category = UserWarning )
500+
496501 # Plotting colormeshes
497502 if p ['ny' ] > 0 :
498503 pcs [0 ][0 ] = axs [0 ,0 ].pcolormesh (x , y , s ['zb' ], cmap = 'viridis' )
499504 pcs [0 ][1 ] = axs [0 ,1 ].pcolormesh (x , y , s ['zne' ], cmap = 'viridis' )
500505 pcs [0 ][2 ] = axs [0 ,2 ].pcolormesh (x , y , s ['rhoveg' ], cmap = 'Greens' , clim = [0 , 1 ])
501506 pcs [1 ][0 ] = axs [1 ,0 ].pcolormesh (x , y , s ['uw' ], cmap = 'plasma' )
502507 pcs [1 ][1 ] = axs [1 ,1 ].pcolormesh (x , y , s ['ustar' ], cmap = 'plasma' )
503- # pcs[1][2] = axs[1,2].pcolormesh(x, y, s['tau'], cmap='plasma')
504508 pcs [1 ][2 ] = axs [1 ,2 ].pcolormesh (x , y , s ['u' ][:, :, 0 ], cmap = 'plasma' )
505509 pcs [2 ][0 ] = axs [2 ,0 ].pcolormesh (x , y , s ['moist' ], cmap = 'Blues' , clim = [0 , 0.4 ])
506510 pcs [2 ][1 ] = axs [2 ,1 ].pcolormesh (x , y , s ['gw' ], cmap = 'viridis' )
@@ -528,11 +532,13 @@ def visualize_spatial(s, p):
528532 pcs [4 ][1 ] = axs [4 ,1 ].scatter (x , y , c = tide_mask_add , cmap = 'binary' , clim = [0 , 1 ])
529533 pcs [4 ][2 ] = axs [4 ,2 ].scatter (x , y , c = wave_mask_add , cmap = 'binary' , clim = [0 , 1 ])
530534
535+ # Re-allow the UserWarning
536+ warnings .filterwarnings ("default" , category = UserWarning )
537+
531538 # Quiver for vectors
532539 skip = 10
533540 axs [1 ,0 ].quiver (x [::skip , ::skip ], y [::skip , ::skip ], s ['uws' ][::skip , ::skip ], s ['uwn' ][::skip , ::skip ])
534541 axs [1 ,1 ].quiver (x [::skip , ::skip ], y [::skip , ::skip ], s ['ustars' ][::skip , ::skip ], s ['ustarn' ][::skip , ::skip ])
535- # axs[1,2].quiver(x[::skip, ::skip], y[::skip, ::skip], s['taus'][::skip, ::skip], s['taun'][::skip, ::skip])
536542 axs [1 ,2 ].quiver (x [::skip , ::skip ], y [::skip , ::skip ], s ['us' ][::skip , ::skip , 0 ], s ['un' ][::skip , ::skip , 0 ])
537543
538544 # Adding titles to the plots
@@ -541,7 +547,6 @@ def visualize_spatial(s, p):
541547 axs [0 ,2 ].set_title ('Vegetation density, rhoveg (-)' )
542548 axs [1 ,0 ].set_title ('Wind velocity, uw (m/s)' )
543549 axs [1 ,1 ].set_title ('Shear velocity, ustar (m/s)' )
544- # axs[1,2].set_title('Shear stress, tau (N/m2)')
545550 axs [1 ,2 ].set_title ('Grain velocity, u (m/s)' )
546551 axs [2 ,0 ].set_title ('Soil moisture content, (-)' )
547552 axs [2 ,1 ].set_title ('Ground water level, gw (m)' )
@@ -573,4 +578,29 @@ def visualize_spatial(s, p):
573578 fig .savefig ('figure_params_initialization.png' , dpi = 300 )
574579 plt .close ()
575580
576- return
581+ return
582+
583+ def output_sedtrails (s , p ):
584+ '''Create additional output for SedTRAILS and save as mat-files.
585+ Chosen for seperate files, such that only relevant (Ct > 0) cells
586+ are exported for memory and speed efficiency'''
587+
588+ nf = p ['nfraction_sedtrails' ]
589+
590+ # Speed and concetration: Only for the first fraction now
591+ x = s ['x' ].flatten ()
592+ y = s ['y' ].flatten ()
593+ us = s ['usST' ][:,:,nf ].flatten ()
594+ un = s ['unST' ][:,:,nf ].flatten ()
595+ pickup = s ['pickup' ][:,:,nf ].flatten ()
596+ dzb = s ['dzb' ].flatten () # Store the bed level change (AEOLIAN ONLY) for every timestep
597+
598+ os .makedirs ('sedtrails_output' , exist_ok = True )
599+
600+ time = p ['_time' ]
601+ if time == 0 : # Save the x and y coordinates only once to save memory
602+ mdic = {'x' : x , 'y' : y , 'us' : us , 'un' : un , 'dzb' : dzb , 'pickup' : pickup }
603+ savemat (os .path .join ('sedtrails_output' , str (int (time )).zfill (12 ) + '.mat' ), mdic )
604+ else :
605+ mdic = {'us' : us , 'un' : un , 'dzb' : dzb , 'pickup' : pickup }
606+ savemat (os .path .join ('sedtrails_output' , str (int (time )).zfill (12 ) + '.mat' ), mdic )
0 commit comments