Skip to content

Commit

Permalink
NEW: Python > Matlab - add loadmodel_netcdf.m from "loadmodel_netcdf.…
Browse files Browse the repository at this point in the history
…py".
  • Loading branch information
inwoo-simba committed Dec 11, 2024
1 parent a775369 commit fc6fbc7
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/m/contrib/inwoo/loadmodel_netcdf.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
%{
% Explain
% load netcdf format ISSM model (~ export_netCDF).
%
% Usage
% md = loadmodel_netcdf('Antarctica.nc');
%
% Inputs
%
% Outputs
%}
function md = loadmodel_netcdf(fname)
warning('WARNING: this script is under developement.');

% initialize model
md = model;

% get information.
info = ncinfo(fname);

% get groups;
GroupNames = {info.Groups.Name};

for i = 1:length(GroupNames)
GroupName = GroupNames{i};
posGroup = strcmpi(GroupName, GroupNames);

disp(GroupName);
for j = 1:length(info.Groups(posGroup).Variables)
VarName = info.Groups(posGroup).Variables(j).Name;
md.(GroupName).(VarName) = transpose(ncread(fname,[GroupName '/' VarName]));
end
break;
end

% figure out groups!

end

0 comments on commit fc6fbc7

Please sign in to comment.