From 75a68ba42e46b498e5e6c5b27daadac7d2293dac Mon Sep 17 00:00:00 2001 From: Qing Liu Date: Mon, 20 May 2024 17:50:05 -0400 Subject: [PATCH 1/3] fix bugs in mwRTM_param matlab scripts --- .../mwRTM_params/Preprocess_L2DCA_mwRTM_params_to_dailymat.m | 2 +- GEOSldas_App/util/shared/matlab/J2000_to_DateTime.m | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/GEOSldas_App/util/inputs/mwRTM_params/Preprocess_L2DCA_mwRTM_params_to_dailymat.m b/GEOSldas_App/util/inputs/mwRTM_params/Preprocess_L2DCA_mwRTM_params_to_dailymat.m index 061229b..45c39c3 100644 --- a/GEOSldas_App/util/inputs/mwRTM_params/Preprocess_L2DCA_mwRTM_params_to_dailymat.m +++ b/GEOSldas_App/util/inputs/mwRTM_params/Preprocess_L2DCA_mwRTM_params_to_dailymat.m @@ -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 & ... diff --git a/GEOSldas_App/util/shared/matlab/J2000_to_DateTime.m b/GEOSldas_App/util/shared/matlab/J2000_to_DateTime.m index d2e52d2..48f1319 100644 --- a/GEOSldas_App/util/shared/matlab/J2000_to_DateTime.m +++ b/GEOSldas_App/util/shared/matlab/J2000_to_DateTime.m @@ -28,11 +28,12 @@ % 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 +date_time_base = augment_date_time( round(J2000_seconds(1)), date_time_epoch ); + 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( round(J2000_seconds(ii)-J2000_seconds(1)), date_time_base ); yr( ii) = date_time.year ; mm( ii) = date_time.month ; From 78205c4a418da29824038a339205fde06be287a6 Mon Sep 17 00:00:00 2001 From: Rolf Reichle Date: Tue, 21 May 2024 09:44:25 -0400 Subject: [PATCH 2/3] added CHANGELOG.md entry; further refined algorithm in J2000_to_DateTime.m --- CHANGELOG.md | 1 + .../util/shared/matlab/J2000_to_DateTime.m | 20 +++++++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f08c221..5ece4c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/GEOSldas_App/util/shared/matlab/J2000_to_DateTime.m b/GEOSldas_App/util/shared/matlab/J2000_to_DateTime.m index 48f1319..0be92af 100644 --- a/GEOSldas_App/util/shared/matlab/J2000_to_DateTime.m +++ b/GEOSldas_App/util/shared/matlab/J2000_to_DateTime.m @@ -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); @@ -28,12 +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 -date_time_base = augment_date_time( round(J2000_seconds(1)), date_time_epoch ); +% 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(ii)-J2000_seconds(1)), date_time_base ); + date_time = augment_date_time( J2000_seconds(ii) - J2000_sec_last ), date_time_last ); yr( ii) = date_time.year ; mm( ii) = date_time.month ; @@ -44,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 % ---------------------------------------------------------------------------------- From accd42404cb2df1583b0b0bfc580974d0fcf5e62 Mon Sep 17 00:00:00 2001 From: Rolf Reichle <54944691+gmao-rreichle@users.noreply.github.com> Date: Tue, 21 May 2024 12:34:53 -0400 Subject: [PATCH 3/3] Fix syntax error in J2000_to_DateTime.m --- GEOSldas_App/util/shared/matlab/J2000_to_DateTime.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GEOSldas_App/util/shared/matlab/J2000_to_DateTime.m b/GEOSldas_App/util/shared/matlab/J2000_to_DateTime.m index 0be92af..c089a39 100644 --- a/GEOSldas_App/util/shared/matlab/J2000_to_DateTime.m +++ b/GEOSldas_App/util/shared/matlab/J2000_to_DateTime.m @@ -38,7 +38,7 @@ for ii = 1:N - date_time = augment_date_time( J2000_seconds(ii) - J2000_sec_last ), date_time_last ); + date_time = augment_date_time( J2000_seconds(ii) - J2000_sec_last, date_time_last ); yr( ii) = date_time.year ; mm( ii) = date_time.month ;