Mango Rainfall

Matthew Gall and Mari McMahon

Background

Mango is a city in Northern Togo that sits on the Oti River, and lies on the national main road for easy access to trade. During the rainy season the Oti river floods the city extensively, but during the dry season it can completely dry up into a plain for cattle to graze through. In this report we are going to try and decide if there is a relationship between the rise in temperature and rainfall in Mango, Togo. The two prior groups studied monthly and annual average temperature data and discovered there is a significant increase in temperatures occurring. Now our task is to decide if this rise in average temperature is affecting the annual rainfall.

In the second report done by Chris of putting the average of each months temperature next to the average of the monthly average of rainfall. The graphs are pictured below and as we start to model this relationship between rainfall and temperature i would suspect that there is going to be a direct relationship between the two just from looking at these graphs.

Rainfall vs. Time

rainfall=Flatten[Import["C:\\Users\\Matthew\\Desktop\\rainfall.xlsx"]];

Length[rainfall]

month=Table[i,{i,1,Length[rainfall]}];

transdata=Transpose[{month,rainfall}];

p1=ListPlot[Flatten[Import["C:\\Users\\Matthew\\Desktop\\rainfall.xlsx"]]]

As our group looked for outliers in the data we could not find any where we had a justifiable reason for throwing out a particular data point. There was a couple reasons for this however the biggest reason is that we would see very dramatic jumps in the data periodically and after a little research we found that in Mango that the dry season is extremely dry, but once February and March roll around rain starts really coming down. There were sharp increases in just the span of a month, but we saw that continually through the years as we looked at the data. Thus we could not find any outliers that needed to be thrown out.

This list plot is a three year span of time which we used to look at the periodicity of the rainfall over time.

ListPlot[{0.`,0.`,0.`,124.8`,83.5`,203.7`,88.2`,95.`,350.3`,18.`,0.`,0.`,0.`,0.`,5.2`,72.`,114.8`,138.1`,274.3`,266.2`,236.6`,54.3`,36.4`,0.9`,0.`,13.`,16.`,35.2`,122.5`,125.4`,358.5`,299.1`,184.7`,117.8`,0.`,0.`}]

lm=LinearModelFit[transdata,{Sin[2π x/12],Cos[2π x/12]},x,ConfidenceLevel->0.95]

lm["ParameterTable"]

p2=Plot[lm[x],{x,1,660}];

Show[p1,p2]

lm2=LinearModelFit[transdata,{x,Sin[2π x/12],Cos[2π x/12]},x,ConfidenceLevel->0.95];

lm2["ParameterTable"]

lm1=LinearModelFit[transdata,{Sin[2π x/12],Cos[2π x/12],Sin[ 2 Pi x/4],Cos[2 Pi x/4],Sin[2 Pi x/6],Cos[2 Pi x/ 6]},x,ConfidenceLevel->0.95]

lm1["ParameterTable"]

p3=Plot[lm1[x],{x,1,660}];

Show[p1,p3]

Show[Plot[lm1[x],{x,1,30}],p1]

lm1["ParameterConfidenceIntervals"]

lm1["RSquared"]

ListPlot[lm["FitResiduals"], Filling->Axis,PlotLabel->"Residuals Plot for Monthly Rainfall Mango Data",Axes->True]

We choose this model which had sine and cosine curves modeled every year, every four months, and every six months. We kept trying to kept trying to add periodic sine and cosine curves to better model the rainfall data however this model had all of its parameters being significant, the highest R^2, the best residual graph, and the best graphical fit. When looking at the residuals and the graph with the data and model we do see that there is a lot of data that the model is not fitting very well. As we said we tried to keep adding periodic frequencies within a time period of a year to try and capture those data points however we ran out of those periodic times and so we had to keep our model as it is now. We did not however see any significant increase in rainfall over the years. When we tried to model the data using purely a linear approach the coefficient parameter of that x was not significant. The t-statistic was -1.26002, which is relatively close to 0, and the p-value was 0.20811. Taking these into consideration we concluded that there was not significant change in rainfall over time.

Rainfall vs. Temperature

maxtemp=Flatten[{35.6,36.4,38.6,36.7,35.7,32.0,29.3,29.1,30.6,35.1,36.9,35.6,
35.5,37.7,39.2,36.9,35.0,30.6,29.9,29.2,30.5,32.8,34.9,35.7,
37.0,38.2,37.8,36.5,33.9,32.9,30.5,29.4,31.3,32.8,35.9,36.5,
35.7,38.5,38.3,36.6,35.2,32.7,30.7,28.8,30.2,34.0,35.8,35.3,
35.4,38.0,39.0,37.4,34.2,31.2,30.7,29.8,30.5,34.2,36.9,35.2,
36.7,37.7,39.2,37.5,35.4,31.7,31.3,30.0,30.6,33.7,36.7,36.3,
35.1,38.2,37.6,36.2,35.2,31.5,30.3,29.1,30.6,34.2,36.5,35.3,
35.1,37.6,38.0,34.9,35.0,31.4,30.7,30.6,30.6,34.0,35.7,36.3,
36.2,39.3,39.7,36.4,35.6,33.1,30.6,29.9,30.8,33.1,35.4,36.8,
37.2,38.0,39.3,38.9,34.3,33.5,30.3,29.1,30.0,34.7,36.3,35.0,
35.1,37.2,38.3,37.3,34.0,32.1,29.8,29.4,30.7,34.1,36.9,35.0,
35.9,38.3,38.9,36.4,34.6,33.0,31.0,30.1,31.3,33.8,36.2,35.2,
35.9,38.8,38.8,38.6,36.4,32.8,31.4,30.6,31.0,34.8,36.4,35.9,
33.8,37.1,39.2,37.8,34.9,33.2,30.5,30.2,30.5,34.0,36.0,34.7,
34.5,37.4,38.7,36.6,34.5,33.0,29.9,30.6,30.3,33.9,36.3,35.9,
35.2,37.0,38.7,37.5,33.9,30.9,30.5,30.3,32.1,32.5,35.5,35.8,
36.6,37.7,38.2,38.9,35.3,33.0,31.4,30.3,31.6,34.0,36.8,34.2,
36.3,38.9,38.0,35.2,33.5,32.7,30.0,30.7,31.5,34.3,35.6,36.3,
37.0,38.1,38.7,38.5,34.7,31.8,30.9,31.1,31.4,34.2,35.8,34.6,
36.7,38.0,39.5,39.2,35.5,32.0,31.7,30.3,32.0,33.6,36.0,33.7,
34.6,38.2,38.4,36.2,33.9,33.3,30.9,30.4,32.3,35.9,36.4,36.6,
35.0,36.5,37.6,37.1,34.5,32.3,31.1,30.7,32.1,33.8,35.6,35.0,
31.9,38.4,39.3,38.8,36.2,31.9,30.8,31.0,31.7,35.8,37.0,36.0,
35.0,37.1,37.5,35.8,34.0,33.3,32.5,32.3,31.8,34.1,36.5,34.0,
35.9,36.3,38.8,37.3,35.7,33.0,30.5,30.3,31.1,35.1,37.0,33.5,
34.9,38.7,39.1,38.1,36.9,33.6,30.5,30.9,31.2,34.4,34.9,33.6,
36.2,38.8,38.8,40.3,38.3,33.1,31.8,31.5,32.4,34.7,37.6,35.5,
34.6,38.0,39.9,37.6,36.7,31.9,30.5,29.8,31.2,35.6,37.1,33.9,
33.8,36.0,38.0,39.6,37.4,32.3,31.2,30.4,31.8,33.9,37.3,35.0,
35.0,36.7,39.3,38.4,35.6,33.3,30.9,31.3,32.4,35.4,37.4,36.5,
36.7,38.8,38.8,37.2,33.6,33.1,30.7,31.0,32.8,34.4,36.4,35.0,
33.7,37.9,39.5,37.5,34.2,32.4,30.9,30.6,31.9,35.2,35.1,35.7,
35.3,38.0,38.8,39.6,36.9,33.9,30.8,31.4,32.0,35.1,37.4,35.7,
34.9,37.6,40.0,39.0,35.9,32.7,30.8,30.9,31.9,33.9,36.1,34.7,
34.3,37.2,39.7,38.6,36.5,34.1,32.0,30.7,33.0,34.7,36.7,36.5,
37.7,39.2,40.2,37.5,35.0,32.6,32.0,30.8,31.8,34.1,36.4,37.0,
37.0,36.5,38.3,36.7,34.0,30.2,31.5,32.0,33.8,35.6,37.2,36.6,
36.2,39.4,40.0,40.4,36.5,33.0,32.2,31.1,32.1,35.5,37.9,36.1,
36.7,37.1,40.6,38.1,36.8,34.5,31.3,30.5,31.3,34.3,37.6,35.9,
36.9,35.8,39.6,39.7,36.5,33.3,31.5,31.4,32.6,35.5,37.8,36.1,
36.5,37.4,40.5,39.4,36.5,34.1,31.9,30.4,31.5,34.4,36.4,35.5,
35.6,37.7,38.9,38.1,35.3,32.6,30.9,31.5,33.2,34.6,37.7,36.5,
36.7,40.0,39.7,37.3,37.8,32.7,32.0,31.8,32.6,36.3,38.1,36.4,
36.4,39.4,39.1,37.2,35.1,32.8,31.7,31.9,32.7,36.5,37.5,37.9,
34.4,38.9,40.5,39.2,36.4,33.6,31.9,31.6,32.9,35.7,38.4,37.6,
37.9,39.2,40.7,40.3,35.9,34.7,32.9,31.7,31.9,35.2,37.3,36.3,
35.0,39.2,40.7,38.3,35.6,33.8,32.0,30.6,32.4,36.4,37.9,36.2,
33.4,37.6,39.5,39.0,35.8,33.3,31.6,31.2,32.3,35.5,38.3,37.0,
35.4,39.7,40.6,37.5,35.8,34.5,31.6,31.6,32.4,34.7,36.8,37.7,
37.6,40.1,40.8,35.2,35.9,33.6,31.3,31.1,31.5,33.9,36.8,36.7,
35.7,38.3,40.3,39.2,36.9,34.1,32.4,31.4,32.5,34.7,37.8,35.8,
35.3,38.1,39.9,37.6,33.9,32.6,31.2,30.5,31.8,34.6,37.4,37.8,
36.0,38.7,40.0,36.8,34.6,32.9,32.0,30.8,32.3,35.0,37.7,35.6,
36.4,38.1,39.2,37.5,36.0,34.6,32.7,30.7,31.4,35.0,37.3,35.9,
34.5,38.1,38.6,38.6,37.9,35.3,32.1,30.8,32.0,34.4,36.9,33.8
}];

mintemp=Flatten[{16.9,17.5,21.7,23.8,22.9,21.1,20.6,19.9,19.5,19.8,16.8,14.8,
15.0,17.9,23.0,23.8,22.0,20.4,20.3,20.1,20.5,20.4,20.7,15.7,
16.3,21.7,22.4,23.1,22.0,20.7,19.9,19.8,19.9,19.9,15.8,15.4,
17.6,19.0,24.0,24.5,23.8,21.8,21.9,21.7,21.5,21.9,20.3,19.7,
19.5,22.1,23.7,24.8,23.3,21.9,22.0,21.5,21.2,21.5,17.7,16.7,
17.2,19.1,24.4,25.1,24.3,22.5,22.2,22.2,21.8,21.4,19.7,17.6,
17.0,21.7,23.6,24.5,23.8,22.1,22.1,21.7,21.6,21.5,19.5,20.1,
17.2,21.4,24.7,23.9,23.6,22.3,22.1,22.1,21.6,21.8,20.1,19.4,
17.3,22.7,26.1,25.1,23.3,22.2,21.4,21.5,21.3,21.3,17.9,16.1,
17.7,20.2,24.3,26.0,22.9,22.3,21.1,21.2,20.5,21.0,18.1,16.5,
15.5,21.1,24.5,24.0,22.5,21.3,20.1,20.5,20.4,20.6,18.5,19.6,
18.1,21.3,25.1,25.0,24.4,22.9,22.1,21.9,22.0,22.1,18.8,19.2,
19.0,22.5,24.7,25.8,24.8,23.1,22.4,22.3,21.4,22.4,18.9,17.9,
18.2,20.1,25.1,25.8,24.4,23.1,22.2,22.3,21.4,21.9,18.7,16.7,
16.1,20.1,24.0,24.7,23.9,22.4,21.9,22.1,21.6,21.6,19.3,18.2,
18.0,22.3,23.7,24.0,23.4,21.8,22.0,21.4,21.9,21.6,20.1,17.0,
18.6,20.3,23.2,26.4,24.9,23.4,22.7,22.3,22.4,21.3,18.2,17.8,
18.4,21.8,25.0,24.9,23.9,22.9,21.9,21.8,21.6,22.0,19.3,18.1,
19.3,19.7,25.1,26.1,24.4,23.3,22.1,23.1,21.7,22.4,20.4,17.8,
20.2,22.4,24.7,26.8,24.9,23.7,22.4,22.1,22.1,21.9,20.4,17.4,
16.8,21.5,24.9,26.0,23.8,23.1,22.5,22.0,22.0,22.2,19.4,18.5,
17.4,21.8,24.2,25.1,24.0,22.8,22.3,21.9,21.6,21.5,18.7,18.1,
17.5,21.8,23.9,26.4,24.9,23.0,22.2,22.5,21.5,21.4,19.4,19.7,
19.0,20.4,24.4,25.3,24.1,23.0,22.3,22.2,21.9,22.3,21.5,18.6,
20.3,21.4,26.4,26.1,25.2,23.3,21.8,22.2,21.8,22.0,20.8,18.3,
18.3,22.7,25.6,26.1,25.4,23.4,22.3,22.4,22.1,22.3,19.4,17.8,
20.0,22.4,24.6,26.9,26.6,23.7,23.0,22.8,22.9,22.4,20.2,20.2,
20.5,22.4,26.6,26.0,25.3,22.8,22.4,22.3,22.6,21.9,20.2,19.0,
17.7,20.5,23.7,26.5,25.1,22.8,22.5,22.5,22.1,21.6,19.4,19.3,
20.7,21.3,23.2,26.4,24.9,23.2,22.5,22.8,22.4,22.7,22.7,21.3,
20.6,23.7,26.3,25.8,24.5,23.9,22.6,22.7,22.5,22.1,19.7,18.7,
19.3,21.4,25.2,25.9,24.2,22.7,22.4,22.4,22.2,22.2,20.3,18.7,
18.1,21.9,25.0,26.9,25.6,23.3,22.3,22.6,22.6,22.4,22.9,19.6,
20.1,21.6,26.1,26.5,24.4,23.2,22.9,22.7,22.8,22.2,18.9,17.6,
17.8,20.5,25.4,26.4,24.8,24.2,22.9,22.4,22.7,22.5,20.0,19.8,
19.4,23.4,26.3,25.7,24.8,23.1,22.8,22.6,22.2,21.7,18.1,18.6,
19.9,20.9,24.6,25.0,24.8,22.9,22.5,22.5,22.8,23.2,20.7,19.4,
19.9,23.5,24.9,24.9,24.8,23.5,23.3,22.7,22.6,23.0,20.0,19.9,
20.1,21.9,26.5,25.8,24.8,23.9,22.9,22.9,22.0,22.1,20.2,18.3,
21.4,19.6,23.9,26.6,24.8,22.3,22.8,22.4,22.1,22.3,20.0,18.1,
18.7,20.6,25.3,27.1,24.8,23.8,22.8,22.0,21.8,21.8,19.5,20.0,
18.5,21.2,24.6,25.6,24.8,23.0,22.1,22.6,23.1,22.6,20.6,18.8,
20.2,24.3,25.1,25.9,24.8,23.5,23.1,23.1,22.8,23.4,21.3,19.1,
20.5,24.5,25.2,25.7,24.8,22.9,22.7,22.9,22.2,23.0,22.3,20.6,
19.6,25.2,27.7,27.6,24.8,23.9,23.2,23.0,22.7,22.5,20.8,20.2,
21.9,22.8,26.9,27.7,24.8,23.8,23.6,23.1,22.2,23.2,19.6,19.4,
19.2,22.5,25.7,26.3,24.8,23.7,23.1,22.6,22.4,23.2,22.6,20.2,
18.0,21.2,25.4,26.2,24.8,23.3,22.9,22.6,22.7,22.7,19.6,21.0,
19.5,24.3,27,25.8,24.8,23.9,22.8,23.2,22.9,23.2,21.4,20.2,
19.9,24.4,27.4,24.9,24.8,24.6,23.6,23.1,23.2,23.1,21.4,18.1,
19.2,24.4,26.7,25.8,24.8,24.1,23.1,22.9,22.8,22.9,20.3,18.9,
19.0,23.2,26.4,25.8,24.8,23.1,22.7,22.2,23.1,22.8,22.2,20.8,
19.6,21.9,27.2,25.3,24.8,23.2,23.0,23.0,22.6,22.9,22.2,19.4,
20.9,23.0,26.3,26.2,24.8,23.8,23.9,23.0,22.3,23.2,22.6,19.5,
19.3,23.4,25.6,26.2,24.8,24.9,23.8,23.4,24.6,23.1,21.3,18.6
}];

newdata=Transpose[{maxtemp,rainfall}];

ListPlot[newdata,PlotLabel->" Max Temperature vs. Rainfall over Time",AxesLabel->{"max temperature","rainfall"}]

In this graph we can really see that it seems that as temperatures are increases we are seeing less and less rainfall in Mango we explore this a little farther along in the report.

newdata1=Transpose[{mintemp,rainfall}];

This next graph is minimum monthly temperature versus rainfall graph.

p4=ListPlot[newdata1,PlotLabel->" Min Temperature vs. Rainfall over Time",AxesLabel->{" min temperature","rainfall"}]

months=Table[n,{n,0,659}];
datamax=Table[{months[[u]],maxtemp[[u]]},{u,660}];
datamin=Table[{months[[u]],mintemp[[u]]},{u,660}];

qm= LinearModelFit[datamax,{x,Sin[(1/6)* π* x],Cos[(1/6) *π* x]},x,ConfidenceLevel->0.95];

qmin= LinearModelFit[datamin,{x,x^2,Sin[(1/6)* π* x],Cos[(1/6) *π* x]},x,ConfidenceLevel->0.95];

p10=ListPlot[datamin];
p2=Plot[qmin[x],{x,0,30},PlotRange->{{0,30},{0,40}}];
Show[p2,p10,Frame->True,PlotLabel->"Report 2 Minimum graph",FrameLabel->{"Months since January 1961","Monthly Minimum Average temperature"}]

Show[Plot[lm1[x],{x,1,30}],p1]

p3=ListPlot[datamax];
p4=Plot[qm[x],{x,0,30},PlotRange-> {{0,30},{0,40}}];
Show[p4,p3,Frame->True,PlotLabel->"Report 2 Maximum graph",FrameLabel->{"Months since January 1961","Monthly Average temperature"}]

Show[p2,p1,p3,p4,Plot[lm1[x]*40/250,{x,1,30}]]

This is a list plot and models for minimum temp, maximum temp, and rainfall all in a two and a half year span and all of the graphs overlap with each other.

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

This is a PDF and it gives us min/ max temperature combinations.

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

This 3-D plot shows the probability of rainfall at these certain minimum and maximum temperatures.

These models and graphs above are giving us an idea of when the most rainfall is occurring and at what minimum and maximum temperatures the most rainfall is occurring. The models of these data sets are also displayed. As we were discussing above rainfall amount is peaking when the maximum monthly averages are at its lowest and rainfall is also decreases dramatically when the maximum monthly temperatures are at its highest. However we do not see this same relationship when we look at the minimum monthly temperature averages and the rainfall monthly averages. For minimum monthly temperatures when we look back at the graph of “Min Temperature vs. Rainfall over time” we see that we are getting the highest rainfall in times of moderate minimum monthly temperatures. Thus the maximum and minimum monthly temperatures are out of phase when it comes to comparing them with rainfall amount over time.

Conclusion

Moving forward we would like any further details about the collection of both data sets rainfall and temperatures.Our rainfall data did not appear to have any mistakes or outliers but other cities may not have been so lucky.For us to analyze how the rise in minimum and maximum temperatures is affecting the Togolese we would like to feel more confident in the consistency of the methods used for data collection.We would also like to get the Togolese meteorologists thoughts on the rise in temperature and how it could affect their nation.