Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto PR - develop β†’ MAPL-v3 - fix bugs in mwRTM_param matlab scripts #47

Merged
merged 4 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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