[Dart-dev] [10125] DART/trunk/DART_LAB/matlab: The long-awaited new set of Matlab GUIs for the DART tutorial.

nancy at ucar.edu nancy at ucar.edu
Wed Apr 20 09:29:07 MDT 2016


Revision: 10125
Author:   thoar
Date:     2016-04-20 09:29:05 -0600 (Wed, 20 Apr 2016)
Log Message:
-----------
The long-awaited new set of Matlab GUIs for the DART tutorial.
There is a TRELLO board for improvements to these, but at least
they work pretty well with both 2012a and 2015b ..

Modified Paths:
--------------
    DART/trunk/DART_LAB/matlab/gaussian_product.m
    DART/trunk/DART_LAB/matlab/oned_ensemble.m
    DART/trunk/DART_LAB/matlab/oned_model.m
    DART/trunk/DART_LAB/matlab/private/g_prod_plot.m
    DART/trunk/DART_LAB/matlab/private/lorenz_63_static_init_model.m
    DART/trunk/DART_LAB/matlab/private/lorenz_96_static_init_model.m
    DART/trunk/DART_LAB/matlab/private/plot_gaussian.m
    DART/trunk/DART_LAB/matlab/run_lorenz_63.m
    DART/trunk/DART_LAB/matlab/run_lorenz_96.m
    DART/trunk/DART_LAB/matlab/twod_ensemble.m

Added Paths:
-----------
    DART/trunk/DART_LAB/matlab/private/stylesheet.m

Removed Paths:
-------------
    DART/trunk/DART_LAB/matlab/gaussian_product.fig
    DART/trunk/DART_LAB/matlab/oned_ensemble.fig
    DART/trunk/DART_LAB/matlab/oned_model.fig
    DART/trunk/DART_LAB/matlab/run_lorenz_63.fig
    DART/trunk/DART_LAB/matlab/run_lorenz_96.fig
    DART/trunk/DART_LAB/matlab/run_template.fig
    DART/trunk/DART_LAB/matlab/twod_ensemble.fig

-------------- next part --------------
Deleted: DART/trunk/DART_LAB/matlab/gaussian_product.fig
===================================================================
(Binary files differ)

Modified: DART/trunk/DART_LAB/matlab/gaussian_product.m
===================================================================
--- DART/trunk/DART_LAB/matlab/gaussian_product.m	2016-04-20 00:13:04 UTC (rev 10124)
+++ DART/trunk/DART_LAB/matlab/gaussian_product.m	2016-04-20 15:29:05 UTC (rev 10125)
@@ -1,4 +1,4 @@
-function varargout = gaussian_product(varargin)
+function gaussian_product
 %% GAUSSIAN_PRODUCT demonstrates the product of two gaussian distributions.
 %
 %    This is fundamental to Kalman filters and to ensemble
@@ -7,211 +7,319 @@
 %    and click on 'Plot Posterior'.
 %
 %    The product (in this case, the 'Posterior') of two gaussians is a gaussian.
-%    If the parameters of the two gaussians are known, the parameters of the 
+%    If the parameters of the two gaussians are known, the parameters of the
 %    resulting gaussian can be calculated.
 %
 % See also: oned_model, oned_ensemble, twod_ensemble,
 %           run_lorenz_63, run_lorenz_96
 
-%% DART software - Copyright 2004 - 2013 UCAR. This open source software is
+%% DART software - Copyright 2004 - 2016 UCAR. This open source software is
 % provided by UCAR, "as is", without charge, subject to all terms of use at
 % http://www.image.ucar.edu/DAReS/DART/DART_download
-%
-% DART $Id$
 
-% Begin initialization code - DO NOT EDIT
-gui_Singleton = 1;
-gui_State = struct('gui_Name',       mfilename, ...
-                   'gui_Singleton',  gui_Singleton, ...
-                   'gui_OpeningFcn', @gaussian_product_OpeningFcn, ...
-                   'gui_OutputFcn',  @gaussian_product_OutputFcn, ...
-                   'gui_LayoutFcn',  [] , ...
-                   'gui_Callback',   []);
-if nargin && ischar(varargin{1})
-    gui_State.gui_Callback = str2func(varargin{1});
-end
+atts = stylesheet;  % get the default fonts and colors
 
-if nargout
-    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
-else
-    gui_mainfcn(gui_State, varargin{:});
-end
-% End initialization code - DO NOT EDIT
+% Specify the figure size in pixels. After that, all positions are
+% specified as fractions (units=Normalized). That way, the objects
+% scale proportionally as the figure gets resized.
 
+figureXmin   = 450; % The horizontal position of the entire figure, in pixels
+figureYmin   = 250; % The vertical   position of the entire figure, in pixels
+figureWidth  = 670; % The width  of the entire figure, in pixels
+figureHeight = 420; % The height of the entire figure, in pixels
 
-% --- Executes just before gaussian_product is made visible.
-function gaussian_product_OpeningFcn(hObject, ~, handles, varargin)
-% This function has no output args, see OutputFcn.
-% hObject    handle to figure
-% eventdata  reserved - to be defined in a future version of MATLAB
-% handles    structure with handles and user data (see GUIDATA)
-% varargin   command line arguments to gaussian_product (see VARARGIN)
+handles.figure1 = figure('Position', [figureXmin figureYmin figureWidth figureHeight], ...
+    'Units', 'pixels', ...
+    'Name','gaussian_product', ...
+    'Color', atts.background);
 
-help gaussian_product
+%Position has units of normalized and therefore the components must be
+%Fractions of figure. Also, the actual text  has FontUnits which are
+%normalized, so the Font Size is a fraction of the text box/ edit box that
+%contains it. Making the font size and box size normalized allows the text
+%size and box size to change proportionately if the user resizes the
+%figure window. This is true for all text/edit boxes and buttons.
 
-% set random number seed to same value to generate known sequences
-rng('default')
+%Creates the graph with given dimensions
+plotXmin   = 0.07;
+plotYmin   = 0.07;
+plotWidth  = 0.6;
+plotHeight = 1.0 - 2*plotYmin; % center the plot graphic
 
-% Choose default command line output for gaussian_product
-handles.output = hObject;
+handles.graph = axes('Position', [plotXmin plotYmin plotWidth plotHeight]);
+set(handles.graph, 'FontSize', atts.fontsize);
 
-% Update handles structure
-guidata(hObject, handles);
+LabelFontSize = 0.40;  % proportional sizes
+EditFontSize  = 0.35;  % proportional sizes
 
-% Plot the initial prior and observation likelihood pdf's
-h = guihandles;
-g_prod_plot(h);
+%% Creates the box surrounding the two Prior edit boxes.
+%  By specifying this handle in the subsequent uicontrols,
+%  the positions are all relative to the uipanel.
+handles.PriorPanel = uipanel('BackgroundColor', atts.green, ...
+    'BorderType','none', ...
+    'Units', 'Normalized', ...
+    'Position',[0.695 0.738 0.260 0.200]);
 
-% UIWAIT makes gaussian_product wait for user response (see UIRESUME)
-% uiwait(handles.figure1);
+x1 = 0.025;
+x2 = 0.750;
+dx1 = x2 - x1 - 0.025;
 
+handles.ui_text_prior_mean = uicontrol( handles.PriorPanel, ...
+    'Style', 'text', ...
+    'Units', 'Normalized', ...
+    'Position', [x1 0.440 dx1 0.430], ...
+    'String', 'Prior Mean ', ...
+    'BackgroundColor', atts.green, ...
+    'ForegroundColor', 'White', ...
+    'HorizontalAlignment', 'right', ...
+    'FontUnits', 'normalized', ...
+    'FontWeight', 'Bold', ...
+    'FontName', atts.fontname, ...
+    'FontSize', LabelFontSize);
 
-% --- Outputs from this function are returned to the command line.
-function varargout = gaussian_product_OutputFcn(~, ~, handles)
-% varargout  cell array for returning output args (see VARARGOUT);
-% hObject    handle to figure
-% eventdata  reserved - to be defined in a future version of MATLAB
-% handles    structure with handles and user data (see GUIDATA)
+handles.ui_edit_prior_mean = uicontrol( handles.PriorPanel, ...
+    'Style', 'edit', ...
+    'Units', 'Normalized', ...
+    'Position', [x2 0.540 0.225 0.420], ...
+    'String', '0', ...
+    'Callback', @edit_prior_mean_Callback, ...
+    'BackgroundColor', 'White', ...
+    'FontUnits', 'normalized', ...
+    'FontName', atts.fontname, ...
+    'FontSize', EditFontSize);
 
-% Get default command line output from handles structure
-varargout{1} = handles.output;
+handles.ui_text_prior_sd = uicontrol( handles.PriorPanel, ...
+    'Style', 'text', ...
+    'Units', 'Normalized', ...
+    'Position', [x1 0.000 dx1 0.430], ...
+    'String', 'Prior SD ', ...
+    'BackgroundColor', atts.green, ...
+    'ForegroundColor', 'White', ...
+    'HorizontalAlignment', 'right', ...
+    'FontUnits', 'normalized', ...
+    'FontWeight', 'Bold', ...
+    'FontName', atts.fontname, ...
+    'FontSize', LabelFontSize);
 
+handles.ui_edit_prior_sd = uicontrol( handles.PriorPanel, ...
+    'Style', 'edit', ...
+    'Units', 'Normalized', ...
+    'Position', [x2 0.040 0.225 0.420], ...
+    'String', '1', ...
+    'Callback', @edit_prior_sd_Callback, ...
+    'BackgroundColor', 'White', ...
+    'FontUnits', 'normalized', ...
+    'FontName', atts.fontname, ...
+    'FontSize', EditFontSize);
 
+%% Creates the box surrounding the two Observation edit boxes.
+handles.ObservationPanel = uipanel('BackgroundColor', atts.red, ...
+    'BorderType','none', ...
+    'Units', 'Normalized', ...
+    'Position',[0.695 0.524 0.260 0.200]);
 
-function edit1_Callback(~, ~, handles)
-% hObject    handle to edit1 (see GCBO)
-% eventdata  reserved - to be defined in a future version of MATLAB
-% handles    structure with handles and user data (see GUIDATA)
+handles.text_observation = uicontrol(handles.ObservationPanel, ...
+    'Style', 'text', ...
+    'Units', 'Normalized', ...
+    'Position', [x1 0.440 dx1 0.430], ...
+    'String', 'Observation ', ...
+    'BackgroundColor', atts.red, ...
+    'ForegroundColor', 'White', ...
+    'HorizontalAlignment', 'right', ...
+    'FontUnits', 'normalized', ...
+    'FontWeight', 'Bold', ...
+    'FontName', atts.fontname, ...
+    'FontSize', LabelFontSize);
 
-% Hints: get(hObject,'String') returns contents of edit1 as text
-%        str2double(get(hObject,'String')) returns contents of edit1 as a double
+handles.ui_edit_observation = uicontrol(handles.ObservationPanel, ...
+    'Style', 'edit', ...
+    'Units', 'Normalized', ...
+    'Position', [x2 0.540 0.225 0.420], ...
+    'String', '1', ...
+    'Callback', @edit_observation_Callback, ...
+    'BackgroundColor', 'White', ...
+    'FontUnits', 'normalized', ...
+    'FontName', atts.fontname, ...
+    'FontSize', EditFontSize);
 
-g_prod_plot(handles);
+handles.text_obs_error_sd = uicontrol(handles.ObservationPanel, ...
+    'Style', 'text', ...
+    'Units', 'Normalized', ...
+    'Position', [x1 0.000 dx1 0.430], ...
+    'String', 'Obs. Error SD ', ...
+    'BackgroundColor', atts.red, ...
+    'ForegroundColor', 'White', ...
+    'HorizontalAlignment', 'right', ...
+    'FontUnits', 'normalized', ...
+    'FontWeight', 'Bold', ...
+    'FontName', atts.fontname, ...
+    'FontSize', LabelFontSize);
 
+handles.ui_edit_obs_error_sd = uicontrol(handles.ObservationPanel, ...
+    'Style', 'edit', ...
+    'Units', 'Normalized', ....
+    'Position', [x2 0.040 0.225 0.420], ...
+    'String', '1', ...
+    'Callback', @edit_obs_error_sd_Callback, ...
+    'BackgroundColor', 'White', ...
+    'FontUnits', 'normalized', ...
+    'FontName', atts.fontname, ...
+    'FontSize', EditFontSize);
 
-% --- Executes during object creation, after setting all properties.
-function edit1_CreateFcn(hObject, ~, ~)
-% hObject    handle to edit1 (see GCBO)
-% eventdata  reserved - to be defined in a future version of MATLAB
-% handles    empty - handles not created until after all CreateFcns called
+%% Creates a Button that when pressed, plots the Posterior.
+handles.ui_button_Plot = uicontrol('Style', 'pushbutton', ...
+    'Units', 'Normalized', ...
+    'Position', [0.725 0.400 0.175 0.102], ...
+    'String', 'Plot Posterior', ...
+    'Callback', @plotGraph_Callback, ...
+    'BackgroundColor','White', ...
+    'FontUnits', 'normalized', ...
+    'FontName', atts.fontname, ...
+    'FontSize', 0.4);
 
-% Hint: edit controls usually have a white background on Windows.
-%       See ISPC and COMPUTER.
-if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
-    set(hObject,'BackgroundColor','white');
-end
+%% Create panel for reporting the Posterior values (the product of the two gaussians).
+handles.PosteriorPanel = uipanel( ...
+    'Position',[0.695 0.100 0.260 0.281], ...
+    'Units', 'Normalized', ...
+    'BorderType', 'none', ...
+    'BackgroundColor', atts.blue, ...
+    'ForegroundColor', 'White', ...
+    'Title', 'Posterior', ...
+    'FontUnits', 'normalized', ...
+    'FontName', atts.fontname, ...
+    'FontSize', 0.2);
+     
+text_xstart = 0.01;
+text_dy     = 0.25;
+text_y      = 0.925 - text_dy - 0.05;
 
-function edit2_Callback(~, ~, handles)
-% hObject    handle to edit2 (see GCBO)
-% eventdata  reserved - to be defined in a future version of MATLAB
-% handles    structure with handles and user data (see GUIDATA)
+handles.ui_text_posterior_mean = uicontrol(handles.PosteriorPanel, ...
+    'Style', 'text', ...
+    'Units', 'Normalized', ...
+    'Position', [text_xstart text_y 0.98 text_dy], ...
+    'String', 'Mean =', ...
+    'BackgroundColor', atts.blue, ...
+    'ForegroundColor', 'White', ...
+    'FontUnits', 'normalized', ...
+    'FontSize', 0.7, ...
+    'FontWeight', 'Bold', ...
+    'FontName', atts.fontname, ...
+    'HorizontalAlignment', 'right');
 
-% Hints: get(hObject,'String') returns contents of edit2 as text
-%        str2double(get(hObject,'String')) returns contents of edit2 as a double
+text_y = text_y - text_dy - 0.05;
+handles.ui_text_posterior_sd = uicontrol(handles.PosteriorPanel, ...
+    'Style', 'text', ...
+    'Units', 'Normalized', ...
+    'Position', [text_xstart text_y 0.98 text_dy], ...
+    'String', 'SD =', ...
+    'BackgroundColor', atts.blue, ...
+    'ForegroundColor', 'White', ...
+    'FontUnits', 'normalized', ...
+    'FontSize', 0.7, ...
+    'FontWeight', 'Bold', ...
+    'FontName', atts.fontname, ...
+    'HorizontalAlignment', 'right');
 
-g_prod_plot(handles);
+text_y = text_y - text_dy - 0.05;
+handles.ui_text_posterior_weight = uicontrol(handles.PosteriorPanel, ...
+    'Style', 'text', ...
+    'Units', 'Normalized', ...
+    'Position', [text_xstart text_y 0.98 text_dy], ...
+    'String', 'Weight =', ...
+    'BackgroundColor', atts.blue, ...
+    'ForegroundColor', 'White', ...
+    'FontUnits', 'normalized', ...
+    'FontSize', 0.7, ...
+    'FontWeight', 'Bold', ...
+    'FontName', atts.fontname, ...
+    'HorizontalAlignment', 'right');
 
+align([handles.ui_text_posterior_mean, ...
+       handles.ui_text_posterior_sd, ...
+       handles.ui_text_posterior_weight], ...
+      'Distribute','None');
+reset_Posterior();
 
-% --- Executes during object creation, after setting all properties.
-function edit2_CreateFcn(hObject, ~, ~)
-% hObject    handle to edit2 (see GCBO)
-% eventdata  reserved - to be defined in a future version of MATLAB
-% handles    empty - handles not created until after all CreateFcns called
+hlist = [handles.PriorPanel, handles.ObservationPanel, handles.ui_button_Plot, handles.PosteriorPanel];
 
-% Hint: edit controls usually have a white background on Windows.
-%       See ISPC and COMPUTER.
-if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
-    set(hObject,'BackgroundColor','white');
-end
+align(hlist,'Center','Distribute')
 
-
-
-function edit3_Callback(~, ~, handles)
-% hObject    handle to edit3 (see GCBO)
-% eventdata  reserved - to be defined in a future version of MATLAB
-% handles    structure with handles and user data (see GUIDATA)
-
-% Hints: get(hObject,'String') returns contents of edit3 as text
-%        str2double(get(hObject,'String')) returns contents of edit3 as a double
-
+%%Plots an initial graph with the default values
 g_prod_plot(handles);
 
+%% ---------------------------------------------------------------------
 
-% --- Executes during object creation, after setting all properties.
-function edit3_CreateFcn(hObject, ~, ~)
-% hObject    handle to edit3 (see GCBO)
-% eventdata  reserved - to be defined in a future version of MATLAB
-% handles    empty - handles not created until after all CreateFcns called
+    function plotGraph_Callback(~,~)
+        %This function plots the graph using the inputs in the 4 edit boxes. It
+        %makes changes to handles, so the function must return an update to
+        %handles. This is done through the function definition.
+        
+        [prior_mean, prior_sd, obs_mean, obs_err_sd, is_err] = g_prod_plot(handles);
+        
+        % If there is an error, zero out the posterior text values
+        % don't try to do posterior computation
+        if(is_err)
+            reset_Posterior();
+            return;
+        end
+        
+        % Compute the posterior mean, sd and weight
+        [post_mean, post_sd, weight] = ...
+            product_of_gaussians(prior_mean, prior_sd, obs_mean, obs_err_sd);
+        post_handle = plot_gaussian(post_mean, post_sd, 1);
+        set(post_handle, 'Color', 'b', 'LineWidth', 2);
+        
+        %Round post_mean, post_sd and weight to 4 decimal places
+        post_mean = round(post_mean * 10000);
+        post_mean = post_mean/10000;
+        post_sd = round(post_sd * 10000);
+        post_sd = post_sd/10000;
+        weight = round(weight * 10000);
+        weight = weight/10000;
+        
+        % Print values
+        str1 = sprintf('Mean = %.4f',post_mean);
+        set(handles.ui_text_posterior_mean, 'String', str1);
+        str1 = sprintf('SD = %.4f',post_sd);
+        set(handles.ui_text_posterior_sd, 'String', str1);
+        
+        % Also plot the weighted posterior as dashed
+        post_handle = plot_gaussian(post_mean, post_sd, weight);
+        set(post_handle, 'Color', 'b', 'LineStyle', '--');
+        str1 = sprintf('Weight = %.4f',weight);
+        set(handles.ui_text_posterior_weight, 'String', str1);
+        
+        h = legend('Prior', 'Obs. Likelihood', 'Posterior', 'Weighted Posterior');
+        set(h, 'box', 'on', 'Location', 'NorthWest')
+        
+    end
 
-% Hint: edit controls usually have a white background on Windows.
-%       See ISPC and COMPUTER.
-if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
-    set(hObject,'BackgroundColor','white');
-end
+    % These functions plot the graph immediately after the user edits a text box
 
+    function edit_prior_mean_Callback(~, ~)
+        g_prod_plot(handles);
+        reset_Posterior();
+    end
 
+    function edit_prior_sd_Callback(~, ~)
+        g_prod_plot(handles);
+        reset_Posterior();
+    end
 
-function edit4_Callback(~, ~, handles)
-% hObject    handle to edit4 (see GCBO)
-% eventdata  reserved - to be defined in a future version of MATLAB
-% handles    structure with handles and user data (see GUIDATA)
+    function edit_observation_Callback(~, ~)
+        g_prod_plot(handles);
+        reset_Posterior();
+    end
 
-% Hints: get(hObject,'String') returns contents of edit4 as text
-%        str2double(get(hObject,'String')) returns contents of edit4 as a double
+    function edit_obs_error_sd_Callback(~, ~)
+        g_prod_plot(handles);
+        reset_Posterior();
+    end
 
-g_prod_plot(handles);
+    function reset_Posterior()
+        set(handles.ui_text_posterior_mean,   'String',   'Mean =         ');
+        set(handles.ui_text_posterior_sd,     'String',     'SD =         ');
+        set(handles.ui_text_posterior_weight, 'String', 'Weight =         ');
+    end
 
-
-% --- Executes during object creation, after setting all properties.
-function edit4_CreateFcn(hObject, ~, ~)
-% hObject    handle to edit4 (see GCBO)
-% eventdata  reserved - to be defined in a future version of MATLAB
-% handles    empty - handles not created until after all CreateFcns called
-
-% Hint: edit controls usually have a white background on Windows.
-%       See ISPC and COMPUTER.
-if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
-    set(hObject,'BackgroundColor','white');
 end
-
-% --- Executes on button press in pushbutton1.
-function pushbutton1_Callback(~, ~, handles)
-% hObject    handle to pushbutton1 (see GCBO)
-% eventdata  reserved - to be defined in a future version of MATLAB
-% handles    structure with handles and user data (see GUIDATA)
-
-% Need to replot prior and obs, then compute posterior and plot
-[prior_mean, prior_sd, obs_mean, obs_err_sd, is_err] = g_prod_plot(handles);
-
-% If there is an error, zero out the posterior text values
-% don't try to do posterior computation
-if(is_err)
-    set(handles.text7, 'String', strcat('Posterior Mean = '));
-    set(handles.text8, 'String', strcat('Posterior SD = '));
-    set(handles.text9, 'String', strcat('Weight = '));
-    return;
-end
-
-% Compute the posterior mean, sd and weight
-[post_mean, post_sd, weight] = ...
-    product_of_gaussians(prior_mean, prior_sd, obs_mean, obs_err_sd);
-post_handle = plot_gaussian(post_mean, post_sd, 1);
-set(post_handle, 'Color', 'b', 'LineWidth', 2);
-
-% Print values
-set(handles.text7, 'String', ['Posterior Mean = ', num2str(post_mean)]);
-set(handles.text8, 'String', ['Posterior SD = ', num2str(post_sd)]);
-
-% Also plot the weighted posterior as dashed
-post_handle = plot_gaussian(post_mean, post_sd, weight);
-set(post_handle, 'Color', 'b', 'Linestyle', '--');
-set(handles.text9, 'String', ['Weight = ', num2str(weight)]);
-
-legend('Prior', 'Obs. Likelihood', 'Posterior', 'Weighted Posterior');
-
-
-% <next few lines under version control, do not edit>
-% $URL$
-% $Revision$
-% $Date$
-

Deleted: DART/trunk/DART_LAB/matlab/oned_ensemble.fig
===================================================================
(Binary files differ)

Modified: DART/trunk/DART_LAB/matlab/oned_ensemble.m
===================================================================
--- DART/trunk/DART_LAB/matlab/oned_ensemble.m	2016-04-20 00:13:04 UTC (rev 10124)
+++ DART/trunk/DART_LAB/matlab/oned_ensemble.m	2016-04-20 15:29:05 UTC (rev 10125)
@@ -1,7 +1,7 @@
-function varargout = oned_ensemble(varargin)
+function oned_ensemble
 %% ONED_ENSEMBLE explore the details of ensemble data assimilation for a scalar.
 %
-%      Click on the 'Create New Ensemble' button to activate the interactive
+%      Push on the 'Create New Ensemble' button to activate the interactive
 %      observation generation mechanism and lay down a set of 'observations'
 %      representative of your ensemble. (Think: Some H() operator has
 %      converted the model state to an expected observation.) This is done by
@@ -32,696 +32,984 @@
 % See also: gaussian_product, oned_model, twod_ensemble, run_lorenz_63,
 %           run_lorenz_96
 
-%% DART software - Copyright 2004 - 2013 UCAR. This open source software is
+%% DART software - Copyright 2004 - 2016 UCAR. This open source software is
 % provided by UCAR, "as is", without charge, subject to all terms of use at
 % http://www.image.ucar.edu/DAReS/DART/DART_download
-%
-% DART $Id$
 
-% Last Modified by GUIDE v2.5 28-Aug-2009 16:29:57
+help oned_ensemble
 
-% Begin initialization code - DO NOT EDIT
-gui_Singleton = 1;
-gui_State = struct('gui_Name',       mfilename, ...
-    'gui_Singleton',  gui_Singleton, ...
-    'gui_OpeningFcn', @oned_ensemble_OpeningFcn, ...
-    'gui_OutputFcn',  @oned_ensemble_OutputFcn, ...
-    'gui_LayoutFcn',  [] , ...
-    'gui_Callback',   []);
-if nargin && ischar(varargin{1})
-    gui_State.gui_Callback = str2func(varargin{1});
-end
+atts = stylesheet; % get the default fonts and colors
 
-if nargout
-    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
-else
-    gui_mainfcn(gui_State, varargin{:});
-end
-% End initialization code - DO NOT EDIT
-
-
-% --- Executes just before oned_ensemble is made visible.
-function oned_ensemble_OpeningFcn(hObject, ~, handles, varargin)
-% This function has no output args, see OutputFcn.
-% hObject    handle to figure
-% eventdata  reserved - to be defined in a future version of MATLAB
-% handles    structure with handles and user data (see GUIDATA)
-% varargin   command line arguments to oned_ensemble (see VARARGIN)
-
-help oned_ensemble
-
-% set random number seed to same value to generate known sequences
+% Set random number seed to same value to generate known sequences
 rng('default')
 
-% Choose default command line output for oned_ensemble
-handles.output = hObject;
-
-% Insert the ensemble structure into this
+% Initialize the basic structure we will be using to hold everything.
 handles.ens_size         = 0;
 handles.ens_members      = 0;
-handles.h_obs_plot       = 0;
-handles.h_update_ens     = 0;
-handles.h_ens_member     = 0;
-handles.h_obs_ast        = 0;
-handles.h_update_lines   = 0;
-handles.observation      = 0;
-handles.obs_error_sd     = 0;
-handles.inflation        = 1.5;
+handles.h_obs_plot       = [];
+handles.h_update_ens     = [];
+handles.h_ens_member     = [];
+handles.h_obs_ast        = [];
+handles.h_update_lines   = [];
 handles.plot_inflation   = false;
-handles.h_inf_ens_member = 0;
-handles.h_inf_up_ens     = 0;
-handles.h_inf_lines      = 0;
-handles.h_inf_axis       = 0;
+handles.h_inf_ens_member = [];
+handles.h_inf_up_ens     = [];
+handles.h_inf_lines      = [];
+handles.h_inf_axis       = [];
 
-% Update handles structure
-guidata(hObject, handles);
+%% -----------------------------------------------------------------------------
 
-% Get the initial observation, obs_error_sd and inflation from the gui
-handles.observation  = str2double(get(handles.edit_observation,  'String'));
-handles.obs_error_sd = str2double(get(handles.edit_obs_error_sd, 'String'));
-handles.inflation    = str2double(get(handles.edit_inflation,    'String'));
+% Specify the figure size in pixels. After that, all positions are 
+% specified as fractions (units=Normalized). That way, the objects
+% scale proportionally as the figure gets resized.
+figXmin   = 450; % The horizontal position of the entire figure, in pixels
+figYmin   = 250; % The vertical   position of the entire figure, in pixels
+figWidth  = 670; % The width  of the entire figure, in pixels
+figHeight = 500; % The height of the entire figure, in pixels
 
-% Go ahead and plot the initial observational error distribution
-handles.h_obs_plot = plot_gaussian(handles.observation, handles.obs_error_sd, 1);
-set(handles.h_obs_plot, 'Color', 'r', 'Linestyle', '--', 'Linewidth', 2);
-hold on
+handles.figure1 = figure('Position', [figXmin figYmin figWidth figHeight], ...
+    'Units', 'Pixels', ...
+    'Name', 'oned_ensemble', ...
+    'Color', atts.background);
 
-% Plot an asterisk
-handles.h_obs_ast = plot(handles.observation, 0, 'r*', 'MarkerSize', 16,'LineWidth',2.0);
+%% -----------------------------------------------------------------------------
+%Position has units of normalized and therefore the components must be
+%Fractions of figure. Also, the actual text  has FontUnits which are
+%normalized, so the Font Size is a fraction of the text box/ edit box that
+%contains it. Making the font size and box size normalized allows the text
+%size and box size to change proportionately if the user resizes the
+%figure window. This is true for all text/edit boxes and buttons.
 
-% Set a basic plotting domain range that includes mean +/- 3 obs SDs
-xlower = handles.observation - 3*handles.obs_error_sd;
-xupper = handles.observation + 3*handles.obs_error_sd;
-ylower = -0.4;
-yupper = 1.0;
-axis([xlower xupper ylower yupper]);
+%% -----------------------------------------------------------------------------
+%  Set up a parent container so we can move the one container around instead of
+%  trying to manipulate the positions of all the components.
 
-set(gca, 'YTick', [0 0.2 0.4 0.6 0.8]);
-set(gca, 'YTickLabel', [0 0.2 0.4 0.6 0.8]);
+handles.observation_panel = uipanel('BackgroundColor',atts.red, ...
+    'BorderType','none', ...
+    'Units', 'Normalized', ...
+    'Position',[0.66  0.744 0.325 0.2]);
 
-hold on
-plot([xlower xupper], [0 0], 'k', 'Linewidth', 2);
+handles.ui_text_observation = uicontrol(handles.observation_panel, ...
+    'Style', 'text', ...
+    'Units', 'Normalized', ...
+    'Position', [0.035 0.600 0.600 0.275], ...
+    'String', 'Observation' , ...
+    'BackgroundColor', atts.red, ...
+    'ForegroundColor', 'White', ...
+    'FontName', atts.fontname, ...
+    'FontUnits', 'normalized', ...
+    'FontSize', 0.6, ...
+    'FontWeight', 'Bold', ...
+    'HorizontalAlignment', 'center');
 
-% Update handles structure
-guidata(hObject, handles);
+handles.ui_edit_observation = uicontrol(handles.observation_panel, ...
+    'Style', 'edit', ...
+    'Units', 'Normalized', ...
+    'Position', [0.675 0.562 0.300 0.373], ...
+    'String', '1', ...
+    'BackgroundColor', 'White', ...
+    'FontName', atts.fontname, ...
+    'FontUnits', 'normalized', ...
+    'FontSize', 0.6, ...
+    'Callback', @edit_observation_Callback);
+handles.observation = str2double(get(handles.ui_edit_observation,'String'));
 
-% Reset focus to the menu gui window
-% Setting the axes clears the legend, gcbo restores focus
-axes(handles.axes1);
+handles.ui_text_obs_error_sd = uicontrol(handles.observation_panel, ...
+    'Style', 'text', ...
+    'Units', 'Normalized', ...
+    'Position', [0.035 0.100 0.600 0.275], ...
+    'String', 'Obs. Error SD', ...
+    'BackgroundColor', atts.red,...
+    'ForegroundColor', 'White', ...
+    'FontName', atts.fontname, ...
+    'FontUnits', 'normalized', ...
+    'FontSize', 0.6, ...
+    'FontWeight','Bold', ...
+    'HorizontalAlignment', 'center');
 
+handles.ui_edit_obs_error_sd = uicontrol(handles.observation_panel, ...
+    'Style', 'edit', ...
+    'Units', 'Normalized', ...
+    'Position', [0.675 0.062 0.300 0.373], ...
+    'String', '1', ...
+    'BackgroundColor', 'White', ...
+    'FontName', atts.fontname, ...
+    'FontUnits', 'normalized', ...
+    'FontSize', 0.6, ...
+    'Callback', @edit_obs_error_sd_Callback);
+handles.obs_error_sd = str2double(get(handles.ui_edit_obs_error_sd,'String'));
 
-% UIWAIT makes oned_ensemble wait for user response (see UIRESUME)
-% uiwait(handles.figure1);
+%% -----------------------------------------------------------------------------
+%  Try to center the boxes with what is on top.
 
+box = get(handles.observation_panel,'Position');
+center = box(1) + box(3)/2.0;
+mywid = 0.250;
+myleft = center - mywid/2.0;
 
-%----------------------------------------------------------------------
+handles.ui_button_create_new_ens = uicontrol('Style', 'pushbutton', ...
+    'Units', 'Normalized', ...
+    'Position', [myleft 0.645 mywid 0.075], ...
+    'String', 'Create New Ensemble', ...
+    'BackgroundColor', 'White', ...
+    'FontUnits', 'normalized', ...
+    'FontName', atts.fontname, ...
+    'FontSize', 0.4, ...
+    'Callback', @button_create_new_ens_Callback);
 
+mywid = 0.200;
+myleft = center - mywid/2.0;
+handles.ui_button_update_ens = uicontrol('style', 'pushbutton', ...
+    'Units', 'Normalized', ...
+    'Enable','Off', ...
+    'Position', [myleft 0.549 mywid 0.075], ...
+    'String', 'Update Ensemble' , ...
+    'BackgroundColor', 'White', ...
+    'FontName', atts.fontname, ...
+    'FontUnits', 'normalized', ...
+    'FontSize', 0.4, ...
+    'Callback', @button_update_ens_Callback);
 
-% --- Outputs from this function are returned to the command line.
-function varargout = oned_ensemble_OutputFcn(~, ~, handles)
-% varargout  cell array for returning output args (see VARARGOUT);
-% hObject    handle to figure
-% eventdata  reserved - to be defined in a future version of MATLAB
-% handles    structure with handles and user data (see GUIDATA)
+%% -----------------------------------------------------------------------------
 
-% Get default command line output from handles structure
-varargout{1} = handles.output;
+handles.inflation_panel = uipanel('BackgroundColor',atts.lightblue, ...
+    'BorderType','none', ...
+    'Position',[0.661 0.282 0.32 0.248]);
 
+handles.ui_checkbox_inflation = uicontrol(handles.inflation_panel, ...
+    'Style', 'checkbox', ...
+    'Units', 'Normalized', ...
+    'Position', [0.037 0.624 0.900 0.335], ...
+    'String', 'Apply Inflation', ...
+    'BackgroundColor', atts.lightblue,...
+    'ForegroundColor', 'k', ...
+    'FontUnits', 'normalized', ...
+    'FontName', atts.fontname, ...
+    'FontSize', 0.4, ...
+    'FontWeight','Bold', ...
+    'Callback', @inflation_toggle_Callback);
 
-%----------------------------------------------------------------------
+handles.ui_slider_inflation = uicontrol(handles.inflation_panel, ...
+    'Style', 'slider', ...
+    'Units', 'Normalized', ...
+    'Position', [0.058 0.411 0.893 0.18], ...
+    'Value', 1,...
+    'Max', 5,...
+    'Min', 1,...
+    'Sliderstep',[0.05 0.2], ...
+    'FontUnits', 'normalized', ...
+    'FontName', atts.fontname, ...
+    'FontSize', 0.5, ...
+    'Enable', 'Off', ...
+    'Callback', @slider_Callback);
 
+handles.ui_text_inflation = uicontrol(handles.inflation_panel, ...
+    'Style', 'text', ...
+    'Units', 'Normalized', ...
+    'Position', [0.018 0.006 0.671 0.29], ...
+    'String', 'Inflation Amount', ...
+    'BackgroundColor', atts.lightblue,...
+    'ForegroundColor', 'k', ...
+    'FontUnits', 'normalized', ...
+    'FontName', atts.fontname, ...
+    'FontSize', 0.4, ...
+    'Enable', 'Off', ...
+    'FontWeight','Bold');
 
-% --- Executes on button press in pushbutton_create_new.
-function pushbutton_create_new_Callback(hObject, ~, handles)
-% hObject    handle to pushbutton_create_new (see GCBO)
-% eventdata  reserved - to be defined in a future version of MATLAB
-% handles    structure with handles and user data (see GUIDATA)
+handles.ui_edit_inflation_label = uicontrol(handles.inflation_panel, ...
+    'Style', 'edit', ...
+    'Units', 'Normalized', ...
+    'Position', [0.718 0.052 0.263 0.258], ...
+    'String', get(handles.ui_slider_inflation,'Value'), ...
+    'BackgroundColor', 'White', ...
+    'FontUnits', 'normalized', ...
+    'FontName', atts.fontname, ...
+    'FontSize', 0.5, ...
+    'Enable', 'Off', ...
+    'Callback', @edit_inflation_Callback);
+handles.inflation = str2double(get(handles.ui_edit_inflation_label,'String'));
 
-% Disable the update ensemble button and all other active buttons
-set(handles.pushbutton_update_ens, 'Enable', 'Off');
-set(handles.edit_observation,      'Enable', 'Off');
-set(handles.edit_obs_error_sd,     'Enable', 'Off');
-set(handles.edit_inflation,        'Enable', 'Off');
+%% -----------------------------------------------------------------------------
+%  doesn't seem to do a great job of centering ... but the distribute is nice.
 
-% Clear out any old ensemble members if they exist
-set(handles.h_ens_member,          'Visible', 'off');
-set(handles.h_inf_ens_member,      'Visible', 'off');
+hlist = [handles.observation_panel,   ...
+         handles.ui_button_create_new_ens,  ...
+         handles.ui_button_update_ens,  ...
+         handles.inflation_panel];
 
-set(handles.h_update_lines,        'Visible', 'off');
-set(handles.h_inf_lines,           'Visible', 'off');
-set(handles.h_inf_axis,            'Visible', 'off');
+align(hlist,'Center','Distribute')
 
-% Turn off any old update points
-set(handles.h_update_ens,          'Visible', 'off');
-set(handles.h_inf_up_ens,          'Visible', 'off');
-set(handles.h_inf_ens_member,      'Visible', 'off');
+%% -----------------------------------------------------------------------------
 
-clear_labels(handles);
+handles.ui_radio_button_group = uibuttongroup ('BackgroundColor', atts.background, ...
+    'BorderType', 'none', ...
+    'Position',[0.776 0.013 0.200 0.256]);
 
-hold on
+handles.ui_radio_button_eakf = uicontrol(handles.ui_radio_button_group, ...
+    'Style', 'radio button', ...
+    'Units', 'Normalized', ...
+    'Position', [0.007 0.667 670 0.253], ...
+    'String', 'EAKF', ...
+    'BackgroundColor', atts.background, ...
+    'Foreground', 'Black', ...
+    'FontUnits', 'normalized', ...
+    'FontName', atts.fontname, ...
+    'FontWeight','Bold', ...
+    'FontSize', 0.5, ...
+    'HandleVisibility', 'On');
 
-% Set a basic plotting domain range that includes mean +/- 3 obs SDs
-xlower = min(handles.observation - 3*handles.obs_error_sd, min(handles.ens_members));
-xupper = max(handles.observation + 3*handles.obs_error_sd, max(handles.ens_members));
-ylower = -0.4;
-yupper = 1.0;
-axis([xlower xupper ylower yupper]);
+handles.ui_radio_button_enkf = uicontrol(handles.ui_radio_button_group, ...
+    'Style', 'radio button', ...
+    'Units', 'Normalized', ...
+    'Position', [0.007 0.347 670 0.253], ...
+    'String', 'EnKF', ...
+    'BackgroundColor', atts.background, ...
+    'Foreground', 'Black', ...
+    'FontUnits', 'normalized', ...
+    'FontName', atts.fontname, ...
+    'FontWeight','Bold', ...
+    'FontSize', 0.5, ...
+    'HandleVisibility', 'Off');
 
-set(gca, 'YTick',      [0 0.2 0.4 0.6 0.8]);
-set(gca, 'YTickLabel', [0 0.2 0.4 0.6 0.8]);
+handles.ui_radio_button_rhf = uicontrol(handles.ui_radio_button_group, ...
+    'Style', 'radio button', ...
+    'Units', 'Normalized', ...
+    'Position', [0.007 0.06 670 0.253], ...
+    'String', 'RHF', ...
+    'BackgroundColor', atts.background, ...
+    'Foreground', 'Black', ...
+    'FontUnits', 'normalized', ...
+    'FontName', atts.fontname, ...
+    'FontWeight','Bold', ...
+    'FontSize', 0.5, ...
+    'HandleVisibility', 'Off');
 
-% Messages are centered in the middle.
-xmid = (xupper + xlower) / 2.0;
-h_click    = text(xmid,  0.8, {'Click inside graphics box to create member',...
-    '(only X value is used)'}, 'FontSize', 16, 'HorizontalAlignment', 'center');
+%% -----------------------------------------------------------------------------
 
-h_err_text = text(xmid, -0.15, 'An ensemble has to have at least 2 members.', ...
-    'FontSize', 16, 'Visible', 'on', 'HorizontalAlignment', 'center','Color', 'r');
+handles.axes = axes ('Units', 'Normalized', ...
+    'Position', [30/figWidth 30/figWidth 0.6000 0.9000], ...
+    'FontName', atts.fontname, ...
+    'FontSize', atts.fontsize, ...
+    'Color','White');
 
-h_finish   = text(xmid, -0.15, 'Click outside of plot to finish', ...
-    'Fontsize', 16, 'Visible', 'off', 'HorizontalAlignment', 'center');
+% This section specifies the annotation for the values on the main graph.
+% By specifying them this way, we can turn them On/Off at will and specify
+% that they scale when the object is resized.
+% FIXME ... these should be part of some uipanel that is on the graphic.
 
-ens_size = 0;
-while ens_size < 100
-    [xt, yt] = ginput(1);
+handles.ui_text_prior_mean = uicontrol('Style', 'text', ...
+    'Units', 'Normalized', ...
+    'Position', [0.052 0.852 0.233 0.065], ...
+    'String', 'Prior Mean = ', ...
+    'BackgroundColor', 'White', ...
+    'ForegroundColor', atts.green, ...
+    'FontUnits', 'normalized', ...
+    'FontName', atts.fontname, ...
+    'FontSize', 0.4, ...
+    'FontWeight','Bold', ...
+    'HorizontalAlignment', 'right');
 
-    if(xt >= xlower && xt <= xupper && yt >= ylower && yt <= yupper)
-        ens_size = ens_size + 1;
-        x(ens_size) = xt;
-        y(ens_size) = 0;
-        handles.h_ens_member(ens_size) = ...
-            plot(x(ens_size), y(ens_size), '*', 'MarkerSize', 16, 'Color', [0 0.73 0],'LineWidth',2.0);
+handles.ui_text_inflated_prior_mean = uicontrol('Style', 'text', ...
+    'Units', 'Normalized', ...
+    'Position', [0.052 0.806 0.233 0.065], ...
+    'String', 'Inflated =      ', ...
+    'Visible', 'Off', ...
+    'BackgroundColor', 'White', ...
+    'ForegroundColor', atts.green, ...
+    'FontUnits', 'normalized', ...
+    'FontName', atts.fontname, ...
+    'FontSize', 0.4, ...
+    'FontWeight','Bold', ...
+    'HorizontalAlignment','right');
 
-        % Display the prior mean and sd
-        prior_mean = mean(x);
-        prior_sd = std(x);
-        set(handles.text2, 'String', ['Prior Mean = ', num2str(prior_mean)]);
-        set(handles.text3, 'String', ['Prior SD = ', num2str(prior_sd)]);
-    elseif (ens_size < 2)
-        set(h_err_text,'FontWeight','bold')
-    else
-        break;
-    end
+handles.ui_text_prior_sd = uicontrol('Style', 'text', ...
+    'Units', 'Normalized', ...
+    'Position', [0.052 0.762 0.233 0.065], ...
+    'String', 'Prior SD = ', ...
+    'BackgroundColor', 'White', ...
+    'ForegroundColor', atts.green, ...
+    'FontUnits', 'normalized', ...
+    'FontName', atts.fontname, ...
+    'FontSize', 0.4, ...
+    'FontWeight','Bold', ...
+    'HorizontalAlignment', 'right');
 
-    % swap messages once you have a minimal ensemble.
-    if (ens_size == 2)
-        set(h_err_text, 'Visible', 'off');
-        set(h_finish, 'Visible', 'on')
-    end
-end
+handles.ui_text_inflated_prior_sd = uicontrol('Style', 'text', ...
+    'Units', 'Normalized', ...
+    'Position', [0.052 0.713 0.233 0.065], ...
+    'String', 'Inflated = ', ...
+    'Visible', 'Off', ...
+    'BackgroundColor', 'White', ...
+    'ForegroundColor',atts.green,...
+    'FontUnits', 'normalized', ...
+    'FontName', atts.fontname, ...
+    'FontSize', 0.4, ...
+    'FontWeight','Bold', ...
+    'HorizontalAlignment','right');
 
-% Ensemble created, compute mean and sd, clean up and return
-% Set the global gui storage
-handles.ens_size    = ens_size;
-handles.ens_members = x;
+handles.ui_text_post_mean = uicontrol('Style', 'text', ...
+    'Units', 'Normalized', ...
+    'Position', [0.340 0.852 0.270 0.065], ...
+    'String', 'Posterior Mean = ', ...
+    'BackgroundColor', 'White', ...
+    'ForegroundColor', 'b', ...
+    'FontUnits', 'normalized', ...
+    'FontName', atts.fontname, ...
+    'FontSize', 0.4, ...
+    'FontWeight','Bold', ...
+    'HorizontalAlignment','right');
 
-% Update handles structure
-guidata(hObject, handles);
+handles.ui_text_inflated_post_mean = uicontrol('Style', 'text', ...
+    'Units', 'Normalized', ...
+    'Position', [0.340 0.806 0.270 0.065], ...
+    'String', 'Inflated = ', ...
+    'Visible', 'Off', ...
+    'BackgroundColor', 'White', ...
+    'ForegroundColor', 'b', ...
+    'FontUnits', 'normalized', ...
+    'FontName', atts.fontname, ...
+    'FontSize', 0.4, ...
+    'FontWeight','Bold', ...
+    'HorizontalAlignment','right');
 
-% Turn off the data entry messages
-set(h_click,  'Visible', 'off');
-set(h_finish, 'Visible', 'off');
+handles.ui_text_post_sd = uicontrol('Style', 'text', ...
+    'Units', 'Normalized', ...
+    'Position', [0.340 0.762 0.270 0.065], ...
+    'String', 'Posterior SD = ', ...
+    'BackgroundColor', 'White', ...
+    'ForegroundColor', 'b', ...
+    'FontUnits', 'normalized', ...
+    'FontName', atts.fontname, ...
+    'FontSize', 0.4, ...
+    'FontWeight','Bold', ...

@@ Diff output truncated at 40000 characters. @@


More information about the Dart-dev mailing list