% loads the POLCOMS-WAM Liverpool bathymetry, which has been extended to
% include LIDAR data.

clear


%Liverpool Bay model bathymetry with LIDAR data at 180m ressolution
[fid1,message]=fopen('Liverpool_LIDARbathy_180m.txt','r','n')

%LB model grid 
nlat = 474;
nlon = 576;
lonw= -3.99875; lone= -2.56125;
lats= 53.1358333; latn= 53.92416663;


dx = (lone-lonw) / (nlon-1);
dy = (latn-lats) / (nlat-1);

xxR= [lonw:dx:lone] ;
yyR= [lats:dy:latn];

bath = zeros(1,nlon*nlat);
int = fix(nlon*nlat / 20) ;
for i=1:int
   i1 = (i-1)*20 + 1;
   i2 = i*20;
   bath(i1:i2) = fscanf(fid1,'%e',20);
end

status = fclose(fid1)

bath1 = zeros(nlon,nlat);
for j=1:nlat
    i1 = (j-1)*nlon + 1;
    i2 = j*nlon;
    bath1(:,j) = bath(i1:i2);
end
bath1=flipud(bath1');
I = find(bath1==-9999.99); bath1(I) = NaN;


figure(1) % correct orientation
pcolor(xxR,yyR,-bath1);shading flat;%caxis([-57.7700 15.2900]);%caxis of the original bathymetry
colormap(jet); colorbar;caxis([-50 100])
xlabel('Longitude')
ylabel('Latitude')
