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

root/adcp/trunk/adcp/adcp_matlab/specmultiplot.m

Revision 168 (checked in by cbc, 16 years ago)

Adding diwasp customizations.

Line 
1 function [Winfo]=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      
31 %set up time, which is Winfo.time as date str in the yymmddHHMM format
32 time=datestr(Winfo.time, 'yymmddHHMM');
33
34 %set up data structure for wave info
35 Winfo.setup={'EMEP UVW','IMLM UVW','EMEP range','IMLM range','EMEP radial','IMLM radial','wavesmon'}';
36 Winfo.hsig=[];
37 Winfo.peakP=[];
38 Winfo.dirP=[];
39 Winfo.Ddir=[];
40 Winfo.Spectrum.EMEPuvw=[];
41 Winfo.Spectrum.IMLMuvw=[];
42 Winfo.Spectrum.EMEPrange=[];
43 Winfo.Spectrum.IMLMrange=[];
44 Winfo.Spectrum.EMEPradial=[];
45 Winfo.Spectrum.IMLMradial=[];
46 Winfo.Spectrum.wavesmon=[];
47
48 %Load the data and run the script
49 for i=1:length(time(:,1))
50     dateinfo=time(i,:);
51
52     pressure=strcat('pressure_',dateinfo,'.txt');
53     range=strcat('range_',dateinfo,'.txt');
54     orbit=strcat('orbit_',dateinfo,'.txt');
55     sysinfo=strcat('sysinfo_',dateinfo,'.txt');
56     spec=strcat('DSpec',dateinfo,'.txt');
57
58     pressure=load(pressure);
59     range=load(range);
60     orbit=load(orbit);
61     sysinfo=load(sysinfo);
62     spec=load(spec);
63
64     %set up data with uvw and pressure, freq at 0.01 and dir at 2
65     [ID,SM,EP]=radialtouvw(pressure,range,orbit,sysinfo,1);
66
67     %run diwasp to generate this spectrum
68     [E_uvw_F01_D2, EPout]=dirspectest(ID,SM,EP,{'PLOTTYPE',0,'MESSAGE',0});
69
70     %now for IMLM
71     EP.method='IMLM';
72     EP.iter=3;
73     [I_uvw_F01_D2, EPout]=dirspectest(ID,SM,EP,{'PLOTTYPE',0,'MESSAGE',0});
74
75     %set up data with ranges, freq and dir at default
76     [ID,SM,EP]=radialtouvw(pressure,range,orbit,sysinfo,2);
77
78     % run diwasp to generate this spectrum with EMEP
79     [E_range_F01_D2, EPout]=dirspectest(ID,SM,EP,{'PLOTTYPE',0,'MESSAGE',0});
80
81     %now with IMLM
82     EP.method='IMLM';
83     EP.iter=3;
84     [I_range_F01_D2, EPout]=dirspectest(ID,SM,EP,{'PLOTTYPE',0,'MESSAGE',0});
85
86     %set up data with radial velocities, freq and dir at default
87     [ID,SM,EP]=radialtouvw(pressure,range,orbit,sysinfo,3);
88
89     % run diwasp to generate this spectrum with EMEP
90     [E_radial_F01_D2, EPout]=dirspectest(ID,SM,EP,{'PLOTTYPE',0,'MESSAGE',0});
91
92     %now with IMLM
93     EP.method='IMLM';
94     EP.iter=3;
95     [I_radial_F01_D2, EPout]=dirspectest(ID,SM,EP,{'PLOTTYPE',0,'MESSAGE',0});
96
97     %Use waveplot to plot the polar, freq and dir plots of the spectra
98
99     [E_UVW_WI,I_UVW_WI,E_range_WI,I_range_WI,wmon_WI,fig1,fig2]=waveplot(E_uvw_F01_D2,I_uvw_F01_D2,E_range_F01_D2,I_range_F01_D2,spec,sysinfo);
100    
101     saveas(fig1,['polar1_' dateinfo '.fig']);
102     saveas(fig2,['dirfreq1_' dateinfo '.fig']);
103    
104     [E_radial_WI,I_radial_WI,fig5,fig6]=radialwaveplot(E_radial_F01_D2,I_radial_F01_D2,spec,sysinfo);
105
106     saveas(fig5,['polar3_' dateinfo '.fig']);
107     saveas(fig6,['dirfreq3_' dateinfo '.fig']);
108    
109     close all;
110    
111     %Make sure wavesmon spectrum is formatted right before outputting, change to m^2/Hz/deg
112     wmon.S=spec/(360*1000*1000);
113    
114     %Fill up the Winfo data structure
115
116     hsig=[vertcat(E_UVW_WI.hsig,I_UVW_WI.hsig,E_range_WI.hsig,I_range_WI.hsig,E_radial_WI.hsig,I_radial_WI.hsig,wmon_WI.hsig)];
117     peakP=[vertcat(E_UVW_WI.tp,I_UVW_WI.tp,E_range_WI.tp,I_range_WI.tp,E_radial_WI.tp,I_radial_WI.tp,wmon_WI.tp)];
118     dirP=[vertcat(E_UVW_WI.dtp,I_UVW_WI.dtp,E_range_WI.dtp,I_range_WI.dtp,E_radial_WI.dtp,I_radial_WI.dtp,wmon_WI.dtp)];
119     Ddir=[vertcat(E_UVW_WI.dp,I_UVW_WI.dp,E_range_WI.dp,I_range_WI.dp,E_radial_WI.dp,I_radial_WI.dp,wmon_WI.dp)];
120    
121    
122     Winfo.hsig=[horzcat(Winfo.hsig,hsig)];
123     Winfo.peakP=[horzcat(Winfo.peakP,peakP)];
124     Winfo.dirP=[horzcat(Winfo.dirP,dirP)];
125     Winfo.Ddir=[horzcat(Winfo.Ddir,Ddir)];
126     Winfo.Spectrum.EMEPuvw=[cat(3,Winfo.Spectrum.EMEPuvw,E_uvw_F01_D2.S)];
127     Winfo.Spectrum.IMLMuvw=[cat(3,Winfo.Spectrum.IMLMuvw,I_uvw_F01_D2.S)];
128     Winfo.Spectrum.EMEPrange=[cat(3,Winfo.Spectrum.EMEPrange,E_range_F01_D2.S)];
129     Winfo.Spectrum.IMLMrange=[cat(3,Winfo.Spectrum.IMLMrange,I_range_F01_D2.S)];
130     Winfo.Spectrum.EMEPradial=[cat(3,Winfo.Spectrum.EMEPradial,E_radial_F01_D2.S)];
131     Winfo.Spectrum.IMLMradial=[cat(3,Winfo.Spectrum.IMLMradial,I_radial_F01_D2.S)];
132     Winfo.Spectrum.wavesmon=[cat(3,Winfo.Spectrum.wavesmon,wmon.S)];
133    
134 end
135
136 %now create the time series plots of the wave info
137 [fig_sigh,fig_pp,fig_dp,fig_dd]=Winfo_plot(Winfo);
138
139 saveas(fig_sigh,['sigh_' dateinfo '.fig']);
140 saveas(fig_pp,['peakp_' dateinfo '.fig']);
141 saveas(fig_dp,['dirpeak_' dateinfo '.fig']);
142 saveas(fig_dd,['domdir_' dateinfo '.fig']);
143
144 close all;
145
146
147
148
Note: See TracBrowser for help on using the browser.