-
Notifications
You must be signed in to change notification settings - Fork 12
/
swhf.m
42 lines (34 loc) · 1.38 KB
/
swhf.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
function [qsw,alb]=swhf(yd,yr,long,lat,dsw)
% SWHF: computes net shortwave heat flux into the ocean and albedo.
% [qsw,alb]=SWHF(yd,yr,long,lat,dsw) computes the net shortwave heat
% flux into the ocean and albedo, using Payne (1972), J. Atm. Sci., 29,
% 959-970, to estimate the instantaneous albedo given the atmospheric
% transmittance (the ratio of measured insolation to the no-atmosphere
% insolation).
%
% INPUT: yd - decimal yearday (e.g., 0000Z Jan 1 is 0.0)
% yr - year (e.g., 1995)
% long - longitude [deg]
% lat - latitude [deg]
% dsw - (measured) insolation [W/m^2]
%
% OUTPUT: qsw - net shortwave heat flux [W/m^2]
% alb - albedo
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 3/8/97: version 1.0
% 7/29/99: version 1.1
% 8/5/99: version 2.0
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% compute sun altitude and no atm solar radiation
[sunalt, sorad]=soradna1(yd,yr,long,lat);
% compute atm transmittance (note: trans=Inf when sorad=0)
trans=inf.*ones(size(sorad));
j=find(sorad>0);
trans(j)=dsw(j)./sorad(j);
% compute albedo (note: alb=NaN when trans>1 or sunalt<0)
alb=albedo(trans, sunalt);
% compute net shortwave heat flux
% (note: qsw set equal to 0 when alb=NaN)
qsw=(1-alb).*dsw;
ind=find(isnan(qsw));
qsw(ind)=zeros(size(ind));