Changeset 19157
- Timestamp:
- 02/26/15 09:07:32 (10 years ago)
- Location:
- issm/trunk-jpl/src/m
- Files:
-
- 2 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/m/classes/model.py
r19048 r19157 29 29 from toolkits import toolkits 30 30 from generic import generic 31 from pfe import pfe 32 from greenplanet import greenplanet 31 33 from balancethickness import balancethickness 32 34 from stressbalance import stressbalance -
issm/trunk-jpl/src/m/contrib/netCDF/export_netCDF.py
r19097 r19157 1 from netCDF4 import Dataset 1 from netCDF4 import Dataset, stringtochar 2 2 import numpy 3 3 import time … … 34 34 Dimension3=NCData.createDimension('Dimension3',numpy.shape(md.mesh.elements)[1]) 35 35 Dimension4=NCData.createDimension('Dimension4',StepNum) 36 Dimension5=NCData.createDimension('Dimension5',2) 36 Dimension5=NCData.createDimension('Dimension5',40) 37 Dimension6=NCData.createDimension('Dimension6',2) 37 38 38 39 DimDict = {len(Dimension1):'Dimension1', … … 40 41 len(Dimension3):'Dimension3', 41 42 len(Dimension4):'Dimension4', 42 len(Dimension5):'Dimension5'} 43 len(Dimension5):'Dimension5', 44 len(Dimension6):'Dimension6'} 43 45 44 46 #get all model classes and create respective groups … … 114 116 elif val_type==list: 115 117 dimensions,DimDict=GetDim(NCData,var,val_shape,DimDict,val_dim,istime) 116 ncvar = Group.createVariable(str(field),str,dimensions,zlib=True) 118 ncvar = Group.createVariable(str(field),'S1',dimensions,zlib=True) 119 charvar=stringtochar(numpy.array(var)) 120 print charvar 121 print charvar.shape 117 122 for elt in range(0,val_dim): 118 123 try: 119 ncvar[elt] = var[elt]124 ncvar[elt] = charvar[elt] 120 125 except IndexError: 121 126 ncvar[0]= " " … … 123 128 elif val_type=='bool': 124 129 dimensions,DimDict=GetDim(NCData,var,val_shape,DimDict,val_dim,istime) 125 ncvar = Group.createVariable(str(field), str,dimensions,zlib=True)130 ncvar = Group.createVariable(str(field),'S1',dimensions,zlib=True) 126 131 for elt in range(0,val_shape[0]): 127 132 ncvar[elt] = str(var[elt]) … … 129 134 elif val_type==collections.OrderedDict: 130 135 dimensions,DimDict=GetDim(NCData,var,val_shape,DimDict,val_dim,istime) 131 ncvar = Group.createVariable(str(field), str,dimensions,zlib=True)136 ncvar = Group.createVariable(str(field),'S1',dimensions,zlib=True) 132 137 for elt in range(0,val_dim): 133 138 ncvar[elt,0]=dict.keys(var)[elt] … … 169 174 def GetDim(NCData,var,shape,DimDict,i,istime): 170 175 output=[] 176 #grab type 177 try: 178 val_type=str(var.dtype) 179 except AttributeError: 180 val_type=type(var) 181 #grab dimension 171 182 for dim in range(0,i): #loop on the dimensions 172 183 if type(shape[0])==int: … … 187 198 NewDim=NCData.createDimension('Dimension'+str(index),numpy.shape(shape)[0]) 188 199 DimDict[len(NewDim)]='Dimension'+str(index) 189 output=[str(DimDict[numpy.shape(dict.keys(var))[0]])]+['Dimension 5']200 output=[str(DimDict[numpy.shape(dict.keys(var))[0]])]+['Dimension6'] 190 201 print 'Defining dimension ' +'Dimension'+str(index) 191 202 break 192 203 if istime: 193 204 output=output+['Dimension4'] 205 #dealing with char and not string as we should so we need to had a string length 206 if val_type=='bool' or val_type==collections.OrderedDict or val_type==list: 207 charvar=stringtochar(numpy.array(var)) 208 stringlength=charvar.shape[charvar.ndim-1] 209 try: 210 output=output+[str(DimDict[stringlength])] #test if the dimension allready exist 211 except KeyError: #if not create it 212 if (shape[dim])>1: 213 index=len(DimDict)+1 214 NewDim=NCData.createDimension('Dimension'+str(index),(stringlength)) 215 DimDict[len(NewDim)]='Dimension'+str(index) 216 output=output+[str(DimDict[stringlength])] 217 print 'Defining dimension ' +'Dimension'+str(index) 194 218 return tuple(output), DimDict -
issm/trunk-jpl/src/m/contrib/netCDF/read_netCDF.m
r19096 r19157 21 21 subclass = netcdf.getAtt(subgroupIDs(j),netcdf.getConstant('NC_GLOBAL'),'classtype'); 22 22 self.results=setfield(self.results,subclass,struct); 23 [ndims nvar natts]=netcdf.inq( groupIDs(j));23 [ndims nvar natts]=netcdf.inq(subgroupIDs(j)); 24 24 varIDs=netcdf.inqVarIDs(subgroupIDs(j)); 25 25 %first loop on group atributes … … 27 27 attname = netcdf.inqAttName(subgroupIDs(j),netcdf.getConstant('NC_GLOBAL'),k-1); 28 28 [xtype,attlen] = netcdf.inqAtt(subgroupIDs(j),netcdf.getConstant('NC_GLOBAL'),attname); 29 %disp(sprintf('In %s, Treating attribute %s of type %i',subclass,attname,xtype));29 disp(sprintf('In %s, Treating attribute %s of type %i',subclass,attname,xtype)); 30 30 %classtype have done is job, no need to keep it any more 31 31 if ~strcmp(attname,'classtype'), … … 43 43 for k=1:length(varIDs), 44 44 [varname, xtype, varDimIDs, varAtts] =netcdf.inqVar(subgroupIDs(j),varIDs(k)); 45 %disp(sprintf('In %s, Treating variable %s of type %i',whichclass,varname,xtype));45 disp(sprintf('In %s, Treating variable %s of type %i',whichclass,varname,xtype)); 46 46 %time dimension seems to be last in our construction 47 47 for l=1:length(varDimIDs), … … 68 68 varID=netcdf.inqVarIDs(groupIDs(i)); 69 69 [varname, xtype, varDimIDs, varAtts] =netcdf.inqVar(groupIDs(i),varID); 70 %disp(sprintf('In %s, Treating variable %s of type %i',whichclass,varname,xtype));70 disp(sprintf('In %s, Treating variable %s of type %i',whichclass,varname,xtype)); 71 71 [dimname,numoffields] = netcdf.inqDim(ncid,varDimIDs(end)); 72 72 self.(groupName)=eval(whichclass); … … 97 97 attname = netcdf.inqAttName(groupIDs(i),netcdf.getConstant('NC_GLOBAL'),j-1); 98 98 [xtype,attlen] = netcdf.inqAtt(groupIDs(i),netcdf.getConstant('NC_GLOBAL'),attname); 99 %disp(sprintf('In %s, Treating attribute %s of type %i',whichclass,attname,xtype));99 disp(sprintf('In %s, Treating attribute %s of type %i',whichclass,attname,xtype)); 100 100 %classtype have done is job, no need to keep it any more 101 101 if ~strcmp(attname,'classtype'), … … 113 113 for j=1:length(varIDs), 114 114 [varname, xtype, varDimIDs, varAtts] =netcdf.inqVar(groupIDs(i),varIDs(j)); 115 %disp(sprintf('In %s, Treating variable %s of type %i',whichclass,varname,xtype));115 disp(sprintf('In %s, Treating variable %s of type %i',whichclass,varname,xtype)); 116 116 %if the value is a single string, we need to transpose it (cross check with python file is necessary) 117 117 if xtype==2 -
issm/trunk-jpl/src/m/contrib/paraview/exportVTK.m
r19104 r19157 112 112 %check which field is a real result and print 113 113 for k=1:num_of_fields 114 if ((numel(sol_struct{j}(timestep).(fieldnames{k})))== ... 115 num_of_points); 114 if ((numel(sol_struct{j}(timestep).(fieldnames{k})))==num_of_points); 116 115 %paraview does not like NaN, replacing 117 116 nanval=find(isnan(sol_struct{j}(timestep).(fieldnames{k}))); -
issm/trunk-jpl/src/m/dev/devpath.py
r17230 r19157 1 1 #!/usr/bin/env python 2 3 2 import os,sys 3 import warnings 4 4 5 5 #Recover ISSM_DIR and USERNAME 6 ISSM_DIR=os.getenv('ISSM_DIR') 7 USERNAME =os.getenv('USER') 6 ISSM_DIR = os.getenv('ISSM_DIR') 7 USERNAME = os.getenv('USER') 8 JPL_SVN = os.getenv('JPL_SVN') 8 9 if(ISSM_DIR==None): 9 10 raise NameError('"ISSM_DIR" environment variable is empty! You should define ISSM_DIR in your .cshrc or .bashrc!') 11 if(JPL_SVN==None): 12 warnings.warn('"JPL_SVN" environment variable is empty! add it to your .cshrc or .bashrc if you want to do distant computing') 10 13 11 14 #Go through src/m and append any directory that contains a *.py file to PATH … … 21 24 sys.path.append(ISSM_DIR + '/lib') 22 25 sys.path.append(ISSM_DIR + '/src/wrappers/python/.libs') 26 # If using clusters, we need to have the path to the cluster settings directory 27 if(JPL_SVN!=None): 28 if os.path.exists(JPL_SVN + '/usr/' + USERNAME): 29 sys.path.append(JPL_SVN + '/usr/' + USERNAME) 30 else: 31 raise NameError ('cluster settings should be in, '+ JPL_SVN +'/usr/' + USERNAME) 23 32 24 33 #Manual imports for commonly used functions -
issm/trunk-jpl/src/m/io/structtonc.m
r15106 r19157 28 28 %Double vector 29 29 elseif isa(field,'double') & size(field,2)==1, 30 if step==1, 30 31 if step==1, 31 32 dim_id = netcdf.defDim(ncid,[fieldname '_size1'],size(field,1)); 32 33 var_id(counter) = netcdf.defVar(ncid,fieldname,'NC_DOUBLE',dim_id); -
issm/trunk-jpl/src/m/os/issmscpin.py
r17480 r19157 55 55 #just use standard unix scp 56 56 #string to copy multiple files using scp: 57 if len(packages)==1: 58 string=packages[0] 57 string='\{'+','.join([str(x) for x in packages])+'\}' 58 59 if port: 60 subprocess.call('scp -P %d %s@localhost:%s %s/. ' % (port,login,os.path.join(path,string),os.getcwd()),shell=True) 59 61 else: 60 string='{' 61 for package in packages: 62 string+=packages[i]+',' 63 string=string[:-1]+'}' 64 65 if port: 66 subprocess.call('scp -P %d %s@localhost:%s %s' % (port,login,os.path.join(path,string),os.getcwd),shell=True) 67 else: 68 subprocess.call('scp %s@%s:%s %s' % (login,host,os.path.join(path,string),os.getcwd),shell=True) 62 subprocess.call('scp %s@%s:%s %s/.' % (login,host,os.path.join(path,string),os.getcwd()),shell=True) 69 63 70 64 #check scp worked -
issm/trunk-jpl/src/m/solve/loadresultsfromcluster.py
r17480 r19157 35 35 #erase the log and output files 36 36 if md.qmu.isdakota: 37 os.remove(os.path.join('qmu'+str(os.getpid()),md.miscellaneous.name+'.outlog')) 38 os.remove(os.path.join('qmu'+str(os.getpid()),md.miscellaneous.name+'.errlog')) 37 filename=os.path.join('qmu'+str(os.getpid()),md.miscellaneous.name) 39 38 else: 40 os.remove(md.miscellaneous.name+'.outlog') 41 os.remove(md.miscellaneous.name+'.errlog') 42 os.remove(md.miscellaneous.name+'.outbin') 43 if not m.ispc(): 44 os.remove(md.private.runtimename+'.tar.gz') 39 filename=md.miscellaneous.name 45 40 46 #erase input file if run was carried out on same platform. 41 TryRem('.errlog',filename) 42 TryRem('.outlog',filename) 43 44 if not m.ispc(): 45 TryRem('.tar.gz',md.private.runtimename) 46 if not md.qmu.isdakota: 47 TryRem('.outbin',filename) 48 49 #erase input file if run was carried out on same platform. 47 50 hostname=socket.gethostname() 48 51 if m.strcmpi(hostname,cluster.name): 49 52 if md.qmu.isdakota: 50 os.remove(os.path.join('qmu'+str(os.getpid()),md.miscellaneous.name+'.bin'))51 os.remove(os.path.join('qmu'+str(os.getpid()),md.miscellaneous.name+'.queue'))53 filename=os.path.join('qmu'+str(os.getpid()),md.miscellaneous.name) 54 TryRem('.queue',filename) 52 55 else: 53 os.remove(md.miscellaneous.name+'.bin')54 os.remove(md.miscellaneous.name+'.toolkits')56 filename=md.miscellaneous.name 57 TryRem('.toolkits',filename) 55 58 if not m.ispc(): 56 os.remove(md.miscellaneous.name+'.queue')59 TryRem('.queue',filename) 57 60 else: 58 os.remove(md.miscellaneous.name+'.bat') 61 TryRem('.bat',filename) 62 63 TryRem('.bin',filename) 59 64 60 65 return md 61 66 67 def TryRem(extension,filename): 68 try: 69 os.remove(filename+extension) 70 except OSError: 71 print 'WARNING, no '+extension+' is present for run '+filename
Note:
See TracChangeset
for help on using the changeset viewer.