Skip to content

Commit

Permalink
fix bug in mwRTM_param matlab scripts (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
gmao-rreichle authored May 21, 2024
2 parents 82b8ee7 + accd424 commit 9d6d699
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

- Bug fix and improved efficiency in matlab script for generation of mwRTM_param.
- Changed EXPDIR to absolute path for POSTPROC_HIST>0 option to work.

### Removed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@
% round date_time to nearest 3 hourly UTC
utc_t2k = round(double(L2_utc_seconds)/L2_dtstep)*L2_dtstep;

[yr, doy, mm, dd, hr, mn] = J2000_to_DateTime( utc_t2k );
[yr, mm, dd, hr, mn, ss, doy, pen] = J2000_to_DateTime( utc_t2k );

% use points for current UTC day only
idx = find(yr == date_time.year & mm == date_time.month & ...
Expand Down
21 changes: 15 additions & 6 deletions GEOSldas_App/util/shared/matlab/J2000_to_DateTime.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
%
% See also GEOSldas module LDAS_DateTimeMod.F90
%
% reichle, 28 Jul 2028
% reichle, 28 Jul 2023
% qliu+reichle, 21 May 2024 - improved efficiency
%
% ---------------------------------------------------------------------------

if ~exist( 'epoch_id', 'var' ) epoch_id = 'TT12'; end % default is what SMAP uses

date_time_epoch = J2000_epoch( epoch_id );
J2000_seconds = round( J2000_seconds ); % ignore milliseconds

N = length(J2000_seconds);

yr = zeros(N,1);
Expand All @@ -28,11 +29,16 @@
% Loop through elements of J2000_seconds for now. In future, should vectorize
% augment_date_time.m, is_leap_year.m, days_in_month.m, get_dofyr_pentad.m

% Assume that all times in J2000_seconds are close to each other (relative to their
% difference from J2000_epoch). Minimize the work done by augment_date_time() by
% using delta between subsequent elements of J2000_seconds.

date_time_last = J2000_epoch( epoch_id ); % initialize loop
J2000_sec_last = 0;

for ii = 1:N

% add (rounded) J2000_seconds to date_time_epoch

date_time = augment_date_time( round(J2000_seconds), date_time_epoch );
date_time = augment_date_time( J2000_seconds(ii) - J2000_sec_last, date_time_last );

yr( ii) = date_time.year ;
mm( ii) = date_time.month ;
Expand All @@ -43,6 +49,9 @@
pen(ii) = date_time.pentad;
doy(ii) = date_time.dofyr ;

J2000_sec_last = J2000_seconds(ii);
date_time_last = date_time;

end

% ----------------------------------------------------------------------------------
Expand Down

0 comments on commit 9d6d699

Please sign in to comment.