rainfalldata=Import["C:\\Users\\vanillagrief35\\Downloads\\TOTAUXPLUVIOMETRIQUESMENSUELS1961-2015 (1).xls"];
Rainfall=Flatten[Table[rainfalldata[[5,i]][[j]],{i,26,59},{j,3,14}]];
mintempdata=Import["C:\\Users\\vanillagrief35\\Downloads\\TOGO-TEMPERATUREMOYENNEMINIMALE61-15.xls"];
maxtempdata=Import["C:\\Users\\vanillagrief35\\Downloads\\TOGO-TEMPERATUREMOYENNEMAXIMALE61-15.xls"];

Length[Rainfall]

Maxtempyears=Table[maxtempdata[[5,i]][[2]],{i,8,41}];
Mintempyears=Table[mintempdata[[5,i]][[2]],{i,7,40}];

Mintempyears=Mintempyears-1982;
Maxtempyears=Maxtempyears-1982;

Mintemp=Flatten[Table[mintempdata[[5,i]][[j]],{i,7,40},{j,3,14}]];
Maxtemp=Flatten[Table[maxtempdata[[5,i]][[j]],{i,8,41},{j,3,14}]];

Mindecyears=Flatten[Table[Mintempyears[[i]]+(j/12),{i,1,34},{j,1,12}]];
Maxdecyears=Flatten[Table[Maxtempyears[[i]]+(j/12),{i,1,34},{j,1,12}]];

Functions preceeded by “Filter” had two points erased due to missing two months in the minimum and maximum temperature data, the months missing were January and February of 2013.

Filtermint=Delete[Mintemp,{{373},{374}}];
Filtermaxt=Delete[Maxtemp,{{373},{374}}];
Filterminy=Delete[Mindecyears,{{373},{374}}];
Filtermaxy=Delete[Maxdecyears,{{373},{374}}];
Filterrain=Delete[Rainfall,{{373},{374}}];

𝒟=SmoothKernelDistribution[Transpose[{Filtermint,Filtermaxt}]];
contour=ContourPlot[PDF[𝒟,{x,y}]//Evaluate,{x,Min[Filtermint],Max[Filtermint]},{y,Min[Filtermaxt],Max[Filtermaxt]},PlotRange->All,AxesLabel->{"Min","Max"},PlotPoints->50,Contours->15,ColorFunction->"TemperatureMap"]

dens=Plot3D[PDF[𝒟,{x,y}]//Evaluate,{x,Min[Filtermint],Max[Filtermint]},{y,Min[Filtermaxt],Max[Filtermaxt]},PlotRange->All,PlotPoints->50,ColorFunction->"TemperatureMap",AxesLabel->{"Min","Max","PDF"}]
ListPointPlot3D[Transpose[{Filtermint,Filtermaxt,Filterrain}],PlotRange->All,ColorFunction->"TemperatureMap",AxesLabel->{"Min","Max","Rainfall"}]

raintable=Table[{i+1981,j,Rainfall[[12*(i-1)+j]]},{i,1,34,1},{j,1,12,1}];
ListPointPlot3D[raintable,PlotRange->All,ColorFunction->"TemperatureMap",AxesLabel->{"Year","Month of the Year","Rainfall"}]

days=Import["http://www.nku.edu/~longa/classes/2018spring/mat375/mini-projects/mini-project-no3/Mango/Mango.dates.txt","List"];
days=Rest[days];

Filterdays=Drop[days,252];

Filterdays=Delete[Filterdays,{{373},{374}}];

minmodel=LinearModelFit[Transpose[{Filterdays,Filtermint}],{1,x,
Sin[2Pi (1 x/365.25)],Cos[2Pi (1 x/365.25)],
Sin[2Pi (2 x/365.25)],Cos[2Pi (2 x/365.25)]
},x];maxmodel=LinearModelFit[Transpose[{Filterdays,Filtermaxt}],{1,x,
Sin[2Pi (1 x/365.25)],Cos[2Pi (1 x/365.25)],
Sin[2Pi (2 x/365.25)],Cos[2Pi (2 x/365.25)],
Sin[2Pi (4 x/365.25)],Cos[2Pi (4x/365.25)]},x];rainmodel=LinearModelFit[Transpose[{Filterdays,Filterrain}],{1,x,
Sin[2Pi (1 x/365.25)],Cos[2Pi (1x/365.25)],
Sin[2Pi (2 x/365.25)],Cos[2Pi (2 x/365.25)]},x];
minmodel["ParameterTable"]
maxmodel["ParameterTable"]
rainmodel["ParameterTable"]

minmodel["RSquared"]
maxmodel["RSquared"]
rainmodel["RSquared"]
minmodel["ParameterConfidenceIntervals"]
maxmodel["ParameterConfidenceIntervals"]
rainmodel["ParameterConfidenceIntervals"]

raindataplot=ListPlot[Transpose[{Filterdays,Filterrain}]];
Manipulate[
rainmodelplot=Plot[rainmodel[x],{x,t*365.25,(t+n)*365.25},PlotRange->{{t*365.25,(t+n)*365.25},{Min[Filterrain],Max[Filterrain]}},PlotLabel->"Model Versus Rain Data",AxesLabel->{"Days","Rainfall"}];
Show[rainmodelplot,raindataplot],
{{t,0},21,50,1},
{{n,1},1,5,1}]

maxtempdataplot=ListPlot[Transpose[{Filterdays,Filtermaxt}]];
Manipulate[
maxmodelplot=Plot[maxmodel[x],{x,t*365.25,(t+n)*365.25},PlotRange->{{t*365.25,(t+n)*365.25},{Min[Filtermaxt],Max[Filtermaxt]}},PlotLabel->"Model Versus Max Temp Data",AxesLabel->{"Days","Max Temp"}];
Show[maxmodelplot,maxtempdataplot],
{{t,0},21,50,1},
{{n,1},1,5,1}]

mintempdataplot=ListPlot[Transpose[{Filterdays,Filtermint}]];
Manipulate[
minmodelplot=Plot[minmodel[x],{x,t*365.25,(t+n)*365.25},PlotRange->{{t*365.25,(t+n)*365.25},{Min[Filtermint],Max[Filtermint]}},PlotLabel->"Model Versus Min Temp Data",AxesLabel->{"Days","Min Temp"}];
Show[minmodelplot,mintempdataplot],
{{t,0},21,50,1},
{{n,1},1,5,1}]

All functions proceeded by “no” are data with No Outliers.

Rainno=Delete[Filterrain,{{21},{37},{56},{59},{60},{61},{73},{84},{106},{108},{131},{139},{149},{160},{168},{193},{196},{250},{256},{258},{259},{260},{261},{262},{264},{265},{267},{268},{269},{270},{271},{275},{276},{289},{300},{312},{372},{383},{388}}];
Length[Rainno]

Mintempno=Delete[Filtermint,{{21},{37},{56},{59},{60},{61},{73},{84},{106},{108},{131},{139},{149},{160},{168},{193},{196},{250},{256},{258},{259},{260},{261},{262},{264},{265},{267},{268},{269},{270},{271},{275},{276},{289},{300},{312},{372},{383},{388}}];
Length[Mintempno]

Maxtempno=Delete[Filtermaxt,{{21},{37},{56},{59},{60},{61},{73},{84},{106},{108},{131},{139},{149},{160},{168},{193},{196},{250},{256},{258},{259},{260},{261},{262},{264},{265},{267},{268},{269},{270},{271},{275},{276},{289},{300},{312},{372},{383},{388}}];
Length[Maxtempno]

Daysno=Delete[Filterdays,{{21},{37},{56},{59},{60},{61},{73},{84},{106},{108},{131},{139},{149},{160},{168},{193},{196},{250},{256},{258},{259},{260},{261},{262},{264},{265},{267},{268},{269},{270},{271},{275},{276},{289},{300},{312},{372},{383},{388}}];
Length[Daysno]

minmodel=LinearModelFit[Transpose[{Daysno,Mintempno}],{1,x,
Sin[2Pi (1 x/365.25)],Cos[2Pi (1 x/365.25)],
Sin[2Pi (2 x/365.25)],Cos[2Pi (2 x/365.25)]
},x];
maxmodel=LinearModelFit[Transpose[{Daysno,Maxtempno}],{1,x,
Sin[2Pi (1 x/365.25)],Cos[2Pi (1 x/365.25)],
Sin[2Pi (2 x/365.25)],Cos[2Pi (2 x/365.25)],
Sin[2Pi (4 x/365.25)],Cos[2Pi (4x/365.25)]},x];
rainmodel=LinearModelFit[Transpose[{Daysno,Rainno}],{1,
Sin[2Pi (1 x/365.25)],Cos[2Pi (1x/365.25)],
Sin[2Pi (2 x/365.25)],Cos[2Pi (2 x/365.25)]},x]
minmodel["ParameterTable"]
maxmodel["ParameterTable"]
rainmodel["ParameterTable"]

minmodel["RSquared"]
maxmodel["RSquared"]
rainmodel["RSquared"]
minmodel["ParameterConfidenceIntervals"]
maxmodel["ParameterConfidenceIntervals"]
rainmodel["ParameterConfidenceIntervals"]

𝒟=SmoothKernelDistribution[Transpose[{Mintempno,Maxtempno}]];
contour=ContourPlot[PDF[𝒟,{x,y}]//Evaluate,{x,Min[Mintempno],Max[Mintempno]},{y,Min[Maxtempno],Max[Maxtempno]},PlotRange->All,PlotLabel->"Min. v. Max. as a function of Rainfall",PlotPoints->50,Contours->15,ColorFunction->"TemperatureMap"]

dens=Plot3D[PDF[𝒟,{x,y}]//Evaluate,{x,Min[Mintempno],Max[Mintempno]},{y,Min[Maxtempno],Max[Maxtempno]},PlotRange->All,PlotPoints->50,ColorFunction->"TemperatureMap",AxesLabel->{"Min","Max","PDF"}]
ListPointPlot3D[Transpose[{Mintempno,Maxtempno,Rainno}],PlotRange->All,ColorFunction->"TemperatureMap",AxesLabel->{"Min","Max","Rainfall"}]

raindataplot=ListPlot[Transpose[{Daysno,Rainno}]]

Manipulate[
rainmodelplot=Plot[rainmodel[x],{x,t*365.25,(t+n)*365.25},PlotRange->{{t*365.25,(t+n)*365.25},{Min[Rainno],Max[Rainno]}},PlotLabel->"Model Versus Rain Data",AxesLabel->{"Days","Rainfall"}];
Show[rainmodelplot,raindataplot],
{{t,0},21,50,1},
{{n,1},1,5,1}]

ListPlot[rainmodel["FitResiduals"],Filling->Axis,PlotLabel->"Residuals of Rain Data"]

scalerain=Rainno*.03/Max[Rainno];
Manipulate[
p1=ListPlot[{{Mintempno[[t]],Maxtempno[[t]]}},PlotRange->All,PlotStyle->{Black,PointSize[0.02+scalerain[[t]]]}];
p2=ListPlot[{{minmodel[Daysno[[t]]],maxmodel[Daysno[[t]]]}},PlotRange->All,PlotStyle->{Blue,PointSize[0.02+Max[{0,rainmodel[Daysno[[t]]]}]*.03/Max[Rainno]]}];
Show[contour,p1,p2],
{{t,1},1,Length[Rainno],1}]