source: LMDZ6/branches/LMDZ_ECRad/libf/phylmd/ecrad/test/ckdmip/calc_hr_error.m @ 4993

Last change on this file since 4993 was 4728, checked in by idelkadi, 11 months ago

Update of ecrad in the LMDZ_ECRad branch of LMDZ:

  • version 1.6.1 of ecrad
  • files are no longer grouped in the same ecrad directory.
  • the structure of ecrad offline is preserved to facilitate updating in LMDZ
  • cfg.bld modified to take into account the new added subdirectories.
  • the interface routines and those added in ecrad are moved to the phylmd directory
File size: 783 bytes
Line 
1% Compute RMS error in heating rate, in K d-1, weighting by the
2% cube-root of pressure, where pressure arguments are in hPa
3function err = calc_hr_error(pressure_hl, hr, hr_ref, pressure_range);
4
5  % If final argument not provided, consider all pressure ranges
6  if nargin < 4
7    pressure_range = [0 Inf];
8  end
9
10  mypow = (1./3);
11 
12  pressure_fl = 0.5.*(pressure_hl(1:end-1,:) + pressure_hl(2:end,:));
13  weight = (pressure_hl(2:end,:)).^mypow - (pressure_hl(1:end-1,:)).^mypow;
14
15  index = find(pressure_fl < pressure_range(1) | pressure_fl >= pressure_range(2));
16  if ~isempty(index)
17    weight(index) = 0;
18  end
19  nprof = size(weight,2);
20  for ii = 1:nprof
21    weight(:,ii) = weight(:,ii) ./ sum(weight(:,ii));
22  end
23  err = sqrt(sum(weight(:) .* (hr(:)-hr_ref(:)).^2)./nprof);
Note: See TracBrowser for help on using the repository browser.