CDIP banner
CDIP banner recent historic documents
sub-menu
Documentation
 
FAQs & Summaries
Glossary
Publications
 
Introduction
  History and Funding
  Program Goals
Wave Measurement
  Wave Generation
  Wave Dynamics
  Irregular Waves
  Spectral Analysis
  Gauging Waves
  Hurricane Events
  Tsunami Events
Instrumentation
  Underwater Sensors
  Surface Buoys
  Meteorological
Data Acquisition
  System Organization
  Hardware
  Software
Data Processing
  System Organization
  Software
  Quality Control
Data Management
  Stations and Sets
  Files and Storage
CDIP Products
  Data Formats
  Web Products
  COOS Integration
  QARTOD
  Wave Eval Tool
  Metadata
  Custom Products
  NDBC XML/NWS Format
  NDBC Dial-A-Buoy
  Access Instructions
 
Related Links

PARAMETERS OVERLAY INTERACTIVE PLOT

Plots the Hs, Tp and Dp for up to 3 stations.

Source Code:


function  good_plot = make_parameter(data_idx, pm_info, sta_info, number_date, ...
                         data, num_stations, marker, pid, wkg1);


  data_idx
  max_gap = 1/6; % number_dates are in days (4 hours)

  max_val = -1e10;
  min_val =  1e10;

  max_date =    0;
  min_date = 1e10;

  hold on;

  stn_idxs = [];

  good_plot = 0;

  for stn=1:num_stations  
    
    if ( any(data(stn,:,data_idx)>=0) ) 

      draw_gapped_line(number_date(stn,:), data(stn,:,data_idx), marker(stn), max_gap);

      max_val = max([max_val,data(stn,:,data_idx)]);
      min_val = min([min_val,data(stn,:,data_idx)]);

      max_date = max([max_date,number_date(stn,:)]);
      min_date = min([min_date,number_date(stn,:)]);

      stn_idxs = [ stn_idxs, stn ];

      good_plot = 1;

    end

  end


% CREATE X AND Y LABELS IF ANY DATA

  if ( good_plot == 1 & max_val > -1e10 & min_val < 1e10 )

% resize y axis

    pos = get(gca,'Position').*[.5 1 1.15 .9]
    set(gca,'Position',pos);

    timespan= max_date - min_date;
    timediv=(timespan/10);
    xar=[min_date:timediv:max_date];

    xlab1=datestr(xar,'mm/dd/yy');
    xlab2=datestr(xar,'HH:MM');

    last_label = length(xlab2);
    dt = [ xlab1(1,1:8),' ',xlab2(1,1:5),' to ', ...
         xlab1(last_label,1:8),' ',xlab2(last_label,1:5) ];

    set(gca,'XLim',[min_date max_date]);
    set(gca,'XTick',xar);
    set(gca,'XTickLabel',xlab1,'fontsize',11);
 
    sl=size(xlab1);
    for i=1:sl(1)
      text(xar(i),-.056*max_val,xlab2(i,1:5),'HorizontalAlignment','center','fontsize',11);
    end
 
    ylim([0 max_val*1.1]);
    ylb = strcat(pm_info.subtitle(data_idx),pm_info.pmunits(data_idx));
    ylabel(ylb,'FontSize',12,'FontWeight','bold');
    text(xar(6),-.1*max_val,'Date (UTC)','HorizontalAlignment','center', ...
    'FontSize',12,'FontWeight','bold');
    text(xar(9),-.12*max_val,'http://cdip.ucsd.edu','HorizontalAlignment','left', ...
    'FontSize',9);
 
    grid;
  
    axes('Units','Normal','Position',[0 0 1 1],'visible','off');

    text(.5,0.85,dt,'FontSize',13, ... % 'FontWeight','bold', ...
    'HorizontalAlignment','Center');

    text(0.5,.97, pm_info.subtitle(data_idx),'FontSize',15, ...
    'FontWeight','bold','HorizontalAlignment','Center');

    for i=1:num_stations
      text(0.5,.96-i*.025,sta_info(i).stname,'FontSize',12, ...
         'FontWeight','bold','Color',marker(i), ...
         'HorizontalAlignment','Center');
    end

% CONVERT PLOT TO GIF


    plt_name = ['pm',num2str(data_idx,'%2.2d'),'_',char(pid)];

    plt_png = [wkg1,plt_name,'.png']
    eval(['print -dpng -r75 ',plt_png])

    clf;

  end

Source Code:


matlabpath(pathdef);

% Example pre-pend info:
% pid = '28976';
% num_stations =  2;
% web = 1; %web interactive htmls and plots
% archive = 1; % archive plots
%-----------------------------------------------------------------------
% Name:
%   .dbase/web_programs/plotpro/matlab_scripts/compendium_ov.m
% Description:
%   Creates overlay of compendium plot. A few lines are pre-pended to this
%   script. (pid and num_stations).
% Called by:
%   .f90/plot_utils.make_plot
%-----------------------------------------------------------------------

% ADD PATH TO ACCESS MATLAB SCRIPTS

path(path,'/project/dbase/web_programs/plotpro/matlab_scripts');


% SET-UP FIGURE

h=figure('Position',[10 10 800 800],'Name',...
   'Compendium Plot','NumberTitle','off','paperposition',[0 0 7.75 7.75], ...
   'defaultaxesposition',[0.15 0.12 .75 .775], 'visible', 'off');

overlay_id = ['01';'02';'03'];
marker = ['b';'r';'m'];


[wkg_full, wkg_short] = wkg_path


% IF ONE STATION PLOT SET NUM_STATIONS TO 1

if ( ~exist('num_stations') )
  num_stations = 1;
end


% LOAD PARAMETER FILE HEADER INFO

parameter_info;


% INITIALIZE VARIABLES USED BELOW

max_records = 2000;
max_stations = 3;

year = zeros(1,max_records)*inf;
month = zeros(1,max_records)*inf;
day = zeros(1,max_records)*inf;
hour = zeros(1,max_records)*inf;
minute = zeros(1,max_records)*inf;
number_date = zeros(num_stations,max_records)*inf;
data = zeros(max_stations, max_records, num_plots)*inf;


% GET STATION INFO, IDENTIFY SURGE AND LOAD DATA

overlay_id = ['01';'02';'03'];

col_idxs = 5 + [1:num_plots];
data_idxs = [1:num_plots];

for stn=1:num_stations

  sta_info(stn) = read_info_file([pid,overlay_id(stn,:)],wkg_full);

  eval(['load ',wkg_full,'list.',pid,overlay_id(stn,:)]);

  num_recs(stn) = size(list,1);

  year = list(:,1)';
  month = list(:,2)';
  day = list(:,3)';
  hour = list(:,4)';
  minute = list(:,5)';

  number_date(stn,1:num_recs(stn))=datenum(year,month,day,hour,minute,0);

  data(stn,1:num_recs(stn),data_idxs) = list(:,col_idxs);

end

I = find(data<0);
data(I) = NaN;


% GET WORKING PATHS

if ( archive == 1 ) % archive the plots (should be only 1 station)
  wkg_full = ['/project/dbase/web_stations/',sta_info(1).stnid,'/24hour/'];
  wkg_short = ['/dbase/web_stations/',sta_info(1).stnid,'/24hour/'];
  txt = ['/usr/bin/rm ',wkg_full,'pm*.*'];
  unix(txt);
end


% LOOP THROUGH COLUMNS OF DATA (PARAMETERS) AND MAKE PLOTS

plot_idxs = [];

for data_idx=data_idxs

  good_plot = make_parameter(data_idx, pm_info, sta_info, number_date, ...
               data, num_stations, marker, pid, wkg_full)

  if ( good_plot == 1)
    plot_idxs = [ plot_idxs, data_idx ];
  end

end

plot_idxs

% LOOP THROUGH PLOTS AND MAKE SHTML FILES

for ( plot_idx=plot_idxs )

  plt_name = ['pm',num2str(plot_idx,'%2.2d'),'_',char(pid)];
  fname = [wkg_full,plt_name,'.shtml'];
  fid = fopen(fname,'w');
  fprintf(fid,'<html><body bgcolor=white link=blue vlink=blue><center>\n');

% make links to other plots, highlight current plot in red.

  plot_cnt = 0;

  for ( j=plot_idxs )
    plot_cnt = plot_cnt + 1;
    tmp_name = ['pm',num2str(j,'%2.2d'),'_',char(pid),'.shtml'];
    p_ref = [wkg_short, tmp_name];
    if ( j == plot_idx )
      cell = ['<font size=4 color=red>',char(subtitle(j)),'</font>\n'];
    else
      cell = ['<font size=2><a href=',p_ref,' >',char(subtitle(j)),'</a></font>\n'];
    end
    fprintf(fid,cell);
    if ( mod(plot_cnt,5) == 0 )
      fprintf(fid,'<br>');
    else
      if ( plot_cnt ~= length(plot_idxs))
          fprintf(fid,' | ');
      end
    end
  end

  fprintf(fid,'<hr>');
  image = [wkg_short,plt_name,'.png'];
  cell = ['<img border=1 width=582 height=582 src=',image,'>'];
  fprintf(fid,cell);
  fprintf(fid,'</center>');
  fprintf(fid,'Return to the <a href=/cdip_htmls/quick.shtml target=_parent> Quick Check </a> page');
  fprintf(fid,'<!--#include virtual="/includes/footer.inc"-->');
  fprintf(fid,'</html>');
  fclose(fid);

end  % loop through plots


% MAKE A FILE WITH THE WEB LOCATION TAG.

if ( web == 1 )

  plt_name = ['pm',num2str(plot_idxs(1),'%2.2d'),'_',char(pid)];
  fname = [wkg_short,plt_name,'.shtml'];

  Location = ['Location: http://cdip.ucsd.edu',fname];
  fid = fopen([wkg_full,'loc',pid],'w');
  fprintf(fid,'%s\n\n',Location)
  fclose(fid);

end

quit;


CDIP's major funding contributors are the US Army Corps of Engineers and the California Department of Boating and Waterways.
Official UCSD Web Page