Home > utilities > calc_rad.m

calc_rad

PURPOSE ^

Calculating instantaneous irradiance from cloud cover.

SYNOPSIS ^

function [instant_rad, rad] = calc_rad(cloud, lat, jul, secs)

DESCRIPTION ^

 Calculating instantaneous irradiance from cloud cover.

 [instant_rad, rad] = calc_rad(cloud, lat, jul, secs)

 DESCRIPTION:
   Calculate the surface irradiance (short wave) as a function of
   latitude and date.

 INPUT:
   cloud   - cloud cover in percentage (0-1)
   lat     - latitude of observations
   jul     - MATLAB date (see HELP DATENUM)
   secs    - Seconds in the day

 OUTPUT:
   instant_rad     -
   rad             -
 
 EXAMPLE USAGE:
   [cloud, lat, jul, secs] = deal(0.8, 42, floor(datenum(T_TIME(12))), 43200)

 NOTES:
   This routine is taken from GOTM-ERSEM.

 Author(s):
   Ricard Torres (Plymouth Marine Laboratory)

 Revision history:
   2014-01-14 Added to the FVCOM toolbox.
   What units!!!?

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [instant_rad, rad] = calc_rad(cloud, lat, jul, secs)
0002 % Calculating instantaneous irradiance from cloud cover.
0003 %
0004 % [instant_rad, rad] = calc_rad(cloud, lat, jul, secs)
0005 %
0006 % DESCRIPTION:
0007 %   Calculate the surface irradiance (short wave) as a function of
0008 %   latitude and date.
0009 %
0010 % INPUT:
0011 %   cloud   - cloud cover in percentage (0-1)
0012 %   lat     - latitude of observations
0013 %   jul     - MATLAB date (see HELP DATENUM)
0014 %   secs    - Seconds in the day
0015 %
0016 % OUTPUT:
0017 %   instant_rad     -
0018 %   rad             -
0019 %
0020 % EXAMPLE USAGE:
0021 %   [cloud, lat, jul, secs] = deal(0.8, 42, floor(datenum(T_TIME(12))), 43200)
0022 %
0023 % NOTES:
0024 %   This routine is taken from GOTM-ERSEM.
0025 %
0026 % Author(s):
0027 %   Ricard Torres (Plymouth Marine Laboratory)
0028 %
0029 % Revision history:
0030 %   2014-01-14 Added to the FVCOM toolbox.
0031 %   What units!!!?
0032 
0033 subname = 'calc_rad';
0034 
0035 global ftbverbose;
0036 if ftbverbose
0037     fprintf('\nbegin : %s\n', subname)
0038 end
0039 
0040 cycle = 365.0;
0041 pi = 3.141592653589793;
0042 rfactor = pi/180.0;
0043 rconstant = 1368.0;
0044 dq = 149.6;
0045 aa = 149.499;
0046 eps = 0.01675;
0047 sk = 1368.0;
0048 noon = 12.0;
0049 
0050 % Parameter values
0051 a = [0.4, 0.517, 0.474, 0.421, 0.38, 0.35, 0.304, 0.23, 0.106, 0.134];
0052 b = [0.386, 0.317, 0.381, 0.413, 0.468, 0.457, 0.438, 0.384, 0.285, 0.295];
0053 nmth = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 30, 30];
0054 lmth = [0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 30, 30];
0055 cnt = -1;
0056 rcnt = -1;
0057 
0058 % Obtain actual day
0059 [yy, mm, dd, hh, min, ss] = datevec(jul);
0060 
0061 % Leap year?
0062 leap_switch = 2000 - yy;
0063 leap_switch = mod(leap_switch, 4);
0064 
0065 switch leap_switch
0066     case 0
0067         day = 0;
0068         for j = 1:mm
0069             day = day + lmth(j);
0070         end
0071         day = day + dd;
0072     otherwise
0073         day = 0;
0074         for j = 1:mm
0075             day = day + nmth(j);
0076         end
0077         day = day + dd;
0078 end
0079 atime = day - 1 + secs / (3600.0 * 24.0);
0080 
0081 latirad = lat * rfactor;
0082 
0083 corr = 0.09 * cloud * 8.0;
0084 
0085 declination = -0.406 * cos(2.0* pi * floor(atime) / cycle);
0086 daylength = acos(-tan(declination) * tan(latirad));
0087 
0088 rad = -1.0 * ((sin(declination) * sin(latirad) * daylength / 2.0 + ...
0089     cos(declination) * cos(latirad) * sin(daylength / 2.0)) * ...
0090     sk / pi * (1.0 - corr));
0091 daylength = daylength / pi * 24.0;
0092 
0093 t = (secs - noon * 3600.0) * pi / (12.0 * 3600.0);
0094 t0 = (noon - 0.5 * daylength) * 3600.0;
0095 t1 = (noon + 0.5 * daylength) * 3600.0;
0096 instant_rad = rad * (cos(t / (2 * daylength / 24.0)) + ...
0097     0.5 * (1 + cos(t / (daylength / 24.0)))) * 2 * pi / (4 + pi);
0098 if (secs < t0) || (secs > t1)
0099     instant_rad = 0.0;
0100 end
0101 
0102 if ftbverbose
0103     fprintf(['end   : ' subname '\n'])
0104 end
0105 
0106 return

Generated on Wed 20-Feb-2019 16:06:01 by m2html © 2005