%OBS_ATTN_Plotmaker
%m-file to create plots of the optical backscatter and beam attenuation data 
%from each station (A-E) at the NY Bight.  
%Labels/Location of text in general was modified for appearance using 
%Adobe Illustrator.  Station F not included since none of the 5 plotted
%variables are available from this station.
%
%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';
    %No ATTN data available
    OBS_file_1 = netcdf('5952tcp-a1h.nc','nowrite');
    OBS_file_2 = netcdf('5952obs-a1h_d2.nc','nowrite');
elseif station == 'B';
    ATTN_file_1 = netcdf('5962att-a1h.nc','nowrite');
    ATTN_file_2 = netcdf('5963att-a1h.nc','nowrite');
    OBS_file_1 = netcdf('5972tc-a1h.nc','nowrite');
    OBS_file_2 = netcdf('5972obs-a1h_d2.nc','nowrite');
elseif station == 'C';
    ATTN_file_1 = netcdf('5982att-a1h.nc','nowrite');
    OBS_file_1 = netcdf('5992tcp-a1h.nc','nowrite');
    OBS_file_2 = netcdf('5992obs-a1h_d2.nc','nowrite');
elseif station == 'D';
    %No ATTN data available
    OBS_file_1 = netcdf('6012tcp-a1h.nc','nowrite');
    OBS_file_2 = netcdf('6012obs-a1h_d2.nc','nowrite');
elseif station == 'E';
    %No ATTN data available
    OBS_file_1 = netcdf('6032tcp-a1h.nc','nowrite');
    OBS_file_2 = netcdf('6032obs-a1h_d2.nc','nowrite');
end

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

%Pull out the beam attenuation data, where available
if station == 'B' | station == 'C';
    ATTN_1_t = ATTN_file_1{'time'}(:);
    ATTN_1_t2 = ATTN_file_1{'time2'}(:);
    ATTN_1_time = singleJD(ATTN_1_t,ATTN_1_t2);
    ATTN_1_data = ATTN_file_1{'ATTN_55'}(:);
    ATTN_1_depth = ATTN_file_1{'depth'}(:);
end

if station == 'B';
    ATTN_2_t = ATTN_file_2{'time'}(:);
    ATTN_2_t2 = ATTN_file_2{'time2'}(:);
    ATTN_2_time = singleJD(ATTN_2_t,ATTN_2_t2);
    ATTN_2_data = ATTN_file_2{'ATTN_55'}(:);
    ATTN_2_depth = ATTN_file_2{'depth'}(:);
end   

%Pull out the optical backscatter data
OBS_1_t = OBS_file_1{'time'}(:);
OBS_1_t2 = OBS_file_1{'time2'}(:);
OBS_1_time = singleJD(OBS_1_t,OBS_1_t2);
OBS_1_data = OBS_file_1{'NEP_56'}(:);
OBS_1_depth = OBS_file_1{'depth'}(:);

OBS_2_t = OBS_file_2{'time'}(:);
OBS_2_t2 = OBS_file_2{'time2'}(:);
OBS_2_time = singleJD(OBS_2_t,OBS_2_t2);
OBS_2_data = OBS_file_2{'NEP_56'}(:);
OBS_2_depth = OBS_file_2{'depth'}(:);

%Plot the beam attenuation data, where available, in subplots 1 & 2
subplot(4,1,1)
if station == 'B' | station == 'C';
    plot(ATTN_1_time,ATTN_1_data)
    axis([startjd endjd 0 10])
    ylabel('m^-^1')
    text(julian(2000,1,1,00),6,['Beam Attenuation at ' num2str(ATTN_1_depth) ' m'])
    gregaxdNM(ATTN_1_time,5)
    set(gca,'ytick',[0 2 4 6 8 10],'yticklabel',[0 2 4 6 8 10])
    title(['Station ' station ' - Beam Attenuation/Optical Backscatter'])
else
    axis([startjd endjd 0 10])
    ylabel('m^-^1')
    text(julian(2000,1,1,00),6,['Beam attenuation data unavailable from Station ' station])
    gregaxdNM(OBS_1_time,5)
    set(gca,'ytick',[0 2 4 6 8 10],'yticklabel',[0 2 4 6 8 10])
    title(['Station ' station ' - Beam Attenuation/Optical Backscatter'])
    set(gca,'box','on')
end

subplot(4,1,2)
if station == 'B';
    plot(ATTN_2_time,ATTN_2_data)
    axis([startjd endjd 0 10])
    ylabel('m^-^1')
    text(julian(2000,1,1,00),6,['Beam Attenuation at ' num2str(ATTN_2_depth) ' m'])
    gregaxdNM(ATTN_2_time,5)
    set(gca,'ytick',[0 2 4 6 8 10],'yticklabel',[0 2 4 6 8 10])
else
    axis([startjd endjd 0 10])
    ylabel('m^-^1')
    text(julian(2000,1,1,00),6,['Beam attenuation data unavailable from Station ' station])
    gregaxdNM(OBS_1_time,5)
    set(gca,'ytick',[0 2 4 6 8 10],'yticklabel',[0 2 4 6 8 10])
    set(gca,'box','on')
end


%Plot the optical backscatter data in subplots 3 & 4
subplot(4,1,3)
plot(OBS_1_time,OBS_1_data)
axis([startjd endjd 0 10])
ylabel('v')
text(julian(2000,1,1,00),3,['Optical Backscatter at ' num2str(OBS_1_depth) ' m'])
gregaxdNM(OBS_1_time,5)
set(gca,'ytick',[0 2 4 6 8 10],'yticklabel',[0 2 4 6 8 10])

subplot(4,1,4)
plot(OBS_2_time,OBS_2_data)
axis([startjd endjd 0 10])
ylabel('v')
text(julian(2000,1,1,00),3,['Optical Backscatter at ' num2str(OBS_2_depth) ' m'])
gregaxd(OBS_2_time,5)
set(gca,'ytick',[0 2 4 6 8 10],'yticklabel',[0 2 4 6 8 10])

orient landscape