Home > webpage_logging > makeWebpageSpectrogram.m

makeWebpageSpectrogram

PURPOSE ^

SYNOPSIS ^

function makeWebpageSpectrogram(d,viewplots,fileroot,windowLength,colorLimits)

DESCRIPTION ^

 Make a spectrogram from each channel of the data and save to file for the
 monitoriing webpage.

 Arguments:
 d - standard CBASS data structure
 viewplots - 1 if you want to see them, 0 if not
 fileroot - [optional, default: 'webpage_spectrogram_%d.png'] - root of
    the files to be saved.  Must contain '%d', which will be formatted with
    the channel number
 windowLength - [optional, default:1024] the size of the windows over
    which to get the spectra.  The default covers about 10s of data
 colorLimits - [optional, default: [-6,4]] The limits of log(power) to
    use for the color scale.
 Returns:
  nothing

 Creates 6 files, by default called webpage_spectrogram_1.png, etc, with
 the spectrograms in.  If you know how to make matlab maintain the apsect
 ratio of the figure when saving it then please change this function to
 make that happen.
%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function makeWebpageSpectrogram(d,viewplots,fileroot,windowLength,colorLimits)
0002 %
0003 % Make a spectrogram from each channel of the data and save to file for the
0004 % monitoriing webpage.
0005 %
0006 % Arguments:
0007 % d - standard CBASS data structure
0008 % viewplots - 1 if you want to see them, 0 if not
0009 % fileroot - [optional, default: 'webpage_spectrogram_%d.png'] - root of
0010 %    the files to be saved.  Must contain '%d', which will be formatted with
0011 %    the channel number
0012 % windowLength - [optional, default:1024] the size of the windows over
0013 %    which to get the spectra.  The default covers about 10s of data
0014 % colorLimits - [optional, default: [-6,4]] The limits of log(power) to
0015 %    use for the color scale.
0016 % Returns:
0017 %  nothing
0018 %
0019 % Creates 6 files, by default called webpage_spectrogram_1.png, etc, with
0020 % the spectrograms in.  If you know how to make matlab maintain the apsect
0021 % ratio of the figure when saving it then please change this function to
0022 % make that happen.
0023 %%%%%%%%%%%%%%%%%%%%%%%%%
0024 if (~exist('viewplots'))
0025    viewplots = 1
0026 end
0027 
0028 if (~exist('fileroot','var'))
0029    fileroot='webpage_spectrogram_%d.png'; 
0030 end
0031 
0032 if (~exist('windowLength','var'))
0033     windowLength=1024;
0034 end
0035 
0036 if (~exist('colorLimits','var'))
0037     colorLimits=[-6 4];
0038 end
0039 
0040 sampling_freq = 100;
0041 nChannels=6;
0042 
0043 start_time=d.antenna0.receiver.utc(1);
0044 
0045 
0046 for channel=1:nChannels,
0047     [S F T P] = spectrogram(d.antenna0.receiver.data(:,channel),windowLength,0,windowLength,sampling_freq);
0048     lP=log10(P);
0049     if (viewplots==0)
0050         f = figure('Position',[100 100 1000 400],'visible','off');
0051     else
0052         f=figure('Position',[100 100 1000 400]);
0053     end
0054         colormap('Gray');
0055     imagesc(T/60./60,F,lP,colorLimits);
0056     colorbar();
0057     xlabel('Time [hours]');
0058     ylabel('Freq [Hz]');
0059     filename = sprintf('%s_%d.png',fileroot,channel);
0060     title_text=sprintf('Log_{10}(power) Channel %d from UTC %f',channel,start_time);
0061     title(title_text);
0062     print(f,'-dpng',filename);
0063     close();
0064 end

Generated on Sun 14-Jun-2015 17:12:45 by m2html © 2005