Changeset 21151
- Timestamp:
- 08/22/16 00:45:40 (9 years ago)
- Location:
- issm/trunk-jpl
- Files:
-
- 282 added
- 274 deleted
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/m/Makefile.am
r21139 r21151 8 8 if !DEVELOPMENT 9 9 bin_SCRIPTS += ${ISSM_DIR}/src/m/qmu/*.m \ 10 ${ISSM_DIR}/src/m/archive/*.m \ 10 11 ${ISSM_DIR}/src/m/qmu/setupdesign/*.m \ 11 12 ${ISSM_DIR}/src/m/qmu/plot/*.m \ … … 50 51 if PYTHON 51 52 if !DEVELOPMENT 52 bin_SCRIPTS += ${ISSM_DIR}/src/m/classes/*.py \ 53 bin_SCRIPTS += ${ISSM_DIR}/src/m/archive/*.py \ 54 ${ISSM_DIR}/src/m/classes/*.py \ 53 55 ${ISSM_DIR}/src/m/classes/clusters/*.py \ 54 56 ${ISSM_DIR}/src/m/consistency/*.py \ -
issm/trunk-jpl/src/m/miscellaneous/netcdf2struct.m
r13012 r21151 5 5 % S=netcdf2struct(File); 6 6 7 %Read netcdf file8 data=readnetcdf(File);7 %Read netcdf file 8 data=readnetcdf(File); 9 9 10 %initialize output11 S=struct();10 %initialize output 11 S=struct(); 12 12 13 %All the variables are in VarArray field14 variables=data.VarArray;15 for i=1:size(variables,2),16 fieldname=deblank(variables(i).Str);17 fieldvalue=double(squeeze(variables(i).Data));18 S.(fieldname)=fieldvalue;19 end13 %All the variables are in VarArray field 14 variables=data.VarArray; 15 for i=1:size(variables,2), 16 fieldname=deblank(variables(i).Str); 17 fieldvalue=double(squeeze(variables(i).Data)); 18 S.(fieldname)=fieldvalue; 19 end 20 20 21 %All the variables are in AttArray field22 variables=data.AttArray;23 for i=1:size(variables,2),24 fieldname=deblank(variables(i).Str);25 fieldvalue=double(variables(i).Val);26 S.(fieldname)=fieldvalue;27 end21 %All the variables are in AttArray field 22 variables=data.AttArray; 23 for i=1:size(variables,2), 24 fieldname=deblank(variables(i).Str); 25 fieldvalue=double(variables(i).Val); 26 S.(fieldname)=fieldvalue; 27 end 28 28 end 29 29 … … 113 113 % Size of NetCDF data type, ID, in bytes 114 114 S = subsref([1,1,2,4,4,8],struct('type','()','subs',{{ID}})); 115 end 115 116 116 117 function T = Type(ID) 117 118 % Matlab string for CDF data type, ID 118 119 T = subsref({'int8','char','int16','int32','single','double'},... 119 struct('type','{}','subs',{{ID}})); 120 struct('type','{}','subs',{{ID}})); 121 end 120 122 121 123 function N = Pad(Num,ID) 122 124 % Number of elements to read after padding to 4 bytes for type ID 123 125 N = (double(Num) + mod(4-double(Num)*Size(ID),4)/Size(ID)).*(Num~=0); 126 end 124 127 125 128 function S = String(fp) 126 129 % Read a CDF string; Size,[String,[Padding]] 127 130 S = fread(fp,Pad(fread(fp,1,'uint32=>uint32'),1),'uint8=>char').'; 131 end 128 132 129 133 function A = ReOrder(A,S) 130 134 % Rearrange CDF array A to size S with matlab ordering 131 135 A = permute(reshape(A,fliplr(S)),fliplr(1:length(S))); 136 end 132 137 133 138 function S = DimArray(fp) … … 139 144 end 140 145 else fread(fp,1,'uint32=>uint32'); S = []; end 146 end 141 147 142 148 function S = AttArray(fp) … … 150 156 end 151 157 else fread(fp,1,'uint32=>uint32'); S = []; end 158 end 152 159 153 160 function S = VarArray(fp) -
issm/trunk-jpl/test/NightlyRun/README
r13143 r21151 34 34 To modify some characteristics, do it in the testxxx.m file. 35 35 Specify the field_names the field_values and the tolerance at the end of the test file. 36 Don't forget to commit the archive (Archivexxx. ncin ../Archives)36 Don't forget to commit the archive (Archivexxx.arch in ../Archives) -
issm/trunk-jpl/test/NightlyRun/runme.m
r20182 r21151 140 140 archive_name=['Archive' num2str(id) ]; 141 141 if strcmpi(procedure,'update'), 142 delete(['../Archives/' archive_name '. nc'])142 delete(['../Archives/' archive_name '.arch']) 143 143 for k=1:length(field_names), 144 144 field=field_values{k}; 145 145 % matlab writes the dimensions reversed and matrices transposed into netcdf, so compensate for that 146 nccreate(['../Archives/' archive_name '.nc'],[archive_name '_field' num2str(k)],... 147 'Dimensions',{[archive_name '_field' num2str(k) '_2'] size(field,2) [archive_name '_field' num2str(k) '_1'] size(field,1)},... 148 'Format','classic'); 149 ncwrite(['../Archives/' archive_name '.nc'],[archive_name '_field' num2str(k)],transpose(field)); 146 archwrite(['../Archives/' archive_name '.arch'],[archive_name '_field' num2str(k)], transpose(field)); 150 147 end 151 disp(sprintf(['File ./../Archives/' archive_name '. ncsaved\n']));148 disp(sprintf(['File ./../Archives/' archive_name '.arch saved\n'])); 152 149 153 150 %CHECK for memory leaks? … … 215 212 216 213 %compare to archive 217 % matlab reads the dimensions reversed and matrices transposed from netcdf, so compensate for that 218 archive=transpose(ncread(['../Archives/' archive_name '.nc'],[archive_name '_field' num2str(k)])); 219 error_diff=full(max(abs(archive(:)-field(:)))/(max(abs(archive))+eps)); 214 %our output is in the correct order (n,1) or (1,1), so we do not need to transpose again 215 archive_cell=archread(['../Archives/' archive_name '.arch'],[archive_name '_field' num2str(k)]); 216 archive=archive_cell{1}; 217 error_diff=full(max(abs(archive(:)-field(:)))/(max(abs(archive(:)))+eps)); 220 218 221 219 %disp test result -
issm/trunk-jpl/test/NightlyRun/runme.py
r20914 r21151 4 4 import socket 5 5 import numpy 6 import netCDF47 6 import sys 8 7 import traceback … … 47 46 from MatlabFuncs import strcmpi 48 47 from MatlabFuncs import ismember 48 from arch import archread 49 from arch import archwrite 50 from arch import archdisp 49 51 50 52 #Get ISSM_DIR variable … … 140 142 archive_name='Archive'+str(id) 141 143 if strcmpi(procedure,'update'): 142 archive=os.path.join('..','Archives',archive_name+'.nc') 143 if os.path.isfile(archive): 144 os.remove(archive) 145 f = netCDF4.Dataset(archive,'w',format='NETCDF3_CLASSIC') 144 archive_file=os.path.join('..','Archives',archive_name+'.arch') 145 if os.path.isfile(archive_file): 146 os.remove(archive_file) 146 147 for k,fieldname in enumerate(field_names): 147 148 field=numpy.array(field_values[k],dtype=float) … … 154 155 field=field.reshape(1,1) 155 156 # Matlab uses base 1, so use base 1 in labels 156 f.createDimension(archive_name+'_field'+str(k+1)+'_1',numpy.size(field,0)) 157 f.createDimension(archive_name+'_field'+str(k+1)+'_2',numpy.size(field,1)) 158 v = f.createVariable(archive_name+'_field'+str(k+1),field.dtype,(archive_name+'_field'+str(k+1)+'_1',archive_name+'_field'+str(k+1)+'_2')) 159 v[:] = field 160 f.close() 161 print "File '%s' saved.\n" % os.path.join('..','Archives',archive_name+'.nc') 157 archwrite(archive_file,archive_name+'_field'+str(k+1),field) 158 print "File '%s' saved.\n" % os.path.join('..','Archives',archive_name+'.arch') 162 159 163 160 #ELSE: CHECK TEST … … 165 162 166 163 #load archive 167 if os.path.exists(os.path.join('..','Archives',archive_name+'. nc')):168 f = netCDF4.Dataset(os.path.join('..','Archives',archive_name+'.nc'),'r')164 if os.path.exists(os.path.join('..','Archives',archive_name+'.arch')): 165 archive_file=os.path.join('..','Archives',archive_name+'.arch') 169 166 else: 170 raise IOError("Archive file '"+os.path.join('..','Archives',archive_name+'. nc')+"' does not exist.")167 raise IOError("Archive file '"+os.path.join('..','Archives',archive_name+'.arch')+"' does not exist.") 171 168 172 169 for k,fieldname in enumerate(field_names): … … 184 181 #compare to archive 185 182 # Matlab uses base 1, so use base 1 in labels 186 if archive_name+'_field'+str(k+1) in f.variables: 187 archive=f.variables[archive_name+'_field'+str(k+1)][:] 188 else: 183 archive=numpy.array(archread(archive_file,archive_name+'_field'+str(k+1))) 184 if archive == None: 189 185 raise NameError("Field name '"+archive_name+'_field'+str(k+1)+"' does not exist in archive file.") 190 186 error_diff=numpy.amax(numpy.abs(archive-field),axis=0)/ \ … … 214 210 raise RuntimeError(message) 215 211 216 f.close()217 212 218 213 except Exception as message:
Note:
See TracChangeset
for help on using the changeset viewer.