clc;clear all;close all
% file='/data3/yiwen/matlab_coawst/particle_tracking/ROMS_log_files/Bitou_WIND/TS_const/Check_UV/20240704_0731/Bitou_ocean_his.nc'
% file='/data3/yiwen/matlab_coawst/particle_tracking/ROMS_log_files/Bitou_WIND/TS_const/Check_UV/20240704_0819/Bitou_ocean_his_0819.nc'
file='/data3/yiwen/matlab_coawst/particle_tracking/ROMS_log_files/Bitou_WIND/TS_const/Check_UV/20240704_0914/Bitou_ocean_his.nc'

lon=ncread(file,'lon_rho');
lat=ncread(file,'lat_rho');

%surface U&V
u6=squeeze(ncread(file,'u_eastward',[1 1 6 13441],[Inf Inf 1 Inf]));  
v6=squeeze(ncread(file,'v_northward',[1 1 6 13441],[Inf Inf 1 Inf]));

%bottom U&V
% u1=squeeze(ncread(file,'u_eastward',[1 1 1 1],[Inf Inf 1 Inf]));  
% v1=squeeze(ncread(file,'v_northward',[1 1 1 1],[Inf Inf 1 Inf]));

patho='/data3/yiwen/matlab_coawst/particle_tracking/Offline_output/2025/0519_tracking/'
% fn = [patho '202407.mat'];
% fn = [patho '202408_0819.mat'];  %temporary
% fn = [patho '202408_0906.mat'];    %temporary
fn = [patho '202408_0914.mat'];
save(fn,'lon','lat','u6','v6','-v7.3')
%%
% let topo position == nan %
% load([pathi1,'case1_0hr'])
% file='Bitou_ocean_his.nc'
% pathi1='/data3/yiwen/matlab_coawst/particle_tracking/1002_tracking/2AREA/'
% lon=ncread(file,'lon_rho');lat=ncread(file,'lat_rho');
% load([pathi1,'case1_0hr'])
% mask=ncread(file,'mask_rho');
% 
% index_x=lon(mask==0);index_x1=round(index_x,5);
% index_y=lat(mask==0);index_y1=round(index_y,5);
% index_x=unique(index_x1);index_y=unique(index_y1);
% xx=round(xx,5);yy=round(yy,5);
% 
% % index_xloc=index_x-10*1e-5<= index_x <=index_x+10*1e-5;
% % index_yloc=index_y-10*1e-5<= index_y <=index_y+10*1e-5;
% logicalIndex = ismember(xx, index_x);
% logicalIndey = ismember(yy, index_y);
% xx(logicalIndex) = 0.4;yy(logicalIndey) = 0.4;
















