%Burst at 100,000ft
%Using a 3000g balloon this time
%Diameter: 11.45 meters approx.
clear all
close all
%% Data Input Layer 
%This is not a function, conversion handled in functions

LaunchAlt = 180; %meters

LocalTemp = 69; %Fahrenheit
LocalPres = 998.33; %mbar

AWOSTemp = 21; %Celcius
AWOSPres = 30.17; %inHg
AWOSDensity = 1300; %feet

BalloonTemp = 73; %Fahrenheit
tankPres = (2700 - 100) + (2650 - 1450); %PSI
tankTemp = 73.5; %Fahrenheit
DragCoef = .45;  

Diameter = 10.5:.1:14.5; %meters

%All in pounds. Unless you all can give it to me in grams, might be easier
PayloadString = [   6.62    %Balloon 3000g
                    4.41    %Command 2000g
                    2.0     %Bach's Box
                    0.00    %Turtlenest 810g 1.79 lbs, cut for more lift
                    .66     %Scorch 300g
                    3.0     %BADASS
                    2.31+.5];  %String:150g Parachute:900g
TotalWeight = sum(PayloadString) *1.1; %some safety factor for the weight

%% Function Call Layer

LocalData = [15;LocalTemp;LocalPres;BalloonTemp;DragCoef;tankPres;
    tankTemp;TotalWeight];
[LocalLift LocalBurst LocalSpeed LocalDelta LocalFill] = LocalMethod(LocalData,Diameter);

AWOSData = [LaunchAlt;AWOSTemp;AWOSPres;AWOSDensity;BalloonTemp;DragCoef;
    tankPres;tankTemp;TotalWeight];
[AWOSLift AWOSBurst AWOSSpeed AWOSDelta AWOSFill] = AWOSMethod(AWOSData,Diameter);

%% Results Layer
Lift = [AWOSLift LocalLift]
Delta = [AWOSDelta LocalDelta]
Speed = [AWOSSpeed LocalSpeed]
Fill = [AWOSFill LocalFill]
figure(1)
hold on
grid on 
title 'Burst Diameter vs. Burst Altitude'
xlabel 'meters'
ylabel 'feet'
plot(Diameter,AWOSBurst(:,1),'r')
plot(Diameter,LocalBurst(:,1),'b')
legend('AWOS Method','Local Method','Location','Southeast')
hold off

figure(2)
hold on
grid on 
title 'Burst Diameter vs. Burst Altitude in meters'
xlabel 'meters'
ylabel 'meters'
plot(Diameter,AWOSBurst(:,2),'r')
plot(Diameter,LocalBurst(:,2),'b')
legend('AWOS Method','Local Method','Location','Southeast')
hold off