 websave('test.nc', 'https://cencoos.org/thoon_ww_data/THWW01-d01_2024-06-02_telemetered.nc');
 %%
ww = readncTHOON('test.nc',[],[],0);

THOON_url = 'https://coastwatch.pfeg.noaa.gov/erddap/tabledap/swfscTrinidadCTD.csv';
Ship = webread(THOON_url);
Ship(1,:) = []; % Remove first row.
Ship.time = datetime(Ship.time, 'InputFormat', 'yyyy-MM-dd''T''HH:mm:ss''Z''', 'TimeZone', 'UTC');
%% Get data in same location as THOON
% Define the target coordinates
wwLat = ww.Latitude(1); % target latitude
wwLon = ww.Longitude(1); % target longitude
wgs84 = wgs84Ellipsoid("m");
distance2ww = distance(Ship.latitude,Ship.longitude,wwLat,wwLon,wgs84) / 1000; % km
%%
Ship_crossover = Ship((Ship.station == 2 & Ship.time.Month == 6),:);
%%
tmpSA = gsw_SA_from_SP(Ship_crossover.salinity,Ship_crossover.depth,Ship_crossover.longitude,Ship_crossover.latitude);
pdens = gsw_pot_rho_t_exact(tmpSA,Ship_crossover.temperature,Ship_crossover.depth,0);

moxy = Ship_crossover.dissolved_oxygen .* 44.6596; % magic number?
Ship_crossover.doxy = moxy ./ (pdens./1000); % micromol/kg
%%
figure
clf
scatter(Ship_crossover.time,Ship_crossover.dissolved_oxygen)
ylabel('Dissolved Oxygen (ml/l)')
%%
figure
clf
scatter(Ship_crossover.time,Ship_crossover.doxy)
ylabel('Dissolved Oxygen (\mumol/kg)')