clear all; close all;
dirstr={...
'../PORCROS/20110506',...                
'../PORCROS/20120628',...
'../PORCROS/20110519',...            
'../PORCROS/20120710',...
'../PORCROS/20110607',...                
'../PORCROS/20120723',...
'../PORCROS/20110712',...                
'../PORCROS/20120802',...
'../PORCROS/20110728',...                
'../PORCROS/20120823',...
'../PORCROS/20110802_cachalot_vu',...    
'../PORCROS/20120909_sicie_regard_vivant_bleublanc',...
'../PORCROS/20110831',...                
'../PORCROS/20120916_regard_vivant_risso',...
'../PORCROS/20110916',...                
'../PORCROS/20120917_regard_vivant_commun_risso_cachalot12m',...
'../PORCROS/20120126',...                
'../PORCROS/20120923',...
'../PORCROS/20120316',...                
'../PORCROS/20121006_bleublanc_cachalot15m_regardvivant',...
'../PORCROS/20120326',...                
'../PORCROS/20130606',...
'../PORCROS/20120504',...                
'../PORCROS/20130630',...
'../PORCROS/20120530_cachalots_vus',...  
'../PORCROS/20131204',...
'../PORCROS/20120606',...       
'../PORCROS/20120607_petardages',...
'../PORCROS/20120615',...
};
dirstrOLD={...
'Antares_066440.21',...
'Antares_066442.21',...
'Antares_066444.21',...
'Antares_066447.21',...
'Antares_066449.21',...
'Antares_066451.21',...
'Antares_066453.21',...
'Antares_066455.21',...
'Antares_066458.21',...
'Antares_066460.21',...
'Antares_066463.21',...
'Antares_066465.21',...
'Antares_066467.21',...
'Antares_066469.21',...
'Antares_066471.21',...
'Antares_066473.21',...
'Antares_066475.21',...
'Antares_066477.21',...
'Antares_066479.21',...
'Antares_066481.21',...
'Antares_066483.21',...
'Antares_066485.21',...
'Antares_066492.21',...
'Antares_066494.21',...
'Antares_066496.21',...
'Antares_066498.21',...
'Antares_066500.21',...
'Antares_066503.21',...
'Antares_066505.21',...
'Antares_066507.21',...
'Antares_066509.21',...
'Antares_066511.21',...
'Antares_066513.21',...
'Antares_066516.21',...
'Antares_066518.21',...
'Antares_066520.21',...
'Antares_066521.21',...
'Antares_066523.21',...
'Antares_066525.21',...
'Antares_066527.21',...
'Antares_066529.21',...
'Antares_066531.21',...
'Antares_066533.21',...
'Antares_066535.21',...
'Antares_066537.21',...
'Antares_066539.21',...
'Antares_066542.21',...
'Antares_066545.21',...
'Antares_066547.21',...
'Antares_066549.21',...
'Antares_066551.21',...
'Antares_066553.21',...
'Antares_066556.21',...
'Antares_066559.21',...
'Antares_066561.21',...
'Antares_066566.21',...
'Antares_066567.21',...
'Antares_066570.21',...
'Antares_066572.21',...
'Antares_066574.21',...
'Antares_066576.21',...
'Antares_066579.21',...
'Antares_066582.21',...
'Antares_066584.21',...
'Antares_066586.21',...
'Antares_066588.21',...
'Antares_066591.21',...
'Antares_066593.21',...
'Antares_066595.21',...
'Antares_066597.21',...
'Antares_066600.21',...
'Antares_066601.21',...
'Antares_066603.21',...
'Antares_066605.21',...
'Antares_066607.21',...
'Antares_066609.21',...
'Antares_066615.21',...
'Antares_066618.21',...
'Antares_066620.21',...
'Antares_066623.21',...
'Antares_066625.21',...
'Antares_066627.21',...
'Antares_066629.21',...
'Antares_066631.21',...
'Antares_066633.21',...
'Antares_066635.21',...
'Antares_066637.21',...
'Antares_066639.21',...
'Antares_066641.21',...
'Antares_066644.21',...
'Antares_066646.21',...
'Antares_066648.21',...
'Antares_066650.21',...
'Antares_066652.21',...
'Antares_066655.21',...
'Antares_066657.21',...
'Antares_066659.21',...
'Antares_066661.21',...
'Antares_066663.21',...
'Antares_066666.21',...
'Antares_066668.21',...
'Antares_066670.21',...
'Antares_066672.21',...
'Antares_066674.21',...
'Antares_066676.21',...
'Antares_066679.21',...
'Antares_066681.21',...
'Antares_066683.21',...
'Antares_066685.21',...
'Antares_066688.21',...
'Antares_066690.21',...
'Antares_066692.21',...
'Antares_066695.21',...
'Antares_066697.21',...
'Antares_066699.21',...
'Antares_066702.21',...
'Antares_066704.21',...
'Antares_066706.21',...
'Antares_066708.21',...
'Antares_066710.21',...
'Antares_066712.21',...
'Antares_066715.21',...
'Antares_066717.21',...
'Antares_066719.21',...
'Antares_066721.21',...
'Antares_066723.21',...
'Antares_066725.21',...
'Antares_066727.21',...
'Antares_066729.21',...
'Antares_066731.21',...
'Antares_066734.21',...
'Antares_066736.21',...
'Antares_066738.21',...
'Antares_066744.21',...
'Antares_066746.21',...
'Antares_066748.21',...
'Antares_066750.21',...
'Antares_066753.21',...
'Antares_066755.21',...
'Antares_066757.21',...
'Antares_066759.21',...
'Antares_066761.21',...
'Antares_066764.21',...
'Antares_066766.21',...
'Antares_066769.21',...
'Antares_066771.21',...
'Antares_066773.21',...
'Antares_066775.21',...
'Antares_066777.21',...
'Antares_066780.21',...
'Antares_066782.21',...
'Antares_066784.21',...
'Antares_066787.21',...
'Antares_066789.21',...
'Antares_066791.21',...
'Antares_066794.21',...
'Antares_066796.21',...
'Antares_066802.21',...
'Antares_066803.21',...
'Antares_066806.21',...
'Antares_066808.21',...
'Antares_066810.21',...
'Antares_066813.21',...
'Antares_066815.21',...
'Antares_066817.21',...
'Antares_066819.21',...
'Antares_066820.21',...
'Antares_066822.21',...
'Antares_066824.21',...
'Antares_066826.21',...
'Antares_066828.21',...
'Antares_066830.21',...
'Antares_066833.21',...
'Antares_066835.21',...
'Antares_066837.21',...
'Antares_066840.21',...
'Antares_066842.21',...
'Antares_066845.21',...
'Antares_066848.21',...
'Antares_066850.21',...
'Antares_066852.21',...
'Antares_066854.21',...
'Antares_066856.21',...
'Antares_066858.21',...
'Antares_066860.21',...
'Antares_066863.21',...
'Antares_066865.21',...
'Antares_066868.21',...
'Antares_066872.21',...
'Antares_066876.21',...
'Antares_066879.21',...
'Antares_066885.21',...
'Antares_066887.21',...
'Antares_066889.21',...
'Antares_066891.21',...
'Antares_066893.21',...
'Antares_066895.21',...
'Antares_066897.21',...
'Antares_066900.21',...
'Antares_066902.21',...
'Antares_067155.21',...
'Antares_067161.21',...
'Antares_067176.21',...
'Antares_067186.21',...
'Antares_067191.21',...
'Antares_067193.21',...
'Antares_067195.21',...
'Antares_067199.21',...
'Antares_067201.21',...
'Antares_067205.21',...
'Antares_067207.21',...
'Antares_067209.21',...
'Antares_067211.21',...
'Antares_067214.21',...
'Antares_067216.21',...
'Antares_067218.21',...
'Antares_067221.21',...
'Antares_067223.21',...
'Antares_067227.21',...
'Antares_067230.21',...
'Antares_067232.21',...
'Antares_067235.21',...
'Antares_067238.21',...
'Antares_067240.21',...
'Antares_067243.21',...
'Antares_067246.21',...
'Antares_067249.21',...
'Antares_067251.21',...
'Antares_067254.21',...
'Antares_067256.21',...
'Antares_067258.21',...
'Antares_067260.21',...
'Antares_067264.21',...
'Antares_067265.21',...
'Antares_067268.21',...
'Antares_067271.21',...
'Antares_067273.21',...
'Antares_067275.21',...
'Antares_067278.21',...
'Antares_067281.21',...
'Antares_067283.21',...
'Antares_067285.21',...
'Antares_067287.21',...
'Antares_067290.21',...
'Antares_067293.21',...
'Antares_067296.21',...
'Antares_067299.21',...
'Antares_067302.21',...
'Antares_067305.21',...
'Antares_067308.21',...
'Antares_067309.21',...
'Antares_067311.21',...
'Antares_067314.21',...
'Antares_067316.21',...
'Antares_067318.21',...
'Antares_067324.21',...
'Antares_067326.21',...
'Antares_067329.21',...
'Antares_067332.21',...
'Antares_067334.21',...
'Antares_067337.21',...
'Antares_067340.21',...
'Antares_067344.21',...
'Antares_067346.21',...
'Antares_067349.21',...
'Antares_067351.21',...
'Antares_067354.21',...
'Antares_067356.21',...
'Antares_067358.21',...
'Antares_067361.21',...
'Antares_067363.21',...
'Antares_067365.21',...
'Antares_067368.21',...
'Antares_067370.21',...
'Antares_067373.21',...
'Antares_067376.21',...
'Antares_067378.21',...
'Antares_067381.21',...
'Antares_067383.21',...
'Antares_067386.21',...
'Antares_067388.21',...
'Antares_067390.21',...
'Antares_067393.21',...
'Antares_067395.21',...
'Antares_067398.21',...
'Antares_067400.21',...
'Antares_067402.21',...
'Antares_067408.21',...
'Antares_067411.21',...
'Antares_067415.21',...
'Antares_067419.21',...
'Antares_067422.21',...
'Antares_067424.21',...
'Antares_067426.21',...
'Antares_067427.21',...
'Antares_067430.21',...
'Antares_067432.21',...
'Antares_067435.21',...
'Antares_067437.21',...
'Antares_067439.21',...
'Antares_067441.21',...
'Antares_067443.21',...
'Antares_067445.21',...
'Antares_067447.21',...
'Antares_067449.21',...
'Antares_067451.21',...
'Antares_067453.21',...
'Antares_067460.21',...
'Antares_067462.21',...
'Antares_067464.21',...
'Antares_067470.21',...
'Antares_067474.21',...
'Antares_067476.21',...
'Antares_067479.21',...
'Antares_067481.21',...
'Antares_067483.21',...
'Antares_067485.21',...
'Antares_067489.21',...
'Antares_067491.21',...
'Antares_067494.21',...
'Antares_067496.21',...
'Antares_067498.21',...
'Antares_067500.21',...
'Antares_067503.21',...
'Antares_067505.21',...
'Antares_067506.21',...
'Antares_067508.21',...
'Antares_067511.21',...
'Antares_067513.21',...
'Antares_067515.21',...
'Antares_067517.21',...
'Antares_067519.21',...
'Antares_067521.21',...
'Antares_067524.21',...
'Antares_067526.21',...
'Antares_067528.21',...
'Antares_067530.21',...
'Antares_067532.21',...
'Antares_067534.21',...
'Antares_067536.21',...
'Antares_067538.21',...
'Antares_067541.21',...
'Antares_067543.21',...
'Antares_067546.21',...
'Antares_067548.21',...
'Antares_067550.21',...
'Antares_067552.21',...
'Antares_067555.21',...
'Antares_067557.21',...
'Antares_067560.21',...
'Antares_067563.21',...
'Antares_067565.21',...
'Antares_067567.21',...
'Antares_067570.21',...
'Antares_067572.21',...
'Antares_067574.21',...
'Antares_067577.21',...
'Antares_067579.21',...
'Antares_067581.21',...
'Antares_067584.21',...
'Antares_067587.21',...
'Antares_067589.21',...
'Antares_067591.21',...
'Antares_067593.21',...
'Antares_067595.21',...
'Antares_067598.21',...
'Antares_067600.21',...
'Antares_067606.21',...
'Antares_067608.21',...
'Antares_067610.21',...
'Antares_067612.21',...
'Antares_067614.21',...
'Antares_067616.21',...
'Antares_067618.21',...
'Antares_067620.21',...
'Antares_067624.21',...
'Antares_067626.21',...
'Antares_067629.21',...
'Antares_067631.21',...
'Antares_067633.21',...
};


mooncalendar2009{8}=0.5*ones(1,200);
mooncalendar2009{9}=0.5*ones(1,200);
mooncalendar2009{10}=0.5*ones(1,200);
mooncalendar2009{11}=0.5*ones(1,200);
mooncalendar2009{12}=0.5*ones(1,200);
mooncalendar2009{13}=0.5*ones(1,200);
mooncalendar2009{14}=0.5*ones(1,200);

mooncalendar2009{8}(100+ [20:27])=linspace(0,0.5, length( 20:27) );
mooncalendar2009{8}(100+ [27:35])=linspace(0.5,1, length( 27:35) );
mooncalendar2009{9}(100+ [-3:4])=linspace(0.5,1, length( -3:4) );
mooncalendar2009{9}(100+ [4:12])=linspace(1,0.5, length( 4:12) );
mooncalendar2009{9}(100+ [12:18])=linspace(0.5,0, length( 12:18) );
mooncalendar2009{9}(100+ [18:26])=linspace(0,0.5, length( 18:26) );
mooncalendar2009{9}(100+ [26:34])=linspace(0.5,1, length( 26:34) );
mooncalendar2009{10}(100+ [-4:4])=linspace(0.5,1, length( -4:4) );
mooncalendar2009{10}(100+ [4:11])=linspace(1,0.5, length( 4:11) );
mooncalendar2009{10}(100+ [11:18])=linspace(0.5,0, length( 11:18) );
mooncalendar2009{10}(100+ [18:26])=linspace(0,0.5, length( 18:26) );
mooncalendar2009{10}(100+ [26:33])=linspace(0.5,1, length( 26:33) );
mooncalendar2009{11}(100+ [-5:2])=linspace(0.5,1, length( -5:2) );
mooncalendar2009{11}(100+ [2:9])=linspace(1,0.5, length( 2:9) );
mooncalendar2009{11}(100+ [9:16])=linspace(0.5,0, length( 9:16) );
mooncalendar2009{11}(100+ [16:24])=linspace(0,0.5, length( 16:24) );

mooncalendar2009{11}(100+ [-6:02])=linspace(0.5,1, length([-6:02]) ); %  7.7720d = 07d 18h 32m
mooncalendar2009{11}(100+ [2:09])=linspace(1,0.5, length([2:09]) ); %    6.8624d = 06d 20h 42m
mooncalendar2009{11}(100+ [9:16])=linspace(0.5,0, length([9:16]) ); %   7.1375d = 07d 03h 18m
mooncalendar2009{11}(100+ [16:24])=linspace(0,0.5, length([16:24]) ); %    8.1010d = 08d 02h 25m

mooncalendar2009{12}(100+ [-6:02])=linspace(0.5,1, length([-6:02]) ); %  7.4106d = 07d 09h 51m
mooncalendar2009{12}(100+ [2:09])=linspace(1,0.5, length([2:09]) ); %    6.6964d = 06d 16h 43m
mooncalendar2009{12}(100+ [9:16])=linspace(0.5,0, length([9:16]) ); %   7.4922d = 07d 11h 49m
mooncalendar2009{12}(100+ [16:24])=linspace(0,0.5, length([16:24]) ); %    8.2319d = 08d 05h 34m
mooncalendar2009{12}(100+ [24:31])=linspace(0.5,1, length([24:31]) ); %  7.0672d = 07d 01h 37m

% mooncalendar2010{1}(100+ [0:07])=linspace(1,0.5, length([0:07]) ); %    6.6435d = 06d 15h 27m
% mooncalendar2010{1}(100+ [7:15 08:11 Fri ])=linspace(0.5,0, length([]) ); %   7.8555d = 07d 20h 32m
% mooncalendar2010{1}(100+ [15:23 11:53 Sat ])=linspace(0,0.5, length([]) ); %    8.1542d = 08d 03h 42m
% mooncalendar2010{1}(100+ [23:30 07:18 Sat ])=linspace(0.5,1, length([]) ); %  6.8085d = 06d 19h 24m

% mooncalendar2010{2}(100+ [-1:06 00:48 Sat ])=linspace(1,0.5, length([]) ); %    6.7297d = 06d 17h 31m
% mooncalendar2010{2}(100+ [6:14 03:51 Sun ])=linspace(0.5,0, length([]) ); %   8.1270d = 08d 03h 03m
% mooncalendar2010{2}(100+ [14:22 01:42 Mon ])=linspace(0,0.5, length([]) ); %    7.9105d = 07d 21h 51m
% mooncalendar2010{2}(100+ [22:28 17:38 Sun ])=linspace(0.5,1, length([]) ); %  6.6635d = 06d 15h 55m

% mooncalendar2010{3}(100+ [0:07 16:42 Sun ])=linspace(1,0.5, length([]) ); %    6.9611d = 06d 23h 04m
% mooncalendar2010{3}(100+ [7:15 22:01 Mon ])=linspace(0.5,0, length([]) ); %   8.2217d = 08d 05h 19m
% mooncalendar2010{3}(100+ [15:23 12:00 Tue ])=linspace(0,0.5, length([]) ); %    7.5826d = 07d 13h 59m
% mooncalendar2010{3}(100+ [23:30 03:25 Tue ])=linspace(0.5,1, length([]) ); %  6.6427d = 06d 15h 25m

% mooncalendar2010{4}(100+ [0:06 10:37 Tue ])=linspace(1,0.5, length([]) ); %    7.2995d = 07d 07h 11m
% mooncalendar2010{4}(100+ [06:14 13:29 Wed ])=linspace(0.5,0, length([]) ); %   8.1195d = 08d 02h 52m
% mooncalendar2010{4}(100+ [14:21 19:20 Wed ])=linspace(0,0.5, length([]) ); %    7.2437d = 07d 05h 51m
% mooncalendar2010{4}(100+ [21:28 13:18 Wed ])=linspace(0.5,1, length([]) ); %  6.7491d = 06d 17h 59m

% mooncalendar2010{5}(100+ [-2:06 05:15 Thu ])=linspace(1,0.5, length([]) ); %    7.6642d = 07d 15h 56m
% mooncalendar2010{5}(100+ [06:14 02:04 Fri ])=linspace(0.5,0, length([]) ); %   7.8677d = 07d 20h 49m
% mooncalendar2010{5}(100+ [14:21 00:43 Fri ])=linspace(0,0.5, length([]) ); %    6.9432d = 06d 22h 38m
% mooncalendar2010{5}(100+ [21:28 00:07 Fri ])=linspace(0.5,1, length([]) ); %  6.9755d = 06d 23h 25m

% mooncalendar2010{6}(100+ [-3:04 23:13 Fri ])=linspace(1,0.5, length([]) ); %    7.9623d = 07d 23h 06m
% mooncalendar2010{6}(100+ [4:12 12:15 Sat ])=linspace(0.5,0, length([]) ); %   7.5427d = 07d 13h 01m
% mooncalendar2010{6}(100+ [12:19 05:29 Sat ])=linspace(0,0.5, length([]) ); %    6.7187d = 06d 17h 15m
% mooncalendar2010{6}(100+ [19:26 12:30 Sat ])=linspace(0.5,1, length([]) ); %  7.2923d = 07d 07h 01m

% mooncalendar2010{7}(100+ [-4:04 15:35 Sun ])=linspace(1,0.5, length([]) ); %    8.1284d = 08d 03h 05m
% mooncalendar2010{7}(100+ [4:11 20:40 Sun ])=linspace(0.5,0, length([]) ); %   7.2119d = 07d 05h 05m
% mooncalendar2010{7}(100+ [11:18 11:11 Sun ])=linspace(0,0.5, length([]) ); %    6.6043d = 06d 14h 30m
% mooncalendar2010{7}(100+ [18:26 02:37 Mon ])=linspace(0.5,1, length([]) ); %  7.6430d = 07d 15h 26m

% mooncalendar2010{8}(100+ [-5:03 05:59 Tue ])=linspace(1,0.5, length([]) ); %    8.1403d = 08d 03h 22m
% mooncalendar2010{8}(100+ [3:10 04:08 Tue ])=linspace(0.5,0, length([]) ); %   6.9233d = 06d 22h 10m
% mooncalendar2010{8}(100+ [10:16 19:14 Mon ])=linspace(0,0.5, length([]) ); %    6.6291d = 06d 15h 06m
% mooncalendar2010{8}(100+ [16:24 18:05 Tue ])=linspace(0.5,1, length([]) ); %  7.9518d = 07d 22h 51m

% mooncalendar2010{9}(100+ [-6:01 18:22 Wed ])=linspace(1,0.5, length([]) ); %    8.0119d = 08d 00h 17m
% mooncalendar2010{9}(100+ [1:08 11:30 Wed ])=linspace(0.5,0, length([]) ); %   6.7139d = 06d 17h 08m
% mooncalendar2010{9}(100+ [8:15 06:50 Wed ])=linspace(0,0.5, length([]) ); %    6.8055d = 06d 19h 20m
% mooncalendar2010{9}(100+ [15:23 10:17 Thu ])=linspace(0.5,1, length([]) ); %  8.1441d = 08d 03h 28m

% mooncalendar2010{10}(100+ [-6:01 04:52 Fri ])=linspace(1,0.5, length([]) ); %    7.7743d = 07d 18h 35m
% mooncalendar2010{10}(100+ [1:07 19:45 Thu ])=linspace(0.5,0, length([]) ); %   6.6197d = 06d 14h 52m
% mooncalendar2010{10}(100+ [7:14 22:27 Thu ])=linspace(0,0.5, length([]) ); %    7.1131d = 07d 02h 43m
% mooncalendar2010{10}(100+ [14:23 02:37 Sat ])=linspace(0.5,1, length([]) ); %  8.1730d = 08d 04h 09m
% mooncalendar2010{10}(100+ [23:30 13:46 Sat ])=linspace(1,0.5, length([]) ); %    7.4648d = 07d 11h 09m

% mooncalendar2010{11}(100+ [0:06 05:52 Sat ])=linspace(0.5,0, length([]) ); %   6.6708d = 06d 16h 06m
% mooncalendar2010{11}(100+ [6:13 17:39 Sat ])=linspace(0,0.5, length([]) ); %    7.4908d = 07d 11h 47m
% mooncalendar2010{11}(100+ [13:21 18:27 Sun ])=linspace(0.5,1, length([]) ); %  8.0339d = 08d 00h 49m
% mooncalendar2010{11}(100+ [21:28 21:36 Sun ])=linspace(1,0.5, length([]) ); %    7.1313d = 07d 03h 09m

% mooncalendar2010{12}(100+ [-2:05 18:36 Sun ])=linspace(0.5,0, length([]) ); %   6.8745d = 06d 20h 59m
% mooncalendar2010{12}(100+ [5:13 14:59 Mon ])=linspace(0,0.5, length([]) ); %    7.8493d = 07d 20h 23m
% mooncalendar2010{12}(100+ [13:21 09:13 Tue ])=linspace(0.5,1, length([]) ); %  7.7602d = 07d 18h 15m
% mooncalendar2010{12}(100+ [21:28 05:18 Tue ])=linspace(1,0.5, length([]) ); %    6.8368d = 06d 20h 05m

mooncalendar2011{1}(100+ [-3:04])=linspace(0.5,0, length([-3:04]) ); %   7.1974d = 07d 04h 44m
mooncalendar2011{1}(100+ [4:12])=linspace(0,0.5, length([4:12]) ); %    8.1033d = 08d 02h 29m
mooncalendar2011{1}(100+ [12:19])=linspace(0.5,1, length([12:19]) ); %  7.4097d = 07d 09h 50m
mooncalendar2011{1}(100+ [19:26])=linspace(1,0.5, length([19:26]) ); %    6.6499d = 06d 15h 36m

mooncalendar2011{2}(100+ [-5:03])=linspace(0.5,0, length([-5:03]) ); %   7.5649d = 07d 13h 33m
mooncalendar2011{2}(100+ [3:11])=linspace(0,0.5, length([3:11]) ); %    8.1997d = 08d 04h 48m
mooncalendar2011{2}(100+ [11:18])=linspace(0.5,1, length([11:18]) ); %  7.0538d = 07d 01h 17m
mooncalendar2011{2}(100+ [18:25])=linspace(1,0.5, length([18:25]) ); %    6.6185d = 06d 14h 51m

mooncalendar2011{3}(100+ [-4:04])=linspace(0.5,0, length([-4:04]) ); %   7.8886d = 07d 21h 20m
mooncalendar2011{3}(100+ [4:13])=linspace(0,0.5, length([4:13]) ); %    8.1243d = 08d 02h 59m
mooncalendar2011{3}(100+ [13:19])=linspace(0.5,1, length([13:19]) ); %  6.7674d = 06d 18h 25m
mooncalendar2011{3}(100+ [19:26])=linspace(1,0.5, length([19:26]) ); %    6.7482d = 06d 17h 57m

mooncalendar2011{4}(100+ [-5:03])=linspace(0.5,0, length([-5:03]) ); %   8.1006d = 08d 02h 25m
mooncalendar2011{4}(100+ [3:11])=linspace(0,0.5, length([3:11]) ); %    7.8980d = 07d 21h 33m
mooncalendar2011{4}(100+ [11:18])=linspace(0.5,1, length([11:18]) ); %  6.6102d = 06d 14h 39m
mooncalendar2011{4}(100+ [18:25])=linspace(1,0.5, length([18:25]) ); %    7.0020d = 07d 00h 03m

mooncalendar2011{5}(100+ [-5:03])=linspace(0.5,0, length([-5:03]) ); %   8.1693d = 08d 04h 04m
mooncalendar2011{5}(100+ [3:10])=linspace(0,0.5, length([3:10]) ); %    7.5710d = 07d 13h 42m
mooncalendar2011{5}(100+ [10:17])=linspace(0.5,1, length([10:17]) ); %  6.6081d = 06d 14h 36m
mooncalendar2011{5}(100+ [17:24])=linspace(1,0.5, length([17:24]) ); %    7.3219d = 07d 07h 44m

mooncalendar2011{6}(100+ [-6:01])=linspace(0.5,0, length([-6:01]) ); %   8.0906d = 08d 02h 10m
mooncalendar2011{6}(100+ [1:09])=linspace(0,0.5, length([1:09]) ); %    7.2138d = 07d 05h 08m
mooncalendar2011{6}(100+ [9:15])=linspace(0.5,1, length([9:15]) ); %  6.7521d = 06d 18h 03m
mooncalendar2011{6}(100+ [15:23])=linspace(1,0.5, length([15:23]) ); %    7.6491d = 07d 15h 35m

mooncalendar2011{7}(100+ [-6:01])=linspace(0.5,0, length([-6:01]) ); %   7.8789d = 07d 21h 06m
mooncalendar2011{7}(100+ [1:08])=linspace(0,0.5, length([1:08]) ); %    6.8997d = 06d 21h 36m
mooncalendar2011{7}(100+ [8:15])=linspace(0.5,1, length([8:15]) ); %  7.0071d = 07d 00h 10m
mooncalendar2011{7}(100+ [15:23])=linspace(1,0.5, length([15:23]) ); %    7.9322d = 07d 22h 22m
mooncalendar2011{7}(100+ [23:30])=linspace(0.5,0, length([23:30]) ); %   7.5679d = 07d 13h 38m

mooncalendar2011{8}(100+ [0:06])=linspace(0,0.5, length([0:06]) ); %    6.6865d = 06d 16h 29m
mooncalendar2011{8}(100+ [6:13])=linspace(0.5,1, length([6:13]) ); %  7.3258d = 07d 07h 49m
mooncalendar2011{8}(100+ [13:21])=linspace(1,0.5, length([13:21]) ); %    8.1229d = 08d 02h 57m
mooncalendar2011{8}(100+ [21:29])=linspace(0.5,0, length([21:29]) ); %   7.2150d = 07d 05h 10m

mooncalendar2011{9}(100+ [-3:04 ])=linspace(0,0.5, length([-3:04]) ); %    6.6078d = 06d 14h 35m
mooncalendar2011{9}(100+ [4:12 ])=linspace(0.5,1, length([4:12]) ); %  7.6579d = 07d 15h 47m
mooncalendar2011{9}(100+ [12:20  ])=linspace(1,0.5, length([12:20]) ); %    8.1749d = 08d 04h 12m
mooncalendar2011{9}(100+ [20:27  ])=linspace(0.5,0, length([20:27]) ); %   6.8959d = 06d 21h 30m

mooncalendar2011{10}(100+ [-4:04  ])=linspace(0,0.5, length([-4:04]) ); %    6.6712d = 06d 16h 07m
mooncalendar2011{10}(100+ [4:12 ])=linspace(0.5,1, length([4:12]) ); %  7.9518d = 07d 22h 51m
mooncalendar2011{10}(100+ [12:20 ])=linspace(1,0.5, length([12:20]) ); %    8.0588d = 08d 01h 25m
mooncalendar2011{10}(100+ [20:26  ])=linspace(0.5,0, length([20:26 ]) ); %   6.6843d = 06d 16h 25m

mooncalendar2011{11}(100+ [-5:02 ])=linspace(0,0.5, length([-5:02]) ); %    6.8627d = 06d 20h 42m
mooncalendar2011{11}(100+ [2:10 ])=linspace(0.5,1, length([2:10]) ); %  8.1514d = 08d 03h 38m
mooncalendar2011{11}(100+ [10:18  ])=linspace(1,0.5, length([10:18]) ); %    7.7868d = 07d 18h 53m
mooncalendar2011{11}(100+ [18:25  ])=linspace(0.5,0, length([18:25 ]) ); %   6.6254d = 06d 15h 01m

mooncalendar2011{12}(100+ [-3:02  ])=linspace(0,0.5, length([-3:02]) ); %    7.1546d = 07d 03h 43m
mooncalendar2011{12}(100+ [2:10  ])=linspace(0.5,1, length([2:10]) ); %  8.1973d = 08d 04h 44m
mooncalendar2011{12}(100+ [10:18 ])=linspace(1,0.5, length([10:18 ]) ); %    7.4245d = 07d 10h 11m
mooncalendar2011{12}(100+ [18:24  ])=linspace(0.5,0, length([18:24]) ); %   6.7213d = 06d 17h 19m

mooncalendar2012{1}(100+ [-6:01 ])=linspace(0,0.5, length([-6:01 ]) ); %    7.5057d = 07d 12h 08m
mooncalendar2012{1}(100+ [1:09  ])=linspace(0.5,1, length([1:09 ]) ); %  8.0524d = 08d 01h 15m
mooncalendar2012{1}(100+ [9:16  ])=linspace(1,0.5, length([9:16 ]) ); %    7.0680d = 07d 01h 38m
mooncalendar2012{1}(100+ [16:23  ])=linspace(0.5,0, length([16:23]) ); %   6.9384d = 06d 22h 31m
mooncalendar2012{1}(100+ [23:31 ])=linspace(0,0.5, length([23:31 ]) ); %    7.8544d = 07d 20h 30m

mooncalendar2012{2}(100+ [0:07 ])=linspace(0.5,1, length([0:07 ]) ); %  7.7390d = 07d 17h 44m
mooncalendar2012{2}(100+ [7:14 ])=linspace(1,0.5, length([7:14]) ); %    6.7987d = 06d 19h 10m
mooncalendar2012{2}(100+ [14:21  ])=linspace(0.5,0, length([14:21 ]) ); %   7.2297d = 07d 05h 31m

mooncalendar2012{3}(100+ [-6:01  ])=linspace(0,0.5, length([-6:01 ]) ); %    8.1159d = 08d 02h 47m
mooncalendar2012{3}(100+ [1:08  ])=linspace(0.5,1, length([1:08 ]) ); %  7.3458d = 07d 08h 18m
mooncalendar2012{3}(100+ [8:15  ])=linspace(1,0.5, length([8:15 ]) ); %    6.6567d = 06d 15h 46m
mooncalendar2012{3}(100+ [15:22  ])=linspace(0.5,0, length([15:22 ]) ); %   7.5500d = 07d 13h 12m
mooncalendar2012{3}(100+ [22:30 ])=linspace(0,0.5, length([22:30]) ); %    8.2108d = 08d 05h 04m

mooncalendar2012{4}(100+ [-1:06  ])=linspace(0.5,1, length([-1:06 ]) ); %  6.9847d = 06d 23h 38m
mooncalendar2012{4}(100+ [6:13])=linspace(1,0.5, length([6:13]) ); %    6.6465d = 06d 15h 31m
mooncalendar2012{4}(100+ [13:21  ])=linspace(0.5,0, length([13:21 ]) ); %   7.8533d = 07d 20h 29m
mooncalendar2012{4}(100+ [21:29  ])=linspace(0,0.5, length([21:29]) ); %    8.1105d = 08d 02h 39m

mooncalendar2012{5}(100+ [-2:06  ])=linspace(0.5,1, length([-2:06 ]) ); %  6.7344d = 06d 17h 38m
mooncalendar2012{5}(100+ [6:12 ])=linspace(1,0.5, length([6:12]) ); %    6.7581d = 06d 18h 12m
mooncalendar2012{5}(100+ [12:21 ])=linspace(0.5,0, length([12:21 ]) ); %   8.0836d = 08d 02h 00m
mooncalendar2012{5}(100+ [21:28 ])=linspace(0,0.5, length([21:28 ]) ); %    7.8534d = 07d 20h 29m

mooncalendar2012{6}(100+ [-3:04 ])=linspace(0.5,1, length([-3:04 ]) ); %  6.6219d = 06d 14h 56m
mooncalendar2012{6}(100+ [4:11 ])=linspace(1,0.5, length([4:11 ]) ); %    6.9791d = 06d 23h 30m
mooncalendar2012{6}(100+ [11:19 ])=linspace(0.5,0, length([11:19 ]) ); %   8.1810d = 08d 04h 21m
mooncalendar2012{6}(100+ [19:27 ])=linspace(0,0.5, length([19:27 ]) ); %    7.5197d = 07d 12h 28m

mooncalendar2012{7}(100+ [-4:03 ])=linspace(0.5,1, length([-4:03 ]) ); %  6.6399d = 06d 15h 21m
mooncalendar2012{7}(100+ [3:11 ])=linspace(1,0.5, length([3:11 ]) ); %    7.2889d = 07d 06h 56m
mooncalendar2012{7}(100+ [11:19 ])=linspace(0.5,0, length([11:19 ]) ); %   8.1084d = 08d 02h 36m
mooncalendar2012{7}(100+ [19:26 ])=linspace(0,0.5, length([19:26 ]) ); %    7.1890d = 07d 04h 32m

mooncalendar2012{8}(100+ [-5:02 ])=linspace(0.5,1, length([-5:02 ]) ); %  6.7717d = 06d 18h 31m
mooncalendar2012{8}(100+ [2:09 ])=linspace(1,0.5, length([2:09 ]) ); %    7.6442d = 07d 15h 28m
mooncalendar2012{8}(100+ [9:17 ])=linspace(0.5,0, length([9:17 ]) ); %   7.8746d = 07d 20h 59m
mooncalendar2012{8}(100+ [17:24  ])=linspace(0,0.5, length([17:24  ]) ); %    6.9160d = 06d 21h 59m
mooncalendar2012{8}(100+ [24:31  ])=linspace(0.5,1, length([24:31 ]) ); %  7.0032d = 07d 00h 05m

mooncalendar2012{9}(100+ [0:08  ])=linspace(1,0.5, length([0:08 ]) ); %    7.9701d = 07d 23h 17m
mooncalendar2012{9}(100+ [8:16 ])=linspace(0.5,0, length([8:16]) ); %   7.5386d = 07d 12h 56m
mooncalendar2012{9}(100+ [16:22  ])=linspace(0,0.5, length([16:22 ]) ); %    6.7293d = 06d 17h 30m
mooncalendar2012{9}(100+ [22:30 ])=linspace(0.5,1, length([22:30 ]) ); %  7.3179d = 07d 07h 38m

mooncalendar2012{10}(100+ [0:08  ])=linspace(1,0.5, length([0:08 ]) ); %    8.1768d = 08d 04h 15m
mooncalendar2012{10}(100+ [8:15  ])=linspace(0.5,0, length([8:15  ]) ); %   7.1870d = 07d 04h 29m
mooncalendar2012{10}(100+ [15:22  ])=linspace(0,0.5, length([15:22 ]) ); %    6.6455d = 06d 15h 30m
mooncalendar2012{10}(100+ [22:29 ])=linspace(0.5,1, length([22:29 ]) ); %  7.6788d = 07d 16h 17m

mooncalendar2012{11}(100+ [0:07  ])=linspace(1,0.5, length([0:07 ]) ); %    8.1987d = 08d 04h 46m
mooncalendar2012{11}(100+ [7:13 ])=linspace(0.5,0, length([7:13 ]) ); %   6.8975d = 06d 21h 32m
mooncalendar2012{11}(100+ [13:20  ])=linspace(0,0.5, length([13:20 ]) ); %    6.6829d = 06d 16h 23m
mooncalendar2012{11}(100+ [20:28  ])=linspace(0.5,1, length([20:28  ]) ); %  8.0101d = 08d 00h 15m

mooncalendar2012{12}(100+ [-2:06 ])=linspace(1,0.5, length([-2:06 ]) ); %    8.0316d = 08d 00h 46m
mooncalendar2012{12}(100+ [6:13 ])=linspace(0.5,0, length([6:13 ]) ); %   6.7154d = 06d 17h 10m
mooncalendar2012{12}(100+ [13:20 ])=linspace(0,0.5, length([13:20 ]) ); %    6.8593d = 06d 20h 37m
mooncalendar2012{12}(100+ [20:28  ])=linspace(0.5,1, length([20:28 ]) ); %  8.2098d = 08d 05h 02m

mooncalendar2013{1}(100+ [-1:05 ])=linspace(1,0.5, length([-1:05]) ); %    7.7338d = 07d 17h 37m
% mooncalendar2013{1}(100+ [5:11 20:44 Fri ])=linspace(0.5,0, length([]) ); %   6.6568d = 06d 15h 46m
% mooncalendar2013{1}(100+ [11:19 00:45 Sat ])=linspace(0,0.5, length([]) ); %    7.1677d = 07d 04h 01m
% mooncalendar2013{1}(100+ [19:27 05:38 Sun ])=linspace(0.5,1, length([]) ); %  8.2037d = 08d 04h 53m

% mooncalendar2013{2}(100+ [-3:03 14:56 Sun ])=linspace(1,0.5, length([]) ); %    7.3874d = 07d 09h 18m
% mooncalendar2013{2}(100+ [3:10 08:20 Sun ])=linspace(0.5,0, length([]) ); %   6.7249d = 06d 17h 24m
% mooncalendar2013{2}(100+ [10:17 21:31 Sun ])=linspace(0,0.5, length([]) ); %    7.5490d = 07d 13h 11m
% mooncalendar2013{2}(100+ [17:25 21:26 Mon ])=linspace(0.5,1, length([]) ); %  7.9968d = 07d 23h 55m

% mooncalendar2013{3}(100+ [-6:04 22:53 Mon ])=linspace(1,0.5, length([]) ); %    7.0602d = 07d 01h 27m
% mooncalendar2013{3}(100+ [4:11 20:51 Mon ])=linspace(0.5,0, length([]) ); %   6.9155d = 06d 21h 58m
% mooncalendar2013{3}(100+ [11:19 18:27 Tue ])=linspace(0,0.5, length([]) ); %    7.8997d = 07d 21h 36m
% mooncalendar2013{3}(100+ [19:27 10:27 Wed ])=linspace(0.5,1, length([]) ); %  7.6671d = 07d 16h 01m

% mooncalendar2013{4}(100+ [-3:03 05:36 Wed ])=linspace(1,0.5, length([]) ); %    6.7981d = 06d 19h 09m
% mooncalendar2013{4}(100+ [3:10 10:35 Wed ])=linspace(0.5,0, length([]) ); %   7.2075d = 07d 04h 59m
% mooncalendar2013{4}(100+ [10:18 13:31 Thu ])=linspace(0,0.5, length([]) ); %    8.1219d = 08d 02h 56m
% mooncalendar2013{4}(100+ [18:25 20:57 Thu ])=linspace(0.5,1, length([]) ); %  7.3099d = 07d 07h 26m

% mooncalendar2013{5}(100+ [-5:02 12:14 Thu ])=linspace(1,0.5, length([]) ); %    6.6368d = 06d 15h 17m
% mooncalendar2013{5}(100+ [2:10 01:28 Fri ])=linspace(0.5,0, length([]) ); %   7.5516d = 07d 13h 14m
% mooncalendar2013{5}(100+ [10:18 05:34 Sat ])=linspace(0,0.5, length([]) ); %    8.1709d = 08d 04h 06m
% mooncalendar2013{5}(100+ [18:25 05:25 Sat ])=linspace(0.5,1, length([]) ); %  6.9933d = 06d 23h 50m
% mooncalendar2013{5}(100+ [25:31 19:58 Fri ])=linspace(1,0.5, length([]) ); %    6.6064d = 06d 14h 33m

mooncalendar2013{6}(100+ [1:08 ])=linspace(0.5,0, length([1:08 ]) ); %   7.8738d = 07d 20h 58m
mooncalendar2013{6}(100+ [8:16 ])=linspace(0,0.5, length([8:16 ]) ); %    8.0607d = 08d 01h 27m
mooncalendar2013{6}(100+ [16:23 ])=linspace(0.5,1, length([16:23 ]) ); %  6.7559d = 06d 18h 08m
mooncalendar2013{6}(100+ [23:30 ])=linspace(1,0.5, length([23:30 ]) ); %    6.7231d = 06d 17h 21m

mooncalendar2013{7}(100+ [0:08 ])=linspace(0.5,0, length([0:08 ]) ); %   8.0978d = 08d 02h 21m
% mooncalendar2013{7}(100+ [8:16 04:18 Tue ])=linspace(0,0.5, length([]) ); %    7.8361d = 07d 20h 04m
% mooncalendar2013{7}(100+ [16:22 19:16 Mon ])=linspace(0.5,1, length([]) ); %  6.6231d = 06d 14h 57m
% mooncalendar2013{7}(100+ [22:29 18:43 Mon ])=linspace(1,0.5, length([]) ); %    6.9776d = 06d 23h 28m

% mooncalendar2013{8}(100+ [-2:06 22:51 Tue ])=linspace(0.5,0, length([]) ); %   8.1718d = 08d 04h 07m
% mooncalendar2013{8}(100+ [6:14 11:56 Wed ])=linspace(0,0.5, length([]) ); %    7.5453d = 07d 13h 05m
% mooncalendar2013{8}(100+ [14:21 02:45 Wed ])=linspace(0.5,1, length([]) ); %  6.6171d = 06d 14h 49m
% mooncalendar2013{8}(100+ [21:28 10:35 Wed ])=linspace(1,0.5, length([]) ); %    7.3266d = 07d 07h 50m

% mooncalendar2013{9}(100+ [-2:05 12:36 Thu ])=linspace(0.5,0, length([]) ); %   8.0842d = 08d 02h 01m
% mooncalendar2013{9}(100+ [5:12 18:08 Thu ])=linspace(0,0.5, length([]) ); %    7.2308d = 07d 05h 32m
% mooncalendar2013{9}(100+ [12:19 12:13 Thu ])=linspace(0.5,1, length([]) ); %  6.7530d = 06d 18h 04m
% mooncalendar2013{9}(100+ [19:27 04:55 Fri ])=linspace(1,0.5, length([]) ); %    7.6963d = 07d 16h 43m

% mooncalendar2013{10}(100+ [-2:05 01:35 Sat ])=linspace(0.5,0, length([]) ); %   7.8605d = 07d 20h 39m
% mooncalendar2013{10}(100+ [5:12 00:02 Sat ])=linspace(0,0.5, length([]) ); %    6.9359d = 06d 22h 28m
% mooncalendar2013{10}(100+ [12:19 00:38 Sat ])=linspace(0.5,1, length([]) ); %  7.0246d = 07d 00h 35m
% mooncalendar2013{10}(100+ [19:27 00:40 Sun ])=linspace(1,0.5, length([]) ); %    8.0019d = 08d 00h 03m

% mooncalendar2013{11}(100+ [-3:03 13:50 Sun ])=linspace(0.5,0, length([]) ); %   7.5483d = 07d 13h 10m
% mooncalendar2013{11}(100+ [3:10 06:57 Sun ])=linspace(0,0.5, length([]) ); %    6.7133d = 06d 17h 07m
% mooncalendar2013{11}(100+ [10:17 16:16 Sun ])=linspace(0.5,1, length([]) ); %  7.3879d = 07d 09h 19m
% mooncalendar2013{11}(100+ [17:25 20:28 Mon ])=linspace(1,0.5, length([]) ); %    8.1750d = 08d 04h 12m

mooncalendar2013{12}(100+ [-5:03 ])=linspace(0.5,0, length([-5:03]) ); %   7.2046d = 07d 04h 55m
mooncalendar2013{12}(100+ [3:09 ])=linspace(0,0.5, length([3:09 ]) ); %    6.6176d = 06d 14h 49m
mooncalendar2013{12}(100+ [9:17  ])=linspace(0.5,1, length([9:17 ]) ); %  7.7614d = 07d 18h 16m
mooncalendar2013{12}(100+ [17:25  ])=linspace(1,0.5, length([17:25]) ); %    8.1802d = 08d 04h 19m


mooncalendar2014{1}(100+ [-5:01 ])=linspace(0.5,0, length([-5:01]) ); %   6.8934d = 06d 21h 26m
% % mooncalendar2014{1}(100+ [:08 04:39 Wed ])=linspace(0,0.5, length([]) ); %    6.6842d = 06d 16h 25m
% % mooncalendar2014{1}(100+ [:16 05:52 Thu ])=linspace(0.5,1, length([]) ); %  8.0506d = 08d 01h 13m
% % mooncalendar2014{1}(100+ [:24 06:19 Fri ])=linspace(1,0.5, length([]) ); %    8.0186d = 08d 00h 27m
% % mooncalendar2014{1}(100+ [:30 22:38 Thu ])=linspace(0.5,0, length([]) ); %   6.6802d = 06d 16h 19m

% mooncalendar2014{2}(100+ [:06 20:22 Thu ])=linspace(0,0.5, length([]) ); %    6.9053d = 06d 21h 44m
% mooncalendar2014{2}(100+ [:15 00:53 Sat ])=linspace(0.5,1, length([]) ); %  8.1881d = 08d 04h 31m
% mooncalendar2014{2}(100+ [:22 18:15 Sat ])=linspace(1,0.5, length([]) ); %    7.7238d = 07d 17h 22m

% mooncalendar2014{3}(100+ [:01 09:00 Sat ])=linspace(0.5,0, length([]) ); %   6.6142d = 06d 14h 44m
% mooncalendar2014{3}(100+ [:08 14:27 Sat ])=linspace(0,0.5, length([]) ); %    7.2271d = 07d 05h 27m
% mooncalendar2014{3}(100+ [:16 18:08 Sun ])=linspace(0.5,1, length([]) ); %  8.1539d = 08d 03h 42m
% mooncalendar2014{3}(100+ [:24 02:46 Mon ])=linspace(1,0.5, length([]) ); %    7.3595d = 07d 08h 38m
% mooncalendar2014{3}(100+ [:30 19:45 Sun ])=linspace(0.5,0, length([]) ); %   6.7074d = 06d 16h 59m

% mooncalendar2014{4}(100+ [:07 09:31 Mon ])=linspace(0,0.5, length([]) ); %    7.5736d = 07d 13h 46m
% mooncalendar2014{4}(100+ [:15 08:42 Tue ])=linspace(0.5,1, length([]) ); %  7.9664d = 07d 23h 12m
% mooncalendar2014{4}(100+ [:22 08:52 Tue ])=linspace(1,0.5, length([]) ); %    7.0066d = 07d 00h 10m
% mooncalendar2014{4}(100+ [:29 07:14 Tue ])=linspace(0.5,0, length([]) ); %   6.9323d = 06d 22h 23m

% mooncalendar2014{5}(100+ [:07 04:15 Wed ])=linspace(0,0.5, length([]) ); %    7.8754d = 07d 21h 01m
% mooncalendar2014{5}(100+ [:14 20:16 Wed ])=linspace(0.5,1, length([]) ); %  7.6674d = 07d 16h 01m
% mooncalendar2014{5}(100+ [:21 13:59 Wed ])=linspace(1,0.5, length([]) ); %    6.7384d = 06d 17h 43m
% mooncalendar2014{5}(100+ [:28 19:40 Wed ])=linspace(0.5,0, length([]) ); %   7.2368d = 07d 05h 41m

% mooncalendar2014{6}(100+ [:05 21:39 Thu ])=linspace(0,0.5, length([]) ); %    8.0823d = 08d 01h 59m
% mooncalendar2014{6}(100+ [:13 05:11 Fri ])=linspace(0.5,1, length([]) ); %  7.3144d = 07d 07h 33m
% mooncalendar2014{6}(100+ [:19 19:39 Thu ])=linspace(1,0.5, length([]) ); %    6.6023d = 06d 14h 27m
% mooncalendar2014{6}(100+ [:27 09:08 Fri ])=linspace(0.5,0, length([]) ); %   7.5623d = 07d 13h 30m

% mooncalendar2014{7}(100+ [:05 12:59 Sat ])=linspace(0,0.5, length([]) ); %    8.1600d = 08d 03h 50m
% mooncalendar2014{7}(100+ [:12 12:25 Sat ])=linspace(0.5,1, length([]) ); %  6.9764d = 06d 23h 26m
% mooncalendar2014{7}(100+ [:19 03:08 Sat ])=linspace(1,0.5, length([]) ); %    6.6135d = 06d 14h 43m
% mooncalendar2014{7}(100+ [:26 23:42 Sat ])=linspace(0.5,0, length([]) ); %   7.8566d = 07d 20h 34m

% mooncalendar2014{8}(100+ [:04 01:50 Mon ])=linspace(0,0.5, length([]) ); %    8.0888d = 08d 02h 08m
% mooncalendar2014{8}(100+ [:10 19:09 Sun ])=linspace(0.5,1, length([]) ); %  6.7220d = 06d 17h 20m
% mooncalendar2014{8}(100+ [:17 13:26 Sun ])=linspace(1,0.5, length([]) ); %    6.7614d = 06d 18h 16m
% mooncalendar2014{8}(100+ [:25 15:13 Mon ])=linspace(0.5,0, length([]) ); %   8.0743d = 08d 01h 47m

% mooncalendar2014{9}(100+ [:02 12:11 Tue ])=linspace(0,0.5, length([]) ); %    7.8739d = 07d 20h 58m
% mooncalendar2014{9}(100+ [:09 02:38 Tue ])=linspace(0.5,1, length([]) ); %  6.6021d = 06d 14h 27m
% mooncalendar2014{9}(100+ [:16 03:05 Tue ])=linspace(1,0.5, length([]) ); %    7.0185d = 07d 00h 27m
% mooncalendar2014{9}(100+ [:24 07:14 Wed ])=linspace(0.5,0, length([]) ); %   8.1728d = 08d 04h 09m

% mooncalendar2014{10}(100+ [:01 20:33 Wed ])=linspace(0,0.5, length([]) ); %    7.5548d = 07d 13h 19m
% mooncalendar2014{10}(100+ [:08 11:51 Wed ])=linspace(0.5,1, length([]) ); %  6.6375d = 06d 15h 18m
% mooncalendar2014{10}(100+ [:15 20:12 Wed ])=linspace(1,0.5, length([]) ); %    7.3482d = 07d 08h 21m
% mooncalendar2014{10}(100+ [:23 22:57 Thu ])=linspace(0.5,0, length([]) ); %   8.1143d = 08d 02h 45m
% mooncalendar2014{10}(100+ [:31 03:48 Fri ])=linspace(0,0.5, length([]) ); %    7.2026d = 07d 04h 52m

% mooncalendar2014{11}(100+ [:06 23:23 Thu ])=linspace(0.5,1, length([]) ); %  6.8156d = 06d 19h 34m
% mooncalendar2014{11}(100+ [:14 16:16 Fri ])=linspace(1,0.5, length([]) ); %    7.7033d = 07d 16h 53m
% mooncalendar2014{11}(100+ [:22 13:32 Sat ])=linspace(0.5,0, length([]) ); %   7.8866d = 07d 21h 17m
% mooncalendar2014{11}(100+ [:29 11:06 Sat ])=linspace(0,0.5, length([]) ); %    6.8986d = 06d 21h 34m

% mooncalendar2014{12}(100+ [:06 13:27 Sat ])=linspace(0.5,1, length([]) ); %  7.0976d = 07d 02h 21m
% mooncalendar2014{12}(100+ [:14 13:51 Sun ])=linspace(1,0.5, length([]) ); %    8.0168d = 08d 00h 24m
% mooncalendar2014{12}(100+ [:22 02:36 Mon ])=linspace(0.5,0, length([]) ); %   7.5312d = 07d 12h 45m
% mooncalendar2014{12}(100+ [:28 19:31 Sun ])=linspace(0,0.5, length([]) ); %    6.7052d = 06d 16h 55m
%FROM http://neoprogrammics.com/basic_lunar_ephemeris/

for imonth=1:12
finimonth=length(mooncalendar2012{imonth})-100;    
if imonth==2,lenimonth=29;
elseif ismember(imonth,[4, 6, 9, 11]), lenimonth=30;
else lenimonth=31;    
end;
imonth
if imonth<12
%mooncalendar2013{imonth}(100+ [finimonth:lenimonth])=mooncalendar2013{imonth+1}(100-(lenimonth-finimonth):100);
mooncalendar2012{imonth}(100+ [finimonth:lenimonth])=mooncalendar2012{imonth+1}(100-(lenimonth-finimonth):100);
%mooncalendar2011{imonth}(100+ [finimonth:lenimonth])=mooncalendar2011{imonth+1}(100-(lenimonth-finimonth):100);
%mooncalendar2010{imonth}(100+ [finimonth:lenimonth])=mooncalendar2010{imonth+1}(100-(lenimonth-finimonth):100);
%mooncalendar2009{imonth}(100+ [finimonth:lenimonth])=mooncalendar2009{imonth+1}(100-(lenimonth-finimonth):100);
else
mooncalendar2012{imonth}(100+ [finimonth:lenimonth])=mooncalendar2013{1}(100-(lenimonth-finimonth):100);   
%mooncalendar2011{imonth}(100+ [finimonth:lenimonth])=mooncalendar2012{1}(100-(lenimonth-finimonth):100); 
%mooncalendar2010{imonth}(100+ [finimonth:lenimonth])=mooncalendar2011{1}(100-(lenimonth-finimonth):100); 
%mooncalendar2009{imonth}(100+ [finimonth:lenimonth])=mooncalendar2010{1}(100-(lenimonth-finimonth):100); 
end;
end;

for Ctdoaecho=[]
c=1484;
mMicroToSurf1ToBottom2=[2300 400]; SeaDepth=sum(mMicroToSurf1ToBottom2);
step=10;maxWhaleDepth=SeaDepth; maxMicroDist=2000;
surf1bottom2str={'surface','bottom', 'all'};
for surf1bottom2all3=1:3
if surf1bottom2all3<=2   
mMicroToSurf=mMicroToSurf1ToBottom2(surf1bottom2all3);
ALLhoriz=1:maxMicroDist;            
if surf1bottom2all3==1
ALLvert=1:maxWhaleDepth;
else 
ALLvert=SeaDepth:-1:(SeaDepth-maxWhaleDepth);    
end;
ALLstephoriz=downsample(ALLhoriz,step);   
ALLstepvert=downsample(ALLvert,step);

tdoa{surf1bottom2all3}=zeros(length(ALLstepvert),length(ALLstephoriz));

for indmEpikitToEpimicro=1:length(ALLstephoriz)
for indmKitToSurf=1:length(ALLstepvert)
mEpikitToEpimicro=ALLstephoriz(indmEpikitToEpimicro);
if surf1bottom2all3==1
mKitToSurf=ALLstepvert(indmKitToSurf);   
else
mKitToSurf=SeaDepth-ALLstepvert(indmKitToSurf); 
end;
mEpimicroEchosurf=(mEpikitToEpimicro*mMicroToSurf)/(mMicroToSurf+mKitToSurf);
mKitMicro=sqrt(mEpikitToEpimicro^2 + (mKitToSurf-mMicroToSurf)^2);
mKitMicroECHO=sqrt(mKitToSurf^2 + (mEpimicroEchosurf-mEpikitToEpimicro)^2) + sqrt(mEpimicroEchosurf^2+mMicroToSurf^2);  
tdoa{surf1bottom2all3}(indmKitToSurf,indmEpikitToEpimicro)=(mKitMicroECHO-mKitMicro)/c;
end;
end;
[X,Y] = meshgrid(ALLstepvert,ALLstephoriz);
[XI,YI] = meshgrid(ALLvert,ALLhoriz);
tdoa{surf1bottom2all3}= interp2(X,Y,tdoa{surf1bottom2all3}',XI,YI);
tdoa{surf1bottom2all3}=tdoa{surf1bottom2all3}'; if surf1bottom2all3==2, tdoa{surf1bottom2all3}=flipud(tdoa{surf1bottom2all3});end;
else
s1=size(tdoa{1});  s2=size(tdoa{2}); s12=min([s1;s2]);  
tdoa{surf1bottom2all3}=(tdoa{1}(1:s12(1),1:s12(2))+tdoa{2}(1:s12(1),1:s12(2)))/2;   
end;

imagesc(tdoa{surf1bottom2all3});text(1850,2300,'Hydro','BackgroundColor',[1 1 1]); colormap('Gray');colorbar;%('location','West');
                        xticklabels =linspace(maxMicroDist,0,8);
                        xticklabels = round(xticklabels*1)/1;
                        xticks = linspace(1, size(tdoa{surf1bottom2all3}, 2), 8);
                        set(gca, 'XTick', xticks, 'XTickLabel', xticklabels);
                        xlabel(['horizontal distance between sound source and hydrophone, m']); ylabel('depth of the sound source, m');
                        title(['TDOA,sec between direct signal and Echo from ' surf1bottom2str{surf1bottom2all3} ' for all source locations'],'FontSize',12);
saveas(gcf,['TDOAEchofrom ' surf1bottom2str{surf1bottom2all3} '.jpg']);
saveas(gcf,['TDOAEchofrom ' surf1bottom2str{surf1bottom2all3} '.eps'],'psc2');
close all;

binBorders{Nbins}=linspace(0.2,0.9,200); 
shallow=reshape(tdoa{surf1bottom2all3}(1:300,:),[],1);
middle=reshape(tdoa{surf1bottom2all3}(300:600,:),[],1);
deep=reshape(tdoa{surf1bottom2all3}(600:900,:),[],1);
minL=min(length(shallow),length(deep));
[Ntdoa] = hist([deep(1:minL), middle(1:minL), shallow(1:minL)],binBorders{Nbins});
figure;bar(binBorders{Nbins},Ntdoa,'');colormap summer;
legend(['deep whale location(600m-900m, mostly hunt); meanTDOAecho=' num2str(nanmean(deep))],...
    ['middle whale location(300m-600m, dive and hunt); meanTDOAecho=' num2str(nanmean(middle))],...
    ['shallow whale location (0-300m, mostly dive); meanTDOAecho=' num2str(nanmean(shallow))],...    
    'Location','NorthOutside');
                        xlabel(['TDOA,sec ']); ylabel('Number of TDOA');
                        title(['Theoretical distribution of TDOA,echo from ' surf1bottom2str{surf1bottom2all3} ' over all whale locations'],'FontSize',14);
saveas(gcf,['TDOAhistEchofrom ' surf1bottom2str{surf1bottom2all3} '.jpg']);
saveas(gcf,['TDOAhistEchofrom ' surf1bottom2str{surf1bottom2all3} '.eps'],'psc2');
close all;
end;


end;


allNbins=[5 30 10 15 20]; %allNbins=[5 10 15 20 25 100 200];
maxdiff = 1.2; mindiff = 0.1; mindiff = 0.8;                          %JULY maxdiff = 1.2; mindiff = 0.1; 
coefNbins=allNbins(end)./allNbins;
for indNbins=1:length(allNbins)
Nbins=allNbins(indNbins);  
Nmoonperc=Nbins;  %Nmoonperc=100;  
ALLperc=0:Nmoonperc;    
 
meanNUMici{Nbins}=zeros(1,Nbins);
binBorders{Nbins}=linspace(mindiff,maxdiff,Nbins);    
allNUMiciBYday=zeros(length(dirstr),Nbins);
allNUMiciBYmoonperc{Nbins}=zeros(Nmoonperc+1,Nbins);
allMOONpercBYday=zeros(1,length(dirstr));
nNUMiciBYmoonperc=zeros(Nmoonperc+1,1);

for CALCiciBYmoonperc=[1]
for istr=1:length(dirstr)
% %OLD s=textread([dirstr{istr} '/README.txt'],'%s');
% s=textread([dirstr{istr} '/20110607_DECAV_20110607_111247.wav_DETECTIONS_part1.txt'],'%s');
% day=s{6}(18:19); 
% month=s{6}(20:22); 
day=dirstr{istr}(18:19);
month=dirstr{istr}(16:17);
day(day=='_')=[]; day=str2num(day);
month(month=='_')=[]; month=str2num(month);
dirstr{istr}(14:15)
if str2num(dirstr{istr}(14:15))~=12, continue; end;

%ANTARES dirp=dir([dirstr{istr} '/DETECTION_SPERM_part*.txt']);
dirp=dir([dirstr{istr} '/*DETECTIONS*.txt']);
p=[];
for idirp=1:length(dirp)
curp=load([dirstr{istr} '/' dirp(idirp).name]);
if size(curp,2)<3, continue; end;
p=[p;curp(:,2)]; %ANTARES p=[p;curp(:,3)];
end;
p(p<=0)=[];
%MYGUESSPORCROS p=0.0052683*p*(250000/48000); %ANTARES p=0.000512*p;
diffp=diff(p);
diffp(diffp<=mindiff)=[];
diffp(diffp>=maxdiff)=[];
if isempty(diffp), continue; end;
[NUMici{Nbins}] = hist(diffp,binBorders{Nbins});

%allMOONpercBYday(istr)=round(mooncalendar2009{month}(100+day)*100);
allMOONpercBYday(istr)=round(mooncalendar2012{month}(100+day)*Nbins);
allNUMiciBYday(istr,:)=NUMici{Nbins};


allMOONpercBYday(istr)



allNUMiciBYmoonperc{Nbins}(1+allMOONpercBYday(istr),:)=allNUMiciBYmoonperc{Nbins}(1+allMOONpercBYday(istr),:)+NUMici{Nbins};
nNUMiciBYmoonperc(1+allMOONpercBYday(istr))=nNUMiciBYmoonperc(1+allMOONpercBYday(istr))+1;

meanNUMici{Nbins}=meanNUMici{Nbins}+NUMici{Nbins};
end;

meanNUMici{Nbins}=meanNUMici{Nbins}/length(dirstr);
for ibin=1:size(allNUMiciBYmoonperc{Nbins},2)
allNUMiciBYmoonperc{Nbins}(:,ibin)=allNUMiciBYmoonperc{Nbins}(:,ibin)./nNUMiciBYmoonperc;
end;

for jphase=1:size(allNUMiciBYmoonperc{Nbins},1)
allNUMiciBYmoonperc{Nbins}(jphase,:)=allNUMiciBYmoonperc{Nbins}(jphase,:)/sum(allNUMiciBYmoonperc{Nbins}(jphase,:));    
end;

existPhases=unique(sort(ALLperc(allMOONpercBYday+1)+1));
[X,Y] = meshgrid(existPhases,1:size(allNUMiciBYmoonperc{Nbins},2));
[XI,YI] = meshgrid(1:size(allNUMiciBYmoonperc{Nbins},1),1:size(allNUMiciBYmoonperc{Nbins},2));
allNUMiciBYmoonpercINTERP{Nbins} = interp2(X,Y,allNUMiciBYmoonperc{Nbins}(existPhases,:)',XI,YI);

save(['iciBYmoonpercaug9.mat'],'allNUMiciBYmoonpercINTERP','allNUMiciBYmoonperc','meanNUMici','binBorders','NUMici');
end;

load(['iciBYmoonpercaug9.mat']); %load(['iciBYmoonperc.mat']); %
for maxSmooth=[4 7 5] %wrev([4:7])
allNUMiciBYmoonpercINTERPsmooth{Nbins}= allNUMiciBYmoonpercINTERP{Nbins};
for raz=3:maxSmooth
for i=1:size(allNUMiciBYmoonpercINTERPsmooth{Nbins},2)
allNUMiciBYmoonpercINTERPsmooth{Nbins}(:,i)=smooth(allNUMiciBYmoonpercINTERPsmooth{Nbins}(:,i));
end;    
for i=1:size(allNUMiciBYmoonpercINTERPsmooth{Nbins},1)
allNUMiciBYmoonpercINTERPsmooth{Nbins}(i,:)=smooth(allNUMiciBYmoonpercINTERPsmooth{Nbins}(i,:));
end;
% for i=1:size(allNUMiciBYmoonpercINTERPsmooth{Nbins},2)
% allNUMiciBYmoonpercINTERPsmooth{Nbins}(:,i)=smooth(allNUMiciBYmoonpercINTERPsmooth{Nbins}(:,i));
% end;
end;

% PeakLinesICImoonperc{Nbins}=zeros(Nmoonperc+1,allNbins(end));
% for iperc=1:size(allNUMiciBYmoonpercINTERPsmooth{Nbins},2)
% [PeakICImoonperc,LocPeakICImoonperc] = findpeaks(allNUMiciBYmoonpercINTERPsmooth{Nbins}(:,iperc),'MINPEAKDISTANCE',allNbins(end)/10); %min(10,allNbins(end)/10));
% PeakLinesICImoonperc{Nbins}(iperc,coefNbins(indNbins)*LocPeakICImoonperc)=1;%=PeakICImoonperc;
% end;
ydive=100*mean(allNUMiciBYmoonpercINTERPsmooth{Nbins}(:,unique(round([65:90]*Nbins/100))),2);
xdive=linspace(0,100,length(ydive));
figure;plot(xdive,ydive,'lineWidth',2);
                        ylabel(['P(ICI)-P(ICI(full moon)), %']); xlabel('lunar phase, % from full');
                        title(['The probapility of diving-ICI (the diving-ICI at full moon is taken as a baseline)'],'FontSize',13); 
saveas(gcf,['Nbins=' num2str(Nbins) 'Smooth=' num2str(maxSmooth) 'divingICIsaug9.jpg']);
saveas(gcf,['Nbins=' num2str(Nbins) 'Smooth=' num2str(maxSmooth) 'divingICIsaug9.eps'],'psc2');
close all;

yShallowEcho=mean(allNUMiciBYmoonpercINTERPsmooth{Nbins}(:,unique(round([24:44]*Nbins/100))),2); %(:,34),2); %
yMiddleEcho=mean(allNUMiciBYmoonpercINTERPsmooth{Nbins}(:,unique(round([40:60]*Nbins/100))),2); %(:,50),2); %
yDeepEcho=mean(allNUMiciBYmoonpercINTERPsmooth{Nbins}(:,unique(round([59:79]*Nbins/100))),2); %(:,69),2); %
figure;plot(xdive,yShallowEcho,xdive,yMiddleEcho,xdive,yDeepEcho,'lineWidth',2);
legend('Shallow-dive echo','Middle-dive echo','Deep-dive echo');
                        ylabel(['Shallow, Middle and Deep echo']); xlabel('lunar phase, % from full');
                        title(['The probapility of Shallow, Middle and Deep echo-ICI'],'FontSize',12); 
saveas(gcf,['Nbins=' num2str(Nbins) 'Smooth=' num2str(maxSmooth) 'DMSechoICIsaug9.jpg']);
saveas(gcf,['Nbins=' num2str(Nbins) 'Smooth=' num2str(maxSmooth) 'DMSechoICIsaug9.eps'],'psc2');
close all;
figure;plot(xdive(1:end-1),100*(yShallowEcho(1:end-1)-yDeepEcho(1:end-1))./yDeepEcho(1:end-1),'lineWidth',2);
                        ylabel(['Shallow-Deep echo, %']); xlabel('lunar phase, % from full');
                        title(['The probapility difference Shallow-Deep echoes as % from Deep echoes'],'FontSize',12); 
saveas(gcf,['Nbins=' num2str(Nbins) 'Smooth=' num2str(maxSmooth) 'DSechoICIsaug9.jpg']);
saveas(gcf,['Nbins=' num2str(Nbins) 'Smooth=' num2str(maxSmooth) 'DSechoICIsaug9.eps'],'psc2');
close all;
yAverEcho=sum([yShallowEcho,yDeepEcho],2);
figure;hold on;
plot(xdive(1:end-1),100*yShallowEcho(1:end-1)./yAverEcho(1:end-1),'lineWidth',2,'LineStyle','--');
plot(xdive(1:end-1),100*yDeepEcho(1:end-1)./yAverEcho(1:end-1),'lineWidth',2,'LineStyle','-');
legend('Shallow-dive echo, %','Deep-dive echo, %','Location','NorthWest');
                        ylabel(['Shallow and Deep echo, % from total Shallow+Deep echoes']); xlabel('lunar phase, % from full');
                        title(['The Deep or Shallow echoes dependance on lunar phase'],'FontSize',12); 
saveas(gcf,['Nbins=' num2str(Nbins) 'Smooth=' num2str(maxSmooth) 'DandSechoICIsaug9.jpg']);
saveas(gcf,['Nbins=' num2str(Nbins) 'Smooth=' num2str(maxSmooth) 'DandSechoICIsaug9.eps'],'psc2');
close all;



% figure;imagesc(PeakLinesICImoonperc{Nbins});colormap(1-colormap('Gray'));
%                         xticklabels =linspace(mindiff,maxdiff,8);
%                         xticklabels = round(xticklabels*10)/10;
%                         xticks = linspace(1, size(PeakLinesICImoonperc{Nbins}, 2), 8);
%                         set(gca, 'XTick', xticks, 'XTickLabel', xticklabels);
%                         xlabel(['ICI,sec ']); ylabel('lunar phase, % from full');
%                         title(['Peaks of ICI in dependance on lunar phase'],'FontSize',14);   
% saveas(gcf,['Nbins=' num2str(Nbins) 'Smooth=' num2str(maxSmooth) 'peaksaug9.jpg']);
% saveas(gcf,['Nbins=' num2str(Nbins) 'Smooth=' num2str(maxSmooth) 'peaksaug9.eps'],'psc2');
% close all;
figure;bar(binBorders{Nbins},meanNUMici{Nbins});
                        xlabel(['ICI,sec ']); ylabel('Average number of ICI');
                        title(['Accumulative histogram: ICI over all lunar phases'],'FontSize',14);
saveas(gcf,['Nbins=' num2str(Nbins) 'Smooth=' num2str(maxSmooth) 'bar1aug9.jpg']);
saveas(gcf,['Nbins=' num2str(Nbins) 'Smooth=' num2str(maxSmooth) 'bar1aug9.eps'],'psc2');
close all;
figure;bar3(allNUMiciBYmoonperc{Nbins});view(130,35);
                        xticklabels =linspace(mindiff,maxdiff,8);
                        xticklabels = round(xticklabels*10)/10;
                        xticks = linspace(1, size(allNUMiciBYmoonpercINTERP{Nbins}', 2), 8);
                        set(gca, 'XTick', xticks, 'XTickLabel', xticklabels);
                        xlabel(['ICI,sec ']); 
                        yticklabels =linspace(0,100,8);
                        yticklabels = round(yticklabels/10)*10;
                        yticks = linspace(1, size(allNUMiciBYmoonpercINTERP{Nbins}', 1), 8);
                        set(gca, 'YTick', yticks, 'YTickLabel', yticklabels);
                        ylabel('lunar phase, % from full');zlabel('Average number of ICI');
                        title(['Distribution of ICI in dependance on lunar phase'],'FontSize',14);
saveas(gcf,['Nbins=' num2str(Nbins) 'Smooth=' num2str(maxSmooth) 'bar3aug9.jpg']);
saveas(gcf,['Nbins=' num2str(Nbins) 'Smooth=' num2str(maxSmooth) 'bar3aug9.eps'],'psc2');
close all;
% figure;imagesc(allNUMiciBYmoonperc{Nbins});colormap(1-colormap('Gray'));colorbar;
%                         xticklabels =linspace(mindiff,maxdiff,8);
%                         xticklabels = round(xticklabels*10)/10;
%                         xticks = linspace(1, size(allNUMiciBYmoonperc{Nbins}, 2), 8);
%                         set(gca, 'XTick', xticks, 'XTickLabel', xticklabels);
%                         xlabel(['ICI,sec ']); ylabel('lunar phase, % from full');
%                         title(['Distribution of ICI in dependance on lunar phase'],'FontSize',14);
% saveas(gcf,['Nbins=' num2str(Nbins) 'Smooth=' num2str(maxSmooth) 'image.jpg']);
% saveas(gcf,['Nbins=' num2str(Nbins) 'Smooth=' num2str(maxSmooth) 'image.eps'],'psc2');
% close all;
figure;imagesc(allNUMiciBYmoonpercINTERP{Nbins}');colormap(1-colormap('Gray'));colorbar;
                        xticklabels =linspace(mindiff,maxdiff,8);
                        xticklabels = round(xticklabels*10)/10;
                        xticks = linspace(1, size(allNUMiciBYmoonpercINTERP{Nbins}', 2), 8);
                        set(gca, 'XTick', xticks, 'XTickLabel', xticklabels);
                        xlabel(['ICI,sec ']); 
                        yticklabels =linspace(0,100,8);
                        yticklabels = round(yticklabels/10)*10;
                        yticks = linspace(1, size(allNUMiciBYmoonpercINTERP{Nbins}', 1), 8);
                        set(gca, 'YTick', yticks, 'YTickLabel', yticklabels);
                        ylabel('lunar phase, % from full');
                        title(['Distribution of ICI in dependance on lunar phase'],'FontSize',14);
saveas(gcf,['Nbins=' num2str(Nbins) 'Smooth=' num2str(maxSmooth) 'imageINTERPaug9.jpg']);
saveas(gcf,['Nbins=' num2str(Nbins) 'Smooth=' num2str(maxSmooth) 'imageINTERPaug9.eps'],'psc2');
close all;
figure;imagesc(allNUMiciBYmoonpercINTERPsmooth{Nbins}');colormap(1-colormap('Gray'));colorbar;
                        xticklabels =linspace(mindiff,maxdiff,8);
                        xticklabels = round(xticklabels*10)/10;
                        xticks = linspace(1, size(allNUMiciBYmoonpercINTERPsmooth{Nbins}', 2), 8);
                        set(gca, 'XTick', xticks, 'XTickLabel', xticklabels);
                        xlabel(['ICI,sec ']); 
                        yticklabels =linspace(0,100,8);
                        yticklabels = round(yticklabels/10)*10;
                        yticks = linspace(1, size(allNUMiciBYmoonpercINTERP{Nbins}', 1), 8);
                        set(gca, 'YTick', yticks, 'YTickLabel', yticklabels);
                        ylabel('lunar phase, % from full');
                        title(['Distribution of ICI in dependance on lunar phase'],'FontSize',14);
saveas(gcf,['Nbins=' num2str(Nbins) 'Smooth=' num2str(maxSmooth) 'imageINTERPsmoothaug9.jpg']);
saveas(gcf,['Nbins=' num2str(Nbins) 'Smooth=' num2str(maxSmooth) 'imageINTERPsmoothaug9.eps'],'psc2');
close all;

allNUMiciBYmoonpercINTERPsmoothTHRESH{Nbins}=zeros(size(allNUMiciBYmoonpercINTERPsmooth{Nbins}));
ALLthreshold=[0.05 0.075 0.095 0.1 0.18] 
for indthreshold=1:length(ALLthreshold) 
threshold=ALLthreshold(indthreshold);     
allNUMiciBYmoonpercINTERPsmoothTHRESH{Nbins}(allNUMiciBYmoonpercINTERPsmooth{Nbins}>threshold)=indthreshold;
end;
figure;imagesc(allNUMiciBYmoonpercINTERPsmoothTHRESH{Nbins}');colormap(1-colormap('Gray')); %colorbar;
                        xticklabels =linspace(mindiff,maxdiff,8);
                        xticklabels = round(xticklabels*10)/10;
                        xticks = linspace(1, size(allNUMiciBYmoonpercINTERPsmoothTHRESH{Nbins}', 2), 8);
                        set(gca, 'XTick', xticks, 'XTickLabel', xticklabels);
                        xlabel(['ICI,sec ']); 
                        yticklabels =linspace(0,100,8);
                        yticklabels = round(yticklabels/10)*10;
                        yticks = linspace(1, size(allNUMiciBYmoonpercINTERP{Nbins}', 1), 8);
                        set(gca, 'YTick', yticks, 'YTickLabel', yticklabels);
                        ylabel('lunar phase, % from full');
                        title(['Distribution of ICI in dependance on lunar phase'],'FontSize',14);
saveas(gcf,['Nbins=' num2str(Nbins) 'Smooth=' num2str(maxSmooth) 'imageINTERPsmoothTHRESHaug9.jpg']);
saveas(gcf,['Nbins=' num2str(Nbins) 'Smooth=' num2str(maxSmooth) 'imageINTERPsmoothTHRESHaug9.eps'],'psc2');
close all;
% figure;bar3(allNUMiciBYday);saveas(gcf,['Nbins=' num2str(Nbins) 'Smooth=' num2str(maxSmooth) 'bar3.jpg']);close all;
% figure;imagesc(allNUMiciBYday);saveas(gcf,['Nbins=' num2str(Nbins) 'Smooth=' num2str(maxSmooth) 'bar3.jpg']);close all;    
end;
end;
