Skip to content

Commit

Permalink
Update to v1.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
s-watanabe-jhod committed Jul 2, 2024
1 parent 6bab4a9 commit df4d55a
Show file tree
Hide file tree
Showing 19 changed files with 93 additions and 125 deletions.
13 changes: 5 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
<img src="https://github.com/s-watanabe-jhod/garpos/assets/68180987/ed955d3c-4c3b-4ca3-91d5-f57b876cfa7b" width=400 alt="GARPOS">
# GARPOS

"GARPOS" (GNSS-Acoustic Ranging combined POsitioning Solver) is an analysis tool for GNSS-Acoustic seafloor positioning.

### Version
Latest version is GARPOS v1.0.1 (Apr. 5. 2022)
Latest version is GARPOS v1.0.2 (Jul. 2. 2024)

#### Major change(s)
* v1.0.2: to apply a mode for "array take-over" (solve each transponder's position and parallel disp. simultaneously)
* v1.0.2: parameter "invtyp" is deleted. Users can set zero in config files to solve limited parameter(s), instead.
* v1.0.1: to set B-spline's knots by time interval (also need to change "Setup.ini" file)
* v1.0.1: to use Cholesky decomposition (module "sksparse" is needed)
* NOTE: some reported that "sksparse" cannot be used on Apple M1 Chip.

# Citation

Expand All @@ -17,6 +18,7 @@ Latest version is GARPOS v1.0.1 (Apr. 5. 2022)
Watanabe, S., Ishikawa, T., Yokota, Y., & Nakamura, Y. (2020). GARPOS: analysis software for the GNSS-A seafloor positioning with simultaneous estimation of sound speed structure, Front. Earth Sci. (https://doi.org/10.3389/feart.2020.597532).

### for code

Shun-ichi Watanabe, Tadashi Ishikawa, Yuto Nakamura & Yusuke Yokota. (2022). GARPOS: Analysis tool for GNSS-Acoustic seafloor positioning (Version 1.0.1). Zenodo. (https://doi.org/10.5281/zenodo.6414642)

## Corresponding author
Expand All @@ -31,11 +33,6 @@ Shun-ichi Watanabe, Tadashi Ishikawa, Yuto Nakamura & Yusuke Yokota. (2022). GAR
"GARPOS" is distributed under the [GPL 3.0] (https://www.gnu.org/licenses/gpl-3.0.html) license.


### Algorithm and documentation

Please see Watanabe, S., Ishikawa, T., Yokota, Y., and Nakamura, Y., (2020) https://doi.org/10.3389/feart.2020.597532


# Requirements

* Python 3.7.3
Expand Down
Binary file removed bin/garpos_v101/f90lib/lib_raytrace.so
Binary file not shown.
Binary file removed bin/garpos_v101/f90lib/subraytrace.mod
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file added bin/garpos_v102/f90lib/lib_raytrace.so
Binary file not shown.
File renamed without changes.
Binary file added bin/garpos_v102/f90lib/subraytrace.mod
Binary file not shown.
4 changes: 2 additions & 2 deletions bin/garpos_v101/forward.py → bin/garpos_v102/forward.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ def calc_gamma(mp, shotdat, imp0, spdeg, knots):
a1 = []
for k, kn in enumerate(knots):
if len(kn) == 0:
a0.append( 0. )
a1.append( 0. )
a0.append( np.zeros(len(shotdat.ST)) )
a1.append( np.zeros(len(shotdat.RT)) )
continue
ct = mp[imp0[k]:imp0[k+1]]
bs = BSpline(kn, ct, spdeg, extrapolate=False)
Expand Down
77 changes: 35 additions & 42 deletions bin/garpos_v101/garpos_main.py → bin/garpos_v102/garpos_main.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -25,60 +25,57 @@
def parallelrun(inplist, maxcore):
"""
Run the model parameter estimation in parallel.
Parameters
----------
inplist : DataFrame
List of arguments for the function.
maxcore : int
maximum number of parallelization.
Returns
-------
inplist : DataFrame
List of arguments for the function in which brief results are added.
"""

npara = len(inplist.index)
mc = min(maxcore, npara)

# Input files
i0 = inplist.cfgfile
i1 = inplist.invcfg

# Output parameters
o1 = inplist.outdir
o2 = inplist.suffix

# Hyperparameters
h0 = inplist.lamb0.values
h1 = inplist.lgrad.values
h2 = inplist.mu_t.values
h3 = inplist.mu_m.values

# Inversion design parameters
p0 = inplist.loc[:, ["de","dn","du"]].values

inp = list(zip(i0,i1,o1,o2,h0,h1,h2,h3,p0))


inp = list(zip(i0,i1,o1,o2,h0,h1,h2,h3))

with Pool(processes=mc) as p:
reslist = p.starmap(MPestimate, inp)
p.close()

inplist["resfile"] = [ r[0] for r in reslist ]
inplist["RMS_dTT"] = [ r[1]/1000. for r in reslist ]
inplist["ABIC"] = [ r[2] for r in reslist ]
inplist["dE"] = [ r[3][0] for r in reslist ]
inplist["dN"] = [ r[3][1] for r in reslist ]
inplist["dU"] = [ r[3][2] for r in reslist ]

return inplist


def drive_garpos(cfgf, icfgf, outdir, suf, maxcore):
"""
Main driver to run GARPOS.
Parameters
----------
cfgf : string
Expand All @@ -91,54 +88,54 @@ def drive_garpos(cfgf, icfgf, outdir, suf, maxcore):
Suffix to be added for result files.
maxcore : int
maximum number of parallelization.
Returns
-------
resf : string
Result site-paramter file name (min-ABIC model).
"""

# Set Hyperparamters for search
icfg = configparser.ConfigParser()
icfg.read(icfgf, 'UTF-8')

lamb0s = icfg.get("HyperParameters", "Log_Lambda0").split()
glambs = icfg.get("HyperParameters", "Log_gradLambda").split()
mu_ts = icfg.get("HyperParameters", "mu_t").split()
mu_ms = icfg.get("HyperParameters", "mu_mt").split()

lamb0s = np.array(list(map(float, lamb0s)))
glambs = np.array(list(map(float, glambs)))
mu_ts = np.array(list(map(float, mu_ts)))
mu_ms = np.array(list(map(float, mu_ms)))

nl = len(lamb0s)
ng = len(glambs)
nt = len(mu_ts)
nm = len(mu_ms)
nmodels = nl * ng * nt * nm

if nmodels == 1:
wkdir = outdir
elif nmodels > 1:
wkdir = outdir+ "/lambda/"
else:
print("error in hyper paramter setting")
sys.exit(1)

if not os.path.exists(wkdir+"/"):
os.makedirs(wkdir)

# Set File Name
cfg = configparser.ConfigParser()
cfg.read(cfgf, 'UTF-8')
site = cfg.get("Obs-parameter", "Site_name")
camp = cfg.get("Obs-parameter", "Campaign")
filebase = site + "." + camp + suf

# Set Input parameter list for ParallelRun
hps = np.array(list(itertools.product(lamb0s, glambs, mu_ts, mu_ms)))

sufs = [ suf ] * nmodels
for i, hp in enumerate(hps):
if nl > 1:
Expand All @@ -149,31 +146,28 @@ def drive_garpos(cfgf, icfgf, outdir, suf, maxcore):
sufs[i] += "_T%03.1f" % hp[2]
if nm > 1:
sufs[i] += "_mt%03.1f" % hp[3]

inputs = pd.DataFrame(sufs, columns = ['suffix'])

inputs['lamb0'] = 10.**hps[:,0]
inputs['lgrad'] = 10.**hps[:,1]
inputs['mu_t'] = hps[:,2]*60.
inputs['mu_m'] = hps[:,3]

print(inputs)

inputs["de"] = 0.0
inputs["dn"] = 0.0
inputs["du"] = 0.0

inputs["cfgfile"] = cfgf
inputs["invcfg"] = icfgf
inputs["outdir"] = wkdir

outputs = parallelrun(inputs, maxcore)

resf = outputs.resfile[0]
score='ABIC'

df = outputs.sort_values(score, ascending=True).reset_index(drop=True)
resf = df.resfile[0]

if nmodels > 1:
print(resf)
bestfile = os.path.basename(resf)
Expand All @@ -182,24 +176,23 @@ def drive_garpos(cfgf, icfgf, outdir, suf, maxcore):
fls = sorted(glob.glob(dfl+"/"+bestfile.replace("-res.dat","-*")))
for ff in fls:
shutil.copy(ff, outdir+"/"+os.path.basename(ff))

# to summarize the results
df["log(Lambda)"] = [math.log10(l) for l in df.lamb0]
df["log(L_grad)"] = [math.log10(l) for l in df.lgrad]
df["mu(t)"] = df.mu_t/60.

df = df.loc[:,[score,"log(Lambda)","log(L_grad)","mu(t)","dE","dN","dU"]]

if nl <= 1:
df=df.drop("log(Lambda)", axis=1)
if ng <= 1:
df=df.drop("log(L_grad)", axis=1)
if nt <= 1:
df=df.drop("mu(t)", axis=1)

print(df)
of = wkdir + "searchres-%s.dat" % filebase
df.to_csv(of)

return resf

Loading

0 comments on commit df4d55a

Please sign in to comment.