Changeset 341


Ignore:
Timestamp:
Sep 22, 2004, 3:38:34 PM (21 years ago)
Author:
ole
Message:

Moved obsolete stuff to the bottom

File:
1 edited

Legend:

Unmodified
Added
Removed
  • inundation/ga/storm_surge/pyvolution/data_manager.py

    r288 r341  
    22There are two kinds of data
    33
    4   1: Constant data: Vertex coordinates and field values
    5   2: Variable data: Conserved quantities
     4  1: Constant data: Vertex coordinates and field values. Stored once
     5  2: Variable data: Conserved quantities. Stored once per timestep.
    66
    77All data is assumed to reside at vertex locations. 
     
    134134    return glob.glob(pattern)
    135135
    136 #Native checkpoint format.
    137 #Information needed to recreate a state is preserved
    138 #FIXME: Rethink and maybe use netcdf format
    139 def cpt_variable_writer(filename, t, v0, v1, v2):
    140     """Store all conserved quantities to file
    141     """
    142 
    143     M, N = v0.shape
    144        
    145     FN = create_filename(filename, 'cpt', M, t)
    146     #print 'Writing to %s' %FN
    147    
    148     fid = open(FN, 'w')
    149     for i in range(M):
    150         for j in range(N):       
    151             fid.write('%.16e ' %v0[i,j])           
    152         for j in range(N):
    153             fid.write('%.16e ' %v1[i,j])                       
    154         for j in range(N):
    155             fid.write('%.16e ' %v2[i,j])                       
    156            
    157         fid.write('\n')
    158     fid.close()
    159 
    160 
    161 def cpt_variable_reader(filename, t, v0, v1, v2):
    162     """Store all conserved quantities to file
    163     """
    164 
    165     M, N = v0.shape
    166        
    167     FN = create_filename(filename, 'cpt', M, t)
    168     #print 'Reading from %s' %FN
    169    
    170     fid = open(FN)
    171 
    172 
    173     for i in range(M):
    174         values = fid.readline().split() #Get one line
    175 
    176         for j in range(N):
    177             v0[i,j] = float(values[j])
    178             v1[i,j] = float(values[3+j])
    179             v2[i,j] = float(values[6+j])
    180    
    181     fid.close()
    182 
    183 def cpt_constant_writer(filename, X0, X1, X2, v0, v1, v2):
    184     """Writes x,y,z,z,z coordinates of triangles constituting the bed
    185     elevation.
    186     Not in use pt
    187     """
    188 
    189     M, N = v0.shape
    190 
    191     print X0
    192     import sys; sys.exit()
    193     FN = create_filename(filename, 'cpt', M)
    194     print 'Writing to %s' %FN
    195    
    196     fid = open(FN, 'w')
    197     for i in range(M):
    198         for j in range(2):       
    199             fid.write('%.16e ' %X0[i,j])   #x, y
    200         for j in range(N):                   
    201             fid.write('%.16e ' %v0[i,j])       #z,z,z,
    202            
    203         for j in range(2):                   
    204             fid.write('%.16e ' %X1[i,j])   #x, y
    205         for j in range(N):                               
    206             fid.write('%.16e ' %v1[i,j]) 
    207        
    208         for j in range(2):                               
    209             fid.write('%.16e ' %X2[i,j])   #x, y
    210         for j in range(N):                                           
    211             fid.write('%.16e ' %v2[i,j])
    212            
    213         fid.write('\n')
    214     fid.close()
    215 
    216 
    217 
    218 #Function for storing out to e.g. visualisation
    219 #FIXME: Do we want this?
    220 #FIXME: Not done yet for this version
    221 def dat_constant_writer(filename, X0, X1, X2, v0, v1, v2):
    222     """Writes x,y,z coordinates of triangles constituting the bed elevation.
    223     """
    224 
    225     M, N = v0.shape
    226        
    227     FN = create_filename(filename, 'dat', M)
    228     #print 'Writing to %s' %FN
    229    
    230     fid = open(FN, 'w')
    231     for i in range(M):
    232         for j in range(2):       
    233             fid.write('%f ' %X0[i,j])   #x, y
    234         fid.write('%f ' %v0[i,0])       #z
    235            
    236         for j in range(2):                   
    237             fid.write('%f ' %X1[i,j])   #x, y
    238         fid.write('%f ' %v1[i,0])       #z
    239        
    240         for j in range(2):                               
    241             fid.write('%f ' %X2[i,j])   #x, y
    242         fid.write('%f ' %v2[i,0])       #z
    243            
    244         fid.write('\n')
    245     fid.close()
    246 
    247 
    248 
    249 def dat_variable_writer(filename, t, v0, v1, v2):
    250     """Store water height to file
    251     """
    252 
    253     M, N = v0.shape
    254        
    255     FN = create_filename(filename, 'dat', M, t)
    256     #print 'Writing to %s' %FN
    257    
    258     fid = open(FN, 'w')
    259     for i in range(M):
    260         fid.write('%.4f ' %v0[i,0])
    261         fid.write('%.4f ' %v1[i,0])
    262         fid.write('%.4f ' %v2[i,0])       
    263 
    264         fid.write('\n')
    265     fid.close()
    266136
    267137
     
    901771
    902772
     773#OBSOLETE STUFF
     774#Native checkpoint format.
     775#Information needed to recreate a state is preserved
     776#FIXME: Rethink and maybe use netcdf format
     777def cpt_variable_writer(filename, t, v0, v1, v2):
     778    """Store all conserved quantities to file
     779    """
     780
     781    M, N = v0.shape
     782       
     783    FN = create_filename(filename, 'cpt', M, t)
     784    #print 'Writing to %s' %FN
     785   
     786    fid = open(FN, 'w')
     787    for i in range(M):
     788        for j in range(N):       
     789            fid.write('%.16e ' %v0[i,j])           
     790        for j in range(N):
     791            fid.write('%.16e ' %v1[i,j])                       
     792        for j in range(N):
     793            fid.write('%.16e ' %v2[i,j])                       
     794           
     795        fid.write('\n')
     796    fid.close()
     797
     798
     799def cpt_variable_reader(filename, t, v0, v1, v2):
     800    """Store all conserved quantities to file
     801    """
     802
     803    M, N = v0.shape
     804       
     805    FN = create_filename(filename, 'cpt', M, t)
     806    #print 'Reading from %s' %FN
     807   
     808    fid = open(FN)
     809
     810
     811    for i in range(M):
     812        values = fid.readline().split() #Get one line
     813
     814        for j in range(N):
     815            v0[i,j] = float(values[j])
     816            v1[i,j] = float(values[3+j])
     817            v2[i,j] = float(values[6+j])
     818   
     819    fid.close()
     820
     821def cpt_constant_writer(filename, X0, X1, X2, v0, v1, v2):
     822    """Writes x,y,z,z,z coordinates of triangles constituting the bed
     823    elevation.
     824    Not in use pt
     825    """
     826
     827    M, N = v0.shape
     828
     829    print X0
     830    import sys; sys.exit()
     831    FN = create_filename(filename, 'cpt', M)
     832    print 'Writing to %s' %FN
     833   
     834    fid = open(FN, 'w')
     835    for i in range(M):
     836        for j in range(2):       
     837            fid.write('%.16e ' %X0[i,j])   #x, y
     838        for j in range(N):                   
     839            fid.write('%.16e ' %v0[i,j])       #z,z,z,
     840           
     841        for j in range(2):                   
     842            fid.write('%.16e ' %X1[i,j])   #x, y
     843        for j in range(N):                               
     844            fid.write('%.16e ' %v1[i,j]) 
     845       
     846        for j in range(2):                               
     847            fid.write('%.16e ' %X2[i,j])   #x, y
     848        for j in range(N):                                           
     849            fid.write('%.16e ' %v2[i,j])
     850           
     851        fid.write('\n')
     852    fid.close()
     853
     854
     855
     856#Function for storing out to e.g. visualisation
     857#FIXME: Do we want this?
     858#FIXME: Not done yet for this version
     859def dat_constant_writer(filename, X0, X1, X2, v0, v1, v2):
     860    """Writes x,y,z coordinates of triangles constituting the bed elevation.
     861    """
     862
     863    M, N = v0.shape
     864       
     865    FN = create_filename(filename, 'dat', M)
     866    #print 'Writing to %s' %FN
     867   
     868    fid = open(FN, 'w')
     869    for i in range(M):
     870        for j in range(2):       
     871            fid.write('%f ' %X0[i,j])   #x, y
     872        fid.write('%f ' %v0[i,0])       #z
     873           
     874        for j in range(2):                   
     875            fid.write('%f ' %X1[i,j])   #x, y
     876        fid.write('%f ' %v1[i,0])       #z
     877       
     878        for j in range(2):                               
     879            fid.write('%f ' %X2[i,j])   #x, y
     880        fid.write('%f ' %v2[i,0])       #z
     881           
     882        fid.write('\n')
     883    fid.close()
     884
     885
     886
     887def dat_variable_writer(filename, t, v0, v1, v2):
     888    """Store water height to file
     889    """
     890
     891    M, N = v0.shape
     892       
     893    FN = create_filename(filename, 'dat', M, t)
     894    #print 'Writing to %s' %FN
     895   
     896    fid = open(FN, 'w')
     897    for i in range(M):
     898        fid.write('%.4f ' %v0[i,0])
     899        fid.write('%.4f ' %v1[i,0])
     900        fid.write('%.4f ' %v2[i,0])       
     901
     902        fid.write('\n')
     903    fid.close()
     904
Note: See TracChangeset for help on using the changeset viewer.