forked from gremau/NMEG_FluxProc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDOYidx.m
26 lines (24 loc) · 772 Bytes
/
DOYidx.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
function idx = DOYidx( DOY )
% DOYidx - calculates the array index for a specified day of year (DOY) in an
% array containing one year's worth of data at 30-minute observation intervals
% (48 observations per day).
%
% DOY may be fractional or integral. 0 <= DOY < 367.
%
% Useful for finding a particular time range within an annual 30-minute dataset.
%
% USAGE
% idx = DOYidx( DOY );
%
% INPUTS
% DOY: numeric; day of year. fractional or integral. 0 <= DOY < 367.
%
% OUTPUTS
% idx: index of DOY in an annual thirty-minute dataset. 0 <= idx <= 17569.
%
% author: Timothy W. Hilton, UNM, June 2012
if ( DOY < 0 ) | ( DOY >= 367 )
error( 'DOY must satisfy 0 <= DOY < 367' );
end
obs_per_day = 48;
idx = int32( ( obs_per_day * DOY ) - obs_per_day + 1 );