org-arl / arlpy

ARL Python Tools
BSD 3-Clause "New" or "Revised" License
119 stars 37 forks source link

parsing custom env failed to recreate environment #39

Closed patel999jay closed 4 years ago

patel999jay commented 4 years ago

I parsed custom env to module but it failed to regenerate simulation scenarios. I had successfully tested the same scenario files with bellhop using matlab, works perfectly fine. Also is there any way to parse non-monotonic ssp ? I am using Bathmetry from GEBCO 2019. Any help would be appreciated.

Here is the example env file that i use.

'BELLHOP - run id = 0; run = 0'
25000              ! FREQUENCY [HZ]
1                      ! NMEDIA
'CVWT'                    ! OPTIONS1
0 0.0 5500        ! NMESH SIGMAS Z(NSSP)
0  1453.8265380859375  / 
171.875  1484.99903106689453  / 
343.75  1487.60022735595703  / 
515.625  1490.45523834228516  / 
687.5  1493.31779479980469  / 
859.375  1496.18764877319336  / 
1031.25  1499.06432342529297  / 
1203.125  1501.94766235351562  / 
1375  1504.838134765625  / 
1546.875  1507.73603057861328  / 
1718.75  1510.63935852050781  / 
1890.625  1513.55051422119141  / 
2062.5  1516.46852111816406  / 
2234.375  1519.39547348022461  / 
2406.25  1522.32242584228516  / 
2578.125  1525.25769424438477  / 
2750  1528.20294189453125  / 
2921.875  1531.14818954467773  / 
3093.75  1534.10316467285156  / 
3265.625  1537.06624603271484  / 
3437.5  1540.02932739257812  / 
3609.375  1543.00338363647461  / 
3781.25  1545.98371124267578  / 
3953.125  1548.96403884887695  / 
4125  1551.95657348632812  / 
4296.875  1554.95368576049805  / 
4468.75  1557.95079803466797  / 
4640.625  1560.96119689941406  / 
4812.5  1563.97454833984375  / 
4984.375  1566.98789978027344  / 
5156.25  1570.01551818847656  / 
5328.125  1573.04456329345703  / 
5500  1576.0736083984375  / 
'A*' 0.0                 ! BOTTOM TYPE
5500 1702.5 409.139 1.935 0.73 2.15  /  ! SAND * 0.65 + GRAVEL * 0.35 BOTTOM TYPE 
1           ! NUMBER OF SOURCES
50  /              ! SOURCE'S DEPTH
2       ! NUMBER OF RX DEPTH(S)
49.899999999068676  50.0999999990686788  /                 ! RX'S DEPTHS
2        !NUMBER OF RX RANGE(S)
3.91162739655877489  3.91182739655877443  /                 ! RX'S RANGES
'AB'                 ! RAY OPTIONS
0              ! NUMBER OF RAYS
-180 180   /           ! START, END ANGLES
0.0 301.109658813476585 4.30301013621465245 ,  ! RAY-STEP , BOX DEPTH, BOX RANGE
mchitre commented 4 years ago

Can you post the arlpy code that you used?

patel999jay commented 4 years ago

Here is the code that i used,

import arlpy.uwapm as pm
import arlpy.plot as plt
import numpy as np

env = pm.create_env2d()
pm.print_env(env) # to check env

ssp = [
           [0,         0.0022477890249762906],
           [1446.0123291015625,            1452.5137939453125],
           [1463.50646209716797,          1473.13202667236328],
           [1466.33708953857422,           1477.57839965820312],
           [1469.17899703979492,           1480.42838668823242],
           [1472.03192138671875,           1483.28749084472656],
           [1474.89564895629883,           1486.15559768676758],
           [1477.76937103271484,           1489.03192901611328],
           [1480.65291595458984,           1491.91645812988281],
           [1483.54705810546875,           1494.80963134765625],
           [1486.45201873779297,           1497.71190643310547],
           [1489.36491394042969,           1500.62077331542969],
           [1492.28920745849609,           1503.53911590576172],
           [1495.223388671875,           1506.46572875976562],
           [1498.17044067382812,           1509.40312957763672],
           [1501.11749267578125,           1512.34053039550781],
           [1504.07640838623047,           1515.28792572021484],
           [1507.049560546875,             1518.247314453125],
           [1510.02271270751953,           1521.20670318603516],
           [1513.00946044921875,           1524.17765045166016],
           [1516.00753784179688,           1527.15822982788086],
           [1519.005615234375,           1530.13880920410156],
           [1522.01885986328125,            1533.1323127746582],
           [1525.040771484375,           1536.13320159912109],
           [1528.06268310546875,           1539.13409042358398],
           [1531.10107421875,           1542.14926147460938],
           [1534.14564514160156,            1545.1697883605957],
           [1537.19021606445312,           1548.19031524658203],
           [1540.25243377685547,           1551.22611999511719],
           [1543.31857299804688,           1554.26531982421875],
           [1546.38471221923828,           1557.30451965332031],
           [1549.46927642822266,           1560.36004638671875],
           [1552.55568313598633,           1563.41720581054688],
           [1555.64208984375,             1566.474365234375],
           [5101,                       1566.474365234375]
]
bathy = [
          [0,5100],             
          [0.213841,           270.083],
          [0.31033,          270.753],
          [0.654562,           271.326],
          [1.01966,           271.259],
          [1.09659,           271.734],
          [1.53731,           271.909],
          [1.72898,           272.099],
          [1.97803,           272.138],
          [2.41875,           273.279],
          [2.43831,           274.131],
          [2.85947,           275.925],
          [3.14764,           276.604],
          [3.3015,            276.786],
          [3.74222,           276.807],
          [3.85566,           276.902],
          [3.91173,           277.162],
          [1000,              277.165]
]
env = pm.create_env2d(
    depth=bathy,
    soundspeed=ssp,
    bottom_soundspeed=1450,
    bottom_density=1200,
    bottom_absorption=1.0,
    tx_depth=50
)
pm.print_env(env) # To check new bathy

pm.plot_env(env, width=900) #to plot env
pm.plot_ssp(env) #to plot env

#I think code runs fine till here, not calculating rays

rays = pm.compute_eigenrays(env) #computer eigenrays
pm.plot_rays(rays, env=env, width=900)

rays = pm.compute_rays(env) #compute rays
pm.plot_rays(rays, env=env, width=900)
#complains about file missing

---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
<ipython-input-128-dbc7cd561bf0> in <module>
----> 1 rays = pm.compute_rays(env)
      2 pm.plot_rays(rays, env=env, width=900)

~/my_project_arlpy/my_project_env/lib/python3.6/site-packages/arlpy/uwapm.py in compute_rays(env, tx_depth_ndx, model, debug)
    345     if debug:
    346         print('[DEBUG] Model: '+model_name)
--> 347     return model.run(env, rays, debug)
    348 
    349 def compute_transmission_loss(env, tx_depth_ndx=0, mode=coherent, model=None, debug=False):

~/my_project_arlpy/my_project_env/lib/python3.6/site-packages/arlpy/uwapm.py in run(self, env, task, debug)
    569         fname_base = self._create_env_file(env, taskmap[task][0])
    570         if self._bellhop(fname_base):
--> 571             results = taskmap[task][1](fname_base)
    572         else:
    573             results = None

~/my_project_arlpy/my_project_env/lib/python3.6/site-packages/arlpy/uwapm.py in _load_rays(self, fname_base)
    726 
    727     def _load_rays(self, fname_base):
--> 728         with open(fname_base+'.ray', 'rt') as f:
    729             f.readline()
    730             f.readline()

FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpjln3_ui3.ray'

I also get plots for env and SSP.

bokeh_plot(1) bokeh_plot

Do i miss something ? Thanks in advance for your help.

mchitre commented 4 years ago

Thanks. This helps. Will try to reproduce it.

harivnkochi commented 4 years ago

It could be the same as this issue: https://github.com/org-arl/arlpy/issues/40

mchitre commented 4 years ago

Just tested this ... the problem is related to the resolution at which the bathymetry is specified. When rounded off to 4 decimal places in km, 2.41875 and 2.43831 become 0.0024, and Bellhop doesn't like repeated points.

This could be fixed by changing the %0.4f in uwapm to increase number of decimal places. But I don't see the point. The simulation doesn't have the fidelity to deal with such small variations, so my suggested fix for @patel999jay is to provide the bathymetry at a courser resolution (no finer than 0.1 m spacing).

mchitre commented 4 years ago

Changing to 6 decimal places in latest release to avoid this problem.