%Sal_Plotmaker
%m-file used to create salinity plots for each individual station (A-F)
%for the New York 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"

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

if station == 'A';
    Sal_file_surf = netcdf('5941mc-a1h.nc','nowrite');
    Sal_file_deep = netcdf('5952tcp-a1h.nc','nowrite');
elseif station == 'B';
    Sal_file_surf = netcdf('5961mc-a1h.nc','nowrite');
    Sal_file_mid_1 = netcdf('5962sc-a1h.nc','nowrite');
    Sal_file_mid_2 = netcdf('5963sc-a1h.nc','nowrite');
    Sal_file_deep = netcdf('5972tc-a1h.nc','nowrite');
elseif station == 'C';
    Sal_file_surf = netcdf('5981mc-a1h.nc','nowrite');
    Sal_file_mid_1 = netcdf('5982sc-a1h.nc','nowrite');
    Sal_file_mid_2 = netcdf('5983sc-a1h.nc','nowrite');
    Sal_file_deep = netcdf('5992tcp-a1h.nc','nowrite');
elseif station == 'D';
    Sal_file_surf = netcdf('6001mc-a1h.nc','nowrite');
    Sal_file_deep = netcdf('6012tcp-a1h.nc','nowrite');
elseif station == 'E';
    Sal_file_surf = netcdf('6021mc-a1h.nc','nowrite');
    Sal_file_deep = netcdf('6032tcp-a1h.nc','nowrite');
elseif station == 'F';
    Sal_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 salinity for stations where it is available & pull the deep data
if station == 'A' | station == 'B' | station == 'C' | station == 'D' | station == 'E';
    surf_t = Sal_file_surf{'time'}(:);
    surf_t2 = Sal_file_surf{'time2'}(:);
    surf_time = singleJD(surf_t,surf_t2);
    surf_sal = Sal_file_surf{'S_40'}(:);
    surf_depth = Sal_file_surf{'depth'}(:);
    
    deep_t = Sal_file_deep{'time'}(:);
    deep_t2 = Sal_file_deep{'time2'}(:);
    deep_time = singleJD(deep_t,deep_t2);
    deep_sal = Sal_file_deep{'S_40'}(:);
    deep_depth = Sal_file_deep{'depth'}(:);
    
subplot(4,1,1)
plot(surf_time,surf_sal)
axis([startjd endjd 26 36])
ylabel('PSU')
text(julian(2000,1,1,00),34,['Depth = ' num2str(surf_depth) ' m'])
gregaxdNM(surf_time,5)
set(gca,'ytick',[26 28 30 32 34 36],'yticklabel',[26 28 30 32 34 36])
title(['Salinity at Station ' station]);

%Plot an empty box with labels for F, where surf. sal. unavailable
elseif station == 'F';
    deep_t = Sal_file_deep{'time'}(:);
    deep_t2 = Sal_file_deep{'time2'}(:);
    deep_time = singleJD(deep_t,deep_t2);
    deep_depth = Sal_file_deep{'depth'}(:);
    deep_sal = Sal_file_deep{'S_40'}(:);
    subplot(4,1,1)
    axis([startjd endjd 26 36])
    ylabel('PSU')
    text(julian(2000,1,1,00),34,'No surface salinity instrumentation at Station F')
    gregaxdNM(deep_time,5)
    set(gca,'ytick',[26 28 30 32 34 36],'yticklabel',[26 28 30 32 34 36])
    title('Salinity at Station F')
    set(gca,'box','on')
end

%Plot the deep salinity from all stations
subplot(4,1,4)
plot(deep_time,deep_sal)
axis([startjd endjd 30 36])
ylabel('PSU')
text(julian(2000,1,1,00),34,['Depth = ' num2str(deep_depth) ' m'])
gregaxd(deep_time,5)
set(gca,'ytick',[30 32 34 36],'yticklabel',[30 32 34 36])

%Plot the mid-depth temperatures for stations B and C
if station == 'B' | station == 'C';
    mid_1_t = Sal_file_mid_1{'time'}(:);
    mid_1_t2 = Sal_file_mid_1{'time2'}(:);
    mid_1_time = singleJD(mid_1_t,mid_1_t2);
    mid_1_sal = Sal_file_mid_1{'S_40'}(:);
    mid_1_depth = Sal_file_mid_1{'depth'}(:);
    
    mid_2_t = Sal_file_mid_2{'time'}(:);
    mid_2_t2 = Sal_file_mid_2{'time2'}(:);
    mid_2_time = singleJD(mid_2_t,mid_2_t2);
    mid_2_sal = Sal_file_mid_2{'S_40'}(:);
    mid_2_depth = Sal_file_mid_2{'depth'}(:);
    
subplot(4,1,2);
    plot(mid_1_time,mid_1_sal)
    ylabel('PSU')
    axis([startjd endjd 30 36])
    text(julian(2000,1,1,00),34,['Depth = ' num2str(mid_1_depth) ' m'])
    gregaxdNM(mid_1_time,5)
    set(gca,'ytick',[30 32 34 36],'yticklabel',[30 32 34 36])
    
subplot(4,1,3);
    plot(mid_2_time,mid_2_sal)
    axis([startjd endjd 30 36])
    ylabel('PSU')
    text(julian(2000,1,1,00),34,['Depth = ' num2str(mid_2_depth) ' m'])
    gregaxdNM(mid_2_time,5)
    set(gca,'ytick',[30 32 34 36],'yticklabel',[30 32 34 36])
    
else
    subplot(4,1,2)
    axis([startjd endjd 30 36])
    ylabel('PSU')
    text(julian(2000,1,1,00),34,'Instrumentation not deployed at this station for this depth')
    gregaxdNM(deep_time,5)
    set(gca,'ytick',[30 32 34 36],'yticklabel',[30 32 34 36])
    set(gca,'box','on')
    
    subplot(4,1,3)
    axis([startjd endjd 30 36])
    ylabel('PSU')
    text(julian(2000,1,1,00),34,'Instrumentation not deployed at this station for this depth')
    gregaxdNM(deep_time,5)
    set(gca,'ytick',[30 32 34 36],'yticklabel',[30 32 34 36])
    set(gca,'box','on')
end  

orient landscape