Changeset 27864
- Timestamp:
- 07/31/23 10:31:28 (20 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/m/contrib/musselman/read_netCDF.m
r27860 r27864 4 4 2. For each variable in each group, update an empty model with the variable's data 5 5 3. Enter nested groups and repeat 6 7 8 If the model you saved has subclass instances that are not in the standard model() class 9 you can: 10 1. Copy lines 30-35, set the "results" string to the name of the subclass instance, 11 2. Copy and modify the make_results_subclasses() function to create the new subclass 12 instances you need. 13 From there, the rest of this script will automatically create the new subclass 14 instance in the model you're writing to and store the data from the netcdf file there. 6 15 %} 7 16 … … 89 98 90 99 91 %{92 function make_results_subclasses()93 global model_copy;94 global NCData;95 resultsGroup = netcdf.inqNcid(NCData, "results");96 subgroups = netcdf.inqGrps(resultsGroup);97 for subgroup = subgroups98 groupName = netcdf.inqGrpName(subgroup)99 100 101 102 class_instance = netcdf.inqVar(resultsGroup, name);103 class_instance_name = convertCharsToStrings(netcdf.getVar(resultsGroup, name, 'char'));104 model_copy.results = setfield(model_copy.results, class_instance, class_instance_name);105 end106 disp('Successfully recreated results struct')107 end108 %}109 110 111 100 function walk_nested_groups(group_location_in_file) 112 101 global model_copy; … … 132 121 if not(isempty(groups)) 133 122 for group = groups 134 disp('found nested group!!')123 %disp('found nested group!!') 135 124 group_id = netcdf.inqNcid(group_location_in_file, netcdf.inqGrpName(group)); 136 disp(netcdf.inqGrpNameFull(group_id))125 %disp(netcdf.inqGrpNameFull(group_id)) 137 126 walk_nested_groups(group); 138 127 end
Note:
See TracChangeset
for help on using the changeset viewer.