clawpack / geoclaw

Version of Clawpack for geophysical waves and flows
http://www.clawpack.org/geoclaw
BSD 3-Clause "New" or "Revised" License
76 stars 87 forks source link

fgmax data issues fg.x and fg.y are no longer increasing #582

Open cjeffr opened 11 months ago

cjeffr commented 11 months ago

I've updated my installation to the most recent version from 5.8.2 and with that some of my fgmax plotting routines failed. I found that fg.x and fg.y are no longer increasing but are the same value across the array. I'm wondering if I'm missing an input change somewhere? I did not remember reading changes to fgmax in the release notes but I did see completed pull requests where changes were made recently. My file moriches_fgmax.data was created using version 5.8.2. Thanks for your help.

Example arrays below with fg.x I can also paste or share screen shots of fg.y if needed. My fgmax declaration is below and the example I have as well.

INPUT:

rundata.fgmax_data.num_fgmax_val = 2 fgmax_grids = rundata.fgmax_data.fgmax_grids

fg = fgmax_tools.FGmaxGrid() fg.point_style = 4 fg.min_level_check = 6 fg.tstart_max = days2seconds(0.5) # just before wave arrives fg.tend_max = days2seconds(1.333) # when to stop monitoring max values fg.dt_check = 5.*3600 # how often to update max values fg.interp_method = 0
fg.xy_fname = '../../fgmax_data/moriches_fgmax.data' # file of 0/1 values in tt3 format fgmax_grids.append(fg) # written to fgmax_grids.data

EXAMPLE OUTPUT

fg.x == [-72.87995372 -72.87995372 -72.87995372 ... -72.87995372 -72.87995372 -72.87995372] fg.X == array([[-72.87995372, -72.87986113, -72.87976853, ..., -72.5802315 , -72.5801389 , -72.58004631], [-72.87995372, -72.87986113, -72.87976853, ..., -72.5802315 , -72.5801389 , -72.58004631], [-72.87995372, -72.87986113, -72.87976853, ..., -72.5802315 , -72.5801389 , -72.58004631], ..., [-72.87995372, -72.87986113, -72.87976853, ..., -72.5802315 , -72.5801389 , -72.58004631], [-72.87995372, -72.87986113, -72.87976853, ..., -72.5802315 , -72.5801389 , -72.58004631], [-72.87995372, -72.87986113, -72.87976853, ..., -72.5802315 , -72.5801389 , -72.58004631]])

Since fg.x = fg.X[:,0] I tried swapping the rows and columns fg.X[0,:] and I get my expected result. array([-72.87995372, -72.87986113, -72.87976853, ..., -72.5802315 , -72.5801389 , -72.58004631])

rjleveque commented 11 months ago

@cjeffr: This is probably a result of the changes in #561, which was included in v5.9.1.

I think this change should have fixed a bug in earlier versions where fg.x was improperly set to fg.X[0,:] rather than fg.X[:,0]. Is it possible that your Python script that calls fgmax_tools.read_output() was taking that bug into account and resetting fg.x after reading? I ask because I had some scripts like that, which I had to modify after fixing the bug.

I just tried running the example in $CLAW/geoclaw/examples/tsunami/chile2010_fgmax-fgout and it seems to run ok, and adding

    print(fg.X[:3, :3])
    print('x = ',fg.x[:3])

at the end of the function plot_fgmax_grid in plot_fgmax.py and then running this script prints out

[[-119.91666667 -119.91666667 -119.91666667]
 [-119.75       -119.75       -119.75      ]
 [-119.58333334 -119.58333334 -119.58333334]]
x =  [-119.91666667 -119.75       -119.58333334]

as expected.

Hope this helps you debug. Let us know if you continue to have problems.

cjeffr commented 11 months ago

Yes I think my plotting routine didn't take into account the indexing added into read_output() I will try that and if it goes well I'll close this issue.

Thanks!