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

root/DPWP/trunk/DPWP/adcp_matlab/specmultiplot.m

Revision 334 (checked in by gdusek, 3 months ago)

Total update to the DPWP code. Significant changes made to direspec, specmultiplot, radialtouvw and IMLM code. 6/14/10

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.
11
12 %%% IMPT NOTE!!! The ADCP height above bottom is manually set in the
13 %%% radialtouvw.m and the radial.m code.  In this case the default is set
14 %%% at .4m  This will be changed in a future release!!
15
16
17 %first set up the time vector going from dateinfo1 to dateinfo2
18 Winfo.time=[];
19
20 date1=datevec(dateinfo1, 'yymmddHHMM');
21 date2=datevec(dateinfo2,'yymmddHHMM');
22
23 if date1 == date2
24     Winfo.time=[datenum(date1)];
25 else
26     Winfo.time=[datenum(date1)];
27     newdate=date1;
28     while datenum(newdate) ~= datenum(date2)
29         newdate=newdate+[0 0 0 timestep 0 0];
30         Winfo.time=[horzcat(Winfo.time,datenum(newdate))];
31     end
32 end
33            
34 %Make a directory for the data
35 mkdir('tempdir');
36
37 %set up time, which is Winfo.time as date str in the yymmddHHMM format
38 time=datestr(Winfo.time, 'yymmddHHMM');
39
40 %set up data structure for wave info
41 Winfo.setup={'IMLM radial'};
42 Winfo.hsig=[];
43 Winfo.hconf=[];
44 Winfo.peakP=[];
45 Winfo.dirP=[];
46 Winfo.Ddir=[];
47 Winfo.Spectrum.EMEPradial=[];
48
49 %Load the data and run the script
50 for i=1:length(time(:,1))
51     dateinfo=time(i,:);
52
53     pressure=strcat('pressure_',dateinfo,'.txt');
54     range=strcat('range_',dateinfo,'.txt');
55     orbit=strcat('orbit_',dateinfo,'.txt');
56     sysinfo=strcat('sysinfo_',dateinfo,'.txt');
57  
58
59     pressure=load(pressure);
60     range=load(range);
61     orbit=load(orbit);
62     sysinfo=load(sysinfo);
63    
64
65     %set up data with radial velocities, freq and dir at default
66     [ID,SM,EP]=radialtouvw(pressure,range,orbit,sysinfo,3); %last input argument represents the data types, 1=p-u-v-w,2=range,3=radials
67    
68    
69     % run diwasp to generate this spectrum with EMEP
70     [radialE,~]=dirspec(ID,SM,EP,{'MESSAGE',0,'PLOTTYPE',0});
71
72     %Use waveplot to plot the polar, freq and dir plots of the spectra
73
74     [E_radial_WI]=waveplot(radialE);
75    
76     %rename the files
77     movefile('tempdir/fig1.fig',['tempdir/polar1_' dateinfo '.fig']);
78     movefile('tempdir/fig2.fig',['tempdir/dirfreq1_' dateinfo '.fig']);
79  
80      
81     %Fill up the Winfo data structure
82
83     hsig=[vertcat(E_radial_WI.hsig)];
84     hconf=[vertcat(E_radial_WI.hconf)];
85     peakP=[vertcat(E_radial_WI.tp)];
86     dirP=[vertcat(E_radial_WI.dtp)];
87     Ddir=[vertcat(E_radial_WI.dp)];
88    
89    
90     Winfo.hsig=[horzcat(Winfo.hsig,hsig)];
91     Winfo.hconf=[horzcat(Winfo.hconf,hconf)];
92     Winfo.peakP=[horzcat(Winfo.peakP,peakP)];
93     Winfo.dirP=[horzcat(Winfo.dirP,dirP)];
94     Winfo.Ddir=[horzcat(Winfo.Ddir,Ddir)];
95     Winfo.Spectrum.EMEPradial=[cat(3,Winfo.Spectrum.EMEPradial,radialE.S)];
96    
97     %save a continuing backup of Winfo in case of an error
98     save('backup_Winfo','Winfo');
99     movefile('backup_Winfo.mat','tempdir');
100 end
101
102 Winfo.Spectrum.EMEPradial=permute(Winfo.Spectrum.EMEPradial,[3,1,2]);
103
104 spec2d=Winfo.Spectrum.EMEPradial;
105 %account for if there are 2 (just one sample) or 3 (time series) dimensions
106 numdimensions=ndims(spec2d);
107 if numdimensions == 3
108     spec2d=spec2d(:,:,1:180);
109 else
110     spec2d=spec2d(:,1:180);
111 end
112
113 %this changes the coordinates from axis to compass (and from direction TO,
114 %to direction FROM)
115 newspec2d=zeros(size(spec2d));
116 for i= 1:size(spec2d,1)
117     if numdimensions == 3
118         oldspec=squeeze(spec2d(i,:,:));
119     else
120         oldspec=spec2d;
121     end
122
123     newspec=zeros(size(oldspec));
124
125     %this is the NEW way to organize the code for SM.dirs=[0:2:358] (edited
126     %on 3/27/09
127     for j = 1:136
128         newspec(:,j)=oldspec(:,137-j);
129     end
130     for j = 137:180
131         newspec(:,j)=oldspec(:,181-(j-136));
132     end
133    
134     if numdimensions == 3
135         newspec2d(i,:,:)=newspec;
136     else
137         newspec2d=newspec;
138     end   
139 end
140
141 %Winfo.Spectrum.EMEPradial=newspec2d;
142
143 %Use this to organize spec IF SM.dirs=[-180:2:178]
144     %for j = 1:46
145     %    newspec(:,j)=oldspec(:,47-j);
146     %end
147     %for j = 47:180
148     %    newspec(:,j)=oldspec(:,181-(j-46));
149     %end
150
151 %*************************************************************************
152 %these following variables can be output if you wish to continue to process the data through
153 %the XWAVES software.
154
155 spec2d=newspec2d*(360/(2*pi));
156 fd=[0.01:0.01:0.4];
157 thetad=[0:2:358];
158 date1=datevec(Winfo.time);
159 td=date1(:,1:5);
160
161 save(['specdata_' dateinfo],'Winfo','spec2d','fd','thetad','td');
162 movefile(['specdata_' dateinfo '.mat'],'tempdir');
163
164 %**************************************************************************
165
166 %first delete the backup_Winfo file
167 %delete('tempdir/backup_Winfo.mat');
168
169 %now create the time series plots of the wave info
170 [fig_sigh,fig_pp,fig_dp,fig_dd]=Winfo_plot(Winfo);
171
172 saveas(fig_sigh,['sigh_' dateinfo '.fig']);
173 saveas(fig_pp,['peakp_' dateinfo '.fig']);
174 saveas(fig_dp,['dirpeak_' dateinfo '.fig']);
175 saveas(fig_dd,['domdir_' dateinfo '.fig']);
176
177 close all;
178
179 movefile(['sigh_' dateinfo '.fig'],'tempdir');
180 movefile(['peakp_' dateinfo '.fig'],'tempdir');
181 movefile(['dirpeak_' dateinfo '.fig'],'tempdir');
182 movefile(['domdir_' dateinfo '.fig'],'tempdir');
183
184 movefile('tempdir',strcat('procdata_',dateinfo));
185
186
187
188
189
Note: See TracBrowser for help on using the browser.