In Terminal, create a tmp.nc file contains necessary variables.
ncks -v nv,iint,Itime,Itime2,Times,lonc,latc,xc,yc,nprocs,partition,zeta superior_0001.nc tmp01.nc
# Variable zeta has the same dimension with variable sst (glc lake surface temperature) and sstwt (weight)
ncap2 -h-s"sst=zeta"-s"sstwt=zeta" tmp01.nc weight.nc
# Add sst and sstwt in the same dimension of zeta
ncatted -h-O-a long_name,sst,o,c,"glc lake surface temperature on fvcom grids" weight.nc
ncatted -h-O-a long_name,sstwt,o,c,"weight" weight.nc
# rename variable attribute
In matlab, extent the time dimension
clc;clear;ncload(['/Users/chuyanzhao/Desktop/FVCOM_output/Lake_Superior/2019/raw_data/LowRes/weight.nc']);%% change variable dimension in nc file
tmp=ones(11986,365);ncwrite('/Users/chuyanzhao/Desktop/FVCOM_output/Lake_Superior/2019/raw_data/LowRes/weight.nc','sstwt',tmp);ncwrite('/Users/chuyanzhao/Desktop/FVCOM_output/Lake_Superior/2019/raw_data/LowRes/weight.nc','sst',tmp);
In matlab, modify the time relevant variables
%% modify iintfori=1:365iint(i)=iint(1)+(i-1)*8640;endncwrite('/Users/chuyanzhao/Desktop/FVCOM_output/Lake_Superior/2019/raw_data/LowRes/weight.nc','iint',iint);%% modify time and date
start_date='2019-01-01 00:00:00';
reference_date='1858-11-17 00:00:00';
num_start_date=datenum(start_date);
num_reference_date=datenum(reference_date);
day_string=strings(1,365);
fvcom_day=strings(1,365);fori=1:365day(i)=num_start_date+(i-1);day_reference(i)=day(i)-num_reference_date;
day_string{i}=datestr(day(i)+0.5,31);fvcom_day(i)=append(day_string{i}(1:10),'T',day_string{i}(12:19),'.000000');tmp_times(i,:)=convertStringsToChars(fvcom_day(i));tmp_itime2(i)=(i-1)*0;end% notice that the dimension is reverse in netcdf file
tmp_times=tmp_times';
day_reference=day_reference';
tmp_times=tmp_itime2';ncwrite('/Users/chuyanzhao/Desktop/FVCOM_output/Lake_Superior/2019/raw_data/LowRes/weight.nc','Times',tmp_times);ncwrite('/Users/chuyanzhao/Desktop/FVCOM_output/Lake_Superior/2019/raw_data/LowRes/weight.nc','time',day_reference);ncwrite('/Users/chuyanzhao/Desktop/FVCOM_output/Lake_Superior/2019/raw_data/LowRes/weight.nc','Itime',day_reference);ncwrite('/Users/chuyanzhao/Desktop/FVCOM_output/Lake_Superior/2019/raw_data/LowRes/weight.nc','Itime2',tmp_itime2);
In matlab, define weight of fvcom results on each node in terms of the distance to boundary