Forgot to include MATLAB files!

This commit is contained in:
Coastlines 2021-09-29 07:44:37 -04:00
parent c4df40c83d
commit 5dc6152e35
34 changed files with 23416 additions and 720 deletions

2
.gitignore vendored
View File

@ -19,6 +19,7 @@
!*.dry
!*.bnw
!*.bnd
!*.m
NDBCdata.txt
WAVE2FLOW_DATA.txt
@ -38,6 +39,7 @@ C7_1400_V2_D.mat
C7_1400_V2_C.mat
Dec6_250Bed.mat
DUNEX_Sept7.mat
NDBCdata.txt
# do not ignore fish dir (needed due to the above bullet point)
#!/m_map

1021
DUNEX_RealtimeV5.m Normal file

File diff suppressed because it is too large Load Diff

1175
DUNEX_RealtimeV6_CAD.m Normal file

File diff suppressed because it is too large Load Diff

1058
DelftInputsV2.m Normal file

File diff suppressed because it is too large Load Diff

2322
Dunex_Operational_36h.m Normal file

File diff suppressed because it is too large Load Diff

2333
Dunex_Operational_48h.m Normal file

File diff suppressed because it is too large Load Diff

2414
Dunex_Operational_Feb28.m Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

2382
Dunex_Operational_Sept_7.m Normal file

File diff suppressed because it is too large Load Diff

55
MatlabTest.m Normal file
View File

@ -0,0 +1,55 @@
%% NC DUNEX Realtime script
% Alexander Rey, August 12, 2019
clear all
cd D:\DUNEX_RT\Operation
echo off;
%% Master Model Time Step
% Every 6 hours
% Download the current UTC time from NIST
% s1 = webread('https://nist.time.gov/actualtime.cgi?lzbc=siqm9b');
% s2 = regexp(s1,'\<timestamp time\=\"(\d*)\"','tokens','once');
% n = str2double(s2);
% nistTime = datetime(n,'ConvertFrom','EpochTime','TicksPerSecond',1e6);
nistTime = datetime(datevec(now))
masterTime = dateshift(nistTime,'start','hour')-hours(6) % Assume script will run at 5 and a half hours after model start
clear nistTime
% masterTime = datetime(2019,06,15,06,00,00);
masterDate = datetime(year(masterTime),month(masterTime),day(masterTime));
%% Download new NASA Map!
host = 'gibs.earthdata.nasa.gov';
path = '/wms/epsg4326/nrt/wms.cgi?';
serverURL = ['https://' host path];
requestURL = [serverURL 'SERVICE=WMS&REQUEST=GetMap&VERSION=1.1.1&' ...
'LAYERS=VIIRS_SNPP_CorrectedReflectance_TrueColor_v1_NRT&'...
'STYLES=&FORMAT=image%2Fpng&TRANSPARENT=true&'...
'HEIGHT=800&WIDTH=1350&TIME=' datestr(masterDate-hours(12),'yyyy-mm-dd') '&SRS=EPSG:4326&'...
'BBOX=-78.5,34.0,-73.5,37.0'];
[A,R] = wmsread(requestURL);
imwrite(A,'NCcurrent.jpg')
copyfile D:\Alexander\erdas_spnad83.tif \\geoserver.engineering.queensu.ca\TIFFS\erdas_spnad83.tif

78
NCOMdownload.m Normal file
View File

@ -0,0 +1,78 @@
%% NCOM download
Count=1;
for Day = 2:10
for t=[45 48 51 54 57 60]
url =['https://ecowatch.ncddc.noaa.gov/thredds/fileServer/us_east/ncom_relo_useast_u_201909' ...
num2str(Day,'%02d') '00_t0' num2str(t,'%02d') '.nc'];
websave(['D:\Alexander\NCOM\201909' ...
num2str(Day,'%02d') '00_t0' num2str(t,'%02d') '.nc'],url)
disp(['201909' num2str(Day,'%02d') '00_t0' num2str(t,'%02d')])
end
end
%%
NCOM.Lat = ncread('https://ecowatch.ncddc.noaa.gov/thredds/dodsC/ncom_us_east_agg/US_East_Apr_05_2013_to_Current_best.ncd',...
'lat',[331],[240]);
NCOM.Lon = ncread('https://ecowatch.ncddc.noaa.gov/thredds/dodsC/ncom_us_east_agg/US_East_Apr_05_2013_to_Current_best.ncd',...
'lon',91,180);
NCOM.depth = ncread('https://ecowatch.ncddc.noaa.gov/thredds/dodsC/ncom_us_east_agg/US_East_Apr_05_2013_to_Current_best.ncd',...
'depth');
NCOM.time = ncread('https://ecowatch.ncddc.noaa.gov/thredds/dodsC/ncom_us_east_agg/US_East_Apr_05_2013_to_Current_best.ncd',...
'time',[9825],[624]);
NCOM.time_run = ncread('https://ecowatch.ncddc.noaa.gov/thredds/dodsC/ncom_us_east_agg/US_East_Apr_05_2013_to_Current_best.ncd',...
'time_run',[9825],[624]);
%[17775],[64]
for missStep = 1:length(MISSING)
tStep = MISSING(missStep)-1
noData=1
while noData==1
NCOM.water_u(:,:,:,tStep+1) = ncread('https://ecowatch.ncddc.noaa.gov/thredds/dodsC/ncom_us_east_agg/US_East_Apr_05_2013_to_Current_best.ncd',...
'water_u',[91 331 1 9825+tStep],[180 240 inf 1],[1 1 1 1]);
NCOM.water_v(:,:,:,tStep+1) = ncread('https://ecowatch.ncddc.noaa.gov/thredds/dodsC/ncom_us_east_agg/US_East_Apr_05_2013_to_Current_best.ncd',...
'water_v',[91 331 1 9825+tStep],[180 240 inf 1],[1 1 1 1]);
NCOM.surf_el(:,:,tStep+1) = ncread('https://ecowatch.ncddc.noaa.gov/thredds/dodsC/ncom_us_east_agg/US_East_Apr_05_2013_to_Current_best.ncd',...
'surf_el',[91 331 9825+tStep],[180 240 1],[1 1 1]);
NCOM.salinity(:,:,:,tStep+1) = ncread('https://ecowatch.ncddc.noaa.gov/thredds/dodsC/ncom_us_east_agg/US_East_Apr_05_2013_to_Current_best.ncd',...
'salinity',[91 331 1 9825+tStep],[180 240 inf 1],[1 1 1 1]);
if (squeeze(NCOM.water_v(100,100,1,tStep+1))==0|squeeze(NCOM.water_u(100,100,1,tStep+1))==0|squeeze(NCOM.surf_el(100,100,tStep+1))==0|squeeze(NCOM.salinity(100,100,1,tStep+1))==0)==1
noData=1
else
noData=0
end
end
disp(missStep)
end
save('NCOM_2016_V4.mat','-v7.3','NCOM')
% https://ecowatch.ncddc.noaa.gov/thredds/dodsC/ncom_us_east_agg/US_East_Apr_05_2013_to_Current_best.ncd?lon[0:1:543],lat[0:1:663],depth[0:1:39],time[17774:1:17838],time_run[17774:1:17838],water_u[17774:1:17838][0:1:39][0:1:663][0:1:543],water_v[17774:1:17838][0:1:39][0:1:663][0:1:543],water_temp[17774:1:17838][0:1:39][0:1:663][0:1:543],salinity[17774:1:17838][0:1:39][0:1:663][0:1:543]
%%
NCOM.mag = vecmag(NCOM.water_u,NCOM.water_v);
depthWeight = [diff(NCOM.depth)' 0];
for Layer = 1:40
DAVfac(:,:,Layer,:) = ones(180,240,1,64).*depthWeight(Layer);
end
DAVtrue = DAVfac;
DAVtrue(isnan(NCOM.mag)==1) = 0;
DAVfac(isnan(NCOM.mag)==1) = nan;
DAVFac2 = sum(DAVtrue,3);
clear DAVtrue
NCOM.dav = nansum(DAVfac.*NCOM.mag,3)./DAVFac2;
NCOM.davX = nansum(DAVfac.*NCOM.water_u,3)./DAVFac2;
NCOM.davY = nansum(DAVfac.*NCOM.water_v,3)./DAVFac2;
save('NCOM2016Final.mat','NCOM')

File diff suppressed because it is too large Load Diff

23
NearestValue.m Normal file
View File

@ -0,0 +1,23 @@
function [idx,difference,gridVal] = NearestValue(val,gridX,gridY)
%% Function to find the nearest point in in a 1D or 2D array.
% Works with a 2D array of X and Y points, given a nearest
% X,Y point to find
% Alexander Rey, Queen's University, Jan 2019
if min(size(gridX)) == 1 % if 1D
tmp = abs(gridX - val); %Find the difference between array and values
[difference, idx] = min(tmp); %Use the index with the smallest diffference
gridVal = gridX(idx);
else %if 2D
tmpX = abs(gridX - val(1));
tmpY = abs(gridY - val(2));
[diffsX,rowsX] = min(tmpX+tmpY); %Create and array of the difference in each row
[diffsY,rowY] = min(diffsX);
idx = [rowsX(rowY) rowY];
difference = [gridX(idx(1),idx(2))-val(1) gridY(idx(1),idx(2))-val(2)];
gridVal = [gridX(idx(1),idx(2)) gridY(idx(1),idx(2))];
end
end

143
d3d_input_uvpFieldsCL_FUN.m Normal file
View File

@ -0,0 +1,143 @@
%PROGRAM d3d_input
%R.P. Mulligan
%this script writes the spatially varying wind and pressure fields for Delft3D....
%3 files are created, 1 for each of u, v and p.
%below the example is for H. Ernesto ...
function [] = d3d_input_uvpFieldsCL_FUN(StartDateIN,m,n,P,u,v,prep,tStep,fName,Times)
%UNTITLED Summary of this function goes here
% Detailed explanation goes here
%user define the txt string for the start date and time:
StartDate = [datestr(StartDateIN,'yyyy-mm-dd HH:MM:SS') ' +00:00'];
%1. input grid parameters-----------------
%these values are produced by "latlon_grid.m", run it first
% m = %number of points in x-dir
% n = %number of points in y-dir
% dx = %dlon in deg
% dy = %dlat in deg
% gridloncentre = round(min(min(gridlon)),0)%deg
% gridlatcentre = round(min(min(gridlat)),0)%deg
%and arrays for u, v, P, prep that are (time, lon, lat)
%and time index is ttt
%write to d3d inputt grid...--------------------------
clear line1 line2 line3;
d3dfile1 = [fName '.amp']; %output file names.
d3dfile2 = [fName '.amu'];
d3dfile3 = [fName '.amv'];
d3dfile4 = [fName '.ampr'];
curline1 = 1;
line1{curline1,:} = ['FileVersion = 1.03'];curline1 = curline1 + 1;
line1{curline1,:} = ['filetype = meteo_on_curvilinear_grid'] ;curline1 = curline1 + 1;
line1{curline1,:} = ['NODATA_value = -999.000'] ;curline1 = curline1 + 1;
line1{curline1,:} = ['grid_file = Cone7LRW.grd'] ;curline1 = curline1 + 1;
line1{curline1,:} = ['first_data_value = grid_llcorner'] ;curline1 = curline1 + 1;
line1{curline1,:} = ['data_row = grid_row'] ;curline1 = curline1 + 1;
line1{curline1,:} = ['n_quantity = 1'] ;curline1 = curline1 + 1;
line1{curline1,:} = ['quantity1 = air_pressure'] ;curline1 = curline1 + 1;
line1{curline1,:} = ['unit1 = Pa'] ;curline1 = curline1 + 1;
for ttt = 1:Times
line1{curline1,:} = ['TIME = ',num2str((ttt-1).*tStep),'.0 hours since ',StartDate] ;curline1 = curline1 + 1;
Psqueeze = squeeze(P(ttt,:,:)); % array is therefore (time, lon, lat)
for jj = 1:m
line1{curline1,:} = [num2str(Psqueeze(jj,1:end),'% 11.1f')];curline1 = curline1 + 1;
end
end%
curline2 = 1;
line2{curline2,:} = ['FileVersion = 1.03'];curline2 = curline2 + 1;
line2{curline2,:} = ['filetype = meteo_on_curvilinear_grid'] ;curline2 = curline2 + 1;
line2{curline2,:} = ['NODATA_value = -999.000'] ;curline2 = curline2 + 1;
line2{curline2,:} = ['grid_file = Cone7LRW.grd'] ;curline2 = curline2 + 1;
line2{curline2,:} = ['first_data_value = grid_llcorner'] ;curline2 = curline2 + 1;
line2{curline2,:} = ['data_row = grid_row'] ;curline2 = curline2 + 1;
line2{curline2,:} = ['n_quantity = 1'] ;curline2 = curline2 + 1;
line2{curline2,:} = ['quantity1 = x_wind'] ;curline2 = curline2 + 1;
line2{curline2,:} = ['unit1 = m s-1'] ;curline2 = curline2 + 1;
for ttt = 1:Times
line2{curline2,:} = ['TIME = ',num2str((ttt-1).*tStep),'.0 hours since ',StartDate] ;curline2 = curline2 + 1;
usqueeze = squeeze(u(ttt,:,:));
for jj = 1:m
line2{curline2,:} = [num2str(usqueeze(jj,1:end),'% 11.3f')];curline2 = curline2 + 1;
end
end
curline3 = 1;
line3{curline3,:} = ['FileVersion = 1.03'];curline3 = curline3 + 1;
line3{curline3,:} = ['filetype = meteo_on_curvilinear_grid'] ;curline3 = curline3 + 1;
line3{curline3,:} = ['NODATA_value = -999.000'] ;curline3 = curline3 + 1;
line3{curline3,:} = ['grid_file = Cone7LRW.grd'] ;curline3 = curline3 + 1;
line3{curline3,:} = ['first_data_value = grid_llcorner'] ;curline3 = curline3 + 1;
line3{curline3,:} = ['data_row = grid_row'] ;curline3 = curline3 + 1;
line3{curline3,:} = ['n_quantity = 1'] ;curline3 = curline3 + 1;
line3{curline3,:} = ['quantity1 = y_wind'] ;curline3 = curline3 + 1;
line3{curline3,:} = ['unit1 = m s-1'] ;curline3 = curline3 + 1;
for ttt = 1:Times
line3{curline3,:} = ['TIME = ',num2str((ttt-1).*tStep),'.0 hours since ',StartDate] ;curline3 = curline3 + 1;
vsqueeze = squeeze(v(ttt,:,:));
for jj = 1:m
line3{curline3,:} = [num2str(vsqueeze(jj,1:end),'% 11.3f')];curline3 = curline3 + 1;
end
end
curline4 = 1;
line4{curline4,:} = ['FileVersion = 1.03'];curline4 = curline4 + 1;
line4{curline4,:} = ['filetype = meteo_on_curvilinear_grid'] ;curline4 = curline4 + 1;
line4{curline4,:} = ['NODATA_value = -999.000'] ;curline4 = curline4 + 1;
line4{curline4,:} = ['grid_file = Cone7LRW.grd'] ;curline4 = curline4 + 1;
line4{curline4,:} = ['first_data_value = grid_llcorner'] ;curline4 = curline4 + 1;
line4{curline4,:} = ['data_row = grid_row'] ;curline4 = curline4 + 1;
line4{curline4,:} = ['n_quantity = 1'] ;curline4 = curline4 + 1;
line4{curline4,:} = ['quantity1 = precipitation'] ;curline4 = curline4 + 1;
line4{curline4,:} = ['unit1 = mm/h'] ;curline4 = curline4 + 1;
for ttt = 1:Times
line4{curline4,:} = ['TIME = ',num2str((ttt-1).*tStep),'.0 hours since ',StartDate] ;curline4 = curline4 + 1;
prepsqueeze = squeeze(prep(ttt,:,:));
for jj = 1:m
line4{curline4,:} = [num2str(prepsqueeze(jj,1:end),'% 11.4f')];curline4 = curline4 + 1;
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%write text files, 1 for each met data
fid = fopen(d3dfile1,'wt'); %should overwrite if file already exists
for ii = 1:(curline1-1)
len = size(line1{ii,:},2);
countP = fprintf(fid,['%' num2str(len) 's\n'],line1{ii,:});
end
fclose(fid);
fid = fopen(d3dfile2,'wt'); %should overwrite if file already exists
for ii = 1:(curline2-1)
len = size(line2{ii,:},2);
countu = fprintf(fid,['%' num2str(len) 's\n'],line2{ii,:});
end
fclose(fid);
fid = fopen(d3dfile3,'wt'); %should overwrite if file already exists
for ii = 1:(curline3-1)
len = size(line3{ii,:},2);
countv = fprintf(fid,['%' num2str(len) 's\n'],line3{ii,:});
end
fclose(fid);
fid = fopen(d3dfile4,'wt'); %should overwrite if file already exists
for ii = 1:(curline4-1)
len = size(line4{ii,:},2);
countv = fprintf(fid,['%' num2str(len) 's\n'],line4{ii,:});
end
fclose(fid);
fclose all
end

135
deg2utm.m Normal file
View File

@ -0,0 +1,135 @@
function [x,y,utmzone] = deg2utm(Lat,Lon)
% -------------------------------------------------------------------------
% [x,y,utmzone] = deg2utm(Lat,Lon)
%
% Description: Function to convert lat/lon vectors into UTM coordinates (WGS84).
% Some code has been extracted from UTM.m function by Gabriel Ruiz Martinez.
%
% Inputs:
% Lat: Latitude vector. Degrees. +ddd.ddddd WGS84
% Lon: Longitude vector. Degrees. +ddd.ddddd WGS84
%
% Outputs:
% x, y , utmzone. See example
%
% Example 1:
% Lat=[40.3154333; 46.283900; 37.577833; 28.645650; 38.855550; 25.061783];
% Lon=[-3.4857166; 7.8012333; -119.95525; -17.759533; -94.7990166; 121.640266];
% [x,y,utmzone] = deg2utm(Lat,Lon);
% fprintf('%7.0f ',x)
% 458731 407653 239027 230253 343898 362850
% fprintf('%7.0f ',y)
% 4462881 5126290 4163083 3171843 4302285 2772478
% utmzone =
% 30 T
% 32 T
% 11 S
% 28 R
% 15 S
% 51 R
%
% Example 2: If you have Lat/Lon coordinates in Degrees, Minutes and Seconds
% LatDMS=[40 18 55.56; 46 17 2.04];
% LonDMS=[-3 29 8.58; 7 48 4.44];
% Lat=dms2deg(mat2dms(LatDMS)); %convert into degrees
% Lon=dms2deg(mat2dms(LonDMS)); %convert into degrees
% [x,y,utmzone] = deg2utm(Lat,Lon)
%
% Author:
% Rafael Palacios
% Universidad Pontificia Comillas
% Madrid, Spain
% Version: Apr/06, Jun/06, Aug/06, Aug/06
% Aug/06: fixed a problem (found by Rodolphe Dewarrat) related to southern
% hemisphere coordinates.
% Aug/06: corrected m-Lint warnings
%-------------------------------------------------------------------------
% Argument checking
%
error(nargchk(2, 2, nargin)); %2 arguments required
n1=length(Lat);
n2=length(Lon);
if (n1~=n2)
error('Lat and Lon vectors should have the same length');
end
% Memory pre-allocation
%
x=zeros(n1,1);
y=zeros(n1,1);
utmzone(n1,:)='60 X';
% Main Loop
%
for i=1:n1
la=Lat(i);
lo=Lon(i);
sa = 6378137.000000 ; sb = 6356752.314245;
%e = ( ( ( sa ^ 2 ) - ( sb ^ 2 ) ) ^ 0.5 ) / sa;
e2 = ( ( ( sa ^ 2 ) - ( sb ^ 2 ) ) ^ 0.5 ) / sb;
e2cuadrada = e2 ^ 2;
c = ( sa ^ 2 ) / sb;
%alpha = ( sa - sb ) / sa; %f
%ablandamiento = 1 / alpha; % 1/f
lat = la * ( pi / 180 );
lon = lo * ( pi / 180 );
Huso = fix( ( lo / 6 ) + 31);
S = ( ( Huso * 6 ) - 183 );
deltaS = lon - ( S * ( pi / 180 ) );
if (la<-72), Letra='C';
elseif (la<-64), Letra='D';
elseif (la<-56), Letra='E';
elseif (la<-48), Letra='F';
elseif (la<-40), Letra='G';
elseif (la<-32), Letra='H';
elseif (la<-24), Letra='J';
elseif (la<-16), Letra='K';
elseif (la<-8), Letra='L';
elseif (la<0), Letra='M';
elseif (la<8), Letra='N';
elseif (la<16), Letra='P';
elseif (la<24), Letra='Q';
elseif (la<32), Letra='R';
elseif (la<40), Letra='S';
elseif (la<48), Letra='T';
elseif (la<56), Letra='U';
elseif (la<64), Letra='V';
elseif (la<72), Letra='W';
else Letra='X';
end
a = cos(lat) * sin(deltaS);
epsilon = 0.5 * log( ( 1 + a) / ( 1 - a ) );
nu = atan( tan(lat) / cos(deltaS) ) - lat;
v = ( c / ( ( 1 + ( e2cuadrada * ( cos(lat) ) ^ 2 ) ) ) ^ 0.5 ) * 0.9996;
ta = ( e2cuadrada / 2 ) * epsilon ^ 2 * ( cos(lat) ) ^ 2;
a1 = sin( 2 * lat );
a2 = a1 * ( cos(lat) ) ^ 2;
j2 = lat + ( a1 / 2 );
j4 = ( ( 3 * j2 ) + a2 ) / 4;
j6 = ( ( 5 * j4 ) + ( a2 * ( cos(lat) ) ^ 2) ) / 3;
alfa = ( 3 / 4 ) * e2cuadrada;
beta = ( 5 / 3 ) * alfa ^ 2;
gama = ( 35 / 27 ) * alfa ^ 3;
Bm = 0.9996 * c * ( lat - alfa * j2 + beta * j4 - gama * j6 );
xx = epsilon * v * ( 1 + ( ta / 3 ) ) + 500000;
yy = nu * v * ( 1 + ta ) + Bm;
if (yy<0)
yy=9999999+yy;
end
try
x(i)=xx;
y(i)=yy;
utmzone(i,:)=sprintf('%02d %c',Huso,Letra);
catch
end
end

32
getutc.m Normal file
View File

@ -0,0 +1,32 @@
function utctime = getutc(timezone)
%UTCTIME = GETUTC(TIMEZONE) Retrieves the Coordinated Universal Time of a given TIMEZONE and converts it
% to a Matlab datenum.
% INPUT:
% TIMEZONE an integer in the range of -12 to 12 specifies the time zone
% OUTPUT:
% UTCTIME returns the current UTC time as a MATLAB datenum. It can be converted to a date string of specified format by the
% the MATLAB function datestr.
%
% Example:
% utctime = getutc(8); % get the UTC time of No.8 time zone (Beijing)
% datestr(utctime,'yyyy-mm-dd HH:MM:SS')
%
% See also DATENUM,DATESTR,WEBREAD,URLREAD
% Dr.Qun Han
% College of Precision Instrument and Opto-electronics Engineering,
% Tianjin University, Tianjin, P.R. China
if nargin<1
timezone = 0;
end
if timezone>12 || timezone<-12
error('Invalid TIMEZONE:Timezone should be in the range of [-12,12].')
end
floor(timezone);
timeServer = 'https://time.is/UTC';
o = weboptions('CertificateFilename','');
uniTime = str2double(regexp(webread(timeServer,o),'\d{13}','match','once'))/1000; % Retrieve the universal time and convert it to seconds
localTime = uniTime+timezone*60*60;
ml = [1970,1,1,0,0,localTime]; %Matlab datenum is defied relative to Jan-01,1970,00:00:00,
utctime = datenum(ml);

Binary file not shown.

50
importASOS.m Normal file
View File

@ -0,0 +1,50 @@
function asos = importASOS(filename, dataLines)
%IMPORTFILE Import data from a text file
% ASOS = IMPORTFILE(FILENAME) reads data from text file FILENAME for
% the default selection. Returns the data as a table.
%
% ASOS = IMPORTFILE(FILE, DATALINES) reads data for the specified row
% interval(s) of text file FILENAME. Specify DATALINES as a positive
% scalar integer or a N-by-2 array of positive scalar integers for
% dis-contiguous row intervals.
%
% Example:
% asos = importASOS("D:\DorianRP\asos.txt", [1, Inf]);
%
% See also READTABLE.
%
% Auto-generated by MATLAB on 11-Dec-2019 13:04:36
%% Input handling
% If dataLines is not specified, define defaults
if nargin < 2
dataLines = [2, Inf];
end
%% Setup the Import Options and import the data
opts = delimitedTextImportOptions("NumVariables", 31);
% Specify range and delimiter
opts.DataLines = dataLines;
opts.Delimiter = ",";
% Specify column names and types
opts.VariableNames = ["station", "valid", "lon", "lat", "tmpf", "dwpf", "relh", "drct", "sknt", "p01i", "alti", "mslp", "vsby", "gust", "skyc1", "skyc2", "skyc3", "skyc4", "skyl1", "skyl2", "skyl3", "skyl4", "wxcodes", "ice_accretion_1hr", "ice_accretion_3hr", "ice_accretion_6hr", "peak_wind_gust", "peak_wind_drct", "peak_wind_time", "feel", "metar"];
opts.VariableTypes = ["categorical", "datetime", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "categorical", "categorical", "categorical", "categorical", "double", "double", "double", "double", "categorical", "double", "double", "double", "double", "double", "double", "double", "string"];
% Specify file level properties
opts.ExtraColumnsRule = "ignore";
opts.EmptyLineRule = "read";
% Specify variable properties
opts = setvaropts(opts, "metar", "WhitespaceRule", "preserve");
opts = setvaropts(opts, ["station", "skyc1", "skyc2", "skyc3", "skyc4", "wxcodes", "metar"], "EmptyFieldRule", "auto");
opts = setvaropts(opts, "valid", "InputFormat", "yyyy-MM-dd HH:mm");
opts = setvaropts(opts, ["tmpf", "dwpf", "relh", "p01i", "mslp", "gust", "skyl1", "skyl2", "skyl3", "skyl4", "ice_accretion_1hr", "ice_accretion_3hr", "ice_accretion_6hr", "peak_wind_gust", "peak_wind_drct", "peak_wind_time", "feel"], "TrimNonNumeric", true);
opts = setvaropts(opts, ["tmpf", "dwpf", "relh", "p01i", "mslp", "gust", "skyl1", "skyl2", "skyl3", "skyl4", "ice_accretion_1hr", "ice_accretion_3hr", "ice_accretion_6hr", "peak_wind_gust", "peak_wind_drct", "peak_wind_time", "feel"], "ThousandsSeparator", ",");
% Import the data
asos = readtable(filename, opts);
end

771
makeCSptsDUNEXR_Dec28.m Normal file
View File

@ -0,0 +1,771 @@
%% Make CS Points
clear pointsCS
load('CSpoints.mat');
% Realtime Points
% Create Observation File
locations = [36.606,-74.840;...
36.260,-75.594;...
36.001,-75.421;...
35.750,-75.330;...
35.025,-75.363;
36.189244, -75.739155;...
36.3205,-75.872;...
36.1656,-75.8155;...
36.0866, -75.76833;...
35.8964389,-75.6220889;...
34.7113528,-76.7368333;...
35.96176,-75.64163;...
36.04318,-75.68936;...
36.12932,-75.74501;...
36.20002, -75.7151];
locNames = {'Virginia Beach Wave',...
'Duck 26 Wave',...
'Nages Head Wave',...
'Oregon Inlet Wave',...
'Diamond Shoals Wave',...
'Duck 11 AWAC',...
'CS North',...
'CS South',...
'USGS CURRITUCK SOUND NR POINT HARBOR',...
'USGS ROANOKE SOUND AT POND ISLAND',...
'USGS BOGUE SOUND AT ATLANTIC BEACH',...
'Villa Dunes SW Dock Shoreline',...
'Hayman St Dock SW Shoreline',...
'Gunther Telephone Pole'...
'Duck 17 Wave'};
for i = 1:length(locations)
pointsCS{i+11,1} = locNames{i};
[pointsCS{i+11,2},pointsCS{i+11,3}] = wgs2utm(locations(i,1),locations(i,2),18,'N');
end
pointsCS{8,3} = pointsCS{8,3} + 2500;
pointsCS{7,2} = pointsCS{7,2} - 500;
[pointsCS{30,2},pointsCS{30,3}]= wgs2utm(34.213,-76.946,18,'N');
[pointsCS{31,2},pointsCS{31,3}]= wgs2utm(36.914,-75.720,18,'N');
pointsCS{30,1} = 'Onslow Bay Wave';
pointsCS{31,1} = 'Cape Henry Wave';
[pointsCS{32,2},pointsCS{32,3}]= wgs2utm(36.0175833,-75.6715833,18,'N');
pointsCS{32,1} = 'Kitty Hawk Airport';
[pointsCS{33,2},pointsCS{33,3}]= wgs2utm(36.20002,-75.7151,18,'N');
pointsCS{33,1} = 'FRF 17m';
pointsCS(33,4) = {'F17'};
pointsCS{10,1} = 'Currituck Sound @ Corolla';
pointsCS(1:21,4) = {'CS 1','CS 2','CS 3','CS 4','CS 5','FP','OI','HT','BF','CC','AS','VB','F26','NH','O18','DS','F11','CN','CS','PH','PI'};
pointsCS(22,4) = {'AB'};
pointsCS(23,4) = {'VD'};
pointsCS(24,4) = {'HD'};
pointsCS(25,4) = {'JC'};
pointsCS(30,4) = {'OB'};
pointsCS(31,4) = {'CH'};
pointsCS(32,4) = {'KH'};
pointsCS{27,1} = 'FRF 6m AWAC';
[pointsCS{27,2},pointsCS{27,3}]= wgs2utm(36.187328,-75.7465267,18,'N');
pointsCS{27,4} = 'F6';
pointsCS(26,4) = {'F17'};
for i = 1:length(locations)
pointsCS{i+11,1} = locNames{i};
[pointsCS{i+11,2},pointsCS{i+11,3}] = wgs2utm(locations(i,1),locations(i,2),18,'N');
end
pointsCS(28,:) = pointsCS(18,:);
pointsCS(29,:) = pointsCS(19,:);
pointsCS{28,1} = 'CS North 2';
pointsCS{29,1} = 'CS South 2';
% NDBC
[pointsCS{34,2},pointsCS{34,3}] = deg2utm(36.778,-76.302);
pointsCS{34,1} = 'Money Point';
[pointsCS{35,2},pointsCS{35,3}] = deg2utm(34.622,-76.525);
pointsCS{35,1} = 'Cape Lookout';
[pointsCS{36,2},pointsCS{36,3}] = deg2utm(36.962,-76.424);
pointsCS{36,1} = 'Dominion Terminal';
pointsCS(34,4) = {'MP'};
pointsCS(35,4) = {'CPL'};
pointsCS(36,4) = {'DV'};
% StatNum
pointsCS{6,5} = 8651370; %Dck
pointsCS{7,5} = 8652587; %OI
pointsCS{8,5} = 8654467; %Hat
pointsCS{9,5} = 8656483; %Beau
pointsCS{12,5} = '44014'; %VB
pointsCS{16,5} = '41025'; %DS
pointsCS{30,5} = '41159'; %OB
pointsCS{31,5} = '44099'; %CH
pointsCS{34,5} = 'MNPV2'; %MP
pointsCS{35,5} = 'CLKN7'; %CL
pointsCS{36,5} = 'DOMV2'; %DV
% Import Winds from NWS
opts = delimitedTextImportOptions("NumVariables", 124);
% Specify range and delimiter
opts.DataLines = [1, Inf];
opts.Delimiter = ",";
% Specify column names and types
opts.VariableNames = ["STATION", "DATE", "REPORT_TYPE", "SOURCE", "AWND", "BackupDirection", "BackupDistance", "BackupDistanceUnit", "BackupElements", "BackupElevation", "BackupElevationUnit", "BackupEquipment", "BackupLatitude", "BackupLongitude", "BackupName", "CDSD", "CLDD", "DSNW", "DailyAverageDewPointTemperature", "DailyAverageDryBulbTemperature", "DailyAverageRelativeHumidity", "DailyAverageSeaLevelPressure", "DailyAverageStationPressure", "DailyAverageWetBulbTemperature", "DailyAverageWindSpeed", "DailyCoolingDegreeDays", "DailyDepartureFromNormalAverageTemperature", "DailyHeatingDegreeDays", "DailyMaximumDryBulbTemperature", "DailyMinimumDryBulbTemperature", "DailyPeakWindDirection", "DailyPeakWindSpeed", "DailyPrecipitation", "DailySnowDepth", "DailySnowfall", "DailySustainedWindDirection", "DailySustainedWindSpeed", "DailyWeather", "HDSD", "HTDD", "HeavyFog", "HourlyAltimeterSetting", "HourlyDewPointTemperature", "HourlyDryBulbTemperature", "HourlyPrecipitation", "HourlyPresentWeatherType", "HourlyPressureChange", "HourlyPressureTendency", "HourlyRelativeHumidity", "HourlySeaLevelPressure", "HourlySkyConditions", "HourlyStationPressure", "HourlyVisibility", "HourlyWetBulbTemperature", "HourlyWindDirection", "HourlyWindGustSpeed", "HourlyWindSpeed", "MonthlyAverageRH", "MonthlyDaysWithGT001Precip", "MonthlyDaysWithGT010Precip", "MonthlyDaysWithGT32Temp", "MonthlyDaysWithGT90Temp", "MonthlyDaysWithLT0Temp", "MonthlyDaysWithLT32Temp", "MonthlyDepartureFromNormalAverageTemperature", "MonthlyDepartureFromNormalCoolingDegreeDays", "MonthlyDepartureFromNormalHeatingDegreeDays", "MonthlyDepartureFromNormalMaximumTemperature", "MonthlyDepartureFromNormalMinimumTemperature", "MonthlyDepartureFromNormalPrecipitation", "MonthlyDewpointTemperature", "MonthlyGreatestPrecip", "MonthlyGreatestPrecipDate", "MonthlyGreatestSnowDepth", "MonthlyGreatestSnowDepthDate", "MonthlyGreatestSnowfall", "MonthlyGreatestSnowfallDate", "MonthlyMaxSeaLevelPressureValue", "MonthlyMaxSeaLevelPressureValueDate", "MonthlyMaxSeaLevelPressureValueTime", "MonthlyMaximumTemperature", "MonthlyMeanTemperature", "MonthlyMinSeaLevelPressureValue", "MonthlyMinSeaLevelPressureValueDate", "MonthlyMinSeaLevelPressureValueTime", "MonthlyMinimumTemperature", "MonthlySeaLevelPressure", "MonthlyStationPressure", "MonthlyTotalLiquidPrecipitation", "MonthlyTotalSnowfall", "MonthlyWetBulb", "NormalsCoolingDegreeDay", "NormalsHeatingDegreeDay", "REM", "REPORT_TYPE1", "SOURCE1", "ShortDurationEndDate005", "ShortDurationEndDate010", "ShortDurationEndDate015", "ShortDurationEndDate020", "ShortDurationEndDate030", "ShortDurationEndDate045", "ShortDurationEndDate060", "ShortDurationEndDate080", "ShortDurationEndDate100", "ShortDurationEndDate120", "ShortDurationEndDate150", "ShortDurationEndDate180", "ShortDurationPrecipitationValue005", "ShortDurationPrecipitationValue010", "ShortDurationPrecipitationValue015", "ShortDurationPrecipitationValue020", "ShortDurationPrecipitationValue030", "ShortDurationPrecipitationValue045", "ShortDurationPrecipitationValue060", "ShortDurationPrecipitationValue080", "ShortDurationPrecipitationValue100", "ShortDurationPrecipitationValue120", "ShortDurationPrecipitationValue150", "ShortDurationPrecipitationValue180", "Sunrise", "Sunset", "TStorms", "WindEquipmentChangeDate"];
opts.VariableTypes = ["string", "string", "double", "double", "string", "string", "string", "string", "string", "string", "string", "string", "string", "string", "string", "string", "string", "string", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "string", "string", "double", "double", "string", "string", "string", "string", "double", "double", "double", "double", "string", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "string", "double", "double", "double", "double", "double", "double", "string", "string", "string", "string", "string", "string", "string", "string", "string", "string", "string", "string", "string", "string", "string", "string", "string", "string", "string", "string", "string", "string", "string", "string", "string", "string", "string", "string", "string", "string", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "string", "datetime"];
opts = setvaropts(opts, 124, "InputFormat", "yyyy-MM-dd");
opts = setvaropts(opts, [2, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 34, 35, 38, 39, 40, 41, 46, 58, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 123], "WhitespaceRule", "preserve");
opts = setvaropts(opts, [3, 51, 59, 60, 61, 62, 63, 64, 95, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120], "TrimNonNumeric", true);
opts = setvaropts(opts, [3, 51, 59, 60, 61, 62, 63, 64, 95, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120], "ThousandsSeparator", ",");
opts = setvaropts(opts, [2, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 34, 35, 38, 39, 40, 41, 46, 58, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 123], "EmptyFieldRule", "auto");
opts.ExtraColumnsRule = "ignore";
opts.EmptyLineRule = "read";
% Import the data
tbl = readtable("NWS.csv", opts);
% Convert to output type
STATION = tbl.STATION;
DATE = tbl.DATE;
REPORT_TYPE = tbl.REPORT_TYPE;
HourlyAltimeterSetting = tbl.HourlyAltimeterSetting;
HourlyPrecipitation = tbl.HourlyPrecipitation;
HourlyStationPressure = tbl.HourlyStationPressure;
HourlyWindDirection = tbl.HourlyWindDirection;
HourlyWindGustSpeed = tbl.HourlyWindGustSpeed;
HourlyWindSpeed = tbl.HourlyWindSpeed;
WindEquipmentChangeDate = tbl.WindEquipmentChangeDate;
WBANs = [93796 93765 93729 03737 03703 13786 13762 13763 00154 13754 03736 13766 93719 03701 13769 00370 03719 93743 03741];
% wBanList = urlreadtable('file:///D:/DorianRP/wbanmasterlist.html');
% wBanList = wBanList{1};
filename = 'lcd-stations.txt';
filename2 = 'awos-stations.txt';
filename3 = 'asos-stations.txt';
wBanList{1} = readWBAN(filename);
wBanList{2} = readAWOS(filename2);
wBanList{3} = readASOS(filename3);
clear filename filename2 filename3
for Stat=[1:length(WBANs)]
localWinds = datetime(DATE(endsWith(STATION,num2str(WBANs(Stat)))),'InputFormat','yyyy-MM-dd''T''HH:mm:ss','TimeZone','America/New_York');
localShift = tzoffset(localWinds);
measuredWinds{Stat+40}(:,1) = datenum(datetime(DATE(endsWith(STATION,num2str(WBANs(Stat)))),'InputFormat','yyyy-MM-dd''T''HH:mm:ss')-localShift);
measuredWinds{Stat+40}(:,2) = HourlyWindSpeed(endsWith(STATION,num2str(WBANs(Stat)))).*0.44704;
measuredWinds{Stat+40}(:,3) = HourlyWindDirection(endsWith(STATION,num2str(WBANs(Stat))));
measueredPres{Stat+40}(:,1) = datenum(datetime(DATE(endsWith(STATION,num2str(WBANs(Stat)))),'InputFormat','yyyy-MM-dd''T''HH:mm:ss')-localShift);
measueredPres{Stat+40}(:,2) = HourlyStationPressure(endsWith(STATION,num2str(WBANs(Stat)))).*3386.3900009071;
precipUse = endsWith(STATION,num2str(WBANs(Stat)))...
& REPORT_TYPE==-15 &...
minute(datetime(DATE,'InputFormat','yyyy-MM-dd''T''HH:mm:ss'))>=40;
clear localWinds localShift
localWinds = datetime(DATE(precipUse),'InputFormat','yyyy-MM-dd''T''HH:mm:ss','TimeZone','America/New_York');
localShift = tzoffset(localWinds);
measueredRain{Stat+40}(:,1) = datenum(datetime(DATE(precipUse),'InputFormat','yyyy-MM-dd''T''HH:mm:ss')-localShift);
measueredRain{Stat+40}(:,2) = HourlyPrecipitation(precipUse).*0.0254*1000;
measueredRain{Stat+40}(isnan(measueredRain{Stat})==1,2)=0;
clear localWinds localShift precipUse
wBanIDX = find(wBanList{1}.WBAN==WBANs(Stat));
wBanSource = 1;
if isempty(wBanIDX)==1
wBanIDX = find(wBanList{2}.WBAN==WBANs(Stat));
wBanSource = 2;
end
if isempty(wBanIDX)==1
wBanIDX = find(wBanList{3}.WBAN==WBANs(Stat));
wBanSource = 3;
end
if isempty(wBanIDX)==1
switch Stat
case 10
[pointsCS{Stat+40,2},pointsCS{Stat+40,3}] = deg2utm(34.90000,-76.88300);
pointsCS{Stat+40,1} = 'CHERRY POINT';
pointsCS{Stat+40,4} = 'CP';
pointsCS{Stat+40,5} = WBANs(Stat);
case 15
[pointsCS{Stat+40,2},pointsCS{Stat+40,3}] = deg2utm(36.8167,-76.0333 );
pointsCS{Stat+40,1} = 'OCEANA NAS';
pointsCS{Stat+40,4} = 'ONS';
pointsCS{Stat+40,5} = WBANs(Stat);
end
else
wbanLat = wBanList{wBanSource}.LAT(wBanIDX);
wbanLon = wBanList{wBanSource}.LON(wBanIDX);
[pointsCS{Stat+40,2},pointsCS{Stat+40,3}] = deg2utm(wbanLat,wbanLon);
pointsCS{Stat+40,1} = wBanList{wBanSource}.LOCATION{wBanIDX};
pointsCS{Stat+40,4} = wBanList{wBanSource}.CALL{wBanIDX};
pointsCS{Stat+40,5} = WBANs(Stat);
end
end
pointsCS(50,4) = {'CPT'};
pointsCS{37,2} = 452000;
pointsCS{37,3} = 3959200;
pointsCS{37,1} = 'OI V2';
pointsCS{38,2} = 347000;
pointsCS{38,3} = 3840000;
pointsCS{38,1} = 'BF V2';
pointsCS{39,2} = 465400;
pointsCS{39,3} = 3883600;
pointsCS{39,1} = 'Hole';
pointsCS{40,2} = 390000;
pointsCS{40,3} = 3930000;
pointsCS{40,1} = 'Pond';
%% AHPS Stations
locations = [36.060710, -75.699941;...
35.595547,-75.470031;...
35.325700,-75.511900;...
35.018333,-76.314444;...
35.024444,-76.691944;
35.435180,-76.399800;...
34.667700,-77.063400;...
35.915000,-76.722778;...
36.298611,-76.218611;...
35.537222,-76.622778;...
35.543333,-77.061944;...
36.4073,-75.9949;...
35.6841,-75.4838;...
35.9081,-75.6683;...
35.1153,-75.9873;...
35.89639,-75.62222;...
34.95630,-76.27830];
locNames = {'Albemarle Sound @ Kitty Hawk ',...
'Pamlico Sound @ Rodanthe Ferry Terminal ',...
'Pamlico Sound @ Avon ',...
'Pamlico Sound @ Cedar Island ',...
'Neuse River @ Oriental ',...
'Pamlico Sound @ Bell Island Pier ',...
'Bogue Sound @ Emerald Isle ',...
'Roanoke River @ Westover ',...
'Pasquotank River near Mariners Wharf Park @ Elizabeth City',...
'Pungo River @ Belhaven',...
'Pamlico River @ Washington',...
'Maple @ Coinjock Creek',...
'Rodanthe 6N @ New Inlet',...
'Manteo - Roanoke Marshes',...
'Coast Guard Station @ Ocracoke',...
'Roanoke Sound',...
'Lola'};
locNamesCODE = {...
'KITN7',... %7
'ROFN7',... %15
'AVON7',... %1
'CTIN7',... %None
'ORLN7',... %10
'BIPN7',... %2
'EMDN7',... %5
'WESN7',... %16
'EMWN7',... %6
'BLHN7',... %3
'PAMN7',... %11
'COJN7',... %4
'PEAN7',... %12
'RMLN7',... %14
'OCAN7',... %9
'RDFN7',... %13
'LOLN7'}; %8
locNamesID = {...
'KH',... %7
'RF',... %15
'AV',... %1
'CI',... %None
'NRO',... %10
'BI',... %2
'EI',... %5
'WO',... %16
'EC',... %6
'BH',... %3
'WH',... %11
'CJ',... %4
'NI',... %12
'RM',... %14
'OC',... %9
'RS',...%13
'LO'}; %8
%[1:7 9 11:16]
for i = 1:length(locations)
[pointsCS{i+59,2},pointsCS{i+59,3}] = wgs2utm(locations(i,1),locations(i,2),18,'N');
pointsCS{i+59,1} = locNames{i};
pointsCS{i+59,5} = locNamesCODE{i};
pointsCS{i+59,4} = locNamesID{i};
end
% M 65
% Faves 74 62 61 60 67 69 70
% Nope 72 66 71 73 68
pointsCS{76,4} = 'LOA';
%% AWOS Pts
asos = importASOS("asos.txt");
opts = delimitedTextImportOptions("NumVariables", 7);
opts.DataLines = [2, Inf];
opts.Delimiter = ",";
opts.VariableNames = ["stid", "station_name", "lat", "lon", "elev", "begints", "iem_network"];
opts.VariableTypes = ["string", "string", "double", "double", "double", "string", "categorical"];
opts.ExtraColumnsRule = "ignore";
opts.EmptyLineRule = "read";
opts = setvaropts(opts, ["stid", "station_name", "begints"], "WhitespaceRule", "preserve");
opts = setvaropts(opts, ["stid", "station_name", "begints", "iem_network"], "EmptyFieldRule", "auto");
% Import the data
awosID = readtable("awosID.csv", opts);
clear opts
stationsASOS = unique(asos.station);
for Stat = 1:length(stationsASOS)
awosIDS = find(asos.station==stationsASOS(Stat),1);
awosIDX = find(awosID.stid==cellstr(stationsASOS(Stat)),1);
pointsCS(Stat+76,5) = cellstr(stationsASOS(Stat));
pointsCS(Stat+76,4) = cellstr(stationsASOS(Stat));
[pointsCS{Stat+76,2},pointsCS{Stat+76,3}] = wgs2utm(asos.lat(awosIDS),asos.lon(awosIDS),18,'N');
pointsCS(Stat+76,1) = {awosID.station_name{awosIDX}};
% pointsCS{Stat+76,1} = pointsCS{Stat+76,1}(2:end-1);
end
pointsCS{77,4} = 'DCG';
pointsCS{78,4} = 'ENG';
pointsCS{90,1} = 'Currituck Country Airport';
pointsCS{90,4} = 'CCA';
pointsCS{88,1} = 'Cherry Point Marine Corps Air Station';
pointsCS{88,4} = 'CPM';
pointsCS{87,4} = 'BOF';
pointsCS{86,4} = 'PIN';
pointsCS{85,1} = 'Beaufort Airport';
pointsCS{85,4} = 'BFA';
pointsCS{85,1} = 'Beaufort Airport';
pointsCS{85,4} = 'BFA';
pointsCS{84,1} = 'Manteo Dare Airport';
pointsCS{84,4} = 'MDA';
pointsCS{83,1} = 'Hatteras Airport';
pointsCS{83,4} = 'HTA';
pointsCS{82,1} = 'First flight Airport';
pointsCS{82,4} = 'FFA';
pointsCS{81,1} = 'New Berm Airport';
pointsCS{81,4} = 'NBA';
pointsCS{80,1} = 'Edenton Airport';
pointsCS{80,4} = 'EDA';
%% Add more details
CSs_F = [6 7 9 22 8 11 18 10 19 20 25 24 23 21];
CSs_F = [6 7 9 22 8 11 18 10 19 20 25 24 23 21 74 60 61 67 69 70 65];
CSsH_F = [12 13 14:16 26 18 19 30 31];
CSU = [27 17 18 19];
CSM = [6 9 12 16 35 42 45 46 50 53 59];
CSM = [6 9 12 16 35 42 45 46 50 53 59 64 68 69 74 76 77:91];
CSM = [6 9 12 16 35 45 46 50 53 59 64 74 76 77 78 82:87 90];
for i = 1:length(pointsCS)
if ismember(i,CSs_F)
pointsCS{i,6} = 'Water Level';
end
if ismember(i,CSsH_F)
pointsCS{i,7} = 'Wave';
end
if ismember(i,CSU)
pointsCS{i,8} = 'Current';
end
if ismember(i,CSM)
pointsCS{i,9} = 'Wind';
end
end
pointsCS([6 13 17 26 27],10) = {'USACE'};
pointsCS([10 11 20:22 33],10) = {'USGS'};
pointsCS([23:25],10) = {'USACE'}; %Conery, Ian
pointsCS([41:59 32],10) = {'NWS'}; %Conery, Ian
pointsCS([30:31],10) = {'CDIP/ USACE'};
pointsCS([16],10) = {'NDBC'};
pointsCS([12],10) = {'NDBC/ USACE'};
pointsCS([14:15],10) = {'NDBC/ UNC'};
pointsCS([18:19],10) = {'UNC'};
pointsCS([9],10) = {'NOAA/ Duke'};
pointsCS([8],10) = {'NOAA/ USCG'};
pointsCS([7],10) = {'NOAA'};
pointsCS([34],10) = {'NDBC/ NOAA'};
pointsCS([35],10) = {'NDBC'};
pointsCS([36],10) = {'NDBC/ NOAA'};
pointsCS([60:76],10) = {'ISU/ HADS'};
pointsCS([77:91],10) = {'ISU/ ASOS'};
% pointsCS([12],7) = {'Wave (3 m Buoy)'};
pointsCS([12],11) = {'47 m'};
% pointsCS([14],7) = {'Wave (Waverider Buoy)'};
pointsCS([14],11) = {'21 m'};
% pointsCS([15],7) = {'Wave (Waverider Buoy)'};
pointsCS([15],11) = {'18 m'};
% pointsCS([16],7) = {'Wave (3 m Buoy)'};
pointsCS([16],11) = {'59 m'};
% pointsCS([30],7) = {'Wave (Datawell Buoy)'};
pointsCS([30],11) = {'30 m'};
% pointsCS([31],7) = {'Wave (Datawell Buoy)'};
pointsCS([31],11) = {'18 m'};
% pointsCS([26],7) = {'Wave (Waverider Buoy)'};
pointsCS([26],11) = {'17 m'};
pointsCS([7],1) = {'Oregon Inlet Marina'};
pointsCS([11],1) = {'Albemarle Sound @ Leonards Point'};
pointsCS([8],1) = {'Hatteras Coast Guard'};
pointsCS([9],1) = {'Beaufort Duke Marine Lab'};
pointsCS([7],1) = {'Oregon Inlet Marina'};
pointsCS([20],1) = {'Currituck Sound @ Point Harbour'};
pointsCS([21],1) = {'Roanoke Sound @ Point Island'};
pointsCS([22],1) = {'Bogue Sound @ Atlantic Beach'};
pointsCS([23],1) = {'Villa Dunes Dock'};
pointsCS([24],1) = {'Kill Devil Hills @ Hayman Street'};
pointsCS([25],1) = {'Jean Guite Creek Outlet'};
pointsCS([27],1) = {'FRF AWAC'};
pointsCS([27],11) = {'6 m'};
pointsCS([17],1) = {'FRF AWAC'};
pointsCS([17],11) = {'11 m'};
% pointsCS([17],8) = {'Current (Nortek AWAC)'};
pointsCS([14],1) = {'Nags Head Buoy'};
pointsCS([15],1) = {'Oregon Inlet Buoy'};
pointsCS([16],1) = {'Diamond Shoals Buoy'};
pointsCS([30],1) = {'Oslow Bay Buoy'};
pointsCS([31],1) = {'Cape Henry Buoy'};
pointsCS([18],1) = {'Currituck Sound North'};
pointsCS([18],11) = {'2.3 m'};
% pointsCS([18],7) = {'Wave (Nortek AWAC)'};
% pointsCS([18],8) = {'Current (Nortek Aquadopp)'};
pointsCS([19],1) = {'Currituck Sound South'};
pointsCS([19],11) = {'2.6 m'};
% pointsCS([19],7) = {'Wave (Nortek AWAC)'};
% pointsCS([19],8) = {'Current (Nortek Aquadopp)'};
% pointsCS([6],8) = {'Current (Nortek AWAC)'};
pointsCS([6],11) = {'6 m'};
pointsCS([6],1) = {'FRF Pier'};
pointsCS([26],1) = {'FRF 17 m Buoy'};
pointsCS([13],1) = {'FRF 26 m Buoy'};
pointsCS([13],11) = {'26 m'};
pointsCS([42],1) = {'Michael J Smith Field'};
pointsCS([45],1) = {'Edenton Northeast Airport'};
pointsCS([46],1) = {'Elizabth City Coast Guard'};
pointsCS([50],1) = {'Cherry Point Marine Corps Air Station'};
pointsCS([50],4) = {'CPM'};
pointsCS([53],1) = {'Coasltal Carolina Airport'};
pointsCS([59],1) = {'Warren Field Airport'};
%% Add Elevation
pointsCS(41,12) = {20.85} ;
pointsCS(45,12) = {6.10} ;
pointsCS(46,12) = {7.5} ;
pointsCS(50,12) = {8.80} ;
pointsCS(50,12) = {9.90};
pointsCS(53,12) = {6.10} ;
pointsCS(59,12) = {11.80};
pointsCS(64,12) = {1.40};
pointsCS(74,12) = {2};
pointsCS(76,12) = {3.74};
pointsCS(77,12) = {0.51};
pointsCS(78,12) = {0.6};
pointsCS(82,12) = {4};
pointsCS(83,12) = {3};
pointsCS(84,12) = {4};
pointsCS(85,12) = {3};
pointsCS(86,12) = {5};
pointsCS(87,12) = {3.16};
pointsCS(90,12) = {5.5};
pointsCS(35,12) = {4.6};
pointsCS(9,12) = {0};
pointsCS(12,12) = {0};
pointsCS(16,12) = {0};
pointsCS(6,12) = {11.4};
%% Adjust out of dry zone
pointsCS{23,2} = pointsCS{23,2} - 100;
pointsCS{32,2} = pointsCS{32,2} - 1000;
pointsCS{51,2} = pointsCS{51,2} - 1000;
pointsCS{62,2} = pointsCS{62,2} - 1000;
pointsCS{43,2} = pointsCS{43,2} - 3000;
pointsCS{72,3} = pointsCS{72,3} - 10000;
pointsCS{60,2} = pointsCS{60,2} - 500;
pointsCS{61,2} = pointsCS{61,2} - 900;
pointsCS{61,3} = pointsCS{61,3} - 250;
pointsCS{92,2} = pointsCS{60,2} + 350;
pointsCS{92,3} = pointsCS{60,3} - 900;
pointsCS{92,1} = [pointsCS{60,1} '_Vsouth'];
pointsCS(92,4:12) = pointsCS(60,4:12);
pointsCS{35,3} = pointsCS{35,3} - 2000;
pointsCS{82,2} = pointsCS{82,2} - 1000;
pointsCS{83,3} = pointsCS{83,3} - 1000;
pointsCS{93,2} = pointsCS{22,2} + 2750;
pointsCS{93,3} = pointsCS{22,3} + 100;
pointsCS{93,1} = [pointsCS{22,1} '_VEast'];
pointsCS(93,4:12) = pointsCS(22,4:12);
pointsCS{94,2} = pointsCS{22,2} - 550;
pointsCS{94,3} = pointsCS{22,3} + 250;
pointsCS{94,1} = [pointsCS{22,1} '_VWest'];
pointsCS(94,4:12) = pointsCS(22,4:12);
pointsCS{95,2} = 350000;
pointsCS{95,3} = 3977900;
pointsCS{95,1} = [pointsCS{67,1} '_VEast'];
pointsCS(95,4:12) = pointsCS(67,4:12);
pointsCS{96,2} = 409700;
pointsCS{96,3} = 3883600;
pointsCS{96,1} = [pointsCS{74,1} '_VSouth'];
pointsCS(96,4:12) = pointsCS(74,4:12);
pointsCS{97,2} = 438200;
pointsCS{97,3} = 3896000;
pointsCS{97,1} = [pointsCS{24,1} '_VSouth'];
pointsCS(97,4:12) = pointsCS(24,4:12);
pointsCS(38,1:12) = pointsCS(9,1:12);
%% DUNEX Points
% Setup the Import Options and import the data
opts = delimitedTextImportOptions("NumVariables", 2);
% Specify range and delimiter
opts.DataLines = [1, Inf];
opts.Delimiter = ",";
% Specify column names and types
opts.VariableNames = ["VarName1", "VarName2"];
opts.VariableTypes = ["double", "double"];
% Specify file level properties
opts.ExtraColumnsRule = "ignore";
opts.EmptyLineRule = "read";
% Import the data
CoordinatesBC = readtable("D:\Alexander\DUNEX\Coordinates_BC.txt", opts);
% Convert to output type
CoordinatesBC = table2array(CoordinatesBC);
% Clear temporary variables
clear opts
for i = 1:length(CoordinatesBC)
pointsCS{i+97,1} = ['DUNEX_' num2str(i)];
pointsCS{i+97,4} = ['D_' num2str(i)];
[pointsCS{i+97,2},pointsCS{i+97,3}] = wgs2utm(CoordinatesBC(i,2),CoordinatesBC(i,1),18,'N');
end
%% Fix two bound pts
[pointsCS{114,3}] = pointsCS{114,3}+400;
[pointsCS{113,2}] = pointsCS{113,2}-500;
% [pointsCS{113,3}] = pointsCS{113,3}+500;
%% DUNEX Points
clear locations locNames locNamesID
locations = [36.400701, -75.823317;...
36.392170, -75.824346;...
35.779135, -75.532475;...
35.746968, -75.496067;...
35.743821, -75.500800;...
35.621202, -75.456779;...
35.620127, -75.464034;...
];
locNames = {'Currituck Banks Estuarine Reserve',...
'Currituck Banks Estuarine Reserve Nearshore',...
'Mid Oregon Inlet',...
'South Oregon Inlet',...
'South Oregon Inlet Nearshore',...
'Round Hammock Bay',...
'Round Hammock Bay Nearshore'};
locNamesID = {...
'CB',...
'CBN',...
'MI',...
'SI',...
'SIN',...
'HB',...
'HBN'}; %8
for i = 1:length(locations)
[pointsCS{i+129,2},pointsCS{i+129,3}] = wgs2utm(locations(i,1),locations(i,2),18,'N');
pointsCS{i+129,1} = locNames{i};
pointsCS{i+129,4} = locNamesID{i};
end
%% Add DUNEX_R
R_PTS = readmatrix("D:\Alexander\DUNEX_R\R. Housego DUNEX groundwater modeling locations_AJMR.xlsx",'Sheet','Combined');
for i = 1:size(R_PTS,1)
pointsCS{i+136,1} = ['DUNEX_R_' num2str(i)];
pointsCS{i+136,4} = ['DR_' num2str(i)];
[pointsCS{i+136,2},pointsCS{i+136,3}] = wgs2utm(R_PTS(i,2),R_PTS(i,1),18,'N');
end
%% Add Mulligan PTS
M_PTS = readcell("D:\Alexander\MulliganPTS_V2.xlsx");
for i = 1:size(M_PTS,1)
pointsCS{i+160,1} = M_PTS{i,1};
pointsCS{i+160,4} = M_PTS{i,4};
[pointsCS{i+160,2},pointsCS{i+160,3}] = wgs2utm(M_PTS{i,2},M_PTS{i,3},18,'N');
end
pointsCS(169,[2 3]) = pointsCS(61,[2 3]);
pointsCS(164,[2 3]) = pointsCS(115,[2 3]);
for i = 1:size(M_PTS,1)
[webPoints(i,1),webPoints(i,2)] = utm2deg(pointsCS{i+160,2},pointsCS{i+160,3},'18 N');
end
%% Add Chris PTS
C_PTS = readcell("D:\Alexander\ChrisPTS.xlsx");
for i = 1:size(C_PTS,1)
pointsCS{i+172,1} = ['Cpt_' C_PTS{i,1}];
pointsCS{i+172,4} = C_PTS{i,1};
[pointsCS{i+172,2},pointsCS{i+172,3}] = wgs2utm(C_PTS{i,2},C_PTS{i,3},18,'N');
end
%% Add Hohonu Pts
%% Check in pol
pol = readPol('D:\Alexander\DUNEX\NCShoreALL.pol');
clear inPol
for PolCount = 1:length(pol)
for CS = 1:length(pointsCS)
inPol(PolCount,CS) = inpolygon(pointsCS{CS,2},pointsCS{CS,3},pol{PolCount}(:,1),pol{PolCount}(:,2));
end
end
find(max(inPol))
%% Save
save('D:\DUNEX_RT\Operation\DUNEX_Sept7.mat','pointsCS')
%% Make Obs Files
flowGrid = load('D:\Alexander\DUNEX_R\Cone7W_100.mat');
% flowGrid = load('D:\Alexander\RT_25m\C7_25.mat');
% flowGrid = load('D:\NCBathy\Cone7\C9S_50.mat')
fileID=fopen('D:\Alexander\Dec28.obs','w');
% fileID=fopen('C9_50MET_V5.obs','w');
for line=1:length(pointsCS)
obsIDX = NearestValue([pointsCS{line,2:3}],flowGrid.data.X,flowGrid.data.Y);
if obsIDX(1) == 1
obsIDX(1) = 2;
end
if obsIDX(2) == 1
obsIDX(2) = 2;
end
if line ==71
fprintf(fileID,[num2str(line) '_' pointsCS{line,1}(1:5) ' %d %d\n'],obsIDX(1),obsIDX(2));
elseif length(pointsCS{line,1})>10
fprintf(fileID,[num2str(line) '_' pointsCS{line,1}(1:10) ' %d %d\n'],obsIDX(1),obsIDX(2));
else
fprintf(fileID,[num2str(line) '_' pointsCS{line,1}(1:end) ' %d %d\n'],obsIDX(1),obsIDX(2));
end
end
fclose(fileID);
fileID=fopen('D:\Alexander\Dec28.loc','w');
clear waveObsPts
% for i = 1:40
for i = 1:length(pointsCS)
obsIDX = NearestValue([pointsCS{i,2:3}],flowGrid.data.X,flowGrid.data.Y);
if obsIDX(1) == 1
obsIDX(1) = 2;
end
if obsIDX(2) == 1
obsIDX(2) = 2;
end
waveObsPts(i,:) = [flowGrid.data.X(obsIDX(1),obsIDX(2)),flowGrid.data.Y(obsIDX(1),obsIDX(2))];
fprintf(fileID,' %1.7f %1.7f\n',[waveObsPts(i,1),waveObsPts(i,2)])';
end
fclose(fileID)
%end

821
makeCSptsDUNEXR_Sept7.m Normal file
View File

@ -0,0 +1,821 @@
%% Make CS Points
clear pointsCS
load('CSpoints.mat');
% Realtime Points
% Create Observation File
locations = [36.606,-74.840;...
36.260,-75.594;...
36.001,-75.421;...
35.750,-75.330;...
35.025,-75.363;
36.189244, -75.739155;...
36.3205,-75.872;...
36.1656,-75.8155;...
36.0866, -75.76833;...
35.8964389,-75.6220889;...
34.7113528,-76.7368333;...
35.96176,-75.64163;...
36.04318,-75.68936;...
36.12932,-75.74501;...
36.20002, -75.7151];
locNames = {'Virginia Beach Wave',...
'Duck 26 Wave',...
'Nages Head Wave',...
'Oregon Inlet Wave',...
'Diamond Shoals Wave',...
'Duck 11 AWAC',...
'CS North',...
'CS South',...
'USGS CURRITUCK SOUND NR POINT HARBOR',...
'USGS ROANOKE SOUND AT POND ISLAND',...
'USGS BOGUE SOUND AT ATLANTIC BEACH',...
'Villa Dunes SW Dock Shoreline',...
'Hayman St Dock SW Shoreline',...
'Gunther Telephone Pole'...
'Duck 17 Wave'};
for i = 1:length(locations)
pointsCS{i+11,1} = locNames{i};
[pointsCS{i+11,2},pointsCS{i+11,3}] = wgs2utm(locations(i,1),locations(i,2),18,'N');
end
pointsCS{8,3} = pointsCS{8,3} + 2500;
pointsCS{7,2} = pointsCS{7,2} - 500;
[pointsCS{30,2},pointsCS{30,3}]= wgs2utm(34.213,-76.946,18,'N');
[pointsCS{31,2},pointsCS{31,3}]= wgs2utm(36.914,-75.720,18,'N');
pointsCS{30,1} = 'Onslow Bay Wave';
pointsCS{31,1} = 'Cape Henry Wave';
[pointsCS{32,2},pointsCS{32,3}]= wgs2utm(36.0175833,-75.6715833,18,'N');
pointsCS{32,1} = 'Kitty Hawk Airport';
[pointsCS{33,2},pointsCS{33,3}]= wgs2utm(36.20002,-75.7151,18,'N');
pointsCS{33,1} = 'FRF 17m';
pointsCS(33,4) = {'F17'};
pointsCS{10,1} = 'Currituck Sound @ Corolla';
pointsCS(1:21,4) = {'CS 1','CS 2','CS 3','CS 4','CS 5','FP','OI','HT','BF','CC','AS','VB','F26','NH','O18','DS','F11','CN','CS','PH','PI'};
pointsCS(22,4) = {'AB'};
pointsCS(23,4) = {'VD'};
pointsCS(24,4) = {'HD'};
pointsCS(25,4) = {'JC'};
pointsCS(30,4) = {'OB'};
pointsCS(31,4) = {'CH'};
pointsCS(32,4) = {'KH'};
pointsCS{27,1} = 'FRF 6m AWAC';
[pointsCS{27,2},pointsCS{27,3}]= wgs2utm(36.187328,-75.7465267,18,'N');
pointsCS{27,4} = 'F6';
pointsCS(26,4) = {'F17'};
for i = 1:length(locations)
pointsCS{i+11,1} = locNames{i};
[pointsCS{i+11,2},pointsCS{i+11,3}] = wgs2utm(locations(i,1),locations(i,2),18,'N');
end
pointsCS(28,:) = pointsCS(18,:);
pointsCS(29,:) = pointsCS(19,:);
pointsCS{28,1} = 'CS North 2';
pointsCS{29,1} = 'CS South 2';
% NDBC
[pointsCS{34,2},pointsCS{34,3}] = deg2utm(36.778,-76.302);
pointsCS{34,1} = 'Money Point';
[pointsCS{35,2},pointsCS{35,3}] = deg2utm(34.622,-76.525);
pointsCS{35,1} = 'Cape Lookout';
[pointsCS{36,2},pointsCS{36,3}] = deg2utm(36.962,-76.424);
pointsCS{36,1} = 'Dominion Terminal';
pointsCS(34,4) = {'MP'};
pointsCS(35,4) = {'CPL'};
pointsCS(36,4) = {'DV'};
% StatNum
pointsCS{6,5} = 8651370; %Dck
pointsCS{7,5} = 8652587; %OI
pointsCS{8,5} = 8654467; %Hat
pointsCS{9,5} = 8656483; %Beau
pointsCS{12,5} = '44014'; %VB
pointsCS{16,5} = '41025'; %DS
pointsCS{30,5} = '41159'; %OB
pointsCS{31,5} = '44099'; %CH
pointsCS{34,5} = 'MNPV2'; %MP
pointsCS{35,5} = 'CLKN7'; %CL
pointsCS{36,5} = 'DOMV2'; %DV
% Import Winds from NWS
opts = delimitedTextImportOptions("NumVariables", 124);
% Specify range and delimiter
opts.DataLines = [1, Inf];
opts.Delimiter = ",";
% Specify column names and types
opts.VariableNames = ["STATION", "DATE", "REPORT_TYPE", "SOURCE", "AWND", "BackupDirection", "BackupDistance", "BackupDistanceUnit", "BackupElements", "BackupElevation", "BackupElevationUnit", "BackupEquipment", "BackupLatitude", "BackupLongitude", "BackupName", "CDSD", "CLDD", "DSNW", "DailyAverageDewPointTemperature", "DailyAverageDryBulbTemperature", "DailyAverageRelativeHumidity", "DailyAverageSeaLevelPressure", "DailyAverageStationPressure", "DailyAverageWetBulbTemperature", "DailyAverageWindSpeed", "DailyCoolingDegreeDays", "DailyDepartureFromNormalAverageTemperature", "DailyHeatingDegreeDays", "DailyMaximumDryBulbTemperature", "DailyMinimumDryBulbTemperature", "DailyPeakWindDirection", "DailyPeakWindSpeed", "DailyPrecipitation", "DailySnowDepth", "DailySnowfall", "DailySustainedWindDirection", "DailySustainedWindSpeed", "DailyWeather", "HDSD", "HTDD", "HeavyFog", "HourlyAltimeterSetting", "HourlyDewPointTemperature", "HourlyDryBulbTemperature", "HourlyPrecipitation", "HourlyPresentWeatherType", "HourlyPressureChange", "HourlyPressureTendency", "HourlyRelativeHumidity", "HourlySeaLevelPressure", "HourlySkyConditions", "HourlyStationPressure", "HourlyVisibility", "HourlyWetBulbTemperature", "HourlyWindDirection", "HourlyWindGustSpeed", "HourlyWindSpeed", "MonthlyAverageRH", "MonthlyDaysWithGT001Precip", "MonthlyDaysWithGT010Precip", "MonthlyDaysWithGT32Temp", "MonthlyDaysWithGT90Temp", "MonthlyDaysWithLT0Temp", "MonthlyDaysWithLT32Temp", "MonthlyDepartureFromNormalAverageTemperature", "MonthlyDepartureFromNormalCoolingDegreeDays", "MonthlyDepartureFromNormalHeatingDegreeDays", "MonthlyDepartureFromNormalMaximumTemperature", "MonthlyDepartureFromNormalMinimumTemperature", "MonthlyDepartureFromNormalPrecipitation", "MonthlyDewpointTemperature", "MonthlyGreatestPrecip", "MonthlyGreatestPrecipDate", "MonthlyGreatestSnowDepth", "MonthlyGreatestSnowDepthDate", "MonthlyGreatestSnowfall", "MonthlyGreatestSnowfallDate", "MonthlyMaxSeaLevelPressureValue", "MonthlyMaxSeaLevelPressureValueDate", "MonthlyMaxSeaLevelPressureValueTime", "MonthlyMaximumTemperature", "MonthlyMeanTemperature", "MonthlyMinSeaLevelPressureValue", "MonthlyMinSeaLevelPressureValueDate", "MonthlyMinSeaLevelPressureValueTime", "MonthlyMinimumTemperature", "MonthlySeaLevelPressure", "MonthlyStationPressure", "MonthlyTotalLiquidPrecipitation", "MonthlyTotalSnowfall", "MonthlyWetBulb", "NormalsCoolingDegreeDay", "NormalsHeatingDegreeDay", "REM", "REPORT_TYPE1", "SOURCE1", "ShortDurationEndDate005", "ShortDurationEndDate010", "ShortDurationEndDate015", "ShortDurationEndDate020", "ShortDurationEndDate030", "ShortDurationEndDate045", "ShortDurationEndDate060", "ShortDurationEndDate080", "ShortDurationEndDate100", "ShortDurationEndDate120", "ShortDurationEndDate150", "ShortDurationEndDate180", "ShortDurationPrecipitationValue005", "ShortDurationPrecipitationValue010", "ShortDurationPrecipitationValue015", "ShortDurationPrecipitationValue020", "ShortDurationPrecipitationValue030", "ShortDurationPrecipitationValue045", "ShortDurationPrecipitationValue060", "ShortDurationPrecipitationValue080", "ShortDurationPrecipitationValue100", "ShortDurationPrecipitationValue120", "ShortDurationPrecipitationValue150", "ShortDurationPrecipitationValue180", "Sunrise", "Sunset", "TStorms", "WindEquipmentChangeDate"];
opts.VariableTypes = ["string", "string", "double", "double", "string", "string", "string", "string", "string", "string", "string", "string", "string", "string", "string", "string", "string", "string", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "string", "string", "double", "double", "string", "string", "string", "string", "double", "double", "double", "double", "string", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "string", "double", "double", "double", "double", "double", "double", "string", "string", "string", "string", "string", "string", "string", "string", "string", "string", "string", "string", "string", "string", "string", "string", "string", "string", "string", "string", "string", "string", "string", "string", "string", "string", "string", "string", "string", "string", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "string", "datetime"];
opts = setvaropts(opts, 124, "InputFormat", "yyyy-MM-dd");
opts = setvaropts(opts, [2, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 34, 35, 38, 39, 40, 41, 46, 58, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 123], "WhitespaceRule", "preserve");
opts = setvaropts(opts, [3, 51, 59, 60, 61, 62, 63, 64, 95, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120], "TrimNonNumeric", true);
opts = setvaropts(opts, [3, 51, 59, 60, 61, 62, 63, 64, 95, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120], "ThousandsSeparator", ",");
opts = setvaropts(opts, [2, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 34, 35, 38, 39, 40, 41, 46, 58, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 123], "EmptyFieldRule", "auto");
opts.ExtraColumnsRule = "ignore";
opts.EmptyLineRule = "read";
% Import the data
tbl = readtable("NWS.csv", opts);
% Convert to output type
STATION = tbl.STATION;
DATE = tbl.DATE;
REPORT_TYPE = tbl.REPORT_TYPE;
HourlyAltimeterSetting = tbl.HourlyAltimeterSetting;
HourlyPrecipitation = tbl.HourlyPrecipitation;
HourlyStationPressure = tbl.HourlyStationPressure;
HourlyWindDirection = tbl.HourlyWindDirection;
HourlyWindGustSpeed = tbl.HourlyWindGustSpeed;
HourlyWindSpeed = tbl.HourlyWindSpeed;
WindEquipmentChangeDate = tbl.WindEquipmentChangeDate;
WBANs = [93796 93765 93729 03737 03703 13786 13762 13763 00154 13754 03736 13766 93719 03701 13769 00370 03719 93743 03741];
% wBanList = urlreadtable('file:///D:/DorianRP/wbanmasterlist.html');
% wBanList = wBanList{1};
filename = 'lcd-stations.txt';
filename2 = 'awos-stations.txt';
filename3 = 'asos-stations.txt';
wBanList{1} = readWBAN(filename);
wBanList{2} = readAWOS(filename2);
wBanList{3} = readASOS(filename3);
clear filename filename2 filename3
for Stat=[1:length(WBANs)]
localWinds = datetime(DATE(endsWith(STATION,num2str(WBANs(Stat)))),'InputFormat','yyyy-MM-dd''T''HH:mm:ss','TimeZone','America/New_York');
localShift = tzoffset(localWinds);
measuredWinds{Stat+40}(:,1) = datenum(datetime(DATE(endsWith(STATION,num2str(WBANs(Stat)))),'InputFormat','yyyy-MM-dd''T''HH:mm:ss')-localShift);
measuredWinds{Stat+40}(:,2) = HourlyWindSpeed(endsWith(STATION,num2str(WBANs(Stat)))).*0.44704;
measuredWinds{Stat+40}(:,3) = HourlyWindDirection(endsWith(STATION,num2str(WBANs(Stat))));
measueredPres{Stat+40}(:,1) = datenum(datetime(DATE(endsWith(STATION,num2str(WBANs(Stat)))),'InputFormat','yyyy-MM-dd''T''HH:mm:ss')-localShift);
measueredPres{Stat+40}(:,2) = HourlyStationPressure(endsWith(STATION,num2str(WBANs(Stat)))).*3386.3900009071;
precipUse = endsWith(STATION,num2str(WBANs(Stat)))...
& REPORT_TYPE==-15 &...
minute(datetime(DATE,'InputFormat','yyyy-MM-dd''T''HH:mm:ss'))>=40;
clear localWinds localShift
localWinds = datetime(DATE(precipUse),'InputFormat','yyyy-MM-dd''T''HH:mm:ss','TimeZone','America/New_York');
localShift = tzoffset(localWinds);
measueredRain{Stat+40}(:,1) = datenum(datetime(DATE(precipUse),'InputFormat','yyyy-MM-dd''T''HH:mm:ss')-localShift);
measueredRain{Stat+40}(:,2) = HourlyPrecipitation(precipUse).*0.0254*1000;
measueredRain{Stat+40}(isnan(measueredRain{Stat})==1,2)=0;
clear localWinds localShift precipUse
wBanIDX = find(wBanList{1}.WBAN==WBANs(Stat));
wBanSource = 1;
if isempty(wBanIDX)==1
wBanIDX = find(wBanList{2}.WBAN==WBANs(Stat));
wBanSource = 2;
end
if isempty(wBanIDX)==1
wBanIDX = find(wBanList{3}.WBAN==WBANs(Stat));
wBanSource = 3;
end
if isempty(wBanIDX)==1
switch Stat
case 10
[pointsCS{Stat+40,2},pointsCS{Stat+40,3}] = deg2utm(34.90000,-76.88300);
pointsCS{Stat+40,1} = 'CHERRY POINT';
pointsCS{Stat+40,4} = 'CP';
pointsCS{Stat+40,5} = WBANs(Stat);
case 15
[pointsCS{Stat+40,2},pointsCS{Stat+40,3}] = deg2utm(36.8167,-76.0333 );
pointsCS{Stat+40,1} = 'OCEANA NAS';
pointsCS{Stat+40,4} = 'ONS';
pointsCS{Stat+40,5} = WBANs(Stat);
end
else
wbanLat = wBanList{wBanSource}.LAT(wBanIDX);
wbanLon = wBanList{wBanSource}.LON(wBanIDX);
[pointsCS{Stat+40,2},pointsCS{Stat+40,3}] = deg2utm(wbanLat,wbanLon);
pointsCS{Stat+40,1} = wBanList{wBanSource}.LOCATION{wBanIDX};
pointsCS{Stat+40,4} = wBanList{wBanSource}.CALL{wBanIDX};
pointsCS{Stat+40,5} = WBANs(Stat);
end
end
pointsCS(50,4) = {'CPT'};
pointsCS{37,2} = 452000;
pointsCS{37,3} = 3959200;
pointsCS{37,1} = 'OI V2';
pointsCS{38,2} = 347000;
pointsCS{38,3} = 3840000;
pointsCS{38,1} = 'BF V2';
pointsCS{39,2} = 465400;
pointsCS{39,3} = 3883600;
pointsCS{39,1} = 'Hole';
pointsCS{40,2} = 390000;
pointsCS{40,3} = 3930000;
pointsCS{40,1} = 'Pond';
%% AHPS Stations
locations = [36.060710, -75.699941;...
35.595547,-75.470031;...
35.325700,-75.511900;...
35.018333,-76.314444;...
35.024444,-76.691944;
35.435180,-76.399800;...
34.667700,-77.063400;...
35.915000,-76.722778;...
36.298611,-76.218611;...
35.537222,-76.622778;...
35.543333,-77.061944;...
36.4073,-75.9949;...
35.6841,-75.4838;...
35.9081,-75.6683;...
35.1153,-75.9873;...
35.89639,-75.62222;...
34.95630,-76.27830];
locNames = {'Albemarle Sound @ Kitty Hawk ',...
'Pamlico Sound @ Rodanthe Ferry Terminal ',...
'Pamlico Sound @ Avon ',...
'Pamlico Sound @ Cedar Island ',...
'Neuse River @ Oriental ',...
'Pamlico Sound @ Bell Island Pier ',...
'Bogue Sound @ Emerald Isle ',...
'Roanoke River @ Westover ',...
'Pasquotank River near Mariners Wharf Park @ Elizabeth City',...
'Pungo River @ Belhaven',...
'Pamlico River @ Washington',...
'Maple @ Coinjock Creek',...
'Rodanthe 6N @ New Inlet',...
'Manteo - Roanoke Marshes',...
'Coast Guard Station @ Ocracoke',...
'Roanoke Sound',...
'Lola'};
locNamesCODE = {...
'KITN7',... %7
'ROFN7',... %15
'AVON7',... %1
'CTIN7',... %None
'ORLN7',... %10
'BIPN7',... %2
'EMDN7',... %5
'WESN7',... %16
'EMWN7',... %6
'BLHN7',... %3
'PAMN7',... %11
'COJN7',... %4
'PEAN7',... %12
'RMLN7',... %14
'OCAN7',... %9
'RDFN7',... %13
'LOLN7'}; %8
locNamesID = {...
'KH',... %7
'RF',... %15
'AV',... %1
'CI',... %None
'NRO',... %10
'BI',... %2
'EI',... %5
'WO',... %16
'EC',... %6
'BH',... %3
'WH',... %11
'CJ',... %4
'NI',... %12
'RM',... %14
'OC',... %9
'RS',...%13
'LO'}; %8
%[1:7 9 11:16]
for i = 1:length(locations)
[pointsCS{i+59,2},pointsCS{i+59,3}] = wgs2utm(locations(i,1),locations(i,2),18,'N');
pointsCS{i+59,1} = locNames{i};
pointsCS{i+59,5} = locNamesCODE{i};
pointsCS{i+59,4} = locNamesID{i};
end
% M 65
% Faves 74 62 61 60 67 69 70
% Nope 72 66 71 73 68
pointsCS{76,4} = 'LOA';
%% AWOS Pts
asos = importASOS("asos.txt");
opts = delimitedTextImportOptions("NumVariables", 7);
opts.DataLines = [2, Inf];
opts.Delimiter = ",";
opts.VariableNames = ["stid", "station_name", "lat", "lon", "elev", "begints", "iem_network"];
opts.VariableTypes = ["string", "string", "double", "double", "double", "string", "categorical"];
opts.ExtraColumnsRule = "ignore";
opts.EmptyLineRule = "read";
opts = setvaropts(opts, ["stid", "station_name", "begints"], "WhitespaceRule", "preserve");
opts = setvaropts(opts, ["stid", "station_name", "begints", "iem_network"], "EmptyFieldRule", "auto");
% Import the data
awosID = readtable("awosID.csv", opts);
clear opts
stationsASOS = unique(asos.station);
for Stat = 1:length(stationsASOS)
awosIDS = find(asos.station==stationsASOS(Stat),1);
awosIDX = find(awosID.stid==cellstr(stationsASOS(Stat)),1);
pointsCS(Stat+76,5) = cellstr(stationsASOS(Stat));
pointsCS(Stat+76,4) = cellstr(stationsASOS(Stat));
[pointsCS{Stat+76,2},pointsCS{Stat+76,3}] = wgs2utm(asos.lat(awosIDS),asos.lon(awosIDS),18,'N');
pointsCS(Stat+76,1) = {awosID.station_name{awosIDX}};
% pointsCS{Stat+76,1} = pointsCS{Stat+76,1}(2:end-1);
end
pointsCS{77,4} = 'DCG';
pointsCS{78,4} = 'ENG';
pointsCS{90,1} = 'Currituck Country Airport';
pointsCS{90,4} = 'CCA';
pointsCS{88,1} = 'Cherry Point Marine Corps Air Station';
pointsCS{88,4} = 'CPM';
pointsCS{87,4} = 'BOF';
pointsCS{86,4} = 'PIN';
pointsCS{85,1} = 'Beaufort Airport';
pointsCS{85,4} = 'BFA';
pointsCS{85,1} = 'Beaufort Airport';
pointsCS{85,4} = 'BFA';
pointsCS{84,1} = 'Manteo Dare Airport';
pointsCS{84,4} = 'MDA';
pointsCS{83,1} = 'Hatteras Airport';
pointsCS{83,4} = 'HTA';
pointsCS{82,1} = 'First flight Airport';
pointsCS{82,4} = 'FFA';
pointsCS{81,1} = 'New Berm Airport';
pointsCS{81,4} = 'NBA';
pointsCS{80,1} = 'Edenton Airport';
pointsCS{80,4} = 'EDA';
%% Add more details
CSs_F = [6 7 9 22 8 11 18 10 19 20 25 24 23 21];
CSs_F = [6 7 9 22 8 11 18 10 19 20 25 24 23 21 74 60 61 67 69 70 65];
CSsH_F = [12 13 14:16 26 18 19 30 31];
CSU = [27 17 18 19];
CSM = [6 9 12 16 35 42 45 46 50 53 59];
CSM = [6 9 12 16 35 42 45 46 50 53 59 64 68 69 74 76 77:91];
CSM = [6 9 12 16 35 45 46 50 53 59 64 74 76 77 78 82:87 90];
for i = 1:length(pointsCS)
if ismember(i,CSs_F)
pointsCS{i,6} = 'Water Level';
end
if ismember(i,CSsH_F)
pointsCS{i,7} = 'Wave';
end
if ismember(i,CSU)
pointsCS{i,8} = 'Current';
end
if ismember(i,CSM)
pointsCS{i,9} = 'Wind';
end
end
pointsCS([6 13 17 26 27],10) = {'USACE'};
pointsCS([10 11 20:22 33],10) = {'USGS'};
pointsCS([23:25],10) = {'USACE'}; %Conery, Ian
pointsCS([41:59 32],10) = {'NWS'}; %Conery, Ian
pointsCS([30:31],10) = {'CDIP/ USACE'};
pointsCS([16],10) = {'NDBC'};
pointsCS([12],10) = {'NDBC/ USACE'};
pointsCS([14:15],10) = {'NDBC/ UNC'};
pointsCS([18:19],10) = {'UNC'};
pointsCS([9],10) = {'NOAA/ Duke'};
pointsCS([8],10) = {'NOAA/ USCG'};
pointsCS([7],10) = {'NOAA'};
pointsCS([34],10) = {'NDBC/ NOAA'};
pointsCS([35],10) = {'NDBC'};
pointsCS([36],10) = {'NDBC/ NOAA'};
pointsCS([60:76],10) = {'ISU/ HADS'};
pointsCS([77:91],10) = {'ISU/ ASOS'};
% pointsCS([12],7) = {'Wave (3 m Buoy)'};
pointsCS([12],11) = {'47 m'};
% pointsCS([14],7) = {'Wave (Waverider Buoy)'};
pointsCS([14],11) = {'21 m'};
% pointsCS([15],7) = {'Wave (Waverider Buoy)'};
pointsCS([15],11) = {'18 m'};
% pointsCS([16],7) = {'Wave (3 m Buoy)'};
pointsCS([16],11) = {'59 m'};
% pointsCS([30],7) = {'Wave (Datawell Buoy)'};
pointsCS([30],11) = {'30 m'};
% pointsCS([31],7) = {'Wave (Datawell Buoy)'};
pointsCS([31],11) = {'18 m'};
% pointsCS([26],7) = {'Wave (Waverider Buoy)'};
pointsCS([26],11) = {'17 m'};
pointsCS([7],1) = {'Oregon Inlet Marina'};
pointsCS([11],1) = {'Albemarle Sound @ Leonards Point'};
pointsCS([8],1) = {'Hatteras Coast Guard'};
pointsCS([9],1) = {'Beaufort Duke Marine Lab'};
pointsCS([7],1) = {'Oregon Inlet Marina'};
pointsCS([20],1) = {'Currituck Sound @ Point Harbour'};
pointsCS([21],1) = {'Roanoke Sound @ Point Island'};
pointsCS([22],1) = {'Bogue Sound @ Atlantic Beach'};
pointsCS([23],1) = {'Villa Dunes Dock'};
pointsCS([24],1) = {'Kill Devil Hills @ Hayman Street'};
pointsCS([25],1) = {'Jean Guite Creek Outlet'};
pointsCS([27],1) = {'FRF AWAC'};
pointsCS([27],11) = {'6 m'};
pointsCS([17],1) = {'FRF AWAC'};
pointsCS([17],11) = {'11 m'};
% pointsCS([17],8) = {'Current (Nortek AWAC)'};
pointsCS([14],1) = {'Nags Head Buoy'};
pointsCS([15],1) = {'Oregon Inlet Buoy'};
pointsCS([16],1) = {'Diamond Shoals Buoy'};
pointsCS([30],1) = {'Oslow Bay Buoy'};
pointsCS([31],1) = {'Cape Henry Buoy'};
pointsCS([18],1) = {'Currituck Sound North'};
pointsCS([18],11) = {'2.3 m'};
% pointsCS([18],7) = {'Wave (Nortek AWAC)'};
% pointsCS([18],8) = {'Current (Nortek Aquadopp)'};
pointsCS([19],1) = {'Currituck Sound South'};
pointsCS([19],11) = {'2.6 m'};
% pointsCS([19],7) = {'Wave (Nortek AWAC)'};
% pointsCS([19],8) = {'Current (Nortek Aquadopp)'};
% pointsCS([6],8) = {'Current (Nortek AWAC)'};
pointsCS([6],11) = {'6 m'};
pointsCS([6],1) = {'FRF Pier'};
pointsCS([26],1) = {'FRF 17 m Buoy'};
pointsCS([13],1) = {'FRF 26 m Buoy'};
pointsCS([13],11) = {'26 m'};
pointsCS([42],1) = {'Michael J Smith Field'};
pointsCS([45],1) = {'Edenton Northeast Airport'};
pointsCS([46],1) = {'Elizabth City Coast Guard'};
pointsCS([50],1) = {'Cherry Point Marine Corps Air Station'};
pointsCS([50],4) = {'CPM'};
pointsCS([53],1) = {'Coasltal Carolina Airport'};
pointsCS([59],1) = {'Warren Field Airport'};
%% Add Elevation
pointsCS(41,12) = {20.85} ;
pointsCS(45,12) = {6.10} ;
pointsCS(46,12) = {7.5} ;
pointsCS(50,12) = {8.80} ;
pointsCS(50,12) = {9.90};
pointsCS(53,12) = {6.10} ;
pointsCS(59,12) = {11.80};
pointsCS(64,12) = {1.40};
pointsCS(74,12) = {2};
pointsCS(76,12) = {3.74};
pointsCS(77,12) = {0.51};
pointsCS(78,12) = {0.6};
pointsCS(82,12) = {4};
pointsCS(83,12) = {3};
pointsCS(84,12) = {4};
pointsCS(85,12) = {3};
pointsCS(86,12) = {5};
pointsCS(87,12) = {3.16};
pointsCS(90,12) = {5.5};
pointsCS(35,12) = {4.6};
pointsCS(9,12) = {0};
pointsCS(12,12) = {0};
pointsCS(16,12) = {0};
pointsCS(6,12) = {11.4};
%% Adjust out of dry zone
pointsCS{23,2} = pointsCS{23,2} - 100;
pointsCS{32,2} = pointsCS{32,2} - 1000;
pointsCS{51,2} = pointsCS{51,2} - 1000;
pointsCS{62,2} = pointsCS{62,2} - 1000;
pointsCS{43,2} = pointsCS{43,2} - 3000;
pointsCS{72,3} = pointsCS{72,3} - 10000;
pointsCS{60,2} = pointsCS{60,2} - 500;
pointsCS{61,2} = pointsCS{61,2} - 900;
pointsCS{61,3} = pointsCS{61,3} - 250;
pointsCS{92,2} = pointsCS{60,2} + 350;
pointsCS{92,3} = pointsCS{60,3} - 900;
pointsCS{92,1} = [pointsCS{60,1} '_Vsouth'];
pointsCS(92,4:12) = pointsCS(60,4:12);
pointsCS{35,3} = pointsCS{35,3} - 2000;
pointsCS{82,2} = pointsCS{82,2} - 1000;
pointsCS{83,3} = pointsCS{83,3} - 1000;
pointsCS{93,2} = pointsCS{22,2} + 2750;
pointsCS{93,3} = pointsCS{22,3} + 100;
pointsCS{93,1} = [pointsCS{22,1} '_VEast'];
pointsCS(93,4:12) = pointsCS(22,4:12);
pointsCS{94,2} = pointsCS{22,2} - 550;
pointsCS{94,3} = pointsCS{22,3} + 250;
pointsCS{94,1} = [pointsCS{22,1} '_VWest'];
pointsCS(94,4:12) = pointsCS(22,4:12);
pointsCS{95,2} = 350000;
pointsCS{95,3} = 3977900;
pointsCS{95,1} = [pointsCS{67,1} '_VEast'];
pointsCS(95,4:12) = pointsCS(67,4:12);
pointsCS{96,2} = 409700;
pointsCS{96,3} = 3883600;
pointsCS{96,1} = [pointsCS{74,1} '_VSouth'];
pointsCS(96,4:12) = pointsCS(74,4:12);
pointsCS{97,2} = 438200;
pointsCS{97,3} = 3896000;
pointsCS{97,1} = [pointsCS{24,1} '_VSouth'];
pointsCS(97,4:12) = pointsCS(24,4:12);
pointsCS(38,1:12) = pointsCS(9,1:12);
%% DUNEX Points
% Setup the Import Options and import the data
opts = delimitedTextImportOptions("NumVariables", 2);
% Specify range and delimiter
opts.DataLines = [1, Inf];
opts.Delimiter = ",";
% Specify column names and types
opts.VariableNames = ["VarName1", "VarName2"];
opts.VariableTypes = ["double", "double"];
% Specify file level properties
opts.ExtraColumnsRule = "ignore";
opts.EmptyLineRule = "read";
% Import the data
CoordinatesBC = readtable("D:\Alexander\DUNEX\Coordinates_BC.txt", opts);
% Convert to output type
CoordinatesBC = table2array(CoordinatesBC);
% Clear temporary variables
clear opts
for i = 1:length(CoordinatesBC)
pointsCS{i+97,1} = ['DUNEX_' num2str(i)];
pointsCS{i+97,4} = ['D_' num2str(i)];
[pointsCS{i+97,2},pointsCS{i+97,3}] = wgs2utm(CoordinatesBC(i,2),CoordinatesBC(i,1),18,'N');
end
%% Fix two bound pts
[pointsCS{114,3}] = pointsCS{114,3}+400;
[pointsCS{113,2}] = pointsCS{113,2}-500;
% [pointsCS{113,3}] = pointsCS{113,3}+500;
%% DUNEX Points
clear locations locNames locNamesID
locations = [36.400701, -75.823317;...
36.392170, -75.824346;...
35.779135, -75.532475;...
35.746968, -75.496067;...
35.743821, -75.500800;...
35.621202, -75.456779;...
35.620127, -75.464034;...
];
locNames = {'Currituck Banks Estuarine Reserve',...
'Currituck Banks Estuarine Reserve Nearshore',...
'Mid Oregon Inlet',...
'South Oregon Inlet',...
'South Oregon Inlet Nearshore',...
'Round Hammock Bay',...
'Round Hammock Bay Nearshore'};
locNamesID = {...
'CB',...
'CBN',...
'MI',...
'SI',...
'SIN',...
'HB',...
'HBN'}; %8
for i = 1:length(locations)
[pointsCS{i+129,2},pointsCS{i+129,3}] = wgs2utm(locations(i,1),locations(i,2),18,'N');
pointsCS{i+129,1} = locNames{i};
pointsCS{i+129,4} = locNamesID{i};
end
%% Add DUNEX_R
R_PTS = readmatrix("D:\Alexander\DUNEX_R\R. Housego DUNEX groundwater modeling locations_AJMR.xlsx",'Sheet','Combined');
for i = 1:size(R_PTS,1)
pointsCS{i+136,1} = ['DUNEX_R_' num2str(i)];
pointsCS{i+136,4} = ['DR_' num2str(i)];
[pointsCS{i+136,2},pointsCS{i+136,3}] = wgs2utm(R_PTS(i,2),R_PTS(i,1),18,'N');
end
%% Add Mulligan PTS
M_PTS = readcell("D:\Alexander\MulliganPTS_V2.xlsx");
for i = 1:size(M_PTS,1)
pointsCS{i+160,1} = M_PTS{i,1};
pointsCS{i+160,4} = M_PTS{i,4};
[pointsCS{i+160,2},pointsCS{i+160,3}] = wgs2utm(M_PTS{i,2},M_PTS{i,3},18,'N');
end
pointsCS(169,[2 3]) = pointsCS(61,[2 3]);
pointsCS(164,[2 3]) = pointsCS(115,[2 3]);
for i = 1:size(M_PTS,1)
[webPoints(i,1),webPoints(i,2)] = utm2deg(pointsCS{i+160,2},pointsCS{i+160,3},'18 N');
end
%% Add Chris PTS
C_PTS = readcell("D:\Alexander\ChrisPTS.xlsx");
for i = 1:size(C_PTS,1)
pointsCS{i+172,1} = ['Cpt_' C_PTS{i,1}];
pointsCS{i+172,4} = C_PTS{i,1};
[pointsCS{i+172,2},pointsCS{i+172,3}] = wgs2utm(C_PTS{i,2},C_PTS{i,3},18,'N');
end
%% Add Hohonu Pts
locations = [
36.22332, -75.772544;...
36.13097, -75.745303;...
36.01498, -75.687458;...
35.910474, -75.594299;...
35.898637, -75.615641;...
35.869354, -75.663404;...
];
locShiftUTM = [
-1500, -1500;...
-200, 0;...
0, -1500;...
400, 100;...
500, -100;...
-100, 0;...
];
locNames = {'Duck Dare County NC',...
'Southern Shores NC',...
'Collington Creek Inn Dock Kill Devil Hills',...
'Jennettes Pier, Nags Head',...
'Hwy 64 Little Bridge',...
'Coastal Studies Institute Wanchese NC'};
locNamesID = {...
'HHD',...
'HHS',...
'HHC',...
'HHJ',...
'HHH',...
'HHW'};
locIDs = [
10015; %Duck, Dare County, NC
10020; %Southern Shores, NC
10011; %Collington Creek Inn Dock, Kill Devil Hills
10012; %Jennette's Pier, Nags Head
10009; %Hwy 64, Little Bridge
10010]; %Coastal Studies Institute, Wanchese, NC
for i = 1:length(locations)
[pointsCS{i+180,2},pointsCS{i+180,3}] = wgs2utm(locations(i,1),locations(i,2),18,'N');
pointsCS{i+180,2} = pointsCS{i+180,2} + locShiftUTM(i,1);
pointsCS{i+180,3} = pointsCS{i+180,3} + locShiftUTM(i,2);
pointsCS{i+180,1} = locNames{i};
pointsCS{i+180,4} = locNamesID{i};
pointsCS{i+180,5} = locIDs(1);
end
%% Check in pol
pol = readPol('D:\Alexander\DUNEX\NCShoreALL.pol');
clear inPol
for PolCount = 1:length(pol)
for CS = 1:length(pointsCS)
inPol(PolCount,CS) = inpolygon(pointsCS{CS,2},pointsCS{CS,3},pol{PolCount}(:,1),pol{PolCount}(:,2));
end
end
find(max(inPol))
%% Save
save('D:\DUNEX_RT\Operation\DUNEX_Sept7.mat','pointsCS','-v7.3')
%% Make Obs Files
flowGrid = load('D:\Alexander\DUNEX_R\Cone7W_100.mat');
% flowGrid = load('D:\Alexander\RT_25m\C7_25.mat');
% flowGrid = load('D:\NCBathy\Cone7\C9S_50.mat')
fileID=fopen('D:\DUNEX_RT\Operation\Sept7.obs','w');
% fileID=fopen('C9_50MET_V5.obs','w');
for line=1:length(pointsCS)
obsIDX = NearestValue([pointsCS{line,2:3}],flowGrid.data.X,flowGrid.data.Y);
if obsIDX(1) == 1
obsIDX(1) = 2;
end
if obsIDX(2) == 1
obsIDX(2) = 2;
end
if line ==71
fprintf(fileID,[num2str(line) '_' pointsCS{line,1}(1:5) ' %d %d\n'],obsIDX(1),obsIDX(2));
elseif length(pointsCS{line,1})>10
fprintf(fileID,[num2str(line) '_' pointsCS{line,1}(1:10) ' %d %d\n'],obsIDX(1),obsIDX(2));
else
fprintf(fileID,[num2str(line) '_' pointsCS{line,1}(1:end) ' %d %d\n'],obsIDX(1),obsIDX(2));
end
end
fclose(fileID);
fileID=fopen('D:\DUNEX_RT\Operation\Sept7.loc','w');
clear waveObsPts
% for i = 1:40
for i = 1:length(pointsCS)
obsIDX = NearestValue([pointsCS{i,2:3}],flowGrid.data.X,flowGrid.data.Y);
if obsIDX(1) == 1
obsIDX(1) = 2;
end
if obsIDX(2) == 1
obsIDX(2) = 2;
end
waveObsPts(i,:) = [flowGrid.data.X(obsIDX(1),obsIDX(2)),flowGrid.data.Y(obsIDX(1),obsIDX(2))];
fprintf(fileID,' %1.7f %1.7f\n',[waveObsPts(i,1),waveObsPts(i,2)])';
end
fclose(fileID)
%end

5
naninterp.m Normal file
View File

@ -0,0 +1,5 @@
function X = naninterp(X)
% Interpolate over NaNs
% See INTERP1 for more info
X(isnan(X)) = interp1(find(~isnan(X)), X(~isnan(X)), find(isnan(X)),'pchip');
return

125
readASOS.m Normal file
View File

@ -0,0 +1,125 @@
function asosstations = readASOS(filename, startRow, endRow)
%IMPORTFILE Import numeric data from a text file as a matrix.
% ASOSSTATIONS = IMPORTFILE(FILENAME) Reads data from text file FILENAME
% for the default selection.
%
% ASOSSTATIONS = IMPORTFILE(FILENAME, STARTROW, ENDROW) Reads data from
% rows STARTROW through ENDROW of text file FILENAME.
%
% Example:
% asosstations = importfile('asos-stations.txt', 3, 920);
%
% See also TEXTSCAN.
% Auto-generated by MATLAB on 2019/11/25 13:24:05
%% Initialize variables.
if nargin<=2
startRow = 3;
endRow = inf;
end
%% Read columns of data as text:
% For more information, see the TEXTSCAN documentation.
formatSpec = '%9s%5s%7s%6s%31s%31s%21s%2s%32s%10s%11s%7s%6s%59s%12s%s%[^\n\r]';
%% Open the text file.
fileID = fopen(filename,'r');
%% Read columns of data according to the format.
% This call is based on the structure of the file used to generate this
% code. If an error occurs for a different file, try regenerating the code
% from the Import Tool.
dataArray = textscan(fileID, formatSpec, endRow(1)-startRow(1)+1, 'Delimiter', '', 'WhiteSpace', '', 'TextType', 'string', 'HeaderLines', startRow(1)-1, 'ReturnOnError', false, 'EndOfLine', '\r\n');
for block=2:length(startRow)
frewind(fileID);
dataArrayBlock = textscan(fileID, formatSpec, endRow(block)-startRow(block)+1, 'Delimiter', '', 'WhiteSpace', '', 'TextType', 'string', 'HeaderLines', startRow(block)-1, 'ReturnOnError', false, 'EndOfLine', '\r\n');
for col=1:length(dataArray)
dataArray{col} = [dataArray{col};dataArrayBlock{col}];
end
end
%% Remove white space around all cell columns.
dataArray{4} = strtrim(dataArray{4});
dataArray{5} = strtrim(dataArray{5});
dataArray{6} = strtrim(dataArray{6});
dataArray{14} = strtrim(dataArray{14});
%% Close the text file.
fclose(fileID);
%% Convert the contents of columns containing numeric text to numbers.
% Replace non-numeric text with NaN.
raw = repmat({''},length(dataArray{1}),length(dataArray)-1);
for col=1:length(dataArray)-1
raw(1:length(dataArray{col}),col) = mat2cell(dataArray{col}, ones(length(dataArray{col}), 1));
end
numericData = NaN(size(dataArray{1},1),size(dataArray,2));
for col=[1,2,3,10,11,13,15]
% Converts text in the input cell array to numbers. Replaced non-numeric
% text with NaN.
rawData = dataArray{col};
for row=1:size(rawData, 1)
% Create a regular expression to detect and remove non-numeric prefixes and
% suffixes.
regexstr = '(?<prefix>.*?)(?<numbers>([-]*(\d+[\,]*)+[\.]{0,1}\d*[eEdD]{0,1}[-+]*\d*[i]{0,1})|([-]*(\d+[\,]*)*[\.]{1,1}\d+[eEdD]{0,1}[-+]*\d*[i]{0,1}))(?<suffix>.*)';
try
result = regexp(rawData(row), regexstr, 'names');
numbers = result.numbers;
% Detected commas in non-thousand locations.
invalidThousandsSeparator = false;
if numbers.contains(',')
thousandsRegExp = '^[-/+]*\d+?(\,\d{3})*\.{0,1}\d*$';
if isempty(regexp(numbers, thousandsRegExp, 'once'))
numbers = NaN;
invalidThousandsSeparator = true;
end
end
% Convert numeric text to numbers.
if ~invalidThousandsSeparator
numbers = textscan(char(strrep(numbers, ',', '')), '%f');
numericData(row, col) = numbers{1};
raw{row, col} = numbers{1};
end
catch
raw{row, col} = rawData{row};
end
end
end
%% Split data into numeric and string columns.
rawNumericColumns = raw(:, [1,2,3,10,11,13,15]);
rawStringColumns = string(raw(:, [4,5,6,7,8,9,12,14,16]));
%% Replace non-numeric cells with NaN
R = cellfun(@(x) ~isnumeric(x) && ~islogical(x),rawNumericColumns); % Find non-numeric cells
rawNumericColumns(R) = {NaN}; % Replace non-numeric cells
%% Make sure any text containing <undefined> is properly converted to an <undefined> categorical
for catIdx = [4,5,6,7,9]
idx = (rawStringColumns(:, catIdx) == "<undefined>");
rawStringColumns(idx, catIdx) = "";
end
%% Create output variable
asosstations = table;
asosstations.NCDCID = cell2mat(rawNumericColumns(:, 1));
asosstations.WBAN = cell2mat(rawNumericColumns(:, 2));
asosstations.COOPID = cell2mat(rawNumericColumns(:, 3));
asosstations.CALL = rawStringColumns(:, 1);
asosstations.LOCATION = rawStringColumns(:, 2);
asosstations.ALT_NAME = rawStringColumns(:, 3);
asosstations.COUNTRY = categorical(rawStringColumns(:, 4));
asosstations.ST = categorical(rawStringColumns(:, 5));
asosstations.COUNTY = categorical(rawStringColumns(:, 6));
asosstations.LAT = cell2mat(rawNumericColumns(:, 4));
asosstations.LON = cell2mat(rawNumericColumns(:, 5));
asosstations.ELEV = categorical(rawStringColumns(:, 7));
asosstations.UTC = cell2mat(rawNumericColumns(:, 6));
asosstations.STNTYPEBEGDT = rawStringColumns(:, 8);
asosstations.GHCND = cell2mat(rawNumericColumns(:, 7));
asosstations.VarName16 = categorical(rawStringColumns(:, 9));

121
readAWOS.m Normal file
View File

@ -0,0 +1,121 @@
function awosstations = readAWOS(filename, startRow, endRow)
%IMPORTFILE Import numeric data from a text file as a matrix.
% AWOSSTATIONS = IMPORTFILE(FILENAME) Reads data from text file FILENAME
% for the default selection.
%
% AWOSSTATIONS = IMPORTFILE(FILENAME, STARTROW, ENDROW) Reads data from
% rows STARTROW through ENDROW of text file FILENAME.
%
% Example:
% awosstations = importfile('awos-stations.txt', 3, 1132);
%
% See also TEXTSCAN.
% Auto-generated by MATLAB on 2019/11/25 13:21:35
%% Initialize variables.
if nargin<=2
startRow = 3;
endRow = inf;
end
%% Read columns of data as text:
% For more information, see the TEXTSCAN documentation.
formatSpec = '%8s%6s%8s%3s%33s%21s%3s%31s%10s%11s%7s%6s%s%[^\n\r]';
%% Open the text file.
fileID = fopen(filename,'r');
%% Read columns of data according to the format.
% This call is based on the structure of the file used to generate this
% code. If an error occurs for a different file, try regenerating the code
% from the Import Tool.
dataArray = textscan(fileID, formatSpec, endRow(1)-startRow(1)+1, 'Delimiter', '', 'WhiteSpace', '', 'TextType', 'string', 'HeaderLines', startRow(1)-1, 'ReturnOnError', false, 'EndOfLine', '\r\n');
for block=2:length(startRow)
frewind(fileID);
dataArrayBlock = textscan(fileID, formatSpec, endRow(block)-startRow(block)+1, 'Delimiter', '', 'WhiteSpace', '', 'TextType', 'string', 'HeaderLines', startRow(block)-1, 'ReturnOnError', false, 'EndOfLine', '\r\n');
for col=1:length(dataArray)
dataArray{col} = [dataArray{col};dataArrayBlock{col}];
end
end
%% Remove white space around all cell columns.
dataArray{4} = strtrim(dataArray{4});
dataArray{5} = strtrim(dataArray{5});
%% Close the text file.
fclose(fileID);
%% Convert the contents of columns containing numeric text to numbers.
% Replace non-numeric text with NaN.
raw = repmat({''},length(dataArray{1}),length(dataArray)-1);
for col=1:length(dataArray)-1
raw(1:length(dataArray{col}),col) = mat2cell(dataArray{col}, ones(length(dataArray{col}), 1));
end
numericData = NaN(size(dataArray{1},1),size(dataArray,2));
for col=[1,2,9,10,12]
% Converts text in the input cell array to numbers. Replaced non-numeric
% text with NaN.
rawData = dataArray{col};
for row=1:size(rawData, 1)
% Create a regular expression to detect and remove non-numeric prefixes and
% suffixes.
regexstr = '(?<prefix>.*?)(?<numbers>([-]*(\d+[\,]*)+[\.]{0,1}\d*[eEdD]{0,1}[-+]*\d*[i]{0,1})|([-]*(\d+[\,]*)*[\.]{1,1}\d+[eEdD]{0,1}[-+]*\d*[i]{0,1}))(?<suffix>.*)';
try
result = regexp(rawData(row), regexstr, 'names');
numbers = result.numbers;
% Detected commas in non-thousand locations.
invalidThousandsSeparator = false;
if numbers.contains(',')
thousandsRegExp = '^[-/+]*\d+?(\,\d{3})*\.{0,1}\d*$';
if isempty(regexp(numbers, thousandsRegExp, 'once'))
numbers = NaN;
invalidThousandsSeparator = true;
end
end
% Convert numeric text to numbers.
if ~invalidThousandsSeparator
numbers = textscan(char(strrep(numbers, ',', '')), '%f');
numericData(row, col) = numbers{1};
raw{row, col} = numbers{1};
end
catch
raw{row, col} = rawData{row};
end
end
end
%% Split data into numeric and string columns.
rawNumericColumns = raw(:, [1,2,9,10,12]);
rawStringColumns = string(raw(:, [3,4,5,6,7,8,11,13]));
%% Replace non-numeric cells with NaN
R = cellfun(@(x) ~isnumeric(x) && ~islogical(x),rawNumericColumns); % Find non-numeric cells
rawNumericColumns(R) = {NaN}; % Replace non-numeric cells
%% Make sure any text containing <undefined> is properly converted to an <undefined> categorical
for catIdx = [1,4,5,6,7,8]
idx = (rawStringColumns(:, catIdx) == "<undefined>");
rawStringColumns(idx, catIdx) = "";
end
%% Create output variable
awosstations = table;
awosstations.NCDCID = cell2mat(rawNumericColumns(:, 1));
awosstations.WBAN = cell2mat(rawNumericColumns(:, 2));
awosstations.COOPID = categorical(rawStringColumns(:, 1));
awosstations.CALL = rawStringColumns(:, 2);
awosstations.LOCATION = rawStringColumns(:, 3);
awosstations.COUNTRY = categorical(rawStringColumns(:, 4));
awosstations.ST = categorical(rawStringColumns(:, 5));
awosstations.COUNTY = categorical(rawStringColumns(:, 6));
awosstations.LAT = cell2mat(rawNumericColumns(:, 3));
awosstations.LON = cell2mat(rawNumericColumns(:, 4));
awosstations.ELEV = categorical(rawStringColumns(:, 7));
awosstations.UTC = cell2mat(rawNumericColumns(:, 5));
awosstations.STNTYPE = categorical(rawStringColumns(:, 8));

52
readPol.m Normal file
View File

@ -0,0 +1,52 @@
function [points] = readPol(fname)
%% reads a Delft3D polygon into a cell array
opts = delimitedTextImportOptions("NumVariables", 5);
% Specify range and delimiter
opts.DataLines = [9, Inf];
opts.Delimiter = " ";
% Specify column names and types
opts.VariableNames = ["VarName1", "Coordinate", "Var3", "Var4", "Var5"];
opts.SelectedVariableNames = ["VarName1", "Coordinate"];
opts.VariableTypes = ["double", "double", "string", "string", "string"];
% Specify file level properties
opts.ExtraColumnsRule = "ignore";
opts.EmptyLineRule = "read";
opts.ConsecutiveDelimitersRule = "join";
opts.LeadingDelimitersRule = "ignore";
% Specify variable properties
opts = setvaropts(opts, ["Var3", "Var4", "Var5"], "WhitespaceRule", "preserve");
opts = setvaropts(opts, ["Var3", "Var4", "Var5"], "EmptyFieldRule", "auto");
% Import the data
NCShoreALL = readtable(fname, opts);
%% Convert to output type
NCShoreALL = table2array(NCShoreALL);
%% Clear temporary variables
clear opts
SegCount = 1;
PtsCount = 1;
for Line = 2:length(NCShoreALL)
if isnan(NCShoreALL(Line,1))==1
elseif Line>3 && isnan(NCShoreALL(Line-1,1))==1
continue
elseif Line>3 && isnan(NCShoreALL(Line-2,1))==1
PtsCount = 1;
SegCount = SegCount+1;
continue
else
points{SegCount}(PtsCount,:) = NCShoreALL(Line,:);
PtsCount = PtsCount+1;
end
end
end

132
readWBAN.m Normal file
View File

@ -0,0 +1,132 @@
function lcdstations = importfile(filename, startRow, endRow)
%IMPORTFILE Import numeric data from a text file as a matrix.
% LCDSTATIONS = IMPORTFILE(FILENAME) Reads data from text file FILENAME
% for the default selection.
%
% LCDSTATIONS = IMPORTFILE(FILENAME, STARTROW, ENDROW) Reads data from
% rows STARTROW through ENDROW of text file FILENAME.
%
% Example:
% lcdstations = importfile('lcd-stations.txt', 1, 272);
%
% See also TEXTSCAN.
% Auto-generated by MATLAB on 2019/11/25 12:59:26
%% Initialize variables.
if nargin<=2
startRow = 1;
endRow = inf;
end
%% Read columns of data as text:
% For more information, see the TEXTSCAN documentation.
formatSpec = '%5s%5s%11s%20s%11s%6s%4s%12s%12s%52s%61s%26s%2s%3s%9s%11s%11s%9s%4s%s%[^\n\r]';
%% Open the text file.
fileID = fopen(filename,'r');
%% Read columns of data according to the format.
% This call is based on the structure of the file used to generate this
% code. If an error occurs for a different file, try regenerating the code
% from the Import Tool.
dataArray = textscan(fileID, formatSpec, endRow(1)-startRow(1)+1, 'Delimiter', '', 'WhiteSpace', '', 'TextType', 'string', 'HeaderLines', startRow(1)-1, 'ReturnOnError', false, 'EndOfLine', '\r\n');
for block=2:length(startRow)
frewind(fileID);
dataArrayBlock = textscan(fileID, formatSpec, endRow(block)-startRow(block)+1, 'Delimiter', '', 'WhiteSpace', '', 'TextType', 'string', 'HeaderLines', startRow(block)-1, 'ReturnOnError', false, 'EndOfLine', '\r\n');
for col=1:length(dataArray)
dataArray{col} = [dataArray{col};dataArrayBlock{col}];
end
end
%% Remove white space around all cell columns.
dataArray{2} = strtrim(dataArray{2});
dataArray{4} = strtrim(dataArray{4});
dataArray{5} = strtrim(dataArray{5});
dataArray{7} = strtrim(dataArray{7});
dataArray{10} = strtrim(dataArray{10});
dataArray{11} = strtrim(dataArray{11});
%% Close the text file.
fclose(fileID);
%% Convert the contents of columns containing numeric text to numbers.
% Replace non-numeric text with NaN.
raw = repmat({''},length(dataArray{1}),length(dataArray)-1);
for col=1:length(dataArray)-1
raw(1:length(dataArray{col}),col) = mat2cell(dataArray{col}, ones(length(dataArray{col}), 1));
end
numericData = NaN(size(dataArray{1},1),size(dataArray,2));
for col=[1,6,8,9,16,17,18,20]
% Converts text in the input cell array to numbers. Replaced non-numeric
% text with NaN.
rawData = dataArray{col};
for row=1:size(rawData, 1)
% Create a regular expression to detect and remove non-numeric prefixes and
% suffixes.
regexstr = '(?<prefix>.*?)(?<numbers>([-]*(\d+[\,]*)+[\.]{0,1}\d*[eEdD]{0,1}[-+]*\d*[i]{0,1})|([-]*(\d+[\,]*)*[\.]{1,1}\d+[eEdD]{0,1}[-+]*\d*[i]{0,1}))(?<suffix>.*)';
try
result = regexp(rawData(row), regexstr, 'names');
numbers = result.numbers;
% Detected commas in non-thousand locations.
invalidThousandsSeparator = false;
if numbers.contains(',')
thousandsRegExp = '^[-/+]*\d+?(\,\d{3})*\.{0,1}\d*$';
if isempty(regexp(numbers, thousandsRegExp, 'once'))
numbers = NaN;
invalidThousandsSeparator = true;
end
end
% Convert numeric text to numbers.
if ~invalidThousandsSeparator
numbers = textscan(char(strrep(numbers, ',', '')), '%f');
numericData(row, col) = numbers{1};
raw{row, col} = numbers{1};
end
catch
raw{row, col} = rawData{row};
end
end
end
%% Split data into numeric and string columns.
rawNumericColumns = raw(:, [1,6,8,9,16,17,18,20]);
rawStringColumns = string(raw(:, [2,3,4,5,7,10,11,12,13,14,15,19]));
%% Replace non-numeric cells with NaN
R = cellfun(@(x) ~isnumeric(x) && ~islogical(x),rawNumericColumns); % Find non-numeric cells
rawNumericColumns(R) = {NaN}; % Replace non-numeric cells
%% Make sure any text containing <undefined> is properly converted to an <undefined> categorical
for catIdx = [2,8,9,10,11,12]
idx = (rawStringColumns(:, catIdx) == "<undefined>");
rawStringColumns(idx, catIdx) = "";
end
%% Create output variable
lcdstations = table;
lcdstations.WBAN = cell2mat(rawNumericColumns(:, 1));
lcdstations.TRANSMITTAL_ID = rawStringColumns(:, 1);
lcdstations.TRANSMITTAL_ID_TYPE = categorical(rawStringColumns(:, 2));
lcdstations.CALL = rawStringColumns(:, 3);
lcdstations.FAA_ID = rawStringColumns(:, 4);
lcdstations.WMO_ID = cell2mat(rawNumericColumns(:, 2));
lcdstations.NWSLI_ID = rawStringColumns(:, 5);
lcdstations.COOP_ID = cell2mat(rawNumericColumns(:, 3));
lcdstations.GHCND_ID = cell2mat(rawNumericColumns(:, 4));
lcdstations.CITY = rawStringColumns(:, 6);
lcdstations.LOCATION = rawStringColumns(:, 7);
lcdstations.LOCATION_AREA = categorical(rawStringColumns(:, 8));
lcdstations.STATE_PROV = categorical(rawStringColumns(:, 9));
lcdstations.FIPS_COUNTRY_CODE = categorical(rawStringColumns(:, 10));
lcdstations.NWS_REGION = categorical(rawStringColumns(:, 11));
lcdstations.LAT = cell2mat(rawNumericColumns(:, 5));
lcdstations.LON = cell2mat(rawNumericColumns(:, 6));
lcdstations.ELEV = cell2mat(rawNumericColumns(:, 7));
lcdstations.ELEV_GROUND_UNIT = categorical(rawStringColumns(:, 12));
lcdstations.UTC = cell2mat(rawNumericColumns(:, 8));

1304
read_grads.m Normal file

File diff suppressed because it is too large Load Diff

View File

@ -13,10 +13,10 @@ Commnt = no. dry points: 1068
Fildry = #NCShoreALLSquare2_100.dry#
Commnt = no. thin dams: 0
Commnt =
Itdate = #2021-09-08#
Itdate = #2021-09-29#
Tunit = #M#
Tstart = 7.2000000e+02
Tstop = 3.6000000e+03
Tstart = 3.6000000e+02
Tstop = 3.2400000e+03
Dt = 0.25
Tzone = 0
Commnt =
@ -93,9 +93,9 @@ PHhydr = #YYYYYY#
PHderv = #YYY#
PHproc = #YYYYYYYYYY#
PHflux = #YYYY#
Flmap = 7.2000000e+02 60 3.6000000e+03
Flhis = 7.2000000e+02 10 3.6000000e+03
Flpp = 7.2000000e+02 60 3.6000000e+03
Flmap = 3.6000000e+02 60 3.2400000e+03
Flhis = 3.6000000e+02 10 3.2400000e+03
Flpp = 3.6000000e+02 60 3.2400000e+03
Flrst = 60
Commnt =
Online = #N#

1281
sdfopen.m Normal file

File diff suppressed because it is too large Load Diff

19
setup_nctoolbox.m Normal file
View File

@ -0,0 +1,19 @@
function setup_nctoolbox
home = fileparts(which(mfilename));
addpath(fullfile(home, 'java'));
addpath(fullfile(home, 'cdm'));
% Added so that we can swap out utitlies modules for different user groups,
% like sura shelf_hypoxia
addpath(genpath(fullfile(home, 'cdm', 'utilities')));
warning off
try
setup_nctoolbox_java;
catch me
ex = MException('MBARI:NCTOOLBOX', 'Failed to setup the Java classpath');
ex.throw
end
warning on
disp('NCTOOLBOX added to Matlab path')

134
utm2deg.m Normal file
View File

@ -0,0 +1,134 @@
function [Lat,Lon] = utm2deg(xx,yy,utmzone)
% -------------------------------------------------------------------------
% [Lat,Lon] = utm2deg(x,y,utmzone)
%
% Description: Function to convert vectors of UTM coordinates into Lat/Lon vectors (WGS84).
% Some code has been extracted from UTMIP.m function by Gabriel Ruiz Martinez.
%
% Inputs:
% x, y , utmzone.
%
% Outputs:
% Lat: Latitude vector. Degrees. +ddd.ddddd WGS84
% Lon: Longitude vector. Degrees. +ddd.ddddd WGS84
%
% Example 1:
% x=[ 458731; 407653; 239027; 230253; 343898; 362850];
% y=[4462881; 5126290; 4163083; 3171843; 4302285; 2772478];
% utmzone=['30 T'; '32 T'; '11 S'; '28 R'; '15 S'; '51 R'];
% [Lat, Lon]=utm2deg(x,y,utmzone);
% fprintf('%11.6f ',lat)
% 40.315430 46.283902 37.577834 28.645647 38.855552 25.061780
% fprintf('%11.6f ',lon)
% -3.485713 7.801235 -119.955246 -17.759537 -94.799019 121.640266
%
% Example 2: If you need Lat/Lon coordinates in Degrees, Minutes and Seconds
% [Lat, Lon]=utm2deg(x,y,utmzone);
% LatDMS=dms2mat(deg2dms(Lat))
%LatDMS =
% 40.00 18.00 55.55
% 46.00 17.00 2.01
% 37.00 34.00 40.17
% 28.00 38.00 44.33
% 38.00 51.00 19.96
% 25.00 3.00 42.41
% LonDMS=dms2mat(deg2dms(Lon))
%LonDMS =
% -3.00 29.00 8.61
% 7.00 48.00 4.40
% -119.00 57.00 18.93
% -17.00 45.00 34.33
% -94.00 47.00 56.47
% 121.00 38.00 24.96
%
% Author:
% Rafael Palacios
% Universidad Pontificia Comillas
% Madrid, Spain
% Version: Apr/06, Jun/06, Aug/06
% Aug/06: corrected m-Lint warnings
%-------------------------------------------------------------------------
% Argument checking
%
error(nargchk(3, 3, nargin)); %3 arguments required
n1=length(xx);
n2=length(yy);
n3=size(utmzone,1);
if (n1~=n2 || n1~=n3)
error('x,y and utmzone vectors should have the same number or rows');
end
c=size(utmzone,2);
if (c~=4)
error('utmzone should be a vector of strings like "30 T"');
end
% Memory pre-allocation
%
Lat=zeros(n1,1);
Lon=zeros(n1,1);
% Main Loop
%
for i=1:n1
if (utmzone(i,4)>'X' || utmzone(i,4)<'C')
fprintf('utm2deg: Warning utmzone should be a vector of strings like "30 T", not "30 t"\n');
end
if (utmzone(i,4)>'M')
hemis='N'; % Northern hemisphere
else
hemis='S';
end
x=xx(i);
y=yy(i);
zone=str2double(utmzone(i,1:2));
sa = 6378137.000000 ; sb = 6356752.314245;
% e = ( ( ( sa ^ 2 ) - ( sb ^ 2 ) ) ^ 0.5 ) / sa;
e2 = ( ( ( sa ^ 2 ) - ( sb ^ 2 ) ) ^ 0.5 ) / sb;
e2cuadrada = e2 ^ 2;
c = ( sa ^ 2 ) / sb;
% alpha = ( sa - sb ) / sa; %f
% ablandamiento = 1 / alpha; % 1/f
X = x - 500000;
if hemis == 'S' || hemis == 's'
Y = y - 10000000;
else
Y = y;
end
S = ( ( zone * 6 ) - 183 );
lat = Y / ( 6366197.724 * 0.9996 );
v = ( c / ( ( 1 + ( e2cuadrada * ( cos(lat) ) ^ 2 ) ) ) ^ 0.5 ) * 0.9996;
a = X / v;
a1 = sin( 2 * lat );
a2 = a1 * ( cos(lat) ) ^ 2;
j2 = lat + ( a1 / 2 );
j4 = ( ( 3 * j2 ) + a2 ) / 4;
j6 = ( ( 5 * j4 ) + ( a2 * ( cos(lat) ) ^ 2) ) / 3;
alfa = ( 3 / 4 ) * e2cuadrada;
beta = ( 5 / 3 ) * alfa ^ 2;
gama = ( 35 / 27 ) * alfa ^ 3;
Bm = 0.9996 * c * ( lat - alfa * j2 + beta * j4 - gama * j6 );
b = ( Y - Bm ) / v;
Epsi = ( ( e2cuadrada * a^ 2 ) / 2 ) * ( cos(lat) )^ 2;
Eps = a * ( 1 - ( Epsi / 3 ) );
nab = ( b * ( 1 - Epsi ) ) + lat;
senoheps = ( exp(Eps) - exp(-Eps) ) / 2;
Delt = atan(senoheps / (cos(nab) ) );
TaO = atan(cos(Delt) * tan(nab));
longitude = (Delt *(180 / pi ) ) + S;
latitude = ( lat + ( 1 + e2cuadrada* (cos(lat)^ 2) - ( 3 / 2 ) * e2cuadrada * sin(lat) * cos(lat) * ( TaO - lat ) ) * ( TaO - lat ) ) * ...
(180 / pi);
Lat(i)=latitude;
Lon(i)=longitude;
end

15
vecmag.m Normal file
View File

@ -0,0 +1,15 @@
function [mag] = vecmag(x,y,z)
%% Tiny function to find the mag of 2 or 3 vectors
% Because I'm tired of writing sqrt
% Alexander Rey, Queen's University, Oct 30 2019
if nargin == 1
mag = x;
elseif nargin == 2
mag = sqrt(x.^2+y.^2);
elseif nargin == 3
mag = sqrt(x.^2+y.^2+z.^2);
end
end

62
water_properties.m Normal file
View File

@ -0,0 +1,62 @@
function water = water_properties
% WATER_PROPERTIES Returns function handles to compute physical properties
% of water dependent on temperature, from 0.1 to 100 celsius.
%
% Water properties:
% Density [kg/m^3]
% Kinematic Viscosity [m^2/s]
% Bulk Modulus [Pa]
%
% Independent variable:
% Temperature [C]
%
% Examples:
% water = water_properties;
% % Compute water properties for a single temperature value
% water.nu(27)
% water.rho(27)
% water.K(27)
% % Create a short alias
% nu = water.nu;
% % Plot viscosity for multiple temperature values
% t = 10:80;
% plot(t,nu(t),'*')
%
% Requires:
% water_data.mat
%
% Author:
% Ildeberto de los Santos Ruiz
% idelossantos@ittg.edu.mx
data_file = 'water_data.mat';
if exist(data_file)
disp('Loading data...')
x = load(data_file);
else
errorStruct.message = 'Data file not found.';
errorStruct.identifier = 'water_properties:fileNotFound';
error(errorStruct)
end
% Temperature (C)
temperature = x.temperature;
% Density, rho (kg/m^3)
density = x.density;
% Kinematic Viscosity, nu (m^2/s)
viscosity = x.viscosity;
% Bulk Modulus, K (Pa)
bulk_modulus = x.bulk_modulus;
% Function handle for density
water.rho = @(t) interp1(temperature,density,t,'spline');
% Function handle for viscosity
water.nu = @(t) interp1(temperature,viscosity,t,'spline');
% Function handle for bulk modulus
water.K = @(t) interp1(temperature,bulk_modulus,t,'spline');

155
wgs2utm.m Normal file
View File

@ -0,0 +1,155 @@
function [x,y,utmzone,utmhemi] = wgs2utm(Lat,Lon,utmzone,utmhemi)
% -------------------------------------------------------------------------
% [x,y,utmzone] = wgs2utm(Lat,Lon,Zone)
%
% Description:
% Convert WGS84 coordinates (Latitude, Longitude) into UTM coordinates
% (northing, easting) according to (optional) input UTM zone and
% hemisphere.
%
% Input:
% Lat: WGS84 Latitude scalar, vector or array in decimal degrees.
% Lon: WGS84 Longitude scalar, vector or array in decimal degrees.
% utmzone (optional): UTM longitudinal zone. Scalar or same size as Lat
% and Lon.
% utmhemi (optional): UTM hemisphere as a single character, 'N' or 'S',
% or array of 'N' or 'S' characters of same size as Lat and Lon.
%
% Output:
% x: UTM easting in meters.
% y: UTM northing in meters.
% utmzone: UTM longitudinal zone.
% utmhemi: UTM hemisphere as array of 'N' or 'S' characters.
%
% Author notes:
% I downloaded and tried deg2utm.m from Rafael Palacios but found
% differences of up to 1m with my reference converters in southern
% hemisphere so I wrote my own code based on "Map Projections - A
% Working Manual" by J.P. Snyder (1987). Quick quality control performed
% only by comparing with LINZ converter
% (www.linz.govt.nz/apps/coordinateconversions/) and Chuck Taylor's
% (http://home.hiwaay.net/~taylorc/toolbox/geography/geoutm.html) on a
% few test points, so use results with caution. Equations not suitable
% for a latitude of +/- 90deg.
%
% UPDATE: Following requests, this new version allows forcing UTM zone
% in input.
%
% Examples:
%
% % set random latitude and longitude arrays
% Lat= 90.*(2.*rand(3)-1)
% Lon= 180.*(2.*rand(3)-1)
%
% % let the function find appropriate UTM zone and hemisphere from data
% [x1,y1,utmzone1,utmhemi1] = wgs2utm(Lat,Lon)
%
% % forcing unique UTM zone and hemisphere for all data entries
% % note: resulting easting and northing are way off the usual values
% [x2,y2,utmzone2,utmhemi2] = wgs2utm(Lat,Lon,60,'S')
%
% % forcing different UTM zone and hemisphere for each data entry
% % note: resulting easting and northing are way off the usual values
% utmzone = floor(59.*rand(3))+1
% utmhemi = char(78 + 5.*round(rand(3)))
% [x3,y3,utmzone3,utmhemi3] = wgs2utm(Lat,Lon,utmzone,utmhemi)
%
% Author:
% Alexandre Schimel
% MetOcean Solutions Ltd
% New Plymouth, New Zealand
%
% Version 2:
% February 2011
%-------------------------------------------------------------------------
%% Argument checking
if ~sum(double(nargin==[2,4]))
error('Wrong number of input arguments');return
end
n1=size(Lat);
n2=size(Lon);
if (n1~=n2)
error('Lat and Lon should have same size');return
end
if exist('utmzone','var') && exist('utmhemi','var')
n3=size(utmzone);
n4=size(utmhemi);
if (sort(n3)~=sort(n4))
error('utmzone and utmhemi should have same size');return
end
if max(n3)~=1 && max(n3)~=max(n1)
error('utmzone should have either same size as Lat and Long, or size=1');return
end
end
% expand utmzone and utmhemi if needed
if exist('utmzone','var') && exist('utmhemi','var')
n3=size(utmzone);
n4=size(utmhemi);
if n3==[1 1]
utmzone = utmzone.*ones(size(Lat));
utmhemi = char(utmhemi.*ones(size(Lat)));
end
end
%% coordinates in radians
lat = Lat.*pi./180;
lon = Lon.*pi./180;
%% WGS84 parameters
a = 6378137; %semi-major axis
b = 6356752.314245; %semi-minor axis
% b = 6356752.314140; %GRS80 value, originally used for WGS84 before refinements
e = sqrt(1-(b./a).^2); % eccentricity
%% UTM parameters
% lat0 = 0; % reference latitude, not used here
if exist('utmzone','var')
Lon0 = 6.*utmzone-183; % reference longitude in degrees
else
Lon0 = floor(Lon./6).*6+3; % reference longitude in degrees
end
lon0 = Lon0.*pi./180; % in radians
k0 = 0.9996; % scale on central meridian
FE = 500000; % false easting
if exist('utmhemi','var')
FN = double(utmhemi=='S').*10000000;
else
FN = (Lat < 0).*10000000; % false northing
end
%% Equations parameters
eps = e.^2./(1-e.^2); % e prime square
% N: radius of curvature of the earth perpendicular to meridian plane
% Also, distance from point to polar axis
N = a./sqrt(1-e.^2.*sin(lat).^2);
T = tan(lat).^2;
C = ((e.^2)./(1-e.^2)).*(cos(lat)).^2;
A = (lon-lon0).*cos(lat);
% M: true distance along the central meridian from the equator to lat
M = a.*( ( 1 - e.^2./4 - 3.*e.^4./64 - 5.*e.^6./256 ) .* lat ...
-( 3.*e.^2./8 + 3.*e.^4./32 + 45.*e.^6./1024 ) .* sin(2.*lat) ...
+( 15.*e.^4./256 + 45.*e.^6./1024 ) .* sin(4.*lat) ...
-(35.*e.^6./3072 ) .* sin(6.*lat) );
%% easting
x = FE + k0.*N.*( A ...
+ (1-T+C) .* A.^3./6 ...
+ (5-18.*T+T.^2+72.*C-58.*eps) .* A.^5./120 );
%% northing
% M(lat0) = 0 so not used in following formula
y = FN + k0.*M + k0.*N.*tan(lat).*( A.^2./2 ...
+ (5-T+9.*C+4.*C.^2) .* A.^4./24 ...
+ (61-58.*T+T.^2+600.*C-330.*eps) .* A.^6./720 );
%% UTM zone
if exist('utmzone','var') && exist('utmhemi','var')
utmzone = utmzone;
utmhemi = utmhemi;
else
utmzone = floor(Lon0./6)+31;
utmhemi = char( 83.* (Lat < 0) + 78.* (Lat >= 0) );
end