%Temp_Plotmaker
%m-file to create plots of the temperature data from each station (A-F)
%at the NY Bight.  Labels/Location of text in general was modified for appearance
%using Adobe Illustrator
%
%Soupy Alexander, 11/18/2001
%
%Requires NetCDF toolbox, Soupy's tools "singleJD.m" and "gregaxdNM.m", and Rich's
%tool "gregaxd.m"

%Determine the file(s) corresponding to the station of interest

station = input('Enter the station of interest, use single quotes ');

if station == 'A';
    Temp_file_surf = netcdf('5941mc-a1h.nc','nowrite');
    Temp_file_deep = netcdf('5952tcp-a1h.nc','nowrite');
elseif station == 'B';
    Temp_file_surf = netcdf('5961mc-a1h.nc','nowrite');
    Temp_file_mid_1 = netcdf('5962sc-a1h.nc','nowrite');
    Temp_file_mid_2 = netcdf('5963sc-a1h.nc','nowrite');
    Temp_file_deep = netcdf('5972tc-a1h.nc','nowrite');
elseif station == 'C';
    Temp_file_surf = netcdf('5981mc-a1h.nc','nowrite');
    Temp_file_mid_1 = netcdf('5982sc-a1h.nc','nowrite');
    Temp_file_mid_2 = netcdf('5983sc-a1h.nc','nowrite');
    Temp_file_deep = netcdf('5992tcp-a1h.nc','nowrite');
elseif station == 'D';
    Temp_file_surf = netcdf('6001mc-a1h.nc','nowrite');
    Temp_file_deep = netcdf('6012tcp-a1h.nc','nowrite');
elseif station == 'E';
    Temp_file_surf = netcdf('6021mc-a1h.nc','nowrite');
    Temp_file_deep = netcdf('6032tcp-a1h.nc','nowrite');
elseif station == 'F';
    Temp_file_deep = netcdf('6043mc-a1h.nc');
end

%Set the time limits for the plot
startjd = julian(1999,12,01,00);
endjd = julian(2000,4,20,00);

%Plot the surface temperature for stations where it is available & pull the deep data
if station == 'A' | station == 'B' | station == 'C' | station == 'D' | station == 'E';
    surf_t = Temp_file_surf{'time'}(:);
    surf_t2 = Temp_file_surf{'time2'}(:);
    surf_time = singleJD(surf_t,surf_t2);
    surf_temp = Temp_file_surf{'T_20'}(:);
    surf_depth = Temp_file_surf{'depth'}(:);
    
    deep_t = Temp_file_deep{'time'}(:);
    deep_t2 = Temp_file_deep{'time2'}(:);
    deep_time = singleJD(deep_t,deep_t2);
    deep_temp = Temp_file_deep{'T_20'}(:);
    deep_depth = Temp_file_deep{'depth'}(:);
    
subplot(4,1,1)
plot(surf_time,surf_temp)
axis([startjd endjd 0 20])
ylabel('^oC')
text(julian(2000,1,1,00),15,['Depth = ' num2str(surf_depth) ' m'])
gregaxdNM(surf_time,5)
set(gca,'ytick',[0 5 10 15 20],'yticklabel',[0 5 10 15 20])
title(['Temperature at Station ' station]);

%Plot an empty box with labels for F, where surf. temp. unavailable
elseif station == 'F';
    deep_t = Temp_file_deep{'time'}(:);
    deep_t2 = Temp_file_deep{'time2'}(:);
    deep_time = singleJD(deep_t,deep_t2);
    deep_depth = Temp_file_deep{'depth'}(:);
    deep_temp = Temp_file_deep{'T_20'}(:);
    subplot(4,1,1)
    axis([startjd endjd 0 20])
    ylabel('^oC')
    text(julian(2000,1,1,00),15,'Surface temperature instrumentation not deployed at Station F')
    gregaxdNM(deep_time,5)
    set(gca,'ytick',[0 5 10 15 20],'yticklabel',[0 5 10 15 20])
    title('Temperature at Station F')
    set(gca,'box','on')
end

%Plot the deep temperature from all stations
subplot(4,1,4)
plot(deep_time,deep_temp)
axis([startjd endjd 0 20])
ylabel('^oC')
text(julian(2000,1,1,00),15,['Depth = ' num2str(deep_depth) ' m'])
gregaxd(deep_time,5)
set(gca,'ytick',[0 5 10 15 20],'yticklabel',[0 5 10 15 20])

%Plot the mid-depth temperatures for stations B and C
if station == 'B' | station == 'C';
    mid_1_t = Temp_file_mid_1{'time'}(:);
    mid_1_t2 = Temp_file_mid_1{'time2'}(:);
    mid_1_time = singleJD(mid_1_t,mid_1_t2);
    mid_1_temp = Temp_file_mid_1{'T_20'}(:);
    mid_1_depth = Temp_file_mid_1{'depth'}(:);
    
    mid_2_t = Temp_file_mid_2{'time'}(:);
    mid_2_t2 = Temp_file_mid_2{'time2'}(:);
    mid_2_time = singleJD(mid_2_t,mid_2_t2);
    mid_2_temp = Temp_file_mid_2{'T_20'}(:);
    mid_2_depth = Temp_file_mid_2{'depth'}(:);
    
subplot(4,1,2);
    plot(mid_1_time,mid_1_temp)
    axis([startjd endjd 0 20])
    ylabel('^oC')
    text(julian(2000,1,1,00),15,['Depth = ' num2str(mid_1_depth) ' m'])
    gregaxdNM(mid_1_time,5)
    set(gca,'ytick',[0 5 10 15 20],'yticklabel',[0 5 10 15 20])
    
subplot(4,1,3);
    plot(mid_2_time,mid_2_temp)
    axis([startjd endjd 0 20])
    ylabel('^oC')
    text(julian(2000,1,1,00),15,['Depth = ' num2str(mid_2_depth) ' m'])
    gregaxdNM(mid_2_time,5)
    set(gca,'ytick',[0 5 10 15 20],'yticklabel',[0 5 10 15 20])
    
else
    subplot(4,1,2)
    axis([startjd endjd 0 20])
    ylabel('^oC')
    text(julian(2000,1,1,00),15,['Mid-depth temperature instrumentation not deployed at Station' station])
    gregaxdNM(deep_time,5)
    set(gca,'ytick',[0 5 10 15 20],'yticklabel',[0 5 10 15 20])
    set(gca,'box','on')
    
    subplot(4,1,3)
    axis([startjd endjd 0 20])
    ylabel('^oC')
    text(julian(2000,1,1,00),15,['Mid-depth temperature instrumentation not deployed at Station' station])
    gregaxdNM(deep_time,5)
    set(gca,'ytick',[0 5 10 15 20],'yticklabel',[0 5 10 15 20])
    set(gca,'box','on')
end  

orient landscape