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/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..c089a39 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,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 ; @@ -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 % ----------------------------------------------------------------------------------