Ignore:
Timestamp:
Apr 26, 2009, 5:35:16 PM (16 years ago)
Author:
rwilson
Message:

Patong beach validation changes plus back-merge changes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • misc/tools/write_large_files/rwil_big_file.py

    r6739 r6906  
    88# that is checked when the file is read.
    99#
    10 # So, element E of slice S ov variable V has the float value:
    11 #     V*1000 + S . E*1.0e-1
     10# So, for variable V (numbering from 0), slice S (starting from 0), element
     11# E will range from 0 to 10**6-1, and the element value will be:
     12#     S*100 + V + E*1.0E-6
    1213# which will look like:
    13 #     VVVSSSS.0EEEEEE
     14#     SSSSVV.EEEEEE
     15# This implies that the maximum number of variables written is 100 (0 to 99).
    1416################################################################################
    1517
     
    2830
    2931# array slice definitions
    30 XDIM = 1024*1024
     32XDIM = 1000*1000
    3133SLICE_SIZE = XDIM*8     # 8 bytes / float
    3234MBYTE = 1024*1024
     
    4749
    4850# mask for variable names
    49 VarnameMask = 'var_%04d'
     51VarnameMask = 'var_%02d'
    5052
    5153
     
    8486
    8587            # create expected slice array
    86             slice_array = slice_array_mask*slice_number + var_num*1000
    87             for x in xrange(XDIM):
    88                 slice_array[x] += x*1.0e-7
     88            slice_array = slice_array_mask*slice_number*100 + var_num
     89            slice_array += ElementIndexArray
    8990
    9091            if Verbose:
     
    9697
    9798            var_array = fid.variables[varname][slice_number,:]
    98 
    99             if var_array != slice_array:
     99            if not num.allclose(var_array, slice_array):
     100##            if num.any(var_array != slice_array):
    100101                print 'Read variable %s, slice %d: got unexpected value' % \
    101102                      (varname, slice_number)
     
    160161
    161162            # create unique slice array
    162             slice_array = slice_array_mask*slice_number + var_num*1000
    163             for x in xrange(XDIM):
    164                 slice_array[x] += x*1.0e-7
     163            slice_array = slice_array_mask*slice_number*100 + var_num
     164            slice_array += ElementIndexArray
    165165
    166166            fid.variables[varname][slice_number,:] = slice_array
     
    168168            if CloseAfterSlice:
    169169                fid.close()
    170                 fid = nc.NetCDFFile(filename, 'al')
    171 #                fid = nc.NetCDFFile(filename, 'a')
     170#                fid = nc.NetCDFFile(filename, 'al')
     171                fid = nc.NetCDFFile(filename, 'a')
    172172
    173173            file_bytes_written += SLICE_SIZE
     
    204204    print "  and <numvars> is the number of variables of the above size"
    205205    print "                    to write.  If not supplied, 1 is assumed."
     206    print "                    There can be at most 100 variables."
    206207    print "  and <opts>    is zero or more of:"
    207208    print "                    -c s    close & open the output file after"
     
    217218def main(argv=None):
    218219    global TimeFileWrite, TimeFileRead, CloseAfterSlice, Verbose
     220    global ElementIndexArray
    219221
    220222    if argv is None:
     
    259261
    260262    var_size = args[0][:-1]
    261     modifier =args[0][-1]
     263    modifier = args[0][-1]
    262264
    263265    if modifier in '0123456789':
     
    280282            usage()
    281283
     284    if num_vars > 100:
     285        usage()
     286
     287    # initialize the global element index array which contains
     288    # 0.EEEEEE in each element.
     289    ElementIndexArray = num.ndarray((XDIM,), 'd')
     290    for x in xrange(XDIM):
     291        ElementIndexArray[x] = x*1.0e-6
     292   
    282293    # write the required file
    283294    filename = write_file(var_size, num_vars)
     
    288299        return 10
    289300
    290     print 'Read/write of NectCDF file was correct'
     301#    print 'Read/write of NectCDF file was correct'
    291302    return 0
    292303
Note: See TracChangeset for help on using the changeset viewer.