%% SIC&SIT validation
clear
clc

% PAROCE SIC
f1='/Volumes/Backup Plus/PAROCE/siconc_all_icemod_1980_2023.nc';% 1980.1-2023.2
% ncdisp(f1)
sic=ncread(f1,'siconc')*100; 
sic22=sic(:,:,516);
sic22(sic22<5)=nan;
sicclim=nanmean(sic(:,:,24:12:372),3);
sicclim(sicclim<5)=nan;
sicano=sic22-sicclim;

% NSIDC SIC
load lon
load lat
% sicano_JJA_grid=griddata(double(lon0),double(lat0),sicano_JJA,lon,lat);
% sicano_OND_grid=griddata(double(lon0),double(lat0),sicano_OND,lon,lat);
load ntSIC
Cclim=nanmean(C(:,:,36:12:384),3);
Cclim(Cclim<5)=nan;
Cano=C(:,:,528)-Cclim;
% diff_JJA=sicano_JJA-Cano_JJA;
% diff_OND=sicano_OND-Cano_OND;

% GIOMAS SIT
filepath='/Volumes/Backup Plus/SIT reanalysis/GIOMAS/thickness/';
% ncdisp(f)
filelist=dir([filepath,'heff*.nc']);
% k=length(filelist);
for i=3:32
  filename=[filepath,filelist(i).name];
  sit(:,:,:,i)=ncread(filename,'heff');
end
sitclim=nanmean(sit,4);
lat0=ncread(filename,'lat_scaler');
lon0=ncread(filename,'lon_scaler');
filename=[filepath,filelist(44).name];
sit22=ncread(filename,'heff');
sitano=sit22-sitclim;
sitano(sit22<0.01)=nan;
sitano_G=sitano(:,:,12);
sitano_G(sitano_G>600)=nan;

% PAROCE SIT
f2='/Volumes/Backup Plus/PAROCE/sivolu_all_icemod_1980_2023.nc';% 1980.1-2023.2
siv=ncread(f2,'sivolu');
siv22=siv(:,:,516);
siv22(isnan(sic22)==1)=nan;
X=ncread(f2,'nav_lon');
Y=ncread(f2,'nav_lat');
X=double(X);
Y=double(Y);
sivclim=nanmean(siv(:,:,24:12:372),3);
sivano=siv22-sivclim;

% quantify
ind=find(X>-180&X<-120&Y>-80&Y<-70);
nanmean(sivano(ind));
nanmean(sicano(ind));

ind=find(lon0>180&lon0<240&lat0>-80&lat0<-70);
nanmean(sitano_G(ind));

ind=find(lon>-180&lon<-120&lat>-80&lat<-70);
nanmean(Cano(ind));

%%
set(gcf,'Position',[350 200 500 500]);
ha = tight_subplot(2,2,[0.08 0.02],[.04 .04],[.02 .02]);
axes(ha(1))
% m_proj('lambert','long',[-179 -110],'lat',[-85 -55]);
% m_proj('azimuthal equal-area','latitude',-90,'radius',55,'rectbox','on');
m_proj('azimuthal equal-area','latitude',-70,'longitude',-140,'radius',30,'rectbox','on');
hold on;
m_pcolor(X,Y,sicano);
m_gshhs_i('color','k');
m_grid('xaxislocation','top','xtick',[-160 -120],'ytick',[-90 -80 -70 -60 -50],'fontsize',10);
colortable = textread('/Users/jinfei/Documents/MATLAB/colorbar/sunshine_diff_12lev.txt');
colormap(ha(1),colortable);
caxis([-50 50]);
% m_line([-120,-120],[-80,-70],'color','r','linewi',2);
% m_line([-180,-180],[-80,-70],'color','r','linewi',2);
% m_line(-180:-120,-70:-70,'color','r','linewi',2);
% m_line(-180:-120,-80:-80,'color','r','linewi',2);

axes(ha(2))
% m_proj('azimuthal equal-area','latitude',-90,'radius',55,'rectbox','on');
m_proj('azimuthal equal-area','latitude',-70,'longitude',-140,'radius',30,'rectbox','on');
hold on;
m_pcolor(lon,lat,Cano);
m_gshhs_i('color','k');
m_grid('xaxislocation','top','xtick',[-160 -120],'ytick',[-90 -80 -70 -60 -50],'fontsize',10);
colortable = textread('/Users/jinfei/Documents/MATLAB/colorbar/sunshine_diff_12lev.txt');
colormap(ha(2),colortable);
caxis([-50 50]);
% m_line([-120,-120],[-80,-70],'color','r','linewi',2);
% m_line([-180,-180],[-80,-70],'color','r','linewi',2);
% m_line(-180:-120,-70:-70,'color','r','linewi',2);
% m_line(-180:-120,-80:-80,'color','r','linewi',2);

axes(ha(3))
% m_proj('azimuthal equal-area','latitude',-90,'radius',55,'rectbox','on');
m_proj('azimuthal equal-area','latitude',-70,'longitude',-140,'radius',30,'rectbox','on');
hold on;
m_pcolor(X,Y,sivano);
m_gshhs_i('patch',[.8 .8 .8],'edgecolor',[.8 .8 .8],'MarkerSize',0.1);
m_grid('xaxislocation','top','xtick',[-160 -120],'ytick',[-90 -80 -70 -60 -50],'fontsize',10);
colortable = textread('/Users/jinfei/Documents/MATLAB/colorbar/ncl_default.txt');
colormap(ha(3),colortable);
caxis([-0.5 0.5]);
% m_line([-120,-120],[-80,-70],'color','r','linewi',2);
% m_line([-180,-180],[-80,-70],'color','r','linewi',2);
% m_line(-180:-120,-70:-70,'color','r','linewi',2);
% m_line(-180:-120,-80:-80,'color','r','linewi',2);

axes(ha(4))
% m_proj('azimuthal equal-area','latitude',-90,'radius',55,'rectbox','on');
m_proj('azimuthal equal-area','latitude',-70,'longitude',-140,'radius',30,'rectbox','on');
hold on;
m_pcolor(lon0,lat0,sitano_G);
m_gshhs_i('patch',[.8 .8 .8],'edgecolor',[.8 .8 .8],'MarkerSize',0.1);
m_grid('xaxislocation','top','xtick',[-160 -120],'ytick',[-90 -80 -70 -60 -50],'fontsize',10);
colortable = textread('/Users/jinfei/Documents/MATLAB/colorbar/ncl_default.txt');
colormap(ha(4),colortable);
caxis([-0.5 0.5]);
% m_line([-120,-120],[-80,-70],'color','r','linewi',2);
% m_line([-180,-180],[-80,-70],'color','r','linewi',2);
% m_line(-180:-120,-70:-70,'color','r','linewi',2);
% m_line(-180:-120,-80:-80,'color','r','linewi',2);
