-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: Allow specifying which components of q to output on each fgout grid #17
Merged
Merged
Changes from 13 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
b372ccc
Merge remote-tracking branch 'origin/main' into radial_slide
rjleveque 5620faf
Merge remote-tracking branch 'origin/main' into radial_slide
rjleveque 8c8e395
testing fgout in radial_slide
rjleveque 4b4780c
updates to geoclaw_radial_slide from March 2024 to test with sea_leve…
rjleveque 39e9b5b
Merge remote-tracking branch 'origin/main' into radial_slide
rjleveque 6280e69
recovered geoclaw_radial_slide/Makefile but this dir should be moved …
rjleveque a365499
restored more geoclaw_radial_slide files
rjleveque 2e7fe4e
Moved examples/geoclaw_radial_slide -> tests/geoclaw_radial_slide
rjleveque b63286e
Changed to sea_level=200 in tests/geoclaw_radial_slide as possible test
rjleveque e75f191
added tests/geoclaw_bouss_radial_slide using geoclaw master branch wi…
rjleveque 006c11f
add examples/radial_slide/pyvista_plotting.py for 3D plot using PyVis…
rjleveque cfd0a14
switch to using fgout_module.f90 from geoclaw, which should handle dc…
rjleveque 8de0326
improve pyvista_plotting.py to also make animation
rjleveque db14e13
change b_eroded to bdif in comment.
kbarnhart 9f56ca9
remove dclaw/src/2d/dig/fgout_module.f90
kbarnhart File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,205 @@ | ||
from pylab import * | ||
import glob, os | ||
import pyvista as pv | ||
from clawpack.geoclaw import topotools | ||
from clawpack.visclaw import animation_tools | ||
from clawpack.geoclaw import fgout_tools | ||
from clawpack.visclaw import colormaps | ||
|
||
warpfactor = 5 # vertical amplification of elevations in 3D plots | ||
|
||
outdir = '_output' | ||
fgno = 1 # fgout grid number | ||
|
||
if 1: | ||
# determine how many fgout frames are in outdir: | ||
fgout_frames = glob.glob(os.path.join(outdir, \ | ||
'fgout%s.t*' % str(fgno).zfill(4))) | ||
nfgout = len(fgout_frames) | ||
fgframenos = array(range(1, nfgout+1)) | ||
print('Found %i fgout frames' % nfgout) | ||
else: | ||
# specify which frames to use: | ||
fgframenos = array(range(1,50,2)) | ||
|
||
|
||
# where to save a png file for each frame, for constructing an animation: | ||
framedir = '_frames' | ||
os.system('mkdir -p %s' % framedir) | ||
os.system('rm %s/*' % framedir) # remove frames from previous version | ||
|
||
window_size = (1200,1200) | ||
|
||
tan = [0.8,0.5,0.2] | ||
light_blue = [0.0,1.0,1.0] | ||
cmap_massfrac = colormaps.make_colormap({0:light_blue, 0.1:light_blue, | ||
1:tan}) | ||
|
||
def plot_topo(): | ||
""" | ||
plot topo from topofile | ||
""" | ||
topo = topotools.Topography('basal_topo.tt3') | ||
z = array([0.]) | ||
x = topo.x | ||
y = -topo.y | ||
X,Y,Z = meshgrid(x, y, z, indexing='ij') | ||
topoxyz = pv.StructuredGrid(X,Y,Z) | ||
|
||
B = flipud(topo.Z) | ||
B = fliplr(B) | ||
topoxyz.point_data['B'] = B.flatten(order='C') | ||
|
||
topowarp = topoxyz.warp_by_scalar('B', factor=warpfactor) | ||
|
||
p = pv.Plotter() | ||
p.add_mesh(topowarp,cmap='gist_earth',clim=(-20,400)) | ||
p.add_title('Topography') | ||
p.show(window_size=window_size) | ||
|
||
def plot_topo_fgout(): | ||
""" | ||
plot topo from an fgout file | ||
""" | ||
fgno = 1 # which fgout grid | ||
|
||
fgout_grid = fgout_tools.FGoutGrid(fgno, outdir, format, qmap='dclaw') | ||
|
||
fgout = fgout_grid.read_frame(1) | ||
|
||
x = fgout.x | ||
y = fgout.y | ||
z = array([0.]) | ||
X,Y,Z = meshgrid(x, y, z, indexing='ij') | ||
topoxyz = pv.StructuredGrid(X,Y,Z) | ||
|
||
B = fgout.B | ||
topoxyz.point_data['B'] = B.flatten(order='C') | ||
warpfactor = 5 # amplification of elevations | ||
topowarp = topoxyz.warp_by_scalar('B', factor=warpfactor) | ||
|
||
h = fgout.h | ||
topoxyz.point_data['h'] = h.flatten(order='C') | ||
warpfactor = 5 # amplification of elevations | ||
hwarp = topoxyz.warp_by_scalar('h', factor=warpfactor) | ||
|
||
eta = fgout.eta | ||
topoxyz.point_data['eta'] = B.flatten(order='C') | ||
warpfactor = 5 # amplification of elevations | ||
etawarp = topoxyz.warp_by_scalar('eta', factor=warpfactor) | ||
|
||
p = pv.Plotter() | ||
p.window_size = window_size | ||
p.add_mesh(topowarp,cmap='gist_earth',clim=(-20,400)) | ||
#p.add_mesh(topowarp,color='g') | ||
p.add_title('Topography fgout.B') | ||
p.show() | ||
|
||
|
||
def plot_fgout(make_animation=False): | ||
""" | ||
If make_animation == False, plot one fgout frame with a slider bar to | ||
change frame number. Also prints the camera position after changing frame, | ||
which you can copy and paste into this function in order to set the | ||
camera position for making an animation. | ||
If make_animation == True, make an mp4 animation of all frames | ||
specified by fgframenos set above. | ||
""" | ||
|
||
global etamesh | ||
|
||
fgno = 1 # which fgout grid | ||
warpfactor = 5 # amplification of elevations | ||
|
||
# Instantiate object for reading fgout frames: | ||
fgout_grid = fgout_tools.FGoutGrid(fgno, outdir, format, qmap='dclaw') | ||
|
||
fgout = fgout_grid.read_frame(1) | ||
|
||
x = fgout.x | ||
y = fgout.y | ||
z = array([0.]) | ||
X,Y,Z = meshgrid(x, y, z, indexing='ij') | ||
topoxyz = pv.StructuredGrid(X,Y,Z) | ||
|
||
B = fgout.B | ||
topoxyz.point_data['B'] = B.flatten(order='C') | ||
topowarp = topoxyz.warp_by_scalar('B', factor=warpfactor) | ||
|
||
p = pv.Plotter(off_screen=make_animation, lighting='three lights') | ||
p.window_size = window_size | ||
#p.add_mesh(topowarp,cmap='gist_earth',clim=(-20,400)) | ||
p.add_mesh(topowarp,color='lightgreen') | ||
etamesh = None | ||
|
||
|
||
def set_frameno(fgframeno): | ||
global etamesh | ||
fgframeno = int(round(fgframeno)) | ||
fgout = fgout_grid.read_frame(fgframeno) | ||
tsec = fgout.t | ||
print('Frame %i, t = %.1f seconds' % (fgframeno, fgout.t)) | ||
|
||
# replace land surface by nan in eta so it only shows water: | ||
# (big tolerance for landslide, would normally be smaller) | ||
eta = where(fgout.h>1, fgout.eta, nan) | ||
|
||
topoxyz.point_data['eta'] = eta.flatten(order='C') | ||
etawarp = topoxyz.warp_by_scalar('eta', factor=warpfactor) | ||
if etamesh: | ||
p.remove_actor(etamesh) | ||
|
||
# color the mesh based on mass fraction, using cmap_massfrac | ||
h = fgout.h | ||
massfrac = divide(fgout.hm, h, where=h>0, out=nan*ones(h.shape)) | ||
etamesh = p.add_mesh(etawarp,scalars=massfrac, | ||
colormap=cmap_massfrac, clim=(0,0.6)) | ||
|
||
p.add_title('Frame %i at time %.1f seconds' % (fgframeno,tsec)) | ||
|
||
if not make_animation: | ||
# print camera position so that this can be copied and pasted | ||
# into this script after adjusting (and then sliding frameno) | ||
print('p.camera_position = ', p.camera_position) | ||
|
||
|
||
# initial camera position: | ||
p.camera_position = [ | ||
(9034.796206317897, -2484.6171987620633, 3703.6128928929047), | ||
(1500.0, 1500.0, 950.89111328125), | ||
(-0.29984440650740857, 0.08916816605502331, 0.949811755059182)] | ||
|
||
|
||
if not make_animation: | ||
fgfr1 = fgframenos[0] | ||
fgfr2 = fgframenos[-1] | ||
p.add_slider_widget(set_frameno, [fgfr1,fgfr2], | ||
value=fgfr1, title='Frame', | ||
pointa=(0.4,0.85), pointb=(0.9,0.85), color='blue', | ||
slider_width=0.02, tube_width=0.005) | ||
|
||
p.show() | ||
|
||
else: | ||
|
||
# make a png file for each frame: | ||
for fgframeno in fgframenos: | ||
set_frameno(fgframeno) | ||
fname_png = '%s/PyVistaFrame%s.png' \ | ||
% (framedir, str(fgframeno).zfill(4)) | ||
p.screenshot(fname_png) | ||
print('Created ',fname_png) | ||
|
||
p.close() | ||
|
||
# combine png files into mp4 animation: | ||
anim = animation_tools.make_anim(framedir, | ||
fname_pattern='PyVistaFrame*.png') | ||
fname_mp4 = 'radial_slide_animation.mp4' | ||
animation_tools.make_mp4(anim, fname_mp4) | ||
print('Created ',fname_mp4) | ||
|
||
if __name__=='__main__': | ||
|
||
plot_fgout(make_animation=False) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rjleveque , @dlgeorge I suggest we delete dclaw/src/2d/dig/fgout_module.f90.
We only have it it as a placeholder that is no longer needed b/c Randy updated the GEOLIB/fgout_module.f90.
Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems best to remove it I guess.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that's fine. The only difference in it was that it set
but this is no longer needed with the geoclaw updates.