Changeset 21257
- Timestamp:
- 10/12/16 04:54:28 (8 years ago)
- Location:
- issm/trunk-jpl/src/m
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/m/contrib/defleurian/netCDF/export_netCDF.py
r21251 r21257 94 94 DimDict=CreateVar(NCData,Var,field,NCgroup,DimDict,False) 95 95 else: 96 print('treating {}.{} of type {}'.format(group,field,type(md.__dict__[group].__dict__[field])))97 96 NCgroup.__setattr__('classtype', str(group)) 98 97 Subgroup=NCgroup.createGroup(str(field)) … … 126 125 'int64':'i8', 127 126 numpy.int64:'i8', 128 str: 'str',129 dict: 'str'}127 str:str, 128 dict:str} 130 129 131 130 val_dim=np.shape(val_shape)[0] … … 133 132 #treating scalar string or bool as atribute 134 133 if val_type==str or val_type==unicode or val_type==bool: 135 Group.__setattr__(str(field) , str(var))134 Group.__setattr__(str(field).capitalize(), str(var)) 136 135 #treating list as string table 137 136 elif val_type==list: … … 141 140 nctype=TypeDict[type(var[0])] 142 141 except IndexError: 143 nctype= 'str'#most probably an empty list take str for that142 nctype=str #most probably an empty list take str for that 144 143 ncvar = Group.createVariable(str(field),nctype,dimensions,zlib=True) 145 144 if val_shape==0: … … 151 150 elif val_type=='bool': 152 151 dimensions,DimDict=GetDim(NCData,var,val_shape,DimDict,val_dim,istime) 153 ncvar = Group.createVariable(str(field), 'str',dimensions,zlib=True)152 ncvar = Group.createVariable(str(field),str,dimensions,zlib=True) 154 153 for elt in range(0,val_shape[0]): 155 154 ncvar[elt] = str(var[elt]) … … 157 156 elif val_type==collections.OrderedDict or val_type==dict: 158 157 dimensions,DimDict=GetDim(NCData,var,val_shape,DimDict,val_dim,istime) 159 ncvar = Group.createVariable(str(field), 'str',dimensions,zlib=True)158 ncvar = Group.createVariable(str(field),str,dimensions,zlib=True) 160 159 for elt in range(0,val_dim): 161 160 ncvar[elt,0]=dict.keys(var)[elt] -
issm/trunk-jpl/src/m/io/loadvars.py
r21252 r21257 189 189 t=indexlist[i] 190 190 if listtype=='dict': 191 Tree[t][str(attr) ]=str(listclass.getncattr(attr))192 else: 193 Tree[t].__dict__[str(attr) ]=str(listclass.getncattr(attr))191 Tree[t][str(attr).lower()]=str(listclass.getncattr(attr)) 192 else: 193 Tree[t].__dict__[str(attr).lower()]=str(listclass.getncattr(attr)) 194 194 else: 195 Tree.__dict__[str(attr) ]=str(listclass.getncattr(attr))195 Tree.__dict__[str(attr).lower()]=str(listclass.getncattr(attr)) 196 196 if listclass.getncattr(attr)=='True': 197 Tree.__dict__[str(attr) ]=True197 Tree.__dict__[str(attr).lower()]=True 198 198 elif listclass.getncattr(attr)=='False': 199 Tree.__dict__[str(attr) ]=False199 Tree.__dict__[str(attr).lower()]=False 200 200 NCFile.close() 201 201 if len(args) >= 2 and isinstance(args[1],(str,unicode)): # (value) … … 227 227 else: 228 228 classe=str(group) 229 class_dict[classe]=[str(getattr(NCData.groups[group],'classtype')),] 230 if class_dict[classe][0] not in ['dict','list']: 231 class_dict[classe].append(__import__(class_dict[classe][0])) 232 class_tree[classe]=[group,] 233 229 try: 230 class_dict[classe]=[str(getattr(NCData.groups[group],'classtype')),] 231 if class_dict[classe][0] not in ['dict','list']: 232 class_dict[classe].append(__import__(class_dict[classe][0])) 233 class_tree[classe]=[group,] 234 except AttributeError: 235 print('group {} is empty'.format(group)) 234 236 NCData.close() 235 237 return class_dict,class_tree
Note:
See TracChangeset
for help on using the changeset viewer.