Updated bathymetry generation with figsave

This commit is contained in:
Edgar P. Burkhart 2022-01-31 17:27:53 +01:00
parent 70a4e4bb59
commit 1969e54342
Signed by: edpibu
GPG Key ID: 9833D3C5A25BD227
3 changed files with 36 additions and 13 deletions

View File

@ -1,3 +1,4 @@
/1_scad /1_scad
/2_stl /2_stl
/3_pd /3_pd
/4_fig

View File

@ -23,3 +23,7 @@ root = 2_stl
[pandas] [pandas]
root = 3_pd root = 3_pd
file = data.hdf file = data.hdf
[fig]
root = 4_fig
format = pgf

View File

@ -27,6 +27,8 @@ folders = {
'stl': pathlib.Path(config['stl']['root']), 'stl': pathlib.Path(config['stl']['root']),
'pandas': pathlib.Path(config['pandas']['root']), 'pandas': pathlib.Path(config['pandas']['root']),
} }
if config.getboolean('fig', 'enable', fallback=False):
folders['fig'] = pathlib.Path(config.get('fig', 'root'))
for path in folders.values(): for path in folders.values():
path.mkdir(exist_ok=True) path.mkdir(exist_ok=True)
@ -94,8 +96,11 @@ for bloc in blocs:
#line.z = all_blocs.z.fillna(line.z) #line.z = all_blocs.z.fillna(line.z)
lim = float(config['main']['bathy_max']) lim = float(config['main']['bathy_max'])
bathy_line = line.z.clip(upper=lim) bathy_line = line.z.copy()
rubble_line = line.z[line.z > lim] #bathy_line = line.z.clip(upper=lim)
bathy_line = bathy_line[(bathy_line.index - L0 < -10) | (bathy_line.index - L0 > 0)]
bathy_line.index = np.where((bathy_line > lim) & (bathy_line.index < L0), bathy_line.index + 10, bathy_line.index)
rubble_line = line.z[(line.z > lim) & (line.index < L0)]
data_dict = {} data_dict = {}
for i in range(blocs.size): for i in range(blocs.size):
@ -163,25 +168,34 @@ if config['main']['plot'] == 'True':
) )
fig, ax = plt.subplots() fig, ax = plt.subplots()
ax.scatter( c = ax.tricontourf(
bathy.lon[flt], bathy.lon[flt],
bathy.lat[flt], bathy.lat[flt],
c=bathy.z[flt], bathy.z[flt],
marker='1', #marker='1',
lw=1, #lw=1,
) )
ax.scatter( fig.colorbar(c, label='Altitude (m)')
ax.plot(
artha.lon, artha.lon,
artha.lat, artha.lat,
color='k', color='k',
marker='+', marker='+',
lw=1, lw=1,
label='Studied domain',
) )
ax.legend()
ax.grid(alpha=.2)
ax.set( ax.set(
xlabel='Longitude (°)',
ylabel='Latitude (°)',
aspect='equal', aspect='equal',
) )
if config.getboolean('fig', 'enable', fallback=False):
fig.savefig(folders['fig'].joinpath(
f'map.{config.get("fig", "format")}'))
fig, ax = plt.subplots() fig, ax = plt.subplots(figsize=(6,2))
ax.plot( ax.plot(
bathy_line.index, bathy_line.index,
bathy_line, bathy_line,
@ -196,21 +210,25 @@ if config['main']['plot'] == 'True':
color='r', color='r',
lw=1, lw=1,
zorder=11, zorder=11,
label='Rubble', label='Armour',
) )
blocs.apply(lambda bloc: ax.fill_between( blocs.apply(lambda bloc: ax.fill_between(
bloc.index, bloc.index,
bloc.z, bloc.z,
color='k', color='k',
zorder=9, zorder=12,
alpha=.1, #alpha=.1,
label='Caisson',
)) ))
ax.set( ax.set(
xlabel='x (m)',
ylabel='y (m)',
aspect='equal', aspect='equal',
xlim=(bathy_line.index.min(), bathy_line.index.max()), xlim=(bathy_line.index.min(), bathy_line.index.max()),
) )
ax.grid() ax.grid()
fig.legend() ax.legend()
if config.getboolean('fig', 'enable', fallback=False):
fig.savefig(folders['fig'].joinpath(
f'bathy.{config.get("fig", "format")}'))
plt.show(block=True) plt.show(block=True)