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

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

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

--

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]=waveplot(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 %account for if there are 2 (just one sample) or 3 (time series) dimensions
100 numdimensions=ndims(spec2d);
101 if numdimensions == 3
102     spec2d=spec2d(:,:,1:180);
103 else
104     spec2d=spec2d(:,1:180);
105 end
106
107 %this changes the coordinates from axis to compass (and from direction TO,
108 %to direction FROM)
109 % NEED TO ADJUST THIS TO AUTOMATICALLY ACOUNT FOR USER INPUTTED SM.dirs!!!
110 newspec2d=zeros(size(spec2d));
111 for i= 1:size(spec2d,1)
112     if numdimensions == 3
113         oldspec=squeeze(spec2d(i,:,:));
114     else
115         oldspec=spec2d;
116     end
117
118     newspec=zeros(size(oldspec));
119
120     %this is the NEW way to organize the code for SM.dirs=[0:2:358] (edited
121     %on 3/27/09
122     for j = 1:136
123         newspec(:,j)=oldspec(:,137-j);
124     end
125     for j = 137:180
126         newspec(:,j)=oldspec(:,181-(j-136));
127     end
128    
129     if numdimensions == 3
130         newspec2d(i,:,:)=newspec;
131     else
132         newspec2d=newspec;
133     end   
134 end
135
136 Winfo.Spectrum.EMEPradial=newspec2d;
137
138 %Use this to organize spec IF SM.dirs=[-180:2:178]
139     %for j = 1:46
140     %    newspec(:,j)=oldspec(:,47-j);
141     %end
142     %for j = 47:180
143     %    newspec(:,j)=oldspec(:,181-(j-46));
144     %end
145
146 %*************************************************************************
147 %these following variables can be output if you wish to continue to process the data through
148 %the XWAVES software.
149
150 spec2d=newspec2d*(360/(2*pi));
151 fd=[0.01:0.01:0.4];
152 thetad=[0:2:358];
153 date1=datevec(Winfo.time);
154 td=date1(:,1:5);
155
156 save(['specdata_' dateinfo],'Winfo','spec2d','fd','thetad','td');
157 movefile(['specdata_' dateinfo '.mat'],'tempdir');
158
159 %**************************************************************************
160
161 %now create the time series plots of the wave info
162 [fig_sigh,fig_pp,fig_dp,fig_dd]=Winfo_plot(Winfo);
163
164 saveas(fig_sigh,['sigh_' dateinfo '.fig']);
165 saveas(fig_pp,['peakp_' dateinfo '.fig']);
166 saveas(fig_dp,['dirpeak_' dateinfo '.fig']);
167 saveas(fig_dd,['domdir_' dateinfo '.fig']);
168
169 movefile(['sigh_' dateinfo '.fig'],'tempdir');
170 movefile(['peakp_' dateinfo '.fig'],'tempdir');
171 movefile(['dirpeak_' dateinfo '.fig'],'tempdir');
172 movefile(['domdir_' dateinfo '.fig'],'tempdir');
173
174 movefile('tempdir',strcat('procdata_',dateinfo));
175
176 close all;
177
178
179
180
Note: See TracBrowser for help on using the browser.