clear;
close all;

addpath /ligo/svncommon/NbSVN/aligonoisebudget/trunk/Externals/SimulinkNb/Utils/
addpath /ligo/svncommon/SeiSVN/seismic/Common/MatlabTools/
%% configure nds
gwd = GWData();
gwd.make_kerberos_ready;
gwd.site_info(2).port = 31200;
gwd.site_info(2).server = 'nds.ligo.caltech.edu';
%%
startTime1 = 1133956817; % Dec 12 2015 12:00:00 UTC

duration1 =30*24*3600;
channelListH1 = {'H1:PEM-EY_WIND_ROOF_WEATHER_MPH.max,m-trend',...1
    'H1:ISI-GND_STS_ITMY_Z_BLRMS_100M_300M.mean,m-trend',...2
    'H1:CDS-SENSMON_CAL_SNSW_EFFECTIVE_RANGE_MPC.mean,m-trend',...3
     };

[dataH1, tIn, ~] =gwd.fetch(startTime1,duration1,channelListH1);

channelListL1 = {'L1:PEM-LVEA_WIND_10M_WEATHER_MPH.max,m-trend',...1 L1:PEM-EX_WIND_WEATHER_MPH
    'L1:ISI-GND_STS_ITMY_Z_BLRMS_100M_300M.mean,m-trend',...2 
    'L1:CDS-SENSEMON_CAL_L1_SNSW_EFFECTIVE_RANGE_MPC.mean,m-trend',...3
     };

[dataL1, tIn, ~] =gwd.fetch(startTime1,duration1,channelListL1);

% for ii =1:(length(tIn));
%     tIn(ii)=tIn(ii)-startTime1;
% end

%%
figure(1)

subplot(311)
plot(tIn,[dataH1(:,1)])
title(channelListH1(1))
ylim([0 50])


subplot(312)
plot(tIn,[dataH1(:,2)])
ylim([0 4e3])
title(channelListH1(2))

subplot(313)
plot(tIn,[dataH1(:,3)])
title(channelListH1(3))
ylim([0 100])

suptitle('H1 30 days december 2015')
%%

figure(2)
subplot(311)
plot(tIn,[dataL1(:,1)])
title(channelListL1(1))
ylim([0 50])

subplot(312)
plot(tIn,[dataL1(:,2)])
title(channelListL1(2))
ylim([0 4e3])

subplot(313)
plot(tIn,[dataL1(:,3)])
title(channelListL1(3))
ylim([0 100])

suptitle('L1 30 days december 2015')

%%

figure(3)
subplot(311)
plot(tIn,[dataL1(:,1) dataH1(:,1)])
title(channelListL1(1))
legend('L1','H1')
ylim([0 50])

subplot(312)
plot(tIn,[dataL1(:,2) dataH1(:,2)])
title(channelListL1(2))
ylim([0 4e3])
legend('L1','H1')

subplot(313)
plot(tIn,[dataL1(:,3) dataH1(:,3)])
title(channelListL1(3))
ylim([0 100])
legend('L1','H1')

suptitle('L1 30 days december 2015')

%%

% startTime2 = 1162987217; % Nov 12 2016 12:00:00 UTC
% 
% % duration1 =30*24*3600;
% % channelListH1 = {'H1:PEM-EY_WIND_ROOF_WEATHER_MPH.mean,m-trend',...1
% %     'H1:ISI-GND_STS_ITMY_Z_BLRMS_100M_300M.mean,m-trend',...2
% %     'H1:CDS-SENSMON_CAL_SNSW_EFFECTIVE_RANGE_MPC.mean,m-trend',...3
% %      };
% 
% [dataH102, tIn, ~] =gwd.fetch(startTime2,duration1,channelListH1);
% %%
% % channelListL1 = {'L1:PEM-LVEA_WIND_10M_WEATHER_MPH.mean,m-trend',...1 L1:PEM-EX_WIND_WEATHER_MPH
% %     'L1:ISI-GND_STS_ITMY_Z_BLRMS_100M_300M.mean,m-trend',...2 
% %     'L1:CDS-SENSEMON_CAL_L1_SNSW_EFFECTIVE_RANGE_MPC.mean,m-trend',...3
% %      };
% 
% [dataL102, tIn, ~] =gwd.fetch(startTime2,duration1,channelListL1);
% 
% %%
% 
% figure(3)
% 
% subplot(311)
% plot(tIn,[dataH1O2(:,1)])
% title(channelListH1(1))
% 
% 
% subplot(312)
% plot(tIn,[dataH1O2(:,2)])
% ylim([0 1e4])
% title(channelListH1(2))
% 
% subplot(313)
% plot(tIn,[dataH1O2(:,3)])
% title(channelListH1(3))
% 
% suptitle('H1 30 days december 2015')
% %%
% 
% figure(4)
% subplot(311)
% plot(tIn,[dataL1O2(:,1)])
% title(channelListL1(1))
% 
% subplot(312)
% plot(tIn,[dataL1O2(:,2)])
% title(channelListL1(2))
% ylim([0 1e4])
% 
% subplot(313)
% plot(tIn,[dataL1O2(:,3)])
% title(channelListL1(3))
% 
% suptitle('L1 30 days december 2015')

