Beispiel #1
0
def bathymetry(pst, ext1, ext2, fit_model='hk', inv='spm', save=True):
    """Compute bathymetry

    Arguments
    ---------
    pst : string
        pst pattern (example: 'MIS_JKB2e*')
    ext1 : string
        file extension for the top interface (e.g. 'srf_cyg.hk.spm')
    ext2 : string
        file extension for the bottom interface (e.g. 'srf_cyg.hk.spm')

    Keywords
    --------
    fit_model : string
        statistical method used
    inv : string
        backscattering model used for physical properties inversion
    save : bool
        wether to save the results in a txt file
    """
    rsr1 = raw.read_rsr(pst, ext1, fit_model=fit_model, inv=inv)
    z1, pik1 = raw.read_pik(pst, ext1)
    z2, pik2 = raw.read_pik(pst, ext2, process='MagHiResInco1')

    # Parameters
    lat = rsr1.lat
    lon = rsr1.lon
    eps = rsr1.eps
    crl = rsr1.crl
    sh = rsr1.eps
    roll = rsr1.roll
    flag = rsr1.flag
    w = rsr1.xa.values.tolist()
    delay = abs(z2[w]-z1[w])*20e-9
    delay[np.isnan(delay)] = 0.

    # Results    
    z = [dns_depth(eps[i], delay[i]) for i, val in enumerate(eps)]
    depth = [i[0] for i in z]
    uncertainty = [i[1] for i in z]
    dns_at_depth = [i[2] for i in z]

    out = {'lat':lat, 'lon':lon, 'eps':eps, 'sh':sh, 'crl':crl, 'delay':delay, 
           'uncertainty':uncertainty, 'depth':depth, 'dns_at_depth':dns_at_depth,
           'roll':roll, 'flag':flag}
    out = pd.DataFrame(out)

    if save is True:
        save_fil = rsr_path + '/' + string.join(pst.split('/'), '_') + '.' + \
                   ext1 + '-' + ext2
        out.to_csv(save_fil + '.bthm.txt', sep='\t', index=False, float_format='%.7f')

    return out
Beispiel #2
0
def inline_rsr(pst, ext, fit_model='hk', inv='spm', save=True, winsize=1000.,
               sampling=250., verbose=True, process='MagHiResInco1', other_gain=logain,
               rng='surface', **kwargs):
    """launch sliding RSR along a track

    Arguments
    ---------
    pst : string
        pst name (e.g. 'MIS/JKB2e/Y35a')
    ext : string
        pik file extension (e.g. 'elg_brn') for the echo
    
    Keywords
    --------
    save : bool
        wether or not to save the results
    """
    #--------------------------------------------------------------------------
    # Data Retrieval
    #--------------------------------------------------------------------------
    geo = raw.read_geo(pst)
    y, val = raw.read_pik(pst, ext, process=process)
    if rng is 'surface':    
        rng = geo.rng[np.arange(val.size)]
    if rng is 'bed':
        bthm = raw.read_bthm(pst, '*', ext)
        air_rng = geo.rng[np.arange(val.size)]
        x, xp, fp = np.arange(val.size), np.arange(bthm.shape[0]), np.array(bthm.depth)
        sub_rng = np.interp(x, xp, fp)
        rng = air_rng + sub_rng
    amp = 10**(calibration(val, rng=rng, other=other_gain)/20.)
    #--------------------------------------------------------------------------
    # Data Retrieval
    #--------------------------------------------------------------------------
    b = rsr.utils.inline_estim(amp, frq=frq, fit_model=fit_model, inv=inv, winsize=winsize, sampling=sampling, verbose=verbose, **kwargs)
    xo = np.round(np.array(b.xo)) # positions of the computed statistics
    b['lat'] = np.array(geo.ix[xo, 'lat'])
    b['lon'] = np.array(geo.ix[xo, 'lon'])
    b['roll'] = np.array(geo.ix[xo, 'roll'])
    b['rng'] = np.array(geo.ix[xo, 'rng'])

    if save is True:
        save_fil = string.replace(os.getcwd(), 'code', 'targ') + '/' + \
                   string.join(pst.split('/'), '_') + '.' + ext + '.' + fit_model + '.' + inv
	title = pst + ' ' + ext
        b.to_csv(save_fil + '.txt', sep='\t', index=False, float_format='%.7f')
        rsr.utils.plot_inline(b, frq=frq, title=title)
        plt.savefig(save_fil + '.png', bbox_inches='tight')
    return b
Beispiel #3
0
def inline_rsr(
    pst,
    ext,
    fit_model="hk",
    inv="spm",
    save=True,
    winsize=1000.0,
    sampling=250.0,
    verbose=True,
    process="MagHiResInco1",
    other_gain=logain,
    rng="surface",
    **kwargs
):
    """launch sliding RSR along a track

    Arguments
    ---------
    pst : string
        pst name (e.g. 'MIS/JKB2e/Y35a')
    ext : string
        pik file extension (e.g. 'elg_brn') for the echo
    
    Keywords
    --------
    save : bool
        wether or not to save the results
    """
    # --------------------------------------------------------------------------
    # Data Retrieval
    # --------------------------------------------------------------------------
    geo = raw.read_geo(pst)
    y, val = raw.read_pik(pst, ext, process=process)
    if rng is "surface":
        rng = geo.rng[np.arange(val.size)]
    if rng is "bed":
        bthm = raw.read_bthm(pst, "*", ext)
        air_rng = geo.rng[np.arange(val.size)]
        x, xp, fp = np.arange(val.size), np.arange(bthm.shape[0]), np.array(bthm.depth)
        sub_rng = np.interp(x, xp, fp)
        rng = air_rng + sub_rng
    amp = 10 ** (calibration(val, rng=rng, other=other_gain) / 20.0)
    # --------------------------------------------------------------------------
    # Data Retrieval
    # --------------------------------------------------------------------------
    b = rsr.utils.inline_estim(
        amp, frq=frq, fit_model=fit_model, inv=inv, winsize=winsize, sampling=sampling, verbose=verbose, **kwargs
    )
    xo = np.round(np.array(b.xo))  # positions of the computed statistics
    b["lat"] = np.array(geo.ix[xo, "lat"])
    b["lon"] = np.array(geo.ix[xo, "lon"])
    b["roll"] = np.array(geo.ix[xo, "roll"])
    b["rng"] = np.array(geo.ix[xo, "rng"])

    if save is True:
        save_fil = (
            string.replace(os.getcwd(), "code", "targ")
            + "/"
            + string.join(pst.split("/"), "_")
            + "."
            + ext
            + "."
            + fit_model
            + "."
            + inv
        )
        title = pst + " " + ext
        b.to_csv(save_fil + ".txt", sep="\t", index=False, float_format="%.7f")
        rsr.utils.plot_inline(b, frq=frq, title=title)
        plt.savefig(save_fil + ".png", bbox_inches="tight")
    return b
Beispiel #4
0
def bathymetry(pst, ext1, ext2, fit_model="hk", inv="spm", save=True):
    """Compute bathymetry

    Arguments
    ---------
    pst : string
        pst pattern (example: 'MIS_JKB2e*')
    ext1 : string
        file extension for the top interface (e.g. 'srf_cyg.hk.spm')
    ext2 : string
        file extension for the bottom interface (e.g. 'srf_cyg.hk.spm')

    Keywords
    --------
    fit_model : string
        statistical method used
    inv : string
        backscattering model used for physical properties inversion
    save : bool
        wether to save the results in a txt file
    """
    rsr1 = raw.read_rsr(pst, ext1, fit_model=fit_model, inv=inv)
    z1, pik1 = raw.read_pik(pst, ext1)
    z2, pik2 = raw.read_pik(pst, ext2, process="MagHiResInco1")

    # Parameters
    lat = rsr1.lat
    lon = rsr1.lon
    eps = rsr1.eps
    crl = rsr1.crl
    sh = rsr1.eps
    roll = rsr1.roll
    flag = rsr1.flag
    w = rsr1.xa.values.tolist()
    delay = abs(z2[w] - z1[w]) * 20e-9
    delay[np.isnan(delay)] = 0.0

    # Results
    z = [dns_depth(eps[i], delay[i]) for i, val in enumerate(eps)]
    depth = [i[0] for i in z]
    uncertainty = [i[1] for i in z]
    dns_at_depth = [i[2] for i in z]

    out = {
        "lat": lat,
        "lon": lon,
        "eps": eps,
        "sh": sh,
        "crl": crl,
        "delay": delay,
        "uncertainty": uncertainty,
        "depth": depth,
        "dns_at_depth": dns_at_depth,
        "roll": roll,
        "flag": flag,
    }
    out = pd.DataFrame(out)

    if save is True:
        save_fil = rsr_path + "/" + string.join(pst.split("/"), "_") + "." + ext1 + "-" + ext2
        out.to_csv(save_fil + ".bthm.txt", sep="\t", index=False, float_format="%.7f")

    return out