Exemplo n.º 1
0
# extract_velocities_3.py can now pull from ptm average files.
# but does it do so correctly?
# maybe.  not obviously wrong.

import track_common
import matplotlib.pyplot as plt
import stompy.plot.cmap as scmap
from stompy.spatial import field

##
turbo = scmap.load_gradient('turbo.cpt')
dem = field.GdalGrid("../../bathy/junction-composite-dem-no_adcp.tif")

##

tracks = track_common.read_from_folder('mergedhydro_v00')
##

track_lengths = [len(t) for t in tracks['withhydro']]

longest = np.argmax(track_lengths)

track = tracks.iloc[38, :]['withhydro']

##

fig, ax = plt.subplots(1, 1, num=1)

ax.plot(track.x, track.y, 'g.')

pad = 50
Exemplo n.º 2
0
    n_expand = di.sum() + 1
    tgts = np.r_[0, np.cumsum(di)]
    expanded = np.nan * np.zeros(n_expand)
    expanded[tgts] = data
    return expanded


##

input_path = "screen_final"
#input_path="with_nonsmolt"
fig_dir = os.path.join(input_path, 'figs-20200921')
if not os.path.exists(fig_dir):
    os.makedirs(fig_dir)

df = track_common.read_from_folder(input_path)

# With multiple velocities, need this stanza to choose one

# RH: return to this code to compare heading distributions
vel_suffix = '_top2m'
df['track'].apply(track_common.calc_velocities,
                  model_u='model_u' + vel_suffix,
                  model_v='model_v' + vel_suffix)

track_common.clip_to_analysis_polygon(df, 'track')


##
def add_more_swim_data(track):
    swim_hdg_rel_uw = np.r_[unwrap(track['swim_hdg_rel'].values[:-1]), np.nan]
Exemplo n.º 3
0
import pandas as pd

from stompy import utils

utils.path("../../../field/hor_yaps")
import track_common

##

master_in="../../../field/hor_yaps/screen_final"

df=track_common.read_from_folder(master_in)

# Make this look like Ed's input:
df_ptm=pd.DataFrame()
df_ptm['track']=df['basename'].str.replace('.csv','')
df_ptm['tag']=df.index.values

##

# Find the x,y for the time of entry:
df_ptm['entry_time']=np.nan # if 1st detection was above array
df_ptm['first_detection_time']=np.nan  # But not before array
df_ptm['exit_time']=np.nan
df_ptm['x']=np.nan
df_ptm['y']=np.nan
df_ptm['route']=""

for idx,rec in df.iterrows():
    entry_t=rec['top_of_array_first']
    if np.isnan(entry_t):
Exemplo n.º 4
0
from stompy.plot import plot_utils
from stompy import utils,memoize
from stompy.grid import unstructured_grid
from stompy.grid import ugrid

import pandas as pd
import xarray as xr
import numpy as np

import track_common
##
import six
six.moves.reload_module(track_common)

if 1: # for fish tracks
    df_in=track_common.read_from_folder('merged_v00')
    output_path='mergedhydro_v00_sun'
else: # for ADCP data
    df_in=track_common.read_from_folder('adcp_2018')
    output_path='adcp_2018_hydro'

col_in='track'
col_out='track'

use_ptm_output=False

if use_ptm_output:
    avg_fns=glob.glob("E:/Home/rustyh/SanJoaquin/model/suntans/cfg008/*/*.nc")
    avg_fns.sort()
    avg_ncs=[]
    for fn in avg_fns:
import seaborn as sns
from stompy import memoize, utils
import pandas as pd
from stompy.io.local import cdec
from scipy.stats.kde import gaussian_kde
from scipy import signal
##

vel_suffix = '_top2m'

fig_dir = "fig_analysis-20210623" + vel_suffix
if not os.path.exists(fig_dir):
    os.makedirs(fig_dir)

##
df_start = track_common.read_from_folder('screen_final')

##

df_start['track'].apply(track_common.calc_velocities,
                        model_u='model_u' + vel_suffix,
                        model_v='model_v' + vel_suffix)

# Do this after the swimspeeds are computed, otherwise when
# a track leaves and comes back, there will be a swim speed
# that jumps from the exit point to the re-entry point
track_common.clip_to_analysis_polygon(df_start, 'track')

##
# Day-night variability
Exemplo n.º 6
0
import os, glob
from stompy import memoize
from stompy.io.local import cdec
from scipy import signal

yaps_dir = "../../../field/hor_yaps"
utils.path(yaps_dir)

import track_common

utils.path("../../../model/suntans")
import common
##

df_start = track_common.read_from_folder(os.path.join(yaps_dir,
                                                      'screen_final'))
t_min = df_start.track.apply(lambda t: t.tnum.min())
t_max = df_start.track.apply(lambda t: t.tnum.min())
t_mid = 0.5 * (t_min + t_max)
df_start['t_mid'] = t_mid


##
@memoize.memoize(lru=10)
def fetch_and_parse(local_file, url, **kwargs):
    if not os.path.exists(local_file):
        if not os.path.exists(os.path.dirname(local_file)):
            os.makedirs(os.path.dirname(local_file))
        utils.download_url(url, local_file, on_abort='remove')
    return pd.read_csv(local_file, **kwargs)
    axs[2].set_xlabel('Standard deviation of position estimates')
    axs[0].set_ylabel('Count of position estimates')
    axs[1].set_ylabel('Count of position estimates')
    axs[2].set_ylabel('Count of position estimates')
    
    fig.savefig(os.path.join(fig_dir,'merge-distribution-stddev.png'))
##

# Write these out so we can get hydro
six.moves.reload_module(track_common)
track_common.dump_to_folder(df_merged,'merged_v00')

##

# Read them back in with hydro
df_mergedh=track_common.read_from_folder('mergedhydro_v00_sun')
if 'withhydro' in df_mergedh.columns:
    del df_mergedh['track']
    df_mergedh.rename( columns={'withhydro':'track'}, inplace=True)

##

df=df_mergedh

# Apply some prefiltering

# This got rid of some actually pretty nice tracks lik 7A96.
# Relax the sd test to 10.0m
    
# Toss solutions with <2 receivers and with std-dev greater than 10.0m
# Then trim the ends to start/end with a 3-rx solution.