clear all;
close all;

% read entire file
load xbfile_full.dat;

% read data into individual arrays
xb_lat = xbfile_full(:,1);
xb_lon = xbfile_full(:,2);
xb_elev = xbfile_full(:,3);
xb = xbfile_full(:,4);
% set plotting range
xi = -117.0:0.05:-109.0;
yi = 39.0:0.05:44.0;
v = [-8 -6 -4 -2 0 2 4 6 8 10 12 14 16 18];
w = [250 500 750 1000 1250 1500 1750 2000 2250 2500 2750 3000 3250 3500 3750];

[XI,YI] = meshgrid(xi,yi);

% plot terrain over entire domain
figure
ZI = griddata(xb_lon,xb_lat,xb_elev,XI,YI);
contour(XI,YI,ZI,w);

% plot background temperature over entire domain
figure
ZZI = griddata(xb_lon,xb_lat,xb,XI,YI);
contourf(XI,YI,ZZI,v);
colorbar;

clear all;

%read truncated file
load xbfile.dat;

% read data into individual arrays
xb_lat = xbfile(:,1);
xb_lon = xbfile(:,2);
xb_elev = xbfile(:,3);
xb = xbfile(:,4);
% set plotting range
xi = -117.0:0.05:-109.0;
yi = 39.0:0.05:44.0;
v = [-8 -6 -4 -2 0 2 4 6 8 10 12 14 16 18];
w = [250 500 750 1000 1250 1500 1750 2000 2250 2500 2750 3000 3250 3500 3750];

[XI,YI] = meshgrid(xi,yi);
figure
ZZI = griddata(xb_lon,xb_lat,xb,XI,YI);
contourf(XI,YI,ZZI,v);
colorbar;

