function plot_JAGUAR_u_N2_yz_20181216_2030(lonque)

% Download functions from Hindley et al. (2021) from
% https://doi.org/10.5281/zenodo.4721883 (Hindley, 2021)
addpath("../nhindley-acp-2020-465-2d5b3b8/AnalysisCode/", "../nhindley-acp-2020-465-2d5b3b8/Functions/")
datadir='../data/';
y=2018;
d=350;
g=196;
cdy='20181216';

fig=figure;
Position = [100 100 700 500];
fig.Position=Position;

t=tiledlayout(1,2);
t.Padding='compact';

f=gobjects(2);


cfile=[datadir '20181216-2030_Model_T_asAIRS196_300m.mat'];
cfile3DST=[datadir 'JAGUAR_fullres_3DST_20181216-2030_g196.mat'];
cfileu=[datadir '20181216-2030_intpu_300m.nc'];

ui = ncread(cfileu,'ui');
load('../JAGUARgrid.mat')
zg=10:0.3:90.1;
xq=knnsearch(Lon,lonque);
Vq = squeeze(ui(xq,:,:));
        
[Zq,Yq]=meshgrid(zg,Lat);

%------------------------------%
%--- Lon-Lat maps           ---%
%------------------------------%
i=1;
f(i)=nexttile;
set(f(i),'Fontsize',10)

axis([45 69 10 70])
xticks(-90:5:90)
xticklabels({'90S' '85S' '80S' '75S' '70S' '65S' '60S' '55S' '50S' '45S' '40S' '35S' '30S' '25S' '20S' '15S' '10S' '5S' 'EQ' '5N' '10N' '15N' '20N' '25N' '30N' '35N' '40N' '45N' '50N' '55N' '60N' '65N' '70N' '75N' '80N' '85N' '90N'})
ytickformat('%g km')
ylabel('Altitude')
hold on
box on
contourf(f(i),Yq,Zq,Vq,'LineStyle','none','LevelStep',1);
colorbar(f(i),'eastoutside')
load('colormap_blue-red.mat')
colormap(f(i),CustomColormap1)
clim([-100 100])
title(f(i),'Zonal Wind (ms^{-1})','FontSize',12,'FontWeight','normal','FontName','Helvetica')
%------------------------------%

load(cfile3DST,"N2");
M = load(cfile);
lon  = squeeze(M.xg(:,:,1));
lon(lon>360) = lon(lon>360)-360; %0 - 360
lat  = squeeze(M.yg(:,:,1));
zg   = M.Model.Alt;
distx = zeros(89,135);
for j=1:135
    for i=1:89
        distx(i,j)=nph_haversine([lat(i,j) lon(i,j)],[lat(i+1,j) lon(i+1,j)]);
    end
end
disty = zeros(90,134);
for j=1:134
    for i=1:90
        disty(i,j)=nph_haversine([lat(i,j) lon(i,j)],[lat(i,j+1) lon(i,j+1)]);
    end
end

locx = zeros(90,135);
for j=1:135
    for i=44:-1:1
        locx(i,j)=locx(i+1,j)-distx(i,j);
    end
    for i=46:90
        locx(i,j)= locx(i-1,j)+distx(i-1,j);
    end
end
locy = zeros(90,135);
for j=2:135
    for i=1:90
        locy(i,j)= locy(i,j-1)+disty(i,j-1);
    end
end

load('grid_granule.mat','xg','yg')
xmin=max(locx(1,:),[],'all');
xmax=min(locx(90,:),[],'all');
ymax=min(locy(:,135),[],'all');
[ygm,xgm]=meshgrid(yg(yg<=ymax),xg((xg>=xmin)&(xg<=xmax)));

lonq = griddata(double(locx),double(locy),double(lon),double(xgm),double(ygm));
latq = griddata(double(locx),double(locy),double(lat),double(xgm),double(ygm));
nlev=size(zg,1);
[nx,ny]=size(xgm);
lonqz=zeros(nlev,nx,ny);
latqz=zeros(nlev,nx,ny);
zgz=zeros(nlev,nx,ny);
for k=1:size(zg)
    lonqz(k,:,:) = lonq;
    latqz(k,:,:) = latq;
end
for i=1:size(lonq,1)
    for j=1:size(lonq,2)
        zgz(:,i,j) = zg;
    end
end
lon1=reshape(lonqz,[],1);
lat1=reshape(latqz,[],1);
zg1=reshape(zgz,[],1);
lonmax = max(lonq,[],"all");
lonmin = min(lonq,[],"all");
latmax = max(latq,[],"all");
latmin = min(latq,[],"all");

latg=linspace(latmin,latmax,100);
long=linspace(lonmin,lonmax,100);
[Yq,Xq,Zq]=meshgrid(latg,long,zg);
xque=knnsearch(transpose(long),lonque);
[Zq2,Yq2]=meshgrid(zg,latg);

i=2;
f(i)=nexttile;
set(f(i),'Fontsize',10)

N2(N2<=0)=NaN;
td = sqrt(N2)*100;
td(:,1,:)=NaN;
td(:,end,:)=NaN;
td(:,:,1)=NaN;
td(:,:,end)=NaN;

td1=double(reshape(td,[],1));
F=scatteredInterpolant(lon1,lat1,zg1,td1,'linear','none');
Vq=F(Xq,Yq,Zq);
Vq=squeeze(Vq(xque,:,:));

axis([45 69 10 70])
xticks(-90:5:90)
xticklabels({'90S' '85S' '80S' '75S' '70S' '65S' '60S' '55S' '50S' '45S' '40S' '35S' '30S' '25S' '20S' '15S' '10S' '5S' 'EQ' '5N' '10N' '15N' '20N' '25N' '30N' '35N' '40N' '45N' '50N' '55N' '60N' '65N' '70N' '75N' '80N' '85N' '90N'})
ytickformat('%g km')
ylabel('Altitude')
hold on
box on
contourf(f(i),Yq2,Zq2,Vq,'LineStyle','none','LevelStep',0.05);
colorbar(f(i),'eastoutside')
colormap(f(i),'jet')
clim([1 3])
title(f(i),'N (10^{-2}s^{-1})','FontSize',12,'FontWeight','normal','FontName','Helvetica')
%------------------------------%
end

