1. Sea breeze raw data can be downloaded from the NOAA website in the United States
https://www.ncei.noaa.gov/data/blended-global-sea-surface-wind-products/access/winds/daily/
2. Taking the daily data in 2018 as an example, the program code for downloading sea breeze raw data using terminal commands is as follows.
for string in uv20180114rt.nc uv20180115rt.nc uv20180116rt.nc uv20180117rt.nc uv20180118rt.nc uv20180119rt.nc uv20180120rt.nc uv20180121rt.nc uv2018 0122rt.nc uv20180123rt.nc uv20180124rt.nc uv20180125rt.nc uv20180126rt.nc uv20180127rt.nc uv20180128rt. nc uv20180129rt.nc uv20180130rt.nc uv20180131rt.nc uv20180201rt.nc uv20180202rt.nc uv20180203rt.nc uv20180204rt.nc uv20180205rt.nc uv20180206 rt.nc uv20180207rt.nc uv20180208rt.nc uv20180209rt.nc uv20180210rt.nc uv20180211rt.nc uv20180212rt.nc uv20180213rt.nc uv20180214rt .nc uv20180215rt.nc uv20180216rt.nc uv20180217rt.nc uv20180218rt.nc uv20180219rt.nc uv20180220rt.nc uv20180221rt.nc uv20180222rt.nc uv201802 23rt.nc uv20180224rt.nc uv20180225rt.nc uv20180226rt.nc uv20180227rt.nc uv20180228rt.nc uv20180301rt.nc uv20180302rt.nc uv20180303rt.nc uv20180304rt.nc uv20180305rt.nc uv20180306rt.nc uv20180307rt.nc uv20180308rt.nc uv20180309rt.nc uv20180310rt.nc uv20180311rt. nc uv20180312rt.nc uv20180313rt.nc uv20180314rt.nc uv20180315rt.nc uv20180316rt.nc uv20180317rt.nc uv20180318rt.nc uv20180319rt. nc uv20180320rt.nc uv20180321rt.nc uv20180322rt.nc uv20180323rt.nc uv20180324rt.nc uv20180325rt.nc uv20180326rt.nc uv20180327rt.nc uv20180328 rt.nc uv20180329rt.nc uv20180330rt.nc uv20180331rt.nc uv20180401rt.nc uv20180402rt.nc uv20180403rt.nc uv20180404rt.nc uv20180405rt .nc uv20180406rt.nc uv20180407rt.nc uv20180408rt.nc uv20180409rt.nc uv20180410rt.nc uv20180411rt.nc uv20180412rt.nc uv20180413rt.nc uv201804 14rt.nc uv20180415rt.nc uv20180416rt.nc uv20180417rt.nc uv20180418rt.nc uv20180419rt.nc uv20180420rt.nc uv20180421rt.nc uv20180422rt.nc uv20180423rt.nc uv20180424rt.nc uv20180425rt.nc uv20180426rt.nc uv20180427rt.nc uv20180428rt.nc uv20180429rt.nc uv20180430rt. nc uv20180501rt.nc uv20180502rt.nc uv20180503rt.nc uv20180504rt.nc uv20180505rt.nc uv20180506rt.nc uv20180507rt.nc uv20180508rt. nc uv20180509rt.nc uv20180510rt.nc uv20180511rt.nc uv20180512rt.nc uv20180513rt.nc uv20180514rt.nc uv20180515rt.nc uv20180516rt.nc uv20180517 rt.nc uv20180518rt.nc uv20180519rt.nc uv20180520rt.nc uv20180521rt.nc uv20180522rt.nc uv20180523rt.nc uv20180524rt.nc uv20180525rt .nc uv20180526rt.nc uv20180527rt.nc uv20180528rt.nc uv20180529rt.nc uv20180530rt.nc uv20180531rt.nc uv20180601rt.nc uv20180602rt.nc uv201806 03rt.nc uv20180604rt.nc uv20180605rt.nc uv20180606rt.nc uv20180607rt.nc uv20180608rt.nc uv20180609rt.nc uv20180610rt.nc uv20180611rt.nc uv20180612rt.nc uv20180613rt.nc uv20180614rt.nc uv20180615rt.nc uv20180616rt.nc uv20180617rt.nc uv20180618rt.nc uv20180619rt. nc uv20180620rt.nc uv20180621rt.nc uv20180622rt.nc uv20180623rt.nc uv20180624rt.nc uv20180625rt.nc uv20180626rt.nc uv20180627rt. nc uv20180628rt.nc uv20180629rt.nc uv20180630rt.nc uv20180701rt.nc uv20180702rt.nc uv20180703rt.nc uv20180704rt.nc uv20180705rt.nc uv20180706 rt.nc uv20180707rt.nc uv20180708rt.nc uv20180709rt.nc uv20180710rt.nc uv20180711rt.nc uv20180712rt.nc uv20180713rt.nc uv20180714rt .nc uv20180715rt.nc uv20180716rt.nc uv20180717rt.nc uv20180718rt.nc uv20180719rt.nc uv20180720rt.nc uv20180721rt.nc uv20180722rt.nc uv201807 23rt.nc uv20180724rt.nc uv20180725rt.nc uv20180726rt.nc uv20180727rt.nc uv20180728rt.nc uv20180729rt.nc uv20180730rt.nc uv20180731rt.nc uv20180801rt.nc uv20180802rt.nc uv20180803rt.nc uv20180804rt.nc uv20180805rt.nc uv20180806rt.nc uv20180807rt.nc uv20180808rt. nc uv20180809rt.nc uv20180810rt.nc uv20180811rt.nc uv20180812rt.nc uv20180813rt.nc uv20180814rt.nc uv20180815rt.nc uv20180816rt. nc uv20180817rt.nc uv20180818rt.nc uv20180819rt.nc uv20180820rt.nc uv20180821rt.nc uv20180822rt.nc uv20180823rt.nc uv20180824rt.nc uv20180825 rt.nc uv20180826rt.nc uv20180827rt.nc uv20180828rt.nc uv20180829rt.nc uv20180830rt.nc uv20180831rt.nc uv20180901rt.nc uv20180902rt .nc uv20180903rt.nc uv20180904rt.nc uv20180905rt.nc uv20180906rt.nc uv20180907rt.nc uv20180908rt.nc uv20180909rt.nc uv20180910rt.nc uv201809 11rt.nc uv20180912rt.nc uv20180913rt.nc uv20180914rt.nc uv20180915rt.nc uv20180916rt.nc uv20180917rt.nc uv20180918rt.nc uv20180919rt.nc uv20180920rt.nc uv20180921rt.nc uv20180922rt.nc uv20180923rt.nc uv20180924rt.nc uv20180925rt.nc uv20180926rt.nc uv20180927rt. nc uv20180928rt.nc uv20180929rt.nc uv20180930rt.nc uv20181001rt.nc uv20181002rt.nc uv20181003rt.nc uv20181004rt.nc uv20181005rt. nc uv20181006rt.nc uv20181007rt.nc uv20181008rt.nc uv20181009rt.nc ;do curl https://www.ncei.noaa.gov/data/blended-global-sea-surface-wind-products/access/winds/daily/2018/$string --output $string done
3. Replace uv20180114rt.nc uv20180115rt.nc… uv20181009rt.nc and the corresponding URLs in the above command with the names of other data in the website to download other data files.
4. The matlab program used to decode .nc files and perform preprocessing.
close all; clear all; clc; % Find all files in the folder in the format '.nc', the file information is stored in the structure WindFileLists, and then loop through WindFileLists WindFileLists=dir(fullfile('/Users/zlh/Downloads/Wind','*.nc')); % Read the loop variable value N=length(WindFileLists); %Use 'length()' function to read the length of the structure % Write the main program of the loop body M1=[];M2=[];M3=[];M4=[];M5=[];M6=[]; M7=[];M8=[];M9=[];M10=[];M11=[];M12=[]; for i=1:N strWindFileName=WindFileLists(i).name; ncid = netcdf.open(strWindFileName); %Open netCDF data file (read-only mode) varid1 = netcdf.inqVarID(ncid,'u'); % Get the ID of variable u in the file varid2 = netcdf.inqVarID(ncid,'v'); varid3 = netcdf.inqVarID(ncid,'w'); varid4 = netcdf.inqVarID(ncid,'lon'); varid5 = netcdf.inqVarID(ncid,'lat'); u = netcdf.getVar(ncid,varid1); %Get the value of the variable v = netcdf.getVar(ncid,varid2); w = netcdf.getVar(ncid,varid3); lon = netcdf.getVar(ncid,varid4); lat = netcdf.getVar(ncid,varid5); netcdf.close(ncid); %Close netCDF data file a = find(lon==122);% Query the wind data located at (31°N, 122°E). The sampling height is 10m at the current time. b = find(lat==31); % Use '' as the character to split the data, and the result is a cell array s=split(strWindFileName,''); % Take the element s{8,9} in the array, first convert it into a string char and then convert it into a number str2num wd1 = str2num(char(s{8})); % month wd2 = str2num(char(s{9})); mm=wd1*10 + wd2; switch mod(mm,12) %classify all data according to the month of each year case 1 M1=[M1;u(a,b) v(a,b) w(a,b)]; case 2 M2=[M2;u(a,b) v(a,b) w(a,b)]; case 3 M3=[M3;u(a,b) v(a,b) w(a,b)]; case 4 M4=[M4;u(a,b) v(a,b) w(a,b)]; case 5 M5=[M5;u(a,b) v(a,b) w(a,b)]; case 6 M6=[M6;u(a,b) v(a,b) w(a,b)]; case 7 M7=[M7;u(a,b) v(a,b) w(a,b)]; case 8 M8=[M8;u(a,b) v(a,b) w(a,b)]; case 9 M9=[M9;u(a,b) v(a,b) w(a,b)]; case 10 M10=[M10;u(a,b) v(a,b) w(a,b)]; case 11 M11=[M11;u(a,b) v(a,b) w(a,b)]; case 0 M12=[M12;u(a,b) v(a,b) w(a,b)]; end end M=[M1;M2;M3;M4;M5;M6;M7;M8;M9;M10;M11;M12]; l=[size(M1,1) size(M2,1) size(M3,1) size(M4,1) size(M5,1) size(M6,1) size(M7,1) size(M8,1 ) size(M9,1) size(M10,1) size(M11,1) size(M12,1)]; Ml=[]; for j=1:size(l,2) Ml=[Ml sum(l(1:j))]; end % Display the netCDF data source content in the command line window ncdisp(strWindFileName) info=ncinfo(strWindFileName)
5. Visualize the preprocessed data and collect statistics on the monthly changes in sea breeze in the target sea area.
Mu=[]; Mv=[]; Mw=[]; for k = 0:11 if k==0 u1 = M(1:Ml(1),1); u1(u1<-9990) = []; v1 = M(1:Ml(1),2); v1(v1<-9990) = []; w1 = M(1:Ml(1),3); w1(w1<-9990) = []; else u1 = M(Ml(k) + 1:Ml(k + 1),1); u1(u1<-9990) = []; v1 = M(Ml(k) + 1:Ml(k + 1),2); v1(v1<-9990) = []; w1 = M(Ml(k) + 1:Ml(k + 1),3); w1(w1<-9990) = []; end u111=max(u1); % max value v111=max(v1); w111=max(w1); u112=min(u1); % min value v112=min(v1); w112=min(w1); if u111>abs(u112) u11=u111; else u11=u112; end if v111>abs(v112) v11=v111; else v11=v112; end if w111>abs(w112) w11=w111; else w11=w112; end u12=mode(u1); % mode number v12=mode(v1); w12=mode(w1); u13=mean(u1); % mean number v13=mean(v1); w13=mean(w1); Mu = [Mu;u11,u12,u13]; Mv = [Mv;v11,v12,v13]; Mw = [Mw;w11,w12,w13]; end figure() subplot(331) bar3(Mu(:,1)) view(35,30) xlabel('u');ylabel('month');zlabel('m/s'); title("max velocity of u","FontSize",10) subplot(332) bar3(Mu(:,2)) view(35,30) xlabel('u');ylabel('month');zlabel('m/s'); title("mode velocity of u","FontSize",10) subplot(333) bar3(Mu(:,3)) view(35,30) xlabel('u');ylabel('month');zlabel('m/s'); title("mean velocity of u","FontSize",10) subplot(334) bar3(Mv(:,1)) view(35,30) xlabel('v');ylabel('month');zlabel('m/s'); title("max velocity of v","FontSize",10) subplot(335) bar3(Mv(:,2)) view(35,30) xlabel('v');ylabel('month');zlabel('m/s'); title("mode velocity of v","FontSize",10) subplot(336) bar3(Mv(:,3)) view(35,30) xlabel('v');ylabel('month');zlabel('m/s'); title("mean velocity of v","FontSize",10) subplot(337) bar3(Mw(:,1)) view(35,30) xlabel('w');ylabel('month');zlabel('m/s'); title("max velocity of w","FontSize",10) subplot(338) bar3(Mw(:,2)) view(35,30) xlabel('w');ylabel('month');zlabel('m/s'); title("mode velocity of w","FontSize",10) subplot(339) bar3(Mw(:,3)) view(35,30) xlabel('w');ylabel('month');zlabel('m/s'); title("mean velocity of w","FontSize",10)
6. Calculate the distribution pattern of sea breeze in the target sea area during the entire time period.
Wdu=M(:,1);% eastward wind speed Wdv=M(:,2);%Northward wind speed Wdw=M(:,3);% combined wind speed Wuv=atan(Wdu./Wdv);%The angle between the wind direction and the north direction Wdu(Wdu<-9990)=[]; Wdv(Wdv<-9990)=[]; Wdw(Wdw<-9990)=[]; Wuv(Wuv<-9990)=[]; Wdu=roundn(Wdu,-1); Wdv=roundn(Wdv,-1); Wdw=roundn(Wdw,-1); Wuv=roundn(Wuv,-1); Wdu1 = tabulate(Wdu);% counts the frequency of elements in the array (x) Wdu2 = array2table(Wdu1, 'VariableNames', ... {'Value','Count','Percent'});%Convert array into table Wdv1 = tabulate(Wdv);% counts the frequency of elements in the array (x) Wdv2 = array2table(Wdv1, 'VariableNames', ... {'Value','Count','Percent'});%Convert array into table Wdw1 = tabulate(Wdw);% counts the frequency of elements in the array (x) Wdw2 = array2table(Wdw1, 'VariableNames', ... {'Value','Count','Percent'});%Convert array into table Wuv1 = tabulate(Wuv);% counts the frequency of elements in the array (x) Wuv2 = array2table(Wuv1, 'VariableNames', ... {'Value','Count','Percent'});%Convert array into table figure() % subplot(1,3,1) % bar(Wdu2.Value,Wdu2.Count); % xlabel("Velocity(m/s)");ylabel("Count") % title("Eastward Velocity of Wind") % subplot(1,3,2) % bar(Wdv2.Value,Wdv2.Count); % xlabel("Velocity(m/s)");ylabel("Count") % title("Northward Velocity of Wind") % subplot(1,3,3) subplot(121) bar(Wdw2.Value,Wdw2.Count); xlabel("Velocity (m/s)");ylabel("Count") title("Compound Velocity of Wind") % subplot(1,3,4) % bar(Wuv2.Value,Wuv2.Count); % xlabel("Degree(rad)");ylabel("Count") % title("Wind Direction To North") % figure() subplot(122) [f,xi]=ksdensity(Wdw); plot(xi,f,'r*'); hold on [mu,sigma]= normfit(Wdw,0.05) % [mu,sigma,muci,sigmaci]= normfit(data,a); % data: original data % a: Confidence % mu: mean % sigma: standard deviation % muci:mean in the interval 1-a % sigmaci: standard deviation within the interval 1-a TJ=ones(100,1); LTJ=length(TJ); N0=normrnd(mu,sigma,1,LTJ); [f1,xi1]=ksdensity(N0); plot(xi1,f1,'b-o'); hold off xlabel('Velocity (m/s)') ylabel('Density') legend('Raw','Fit') title("Raw data & amp; Probability density function") txt = { ['Miu_{MW} = ' num2str(mu)]; ['Sigma_{MW} = ' num2str(sigma)] }; text(xi(60),f(60) + 0.12,txt)
7. Save and process important sea breeze data
%The matrix that needs to be saved data7=[Mu,Mv,Mw]; % row name row={'m1';'m2';'m3';'m4';'m5';'m6';'m7';'m8' ;'m9';'m10';'m11';'m12'}; % column name col={'data7','max_u','mode_u','mean_u','max_v','mode_v','mean_v','max_w' ,'mode_w','mean_w'}; %Generate table, generated by columns result=table(row,data7(:,1),data7(:,2),data7(:,3),data7(:,4),data7(:,5),data7(:,6),data7( :,7),data7(:,8),data7(:,9),'VariableNames',col); %Save form writetable(result, 'data7.csv'); % bar(Wdu2.Value,Wdu2.Count); % title("Eastward Velocity of Wind") % bar(Wdv2.Value,Wdv2.Count); % title("Northward Velocity of Wind") % bar(Wdw2.Value,Wdw2.Count); % title("Compound Velocity of Wind") LEu=length(Wdu2.Value); LNv=length(Wdv2.Value); LCw=length(Wdw2.Value); Lmax=max([LEu,LNv,LCw]); Eu=[[Wdu2.Value;zeros(Lmax-LEu,1)],[Wdu2.Count;zeros(Lmax-LEu,1)]]; Nv=[[Wdv2.Value;zeros(Lmax-LNv,1)],[Wdv2.Count;zeros(Lmax-LNv,1)]]; Cw=[[Wdw2.Value;zeros(Lmax-LCw,1)],[Wdw2.Count;zeros(Lmax-LCw,1)]]; data8=[Eu,Nv,Cw]; csvwrite('data8.csv',data8);
8. This is what batch acquisition, decoding and preprocessing, statistics and storage of sea breeze data look like.
Interested friends are welcome to communicate and make corrections.