Skip to content

Commit

Permalink
Feature/202410 update (#40)
Browse files Browse the repository at this point in the history
* change nodata_value to -99999 in topotools

Previous value -9999 did not have enough digits since new etopo 2022
data has this as an actual topography value in the Mariana Trench
(when written with `Z_format='%.0f'`).

* Fix bug related to tracking pressure at gauges

* simplify make_fgout_animation.py use of update_artists

These do not need to be passed into update, unpacked, and repacked,
since the objects created in the script will be used into update.
If blit==False then they are not needed at all.

* use image backend Agg in make_fgout_animation.py so animation size agrees with specified figure size

* set blit=False and auto-detect number of fgout frames

* clean up make_fgout_animation.py

* added new chile2010_fgmax-fgout/make_fgout_animation_with_transect.py

* Add dZ_format parameter to DTopography.write function

The default is now '%.3f', millimeter resolution, making smaller dtopo
files than previously.

* handle 0 radius

* fix type on set_pressure

* fix duplicate r

* make comparison fp-safe

* handle underflow

* avoid underflow in wind setting too

* point to riemann/src for Riemann solvers

* Remove Riemann solvers from src/2d/bouss, Makefile.common points to riemann/src

Note that rpn2_geoclaw.f and geoclaw_riemann_utils.f were update in riemann/src
to handle 5 waves and rpt2_geoclaw_sym.f was discarded in favor of
standard rpt2.f, which works fine with 5 waves.

* Initial CI GitHub action script

* Update testing.yml

* Add checking out of clawpack and geoclaw

* Add lint and testing to CI

* Disable linting for the time being

* Re-enable linting but only for geoclaw

* Exclude old_topotools.py

Do not want to touch the old topotools file for reference.

* initial commit of xarray backends and example use file

* remove extra words

* relax assumption of where command is issued (no longer needs to be in run directory).

* Fix up gauge plotting for storm surge

Includes a couple of minor bugs related to gauge plotting.  Major change
involves how we now plot the gauge data.

* Add dry gauge plotting

* create gauge filenames that allow more than 5 digits in gauge number

If fewer than 5 digits, still add zero padding e.g. gauge00012.txt
but no longer throws an error for large gauge numbers, e.g. gauge1234567.txt

* cleaner way to zero pad only if fewer than 5 digits using I0.5 format

* Cleanup and reimplement reading of ATCF and writing of GeoClaw storms

* Minor string comparison bug fix

* Extract name of storm from file name

* Minor tweaks and fixes

* Fix missing comma

* AutoPEP8 surge code

* add more information about rioxarray

* better import error for rioxarray

* add B and level

* add fgout output_style parameter and support for array of output_times

* remove trailing whitespaces in fgout_module.f990

* Refactor fgout_module.f90 so it works for either GeoClaw or D-Claw

and support in fgout_tools.py for new dclaw attribute dclaw to set in setrun.py
to indicate D-Claw, in which case 7 components of q are output instead of 4.
Support for eventually indicating fewer components to output.

* Use geoclaw module rho

* Remove module level parameters that were not needed or were specific

These mostly pertained to the CLE code.

* Initial implementation of rotation control

* Minor bugfixes and rearranging

* Fix bugs in the non-spherical coordinates for storms"

* fix fgout_tools.FGoutGrid.read_fgout_grids_data for time array

Now that `output_style==2` is supported for fgout grids (an array of times,
see clawpack#617), the function
fgout_tools.FGoutGrid.read_fgout_grids_data needs to be fixed to properly
read in the new format of `fgout_grids.data`, also note that `nout`
now comes before `tstart` and `tend` for `output_style==1`.

* Add kwargs to Topography reading

* Add radii to plotting options

* Add plotting of storm tracks

* add clip example

* return ds

* Allow specifying which components of q to output on each fgout grid

Modifications to fgout_module.f90 and fgout_tools.py, primarily.
Can now set `fgout.q_out_vars` to a list of which components of q
to output for each fgout frame (Fortran indexing). The default is
`fgout.q_out_vars = [1,2,3,4]` for all components of q[1:3] and
also eta (4), consistent with the previous behavior.

The user could also/instead ask to output the topo B
as component 5.  (If two out of three of h, eta, B are output then the
other can be computed from these.)

Note that this list is written out to `fgout_grids.data` rather than a
boolean list of True/False values for each possible component as is done
in other places in GeoClaw.

* working on dclaw variables

* Fix fgout_tools.py to support fgout.q_out_vars also for Boussinesq or D-Claw

When instantiating fgout_tools.FGoutGrid object, new qmap parameter can be set
to 'geoclaw', 'geoclaw-bouss', 'dclaw', or a custom dictionary.
(Eventually add 'dclaw-bouss' option also).
This dictionary has the form `{'h':1, 'hu':2, etc}` with mapping from fgout
variable names to Fortran indices of q in the code creating the fgout output.

* Update topo_module.f90

The `character` variables that were storing variable names and IDs for NetCDF topography reading were only length 10.  This just makes them 64 characters long.  Probably too long but not really a big deal.

* fix data_file -> data_path

* add FGoutGrid.read_fgout_grids_data_pre511 for reading legacy fgout_grids.data from before v5.11

* add to doc string for pre511

* print more helpful error msg if fgout_grids.data seems to be pre511

* force user to call read_fgout_grids_data before read_frame

* Fix chiles2010_fgmax-fgout scripts to make fgout animations

Now need to call fgout_grid.read_fgout_grids_data() explicitly,
but do not need to set format.

* Leave output_format as an argument to FGoutGrids.__init__ but not that
this is ignored since it is read from fgout_grids.data.
Also properly handle output_format == 2 for binary32.

* fix qmap=='geoclaw-bouss' mapping

* wip

* first pass at using revised fgout data structure with backends.

* add a few more comments.

* name updates

* bdiff->bdif

* remove vestigial _qelements

* Add example that should work with/without dask

* improve drytol handling

(now tested for both absence of h, and absence of h, eta, and B)

* don't specify error type.

* switch from hard coded drytol to user-specified drytol

* update use of dry_tolerance

* fix exceptions.

* update examples/tsunami/chile2010/setplot.py

Improve this by using new options added in recent releases so the
plots look better and this can better serve as a template for other
problems.

* Fix src/bouss/amr2.f90 call to set_fgout, adding nvar

This was modified in the shallow/amr2.f90 code to support more fgout
flexibility in clawpack#624, and this change is also required in the bouss version.

Also enhanced the examples/bouss README files a bit.

---------

Co-authored-by: Randy LeVeque <rjl@uw.edu>
Co-authored-by: Kyle Mandli <kyle.Mandli@gmail.com>
Co-authored-by: Barnhart, Katherine (Katy) Ruth <krbarnhart@usgs.gov>
  • Loading branch information
4 people authored Oct 14, 2024
1 parent c688ba4 commit 55c000c
Show file tree
Hide file tree
Showing 16 changed files with 1,913 additions and 765 deletions.
6 changes: 6 additions & 0 deletions examples/bouss/README.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

GeoClaw Boussinesq solver examples

The radial_flat subdirectory contains one example using the Boussinesq
solver introduced in Clawpack v5.10.0.

Expand All @@ -14,8 +16,12 @@ OpenMP along with MPI. Some flags have to be set as environment variables
or directly in the application Makefile, e.g. see the lines commented out in
radial_flat/Makefile.

The file setenv.sh illustrates how you might set some environment
variables for the bash shell.

A file petscMPIoptions is also required to set some PETSc parameters for the
iterative method used to solve the large sparse linear systems that arise at
each refinement level when the Boussinesq equations are solved.
One of the environment variables mentioned above points to this file, and a
sample is included in this directory.

9 changes: 9 additions & 0 deletions examples/bouss/radial_flat/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ A Gaussian hump of water at the origin spreads out over a flat bottom,
as specified by the topo file `flat100.txt` (uniform water depth 100 m).
The equations are solved in Cartesian coordinates with the SGN equations.

Running the GeoClaw Boussinesq solvers requires PETSc and MPI.
For more details see the documentation
https://www.clawpack.org/bouss2d.html
and
$CLAW/geoclaw/examples/bouss/README.txt
Run
make check
in this directory to check if things seem ok for running this code.

A flagregion specified by `RuledRectangle_Diagonal.data` (that is created by
code in `setrun.py` is used to allow flagging for refinement to
level 2 only near the diagonal (for abs(x-y) < 1000). The code is set up to
Expand Down
67 changes: 33 additions & 34 deletions examples/tsunami/chile2010/setplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,14 @@ def addgauges(current_data):

# Set up for axes in this figure:
plotaxes = plotfigure.new_plotaxes('pcolor')
plotaxes.title = 'Surface'
plotaxes.scaled = True

def fixup(current_data):
import pylab
addgauges(current_data)
t = current_data.t
t = t / 3600. # hours
pylab.title('Surface at %4.2f hours' % t, fontsize=20)
pylab.xticks(fontsize=15)
pylab.yticks(fontsize=15)
plotaxes.afteraxes = fixup
plotaxes.title = 'Surface at time h:m:s'
plotaxes.aspect_latitude = -30.
plotaxes.xticks_fontsize = 10
plotaxes.yticks_fontsize = 10
plotaxes.xlabel = 'longitude'
plotaxes.ylabel = 'latitude'

plotaxes.afteraxes = addgauges

# Water
plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor')
Expand All @@ -78,6 +74,8 @@ def fixup(current_data):
plotitem.pcolor_cmin = -0.2
plotitem.pcolor_cmax = 0.2
plotitem.add_colorbar = True
plotitem.colorbar_shrink = 0.8
plotitem.colorbar_extend = 'both'
plotitem.amr_celledges_show = [0,0,0]
plotitem.patchedges_show = 1

Expand Down Expand Up @@ -114,18 +112,37 @@ def fixup(current_data):

# Set up for axes in this figure:
plotaxes = plotfigure.new_plotaxes()
plotaxes.xlimits = 'auto'
plotaxes.ylimits = 'auto'
plotaxes.time_scale = 1/3600. # convert to hours
plotaxes.xlimits = [0, 9]
plotaxes.ylimits = [-0.3, 0.3]
plotaxes.title = 'Surface'
plotaxes.title_fontsize = 15
plotaxes.time_label = 'time (hours)'
plotaxes.ylabel = 'surface elevation (m)'
plotaxes.grid = True

def add_obs(current_data):
from pylab import plot, legend
gaugeno = current_data.gaugeno
if gaugeno == 32412:
try:
tgauge = TG32412[:,0] / 3600. # convert to hours
plot(tgauge, TG32412[:,1], 'r', linewidth=1.0)
legend(['GeoClaw','Obs'],loc='lower right')
except: pass

plotaxes.afteraxes = add_obs

# Plot surface as blue curve:
plotitem = plotaxes.new_plotitem(plot_type='1d_plot')
plotitem.plot_var = 3
plotitem.plot_var = 3 # eta
plotitem.plotstyle = 'b-'
plotitem.kwargs = {'linewidth':1.8}


# Plot topo as green curve:
plotitem = plotaxes.new_plotitem(plot_type='1d_plot')
plotitem.show = False
plotitem.show = False # not being used

def gaugetopo(current_data):
q = current_data.q
Expand All @@ -137,24 +154,6 @@ def gaugetopo(current_data):
plotitem.plot_var = gaugetopo
plotitem.plotstyle = 'g-'

def add_zeroline(current_data):
from pylab import plot, legend, xticks, floor, axis, xlabel
t = current_data.t
gaugeno = current_data.gaugeno

if gaugeno == 32412:
try:
plot(TG32412[:,0], TG32412[:,1], 'r')
legend(['GeoClaw','Obs'],loc='lower right')
except: pass
axis((0,t.max(),-0.3,0.3))

plot(t, 0*t, 'k')
n = int(floor(t.max()/3600.) + 2)
xticks([3600*i for i in range(n)], ['%i' % i for i in range(n)])
xlabel('time (hours)')

plotaxes.afteraxes = add_zeroline


#-----------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
fgno = 1 # which fgout grid

outdir = '_output'
format = 'binary' # format of fgout grid output

if 1:
# use all fgout frames in outdir:
Expand All @@ -48,7 +47,8 @@
fgframes = range(1,26) # frames of fgout solution to use in animation

# Instantiate object for reading fgout frames:
fgout_grid = fgout_tools.FGoutGrid(fgno, outdir, format)
fgout_grid = fgout_tools.FGoutGrid(fgno, outdir)
fgout_grid.read_fgout_grids_data()


# Plot one frame of fgout data and define the Artists that will need to
Expand Down
Loading

0 comments on commit 55c000c

Please sign in to comment.