<jupyter_start><jupyter_text>Stokes drift at ocean station PapaThis notebook computes the surface Stokes drift from the momentum fluxes assuming a constant Langmuir number.<jupyter_code>import sys
import os
import numpy as np
import xarray as xr
import pandas as pd
sys.path.append("../gotmtool")
from gotmtool import *<jupyter_output><empty_output><jupyter_text>Load data<jupyter_code>paparoot = os.environ['HOME']+'/data/OCS/Papa/Papa_20100616-20150101'
startdate = '2012-03-20'
enddate = '2013-03-22'
La_turb = 0.31
rho = 1027.<jupyter_output><empty_output><jupyter_text>Compute Stokes drift<jupyter_code># load momentum flux input data
fname = 'tau50n145w_hr.cdf'
ds = xr.load_dataset(paparoot+'/'+fname).sel(time=slice(startdate, enddate))
if '_FillValue' in ds.attrs:
    skipvalue = ds.attrs['_FillValue']
elif 'missing_value' in ds.attrs:
    skipvalue = ds.attrs['missing_value']
else:
    skipvalue = None
time = ds.time.values
ntime = time.size
dttime = [pd.Timestamp(time[i]).to_pydatetime() for i in np.arange(ntime)]
# vector variable
vnamex = 'TX_442'
vnamey = 'TY_443'
datax = ds.data_vars[vnamex].values.squeeze()
datay = ds.data_vars[vnamey].values.squeeze()
us0 = np.sign(datax)*np.sqrt(np.abs(datax)/rho)*La_turb**(-2)
vs0 = np.sign(datay)*np.sqrt(np.abs(datay)/rho)*La_turb**(-2)
us0[datax==skipvalue] = np.nan
vs0[datay==skipvalue] = np.nan<jupyter_output><empty_output><jupyter_text>Save Stokes drift to file<jupyter_code>dat_dump_ts(dttime, [us0, vs0], 'ospapa_us0_La0p{:d}.dat'.format(int(La_turb*100))
            , skip_value=np.nan)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14339622641509434, 'fraction_numerical': 0.03962264150943396, 'mean_word_length': 6.434579439252336, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '323634', 'license': 'MIT', 'n_tokens_mistral': 669, 'n_tokens_neox': 626, 'n_words': 114, 'path': 'OSPapa/preprocess_OSPapa_Stokes_drift_const_La.ipynb', 'repo_name': 'qingli411/A2020_CVMix_in_GOTM', 'size': '1590'}