function []=massBalancePlotF(dtc, surface_distance, bottom_distance, time_stamp, initial_snow_depth, distance_between_rangefinders)
 %%this function creates a mass balance plot from the SIMB3 datasheet.
 %for more information, visit: https://www.cryosphereinnovation.com/articles/simb3-matlab
 %Last updated: 4/23/2021 by Cameron Planck
  
%transpose arrays for plotting
dtc=dtc';
surface_distance=surface_distance';
bottom_distance=bottom_distance';
time_stamp = time_stamp';
 
%get length of datasheet
[~,n]=size(dtc);

%define surface rangefinder height above ice and snow height from first rangefinder reading
height_above_ice=surface_distance(1) + initial_snow_depth;
snow_height=height_above_ice - surface_distance;
ice_thickness = distance_between_rangefinders - height_above_ice - bottom_distance;

%realign x-axis as serial dates proleptic ISO calendar (days since
%00-Jan-000)
x=datetime(time_stamp,'ConvertFrom','excel');
x=datenum(x);

%define temperature string position (height above ice)
temp_string_length = 3.84; %standard SIMB3 temperature string has 2 cm spacing and 192 thermistors
temp_string_offset = 0; %the axial distance between the surface rangefinder and the first thermistor on the DTC
temp_string_top = height_above_ice - temp_string_offset;
temp_string_bottom = temp_string_length - temp_string_top;
temp_string_bottom = -temp_string_bottom; %make negative for plotting

%create y-axis spacing from first thermistor to last thermistor
y=linspace(temp_string_top,temp_string_bottom,192);

%generate mesh for temperature string plotting
[X,Y]=meshgrid(x,y);
 
%plot temperature string
figure('DefaultAxesFontSize',14)
pcolor(X,Y,dtc), hold on
shading interp, colormap jet
caxis([-40 0])
cb=colorbar;
cb.Location='eastoutside';

%color area between ice surface and snow height
snow_color = [125 125 125]/255; %grey
patch([x, fliplr(x)], [snow_height, zeros(1,n)], snow_color,'EdgeColor',snow_color)

%color area between snow height and upper plot boundary
patch([x, fliplr(x)], [snow_height, fliplr(2*ones(1,n))], 'white','EdgeColor','white','LineWidth',2)

%color area between bottom position and lower plot boundary
patch([x, fliplr(x)], [-ice_thickness, fliplr(-3*ones(1,n))], 'blue','EdgeColor','blue','LineWidth',4)

%format axes
clabel = get(cb,'YTickLabel');
clabel = strcat(clabel,'{\circ}C');
set(cb,'YTickLabel',clabel);
ylabel('Depth')
set(gca, 'LineWidth', 3);
ylim([-3 1])

%convert x-axis labels to dates
num_ticks = 4;
L = get(gca,'XLim');
set(gca,'XTick',linspace(L(1),L(2),num_ticks))
datetick('x', 'yyyy-mm-dd','keepticks');






