NCCOOS Trac Projects: Top | Web | Platforms | Processing | Viz | Sprints | Sandbox | (Wind)

root/DPWavesProc/trunk/DPWavesProc/adcp_matlab/specmultiplot.m

Revision 217 (checked in by gdusek, 15 years ago)

updated a few things in adcp processing

Line 
1 function [Winfo,spec2d,fd,thetad,td]=specmultiplot(dateinfo1,dateinfo2,timestep);
2 %where dateinfo1 and 2 are the strings of the first and last date extension
3 %of the pressure,range,etc files and timestep is the time in hours between
4 %each burst
5
6 %This function takes the pressure, range, orbit and sysinfo files created
7 %in python and outputs a Winfo data structure with the sig wave height,
8 %peak period, direction of peak period and dominant dir.  It also generates
9 %polar plots and 2d freq and directional plots of a variety of different
10 %estimation methods, resolutions and the wavesmon output.
11
12
13 %first set up the time vector going from dateinfo1 to dateinfo2
14 Winfo.time=[];
15
16 date1=datevec(dateinfo1, 'yymmddHHMM');
17 date2=datevec(dateinfo2,'yymmddHHMM');
18
19 if date1 == date2
20     Winfo.time=[datenum(date1)];
21 else
22     Winfo.time=[datenum(date1)];
23     newdate=date1;
24     while datenum(newdate) ~= datenum(date2)
25         newdate=newdate+[0 0 0 timestep 0 0];
26         Winfo.time=[horzcat(Winfo.time,datenum(newdate))];
27     end
28 end
29            
30 %Make a directory for the data
31 mkdir('tempdir');
32
33 %set up time, which is Winfo.time as date str in the yymmddHHMM format
34 time=datestr(Winfo.time, 'yymmddHHMM');
35
36 %set up data structure for wave info
37 Winfo.setup={'EMEP radial'};
38 Winfo.hsig=[];
39 Winfo.hconf=[];
40 Winfo.peakP=[];
41 Winfo.dirP=[];
42 Winfo.Ddir=[];
43 Winfo.Spectrum.EMEPradial=[];
44
45 %Load the data and run the script
46 for i=1:length(time(:,1))
47     dateinfo=time(i,:);
48
49     pressure=strcat('pressure_',dateinfo,'.txt');
50     range=strcat('range_',dateinfo,'.txt');
51     orbit=strcat('orbit_',dateinfo,'.txt');
52     sysinfo=strcat('sysinfo_',dateinfo,'.txt');
53  
54
55     pressure=load(pressure);
56     range=load(range);
57     orbit=load(orbit);
58     sysinfo=load(sysinfo);
59    
60
61     %set up data with radial velocities, freq and dir at default
62     [ID,SM,EP]=radialtouvw(pressure,range,orbit,sysinfo,3);
63
64     % run diwasp to generate this spectrum with EMEP
65     [radialE, EPout]=dirspec(ID,SM,EP,{'PLOTTYPE',0,'MESSAGE',0});
66
67     %Use waveplot to plot the polar, freq and dir plots of the spectra
68
69     [E_radial_WI,fig1,fig2]=waveplottest1(radialE,sysinfo);
70    
71     saveas(fig1,['polar1_' dateinfo '.fig']);
72     saveas(fig2,['dirfreq1_' dateinfo '.fig']);
73    
74     movefile(['polar1_' dateinfo '.fig'],'tempdir');
75     movefile(['dirfreq1_' dateinfo '.fig'],'tempdir');
76     close all;
77    
78    
79     %Fill up the Winfo data structure
80
81     hsig=[vertcat(E_radial_WI.hsig)];
82     hconf=[vertcat(E_radial_WI.hconf)];
83     peakP=[vertcat(E_radial_WI.tp)];
84     dirP=[vertcat(E_radial_WI.dtp)];
85     Ddir=[vertcat(E_radial_WI.dp)];
86    
87    
88     Winfo.hsig=[horzcat(Winfo.hsig,hsig)];
89     Winfo.hconf=[horzcat(Winfo.hconf,hconf)];
90     Winfo.peakP=[horzcat(Winfo.peakP,peakP)];
91     Winfo.dirP=[horzcat(Winfo.dirP,dirP)];
92     Winfo.Ddir=[horzcat(Winfo.Ddir,Ddir)];
93     Winfo.Spectrum.EMEPradial=[cat(3,Winfo.Spectrum.EMEPradial,radialE.S)];
94 end
95
96 Winfo.Spectrum.EMEPradial=permute(Winfo.Spectrum.EMEPradial,[3,1,2]);
97
98 spec2d=Winfo.Spectrum.EMEPradial;
99 spec2d=spec2d(:,:,1:180);
100 spec2d=spec2d*(360/(2*pi));
101
102 %this changes the coordinates from axis to compass
103 newspec2d=zeros(size(spec2d));
104 for i= 1:size(spec2d,1)
105     oldspec=squeeze(spec2d(i,:,:));
106
107     newspec=zeros(size(oldspec));
108
109     for j = 1:46
110         newspec(:,j)=oldspec(:,47-j);
111     end
112     for j = 47:180
113         newspec(:,j)=oldspec(:,181-(j-46));
114     end
115    
116     %firstspec=newspec(:,91:180);
117     %secondspec=newspec(:,1:90);
118     %newspec=cat(2,firstspec,secondspec);
119    
120     newspec2d(i,:,:)=newspec;   
121 end
122
123 Winfo.Spectrum.EMEPradial=newspec2d;
124
125 %*************************************************************************
126 %these following variables can be output if you wish to continue to process the data through
127 %the XWAVES software.
128
129 spec2d=newspec2d;
130 fd=[0.01:0.01:0.4];
131 thetad=[0:2:358];
132 date1=datevec(Winfo.time);
133 td=date1(:,1:5);
134
135 save(['specdata_' dateinfo],'Winfo','spec2d','fd','thetad','td');
136 movefile(['specdata_' dateinfo '.mat'],'tempdir');
137
138 %**************************************************************************
139
140 %now create the time series plots of the wave info
141 [fig_sigh,fig_pp,fig_dp,fig_dd]=Winfo_plot1(Winfo);
142
143 saveas(fig_sigh,['sigh_' dateinfo '.fig']);
144 saveas(fig_pp,['peakp_' dateinfo '.fig']);
145 saveas(fig_dp,['dirpeak_' dateinfo '.fig']);
146 saveas(fig_dd,['domdir_' dateinfo '.fig']);
147
148 movefile(['sigh_' dateinfo '.fig'],'tempdir');
149 movefile(['peakp_' dateinfo '.fig'],'tempdir');
150 movefile(['dirpeak_' dateinfo '.fig'],'tempdir');
151 movefile(['domdir_' dateinfo '.fig'],'tempdir');
152
153 movefile('tempdir',strcat('procdata_',dateinfo));
154
155 close all;
156
157
158
159
Note: See TracBrowser for help on using the browser.