-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsubsolar.m
More file actions
32 lines (27 loc) · 928 Bytes
/
subsolar.m
File metadata and controls
32 lines (27 loc) · 928 Bytes
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
function [lat,lon] = subsolar(Y,M,D,h,m,s)
% subsolar.m
% 13 May 2022
%
% Calculates subsolar point in lat/lon coordinates from universal time
% input. Subsolar point latitude = solar declination; subsolar point
% longitude calculated from time of day.
%
% Supported input formats: Nx1 datenum, Nx6 [yy mm dd HH MM SS], or 6
% separate vectors of yy mm dd HH MM SS.
switch nargin
case 1
if size(Y,2) == 1
timein = datetime(Y,'ConvertFrom','datenum');
elseif size(Y,2) == 6
timein = datetime(Y);
else
error("Numeric data must be an Nx1 array of datenums, or an Nx6 array with columns [yyyy mm dd HH MM SS]");
end
case 6
timein = datetime(Y,M,D,h,m,s);
end
days = day(timein,'dayofyear');
hour_frac = rem(datenum(timein),1);
lon = 180 - hour_frac*360;
lat = asind(sind(23.45)*sind(360*(days - 81)/365));
end