[Dart-dev] [4832] DART/trunk/matlab: The WRF interface for plot_correl is ready for use.

nancy at ucar.edu nancy at ucar.edu
Wed Mar 30 09:23:18 MDT 2011


Revision: 4832
Author:   thoar
Date:     2011-03-30 09:23:18 -0600 (Wed, 30 Mar 2011)
Log Message:
-----------
The WRF interface for plot_correl is ready for use.

Modified Paths:
--------------
    DART/trunk/matlab/GetWRFInfo.m
    DART/trunk/matlab/PlotCorrel.m

-------------- next part --------------
Modified: DART/trunk/matlab/GetWRFInfo.m
===================================================================
--- DART/trunk/matlab/GetWRFInfo.m	2011-03-29 20:43:57 UTC (rev 4831)
+++ DART/trunk/matlab/GetWRFInfo.m	2011-03-30 15:23:18 UTC (rev 4832)
@@ -368,25 +368,26 @@
 
 % get the domain id from the pgvar string
 
-dID = 1;
+indx = strfind(pgvar,'_d');
+dID  = pgvar(indx:length(pgvar));
 
 if ( isempty(latstag) && isempty(lonstag) )
 
    % Both unstaggered.
-   latmat = nc_varget(fname, 'XLAT_d01');
-   lonmat = nc_varget(fname,'XLONG_d01');
+   latmat = nc_varget(fname,sprintf( 'XLAT%s',dID));
+   lonmat = nc_varget(fname,sprintf('XLONG%s',dID));
 
 elseif ( isempty(latstag) )
 
    % LAT unstaggered, LON staggered.
-   latmat = nc_varget(fname, 'XLAT_U_d01');
-   lonmat = nc_varget(fname,'XLONG_U_d01');
+   latmat = nc_varget(fname,sprintf( 'XLAT_U%s',dID));
+   lonmat = nc_varget(fname,sprintf('XLONG_U%s',dID));
 
 else
 
    % LAT staggered, LON unstaggered.
-   latmat = nc_varget(fname, 'XLAT_V_d01');
-   lonmat = nc_varget(fname,'XLONG_V_d01');
+   latmat = nc_varget(fname,sprintf( 'XLAT_V%s',dID));
+   lonmat = nc_varget(fname,sprintf('XLONG_V%s',dID));
 
 end
 

Modified: DART/trunk/matlab/PlotCorrel.m
===================================================================
--- DART/trunk/matlab/PlotCorrel.m	2011-03-29 20:43:57 UTC (rev 4831)
+++ DART/trunk/matlab/PlotCorrel.m	2011-03-30 15:23:18 UTC (rev 4832)
@@ -198,14 +198,28 @@
 
       base_mem = Get1Ens( pinfo.fname, pinfo.base_var, pinfo.base_tmeind, ... 
                     pinfo.base_lvlind, pinfo.base_latind, pinfo.base_lonind );
-
+      if (std(base_mem) == 0.0) 
+          warning('%s at level %d lat %d lon %d time %s is a constant\n',pinfo.base_var,...
+             pinfo.base_lvlind,pinfo.base_latind,pinfo.base_lonind,datestr(pinfo.base_time))
+          error('Cannot calculate correlation coefficient with a constant.')
+      end
+      
       comp_ens = GetEnsLevel( pinfo.fname,       pinfo.comp_var, ...
                               pinfo.base_tmeind, pinfo.comp_lvlind);
-
+      if (std(comp_ens(:)) == 0.0) 
+          warning('%s at level %d time %s is a constant\n',pinfo.comp_var,...
+             pinfo.comp_lvlind, datestr(pinfo.base_time))
+          error('Cannot calculate correlation coefficient with a constant.')
+      end
+      
       nmembers = size(comp_ens,1);
 
       corr = zeros(nxny,1);
 
+      % Really should check to see if each comp_ens is a constant value as
+      % well - this is slow enough already.
+      
+      fprintf('Performing correlations at %d locations ...\n',nxny)
       for i = 1:nxny,
          x = corrcoef(base_mem, comp_ens(:, i));
          corr(i) = x(1, 2);


More information about the Dart-dev mailing list