Skip to content

Commit 9d6d699

Browse files
fix bug in mwRTM_param matlab scripts (#46)
2 parents 82b8ee7 + accd424 commit 9d6d699

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1717

1818
### Fixed
1919

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

2223
### Removed

GEOSldas_App/util/inputs/mwRTM_params/Preprocess_L2DCA_mwRTM_params_to_dailymat.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@
189189
% round date_time to nearest 3 hourly UTC
190190
utc_t2k = round(double(L2_utc_seconds)/L2_dtstep)*L2_dtstep;
191191

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

194194
% use points for current UTC day only
195195
idx = find(yr == date_time.year & mm == date_time.month & ...

GEOSldas_App/util/shared/matlab/J2000_to_DateTime.m

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@
66
%
77
% See also GEOSldas module LDAS_DateTimeMod.F90
88
%
9-
% reichle, 28 Jul 2028
9+
% reichle, 28 Jul 2023
10+
% qliu+reichle, 21 May 2024 - improved efficiency
1011
%
1112
% ---------------------------------------------------------------------------
1213

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

15-
date_time_epoch = J2000_epoch( epoch_id );
16-
16+
J2000_seconds = round( J2000_seconds ); % ignore milliseconds
17+
1718
N = length(J2000_seconds);
1819

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

32+
% Assume that all times in J2000_seconds are close to each other (relative to their
33+
% difference from J2000_epoch). Minimize the work done by augment_date_time() by
34+
% using delta between subsequent elements of J2000_seconds.
35+
36+
date_time_last = J2000_epoch( epoch_id ); % initialize loop
37+
J2000_sec_last = 0;
38+
3139
for ii = 1:N
3240

33-
% add (rounded) J2000_seconds to date_time_epoch
34-
35-
date_time = augment_date_time( round(J2000_seconds), date_time_epoch );
41+
date_time = augment_date_time( J2000_seconds(ii) - J2000_sec_last, date_time_last );
3642

3743
yr( ii) = date_time.year ;
3844
mm( ii) = date_time.month ;
@@ -43,6 +49,9 @@
4349
pen(ii) = date_time.pentad;
4450
doy(ii) = date_time.dofyr ;
4551

52+
J2000_sec_last = J2000_seconds(ii);
53+
date_time_last = date_time;
54+
4655
end
4756

4857
% ----------------------------------------------------------------------------------

0 commit comments

Comments
 (0)