% gfd_read_sfc_flux_data
% Script to read in gfd flux data
% GNPetersen January 2008
% Including bulk values
% See notes at bottom for more information

dirf = '/local/e607/GFDex/FAAM';
file = 'gfd_sfc_flux_data.txt';
cd(dirf);
flux_data = load(file);


jday        = flux_data(:,1);       % Julian day of start of run
cday        = flux_data(:,2);       % Calendar day of start of run
BXXX        = flux_data(:,3);       % Mission identifier
lat         = flux_data(:,4);       % Latitude (deg)
lon         = flux_data(:,5);       % Longitude (deg)
flag        = flux_data(:,6);       % 1: sea, 2: MIZ/ice
dist        = flux_data(:,7);       % Length of run (km)
altitude    = flux_data(:,8);       % Radar altitude (m)
altitude_std= flux_data(:,9);       % Stdev radar altitude (m)
heading     = flux_data(:,10);      % Heading (deg)
pressure    = flux_data(:,11);      % Air pressure (hPa)
wind_speed  = flux_data(:,12);      % Horisontal wind speed (m s-1)
wind_dir    = flux_data(:,13);      % Wind direction (deg)
vert_wind   = flux_data(:,14);      % Vertical wind velocity (m s-1)
temp        = flux_data(:,15);      % Air temperature (K)
temp_dew    = flux_data(:,16);      % Dew point (K)
q           = flux_data(:,17);      % Air specific humidity (g/kg)  
theta       = flux_data(:,18);      % Pot. temp., 1.order approximation: theta = T+gamma.z  (K)  
theta_v     = flux_data(:,19);      % Virtual pot. temperature (K)
rho         = flux_data(:,20);      % Density (kg m-3)  
mslp        = flux_data(:,21);      % Mean sea level pressure
temp_sfc    = flux_data(:,22);      % Surface temperature (K) (Upwell. brightn. temp.) 
q_sfc       = flux_data(:,23);      % Surface air specific humidity (g kg-1)
sw_up       = flux_data(:,24);      % Short wave upward (W m-2) 
sw_down     = flux_data(:,25);      % Short wave downward (W m-2)
lw_up       = flux_data(:,26);      % Long wave upward (W m-2) 
lw_down     = flux_data(:,27);      % Long wave downward (W m-2) 
u_10m       = flux_data(:,28);      % Wind speed adjusted to 10 m (m s-1)
t_2m        = flux_data(:,29);      % Temperature adjusted to 2 m (K)
q_2m        = flux_data(:,30);      % Specific humidity adjusted to 2 m (g kg-1)
rh_2m       = flux_data(:,31);      % Relative humidity at 2 m (%)
u_10N       = flux_data(:,32);      % 10-m neutral wind speed (m s-1)
L           = flux_data(:,33);      % Monin-Obukhov length (m)
tau         = flux_data(:,34);      % Wind stress (N m-2)
ustar       = flux_data(:,35);      % Friction velocity (m s-1)
z0          = flux_data(:,36);      % Surface roughness length (m)
Cdn         = flux_data(:,37);      % 10-m neutral drag coefficient
SH          = flux_data(:,38);      % Sensible heat flux (W m-2)
thetastar   = flux_data(:,39);      % Friction potential temperature (K)
tstar       = flux_data(:,40);      % Friction temperature (K)
z0_t        = flux_data(:,41);      % Surface roughness lenght wrt heat based on theta (m)
Chn         = flux_data(:,42);      % 10-m neutral heat exchange coefficient 
LH          = flux_data(:,43);      % Latent heat flux (W m-2)
qstar       = flux_data(:,44);      % Friction moisture (g kg-1)
z0_q        = flux_data(:,45);      % Surface roughness lenght wrt moisture (m)
Cen         = flux_data(:,46);      % 10-m neutral moisture exchange coefficient
% BULK algorithms:
tau_bulk    = flux_data(:,47);      % Smith (1988): wind stress (N m-2)
SH_bulk     = flux_data(:,48);      % Smith (1988): sensible heat flux (W m-2)
LH_bulk     = flux_data(:,49);      % Smith (1988): latent heat flux (W m-2)
u_10N_coare = flux_data(:,50);      % Coare3.0: 10-m neutral wind speed (m s-1)
u_10m_coare = flux_data(:,51);      % Coare3.0: 10-m wind speed (m s-1)
t_2m_coare  = flux_data(:,52);      % Coare3.0: 2-m temperature (K)
q_2m_coare  = flux_data(:,53);      % Coare3.0: 2-m specific humidity (g kg-1)
rh_2m_coare = flux_data(:,54);      % Coare3.0: 2-m relative humidity (%)
tau_coare   = flux_data(:,55);      % Coare3.0: wind stress (W m-2)
z0_coare    = flux_data(:,56);      % Coare3.0: surface roughness length (m)
Cdn_coare   = flux_data(:,57);      % Coare3.0: 10-m neutral drag coefficient
SH_coare    = flux_data(:,58);      % Coare3.0: sensible heat flux (W m-2)
z0_t_coare  = flux_data(:,59);      % Coare3.0: surface roughness length wrt heat (m)
Chn_coare   = flux_data(:,60);      % Coare3.0: 10-m neutral heat exchange coefficient
LH_coare    = flux_data(:,61);      % Coare3.0: latent heat flux (W m-2)
z0_q_coare  = flux_data(:,62);      % Coare3.0: surface roughness length wrt moisture (m)
Cen_coare   = flux_data(:,63);      % Coare3.0: 10-m neutral moisture exchange coefficient
tau_bulk_gfd= flux_data(:,64);      % Smith (1988) w/GFD coeffs: Cdn = 2.04e-03
SH_bulk_gfd = flux_data(:,65);      % Smith (1988): Chn = 1.63e-03
LH_bulk_gfd = flux_data(:,66);      % Smith (1988): Cen = 1.57e-03

sday = jday + datenum(2006,12,31,0,0,0);    % serial day

sea = find(flag == 1);
ice = find(flag == 2);

% Note:
% 
% * B268 u_10m_coare and u_10N_coare are missing, use EC values instead
%   u_10m_coare(find(BXXX==268)) = u_10m(find(BXXX==268));
%   u_10N_coare(find(BXXX==268)) = u_10N(find(BXXX==268));
% * B268 has only eddy covariance momentum fluxes
% * B274 has no eddy covariance fluxes
% * B274 air temperature is the deiced temp - 0.48K
% * B268, B271 and B274 temp_sfc is the OSTIA SST - 1.5K
% * B274 horizontal wind is substitute wind derived by Alan Wolley, FAAM, 
%   there is no vertical component.
% * theta = temp + gamma * altitude, gamma =   = 0.00975 K m-1

return;
