<jupyter_start><jupyter_text>The following cell loads the dataset from an ERDDAP server.  It can be accessed like a opendap/thredds server for netcdf, but sends the data in a **streaming** format which is hard to figure out how to parse.  So instead, download a temporary file specifying the parameters in the url. Alternatives would be to access streaming version of csv file or other filetype from ERDDAP Server and process via pandas<jupyter_code>OcculusGlider = "http://krafla.pmel.noaa.gov:8080/erddap/tabledap/sg401_b9ae_ed68_1861"
cmap = cmocean.cm.thermal
temp_filename = "data/ogtmp.nc"

start_date="2017-07-15"
end_date  ="2017-12-31" 
urllib.urlretrieve(OcculusGlider+".ncCFMA?profileid%2Ctemperature%2Csalinity%2Cdepth%2Ctime&time%3E="+start_date+"T23%3A52%3A00Z&glider=%22Seaglider%20SG401%22",temp_filename)

start_date_dt = datetime.datetime.strptime(start_date,"%Y-%m-%d"),
end_date_dt   = datetime.datetime.strptime(end_date,"%Y-%m-%d")<jupyter_output><empty_output><jupyter_text>Analysis portion.**Purpose: What is the daily distance travelled in nm of the glider?****Method: Calculate the distance between dives on a great circle.  Then sum up each day.  This will give the total distance travelled as opposed to the geometric distance between the first and last dive**<jupyter_code>#datanc = nc.Dataset('data/tmp.nc') #using netcdf library
dataxa = xa.open_dataset('data/ogtmp.nc')

#print dataxa
lat = dataxa.latitude.groupby('profile').mean().values
lon = dataxa.longitude.groupby('profile').mean().values
datatime = dataxa.time.groupby('profile').first().values
from geographiclib.geodesic import Geodesic
import numpy as np

distance = np.ones_like(lat) -1
proftime = np.array([])

for i,v in enumerate(lat):
    proftime = np.hstack([proftime,pd.Timestamp(datatime[i][0]).to_pydatetime()])
    distance[i] = Geodesic.WGS84.Inverse(lat[i],lon[i],lat[i+1],lon[i+1])['s12'] #meters

df = pd.DataFrame(data=distance,index=proftime,columns=['distance'])
dailydistance = df.groupby(pd.TimeGrouper(freq='D')).sum()

#meter to Nautical Mile = x*0.000539957

dailydistance['nm'] = dailydistance['distance']*0.000539957
plt.figure(1, figsize=(18, 6), facecolor='w', edgecolor='w')
plt.subplot(1,1,1)
dailydistance.nm.plot(style='b.')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13476733977172958, 'fraction_numerical': 0.038191395961369626, 'mean_word_length': 6.7517006802721085, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '132001', 'license': 'MIT', 'n_tokens_mistral': 868, 'n_tokens_neox': 800, 'n_words': 181, 'path': 'OculusGlider/2017_OculusGlider_ScienceSubset_Validation/ERDDAP-OculusGlider-SG401_Distance.ipynb', 'repo_name': 'shaunwbell/ipythonnb', 'size': '2278'}