Changeset 25458
- Timestamp:
- 08/25/20 03:56:28 (5 years ago)
- Location:
- issm/trunk-jpl/src/m/contrib/defleurian/netCDF
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/m/contrib/defleurian/netCDF/export_netCDF.m
r24530 r25458 29 29 end 30 30 31 dimlist=[ 40,2,md.mesh.numberofelements,md.mesh.numberofvertices,size(md.mesh.elements,2)];31 dimlist=[2,md.mesh.numberofelements,md.mesh.numberofvertices,size(md.mesh.elements,2)]; 32 32 33 33 %define netcdf dimensions 34 DimSize(1).index=netcdf.defDim(ncid,' Dimension1',StepNum);34 DimSize(1).index=netcdf.defDim(ncid,'Time',StepNum); 35 35 [DimSize(1).name,DimSize(1).value]=netcdf.inqDim(ncid,DimSize(1).index); 36 36 DimValue(1)=DimSize(1).value; 37 DimSize(2).index=netcdf.defDim(ncid,'UnLim',netcdf.getConstant('NC_UNLIMITED')); 38 [DimSize(2).name,DimSize(2).value]=netcdf.inqDim(ncid,DimSize(2).index); 39 DimValue(2)=DimSize(2).value; 37 40 for i=1:5 38 41 if sum(dimlist(i) == DimValue) == 0 39 DimSize(i+ 1).index=netcdf.defDim(ncid,['Dimension' num2str(i+1)],dimlist(i));40 [DimSize(i+ 1).name,DimSize(i+1).value]=netcdf.inqDim(ncid,DimSize(i+1).index);41 DimValue(i+ 1)=DimSize(i+1).value;42 DimSize(i+2).index=netcdf.defDim(ncid,['Dimension' num2str(i+2)],dimlist(i)); 43 [DimSize(i+2).name,DimSize(i+2).value]=netcdf.inqDim(ncid,DimSize(i+2).index); 44 DimValue(i+2)=DimSize(i+2).value; 42 45 end 43 46 end -
issm/trunk-jpl/src/m/contrib/defleurian/netCDF/export_netCDF.py
r25191 r25458 16 16 else: 17 17 for r in row: 18 #print("appending {}".format(r)) 18 19 self.data.append(r) 19 20 … … 126 127 if verbose > 4: 127 128 print("=$$=creating var for {}.{}.{}".format(group, field, subfield)) 128 print( lastindex)129 print("last index of the list is {}".format(lastindex)) 129 130 StackedVar = SqueezeVar(StackedVar.finalize(int(lastindex))) 130 131 DimDict, ncvar = CreateVar(NCData, StackedVar, subfield, Subgroup, DimDict) … … 156 157 if ncvar is not None: 157 158 FillVar(ncvar, Var) 159 # this is a multi layered group thta should not be an "else" 158 160 else: 159 161 NCgroup.__setattr__('classtype', str(group)) 160 162 Subgroup = NCgroup.createGroup(str(field)) 161 Subgroup.__setattr__('classtype', md.__dict__[group].__class__.__name__) 163 if str(group) == 'solidearth' and str(field) == 'settings': 164 Subgroup.__setattr__('classtype', 'solidearthsettings') 165 else: 166 Subgroup.__setattr__('classtype', str(field)) 162 167 subfields = dict.keys(md.__dict__[group].__dict__[field].__dict__) 163 168 for subfield in subfields: … … 260 265 try: 261 266 val_type = str(invar.dtype) 267 if val_type.startswith('<U'): 268 val_type = 'stringarray' 262 269 except AttributeError: 263 270 val_type = type(invar) … … 267 274 else: 268 275 val_shape = np.shape(invar) 276 269 277 # Now fill up variable 270 278 # treating list as string table … … 275 283 for elt in range(0, val_shape[0]): 276 284 ncvar[elt] = invar[elt] 285 # writing string table 286 elif val_type == "stringarray": 287 for elt in range(0, val_shape[0]): 288 ncvar[elt] = invar[elt] 277 289 # treating bool tables as string tables 278 290 elif val_type == 'bool':
Note:
See TracChangeset
for help on using the changeset viewer.