% plots to replace GMT plots in the digital archive,
% for regions where the VERTCON 3.0 authors did not use
% or only used portions of the GMT 0.4 surface product

clear; close all;

% ------------ path setup ---------------------
% path to base of all VERTCON3 items
basepth = 'Q:\VERTCON3\';
% local path to FlaggedGrids/Final products
pth = [basepth 'FlaggedGrids\FinalV2\'];

addpath([basepth 'VERTCON3toolbox']);
figPth = [basepth 'plots\']
%figPth = 'C:\Users\andria.bilich\Documents\projects\VERTCON\';


% ------------ Puerto Rico ---------------------
clear d;
% create a file object
d.fbase = 'lt.prvd02.pr';
d.filter = 0;
d.grid = 60;
% ---->> transformation 
[d.A, d.lat, d.lon] = readBgrid([pth d.fbase '.trn.b']);
d.pltType = 'mtcd';
% full grid
d.zone = 'entire';
% d.ofile = sprintf('c%soht.%s.%03d.%s.jpg',...
%         d.pltType, d.fbase, d.filter, d.zone);
d.ofile = sprintf('c%soht.%s.%03d.%d.%d.04.%s.jpg',...
    d.pltType, d.fbase, d.filter, d.grid, d.grid, d.zone);
d.gridLim = [[min(d.lon) max(d.lon)] min(d.lat) max(d.lat)];
plotBgrid_obj(d);
tightFig(gca);
print('-djpeg',[figPth d.ofile]);
% zoom on Puerto Rico
d.zone = 'puertorico';
d.ofile = sprintf('c%soht.%s.%03d.%d.%d.04.%s.jpg',...
    d.pltType, d.fbase, d.filter, d.grid, d.grid, d.zone);
d.gridLim = [292.6 294.6 17.7 18.7];
plotBgrid_obj(d);
tightFig(gca);
print('-djpeg',[figPth d.ofile]);

% ---->> error
[d.A, d.lat, d.lon] = readBgrid([pth d.fbase '.err.b']);
d.pltType = 'mete';
% full grid
d.zone = 'entire';
d.ofile = sprintf('c%soht.%s.%03d.%d.%d.%s.jpg',...
    d.pltType, d.fbase, d.filter, d.grid, d.grid, d.zone);
d.gridLim = [[min(d.lon) max(d.lon)] min(d.lat) max(d.lat)];
plotBgrid_obj(d);
tightFig(gca);
print('-djpeg',[figPth d.ofile]);
% zoom on Puerto Rico
d.zone = 'puertorico';
d.ofile = sprintf('c%soht.%s.%03d.%d.%d.%s.jpg',...
    d.pltType, d.fbase, d.filter, d.grid, d.grid, d.zone);
d.gridLim = [292.6 294.6 17.7 18.7];
plotBgrid_obj(d);
tightFig(gca);
print('-djpeg',[figPth d.ofile]);



% ------------ American Samoa ---------------------
clear d;
zone = {'tutuila' 'manua-isls'};
bound = [189.10 189.50 -14.40 -14.20; 
         190.20 190.70 -14.30 -14.10];

% create a file object
d.fbase = 'lt.asvd02.as';
d.grid = 120;
d.filter = 3;
% ---->> transformation 
[d.A, d.lat, d.lon] = readBgrid([pth d.fbase '.trn.b']);
d.pltType = 'mtcd';
% full grid
d.zone = 'entire';
d.ofile = sprintf('c%soht.%s.%03d.%d.%d.04.%s.jpg',...
    d.pltType, d.fbase, d.filter, d.grid, d.grid, d.zone);
d.gridLim = [[min(d.lon) max(d.lon)] min(d.lat) max(d.lat)];
plotBgrid_obj(d);
tightFig(gca);
print('-djpeg',[figPth d.ofile]);
% subareas/zones
for i = 1:length(zone)
    d.zone = zone{i};
    d.gridLim = bound(i,:);
    d.ofile = sprintf('c%soht.%s.%03d.%d.%d.04.%s.jpg',...
        d.pltType, d.fbase, d.filter, d.grid, d.grid, d.zone);
    plotBgrid_obj(d);
    tightFig(gca);
    print('-djpeg',[figPth d.ofile]);
end

% ---->> error 
[d.A, d.lat, d.lon] = readBgrid([pth d.fbase '.err.b']);
d.pltType = 'mete';
% full grid
d.zone = 'entire';
d.ofile = sprintf('c%soht.%s.%03d.%d.%d.%s.jpg',...
    d.pltType, d.fbase, d.filter, d.grid, d.grid, d.zone);
d.gridLim = [[min(d.lon) max(d.lon)] min(d.lat) max(d.lat)];
plotBgrid_obj(d);
tightFig(gca);
print('-djpeg',[figPth d.ofile]);
% subareas/zones
for i = 1:length(zone)
    d.zone = zone{i};
    d.gridLim = bound(i,:);
    d.ofile = sprintf('c%soht.%s.%03d.%d.%d.%s.jpg',...
        d.pltType, d.fbase, d.filter, d.grid, d.grid, d.zone);
    plotBgrid_obj(d);
    tightFig(gca);
    print('-djpeg',[figPth d.ofile]);
end


% ------------ CNMI ---------------------
clear d;
zone = {'rota' 'tin-saip'};
bound = [145.0 145.40 14.0 14.3; 
         145.50 145.90 14.80 15.40];

% create a file object
d.fbase = 'lt.nmvd03.cnmi';
d.grid = 60;
d.filter = 0;
% ---->> transformation 
[d.A, d.lat, d.lon] = readBgrid([pth d.fbase '.trn.b']);
d.pltType = 'mtcd';
% full grid
d.zone = 'entire';
d.ofile = sprintf('c%soht.%s.%03d.%d.%d.04.%s.jpg',...
    d.pltType, d.fbase, d.filter, d.grid, d.grid, d.zone);
d.gridLim = [[min(d.lon) max(d.lon)] min(d.lat) max(d.lat)];
plotBgrid_obj(d);
tightFig(gca);
print('-djpeg',[figPth d.ofile]);
% subareas/zones
for i = 1:length(zone)
    d.zone = zone{i};
    d.gridLim = bound(i,:);
    d.ofile = sprintf('c%soht.%s.%03d.%d.%d.04.%s.jpg',...
        d.pltType, d.fbase, d.filter, d.grid, d.grid, d.zone);
    plotBgrid_obj(d);
    tightFig(gca);
    print('-djpeg',[figPth d.ofile]);
end

% ---->> error 
[d.A, d.lat, d.lon] = readBgrid([pth d.fbase '.err.b']);
d.pltType = 'mete';
% full grid
d.zone = 'entire';
d.ofile = sprintf('c%soht.%s.%03d.%d.%d.%s.jpg',...
    d.pltType, d.fbase, d.filter, d.grid, d.grid, d.zone);
d.gridLim = [[min(d.lon) max(d.lon)] min(d.lat) max(d.lat)];
plotBgrid_obj(d);
tightFig(gca);
print('-djpeg',[figPth d.ofile]);
% subareas/zones
for i = 1:length(zone)
    d.zone = zone{i};
    d.gridLim = bound(i,:);
    d.ofile = sprintf('c%soht.%s.%03d.%d.%d.%s.jpg',...
        d.pltType, d.fbase, d.filter, d.grid, d.grid, d.zone);
    plotBgrid_obj(d);
    tightFig(gca);
    print('-djpeg',[figPth d.ofile]);
end



% ------------ Guam ---------------------
clear d;
% create a file object
d.fbase = 'guvd63.guvd04.guam';
d.filter = 0;
d.grid = 60;
% ---->> transformation 
[d.A, d.lat, d.lon] = readBgrid([pth d.fbase '.trn.b']);
d.pltType = 'mtcd';
% full grid
d.zone = 'entire';
d.ofile = sprintf('c%soht.%s.%03d.%d.%d.04.%s.jpg',...
    d.pltType, d.fbase, d.filter, d.grid, d.grid, d.zone);
d.gridLim = [[min(d.lon) max(d.lon)] min(d.lat) max(d.lat)];
plotBgrid_obj(d);
tightFig(gca);
print('-djpeg',[figPth d.ofile]);
% tight on Guam island
d.zone = 'guam';
d.gridLim = [144.50 145.10 13.20 13.7];
d.ofile = sprintf('c%soht.%s.%03d.%d.%d.04.%s.jpg',...
    d.pltType, d.fbase, d.filter, d.grid, d.grid, d.zone);
plotBgrid_obj(d);
tightFig(gca);
print('-djpeg',[figPth d.ofile]);
% ---->> error 
[d.A, d.lat, d.lon] = readBgrid([pth d.fbase '.err.b']);
d.pltType = 'mete';
% full grid
d.zone = 'entire';
d.ofile = sprintf('c%soht.%s.%03d.%d.%d.%s.jpg',...
    d.pltType, d.fbase, d.filter, d.grid, d.grid, d.zone);
d.gridLim = [[min(d.lon) max(d.lon)] min(d.lat) max(d.lat)];
plotBgrid_obj(d);
tightFig(gca);
print('-djpeg',[figPth d.ofile]);
% tight on Guam island
d.zone = 'guam';
d.gridLim = [144.50 145.10 13.20 13.7];
d.ofile = sprintf('c%soht.%s.%03d.%d.%d.%s.jpg',...
    d.pltType, d.fbase, d.filter, d.grid, d.grid, d.zone);
plotBgrid_obj(d);
tightFig(gca);
print('-djpeg',[figPth d.ofile]);



% ------------ Virgin Islands ---------------------
clear d;
zone = {'stcroix', 'stthomas'};
bound = [295.05 295.466667 17.633 17.833; 
         294.866667 295.20 18.250 18.450];

% create a file object
d.fbase = 'lt.vivd09.vi';
d.grid = 60;
d.filter = 0;
% ---->> transformation 
[d.A, d.lat, d.lon] = readBgrid([pth d.fbase '.trn.b']);
d.pltType = 'mtcd';
% full grid
d.zone = 'entire';
d.ofile = sprintf('c%soht.%s.%03d.%d.%d.04.%s.jpg',...
    d.pltType, d.fbase, d.filter, d.grid, d.grid, d.zone);
d.gridLim = [[min(d.lon) max(d.lon)] min(d.lat) max(d.lat)];
plotBgrid_obj(d);
tightFig(gca);
print('-djpeg',[figPth d.ofile]);
% subareas/zones
for i = 1:length(zone)
    d.zone = zone{i};
    d.gridLim = bound(i,:);
    d.ofile = sprintf('c%soht.%s.%03d.%d.%d.04.%s.jpg',...
        d.pltType, d.fbase, d.filter, d.grid, d.grid, d.zone);
    plotBgrid_obj(d);
    tightFig(gca);
    print('-djpeg',[figPth d.ofile]);
end

% ---->> error 
[d.A, d.lat, d.lon] = readBgrid([pth d.fbase '.err.b']);
d.pltType = 'mete';
% full grid
d.zone = 'entire';
d.ofile = sprintf('c%soht.%s.%03d.%d.%d.%s.jpg',...
    d.pltType, d.fbase, d.filter, d.grid, d.grid, d.zone);
d.gridLim = [[min(d.lon) max(d.lon)] min(d.lat) max(d.lat)];
plotBgrid_obj(d);
tightFig(gca);
print('-djpeg',[figPth d.ofile]);
% subareas/zones
for i = 1:length(zone)
    d.zone = zone{i};
    d.gridLim = bound(i,:);
    d.ofile = sprintf('c%soht.%s.%03d.%d.%d.%s.jpg',...
        d.pltType, d.fbase, d.filter, d.grid, d.grid, d.zone);
    plotBgrid_obj(d);
    tightFig(gca);
    print('-djpeg',[figPth d.ofile]);
end



