cmap='jet') pc.set_clim([-0.1, 0.1]) cbar = fig.colorbar(pc, ax=ax) cbar.set_label('%s (%s)' % (data_nc_SEP.var_varname, data_nc_SEP.var_ncattrs['units'])) ax.set_title('t=%d (%s)' % (timestep, data_nc_SEP.var_times.iloc[timestep])) ax.set_aspect('equal') #ax.quiver(data_nc_XZ[::2,::2], data_nc_YZ[::2,::2], vel_x[::2,::2], vel_y[::2,::2], # scale=3,color='w',width=0.005)#, edgecolor='face', cmap='jet') fig.tight_layout() plt.savefig(os.path.join(dir_output, 'waqua_DCSM_map_wl')) #HIS ZUNO file_nc = r'p:\1204257-dcsmzuno\2019\DCSMv6\A01\SDS-A01_his.nc' vars_pd, dims_pd = get_ncvardimlist(file_nc=file_nc) data_nc_NAMWL = get_hisstationlist(file_nc=file_nc, varname='NAMWL') #data_nc_NAMC = get_hisstationlist(file_nc=file_nc, varname='NAMC') data_nc_ZWL = get_ncmodeldata(file_nc=file_nc, varname='ZWL', timestep='all', station='all') #data_nc_ZCURU = get_ncmodeldata(file_nc=file_nc, varname='ZCURU',timestep='all',station='all') #data_nc_ZCURV = get_ncmodeldata(file_nc=file_nc, varname='ZCURV',timestep='all',station='all') fig, ax = plt.subplots(figsize=(16, 7)) for iS in range(10): ax.plot(data_nc_ZWL.var_times, data_nc_ZWL[:, iS], label=data_nc_NAMWL['NAMWL'].iloc[iS], linewidth=1) ax.legend(loc=1)
os.path.join( dir_output, '%s_%s_vec' % (os.path.basename(file_nc).replace('.', ''), varname))) for ax in axs: ax.set_xlim([25000, 65000]) ax.set_ylim([2500, 15000]) plt.savefig( os.path.join( dir_output, '%s_%s_veczoom' % (os.path.basename(file_nc).replace('.', ''), varname))) #HISFILE file_nc = r'p:\11203869-morwaqeco3d\05-Tidal_inlet\02_FM_201910\FM_MF10_Max_30s\fm\DFM_OUTPUT_inlet\inlet_his.nc' vars_pd, dims_pd = get_ncvardimlist(file_nc=file_nc) vars_pd_sel = vars_pd[vars_pd['long_name'].str.contains('level')] stat_list = get_hisstationlist(file_nc, varname='station_name') crs_list = get_hisstationlist(file_nc, varname='cross_section_name') var_names = ['waterlevel', 'bedlevel'] #,'mesh2d_ssn'] for iV, varname in enumerate(var_names): data_fromhis = get_ncmodeldata(file_nc=file_nc, varname=varname, timestep='all', station='all') var_longname = vars_pd['long_name'][vars_pd['nc_varkeys'] == varname].iloc[0] fig, ax = plt.subplots(1, 1, figsize=(10, 5)) for iS, stat in enumerate(data_fromhis.var_stations['station_name']): ax.plot(data_fromhis.var_times, data_fromhis[:, iS],
import matplotlib.pyplot as plt plt.close('all') from dfm_tools.get_nc import get_netdata, get_ncmodeldata, plot_netmapdata from dfm_tools.get_nc_helpers import get_ncvardimlist, get_timesfromnc, get_hisstationlist, get_ncfilelist #uncomment the line below, copy data locally and change this path to increase performance dir_testinput = os.path.join(r'E:\proj\Pescadero\Model_Runs\Testing') file_nc_map = os.path.join(dir_testinput, 'run_tide_test-v12A', 'DFM_OUTPUT_flowfm', 'flowfm_map.nc') file_nc_his = os.path.join(dir_testinput, 'run_tide_test-v12A', 'DFM_OUTPUT_flowfm', 'flowfm_his.nc') #get lists with vars/dims, times, station/crs/structures vars_pd, dims_pd = get_ncvardimlist(file_nc=file_nc_map) times_pd = get_timesfromnc(file_nc=file_nc_map) statlist_pd = get_hisstationlist(file_nc=file_nc_his, varname='station_name') #retrieve his data data_fromhis_wl = get_ncmodeldata(file_nc=file_nc_his, varname='waterlevel', station='all', timestep='all') fig, ax = plt.subplots(1, 1, figsize=(10, 5)) for iP, station in enumerate(data_fromhis_wl.var_stations['station_name']): ax.plot(data_fromhis_wl.var_times, data_fromhis_wl[:, iP], '-', label=station) ax.legend() ax.set_ylabel( '%s (%s)' %
(data_fromnc_u.var_ncattrs['units'])) ax.set_title('t=%d (%s)' % (timestep, data_fromnc_u.var_times.loc[timestep])) ax.set_aspect('equal') thinning = 5 ax.quiver( data_fromnc_edgex[::thinning, ::thinning], data_fromnc_edgey[::thinning, ::thinning], data_fromnc_u[timestep, ::thinning, ::thinning], data_fromnc_v[timestep, ::thinning, ::thinning], color='w') #,scale=3,width=0.005)#, edgecolor='face', cmap='jet') fig.tight_layout() plt.savefig(os.path.join(dir_output, 'SFINCS_velocity_pcolorquiver')) #SFINCS HIS #file_nc = r'p:\11202255-sfincs\Testbed\Original_tests\01_Implementation\14_restartfile\sfincs_his.nc' file_nc = r'p:\11202255-sfincs\Testbed\Original_tests\03_Application\04_Tsunami_Japan_Sendai\sfincs_his.nc' vars_pd, dims_pd = get_ncvardimlist(file_nc=file_nc) station_names = get_hisstationlist(file_nc=file_nc, varname='point_zs') data_fromnc_his = get_ncmodeldata(file_nc=file_nc, varname='point_zs', station='all', timestep='all') fig, ax = plt.subplots() for iS, stat_name in enumerate(data_fromnc_his.var_stations['station_name']): ax.plot(data_fromnc_his.var_times, data_fromnc_his[:, iS], label=stat_name) ax.legend() plt.savefig(os.path.join(dir_output, 'SFINCS_hiszs'))