Changeset 200 in lmdz_wrf for trunk/tools


Ignore:
Timestamp:
Dec 5, 2014, 11:36:40 AM (10 years ago)
Author:
lfita
Message:

Fixing issues with 2D in 'setvar_asciivalues',now working

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/nc_var_tools.py

    r199 r200  
    84608460        else:
    84618461            newval = True
    8462     elif vtype = '|S1':
    8463         newval = char(val)
     8462    elif vtype == '|S1':
     8463        newval = val
     8464    elif vtype == 'str':
     8465        print val, type(val)
     8466        newval = str(val)
    84648467    else:
    84658468        print errormsg
     
    85138516    values = np.zeros((objvar.shape), dtype=vartype)
    85148517
    8515     valfinal = np.zeros((1), dtype=vartype)
    8516 
    85178518    it = 0
    85188519    if Ndims == 1:
     8520        valfinal = np.zeros((1), dtype=vartype)
    85198521        for line in objasciif:
    85208522            val = (line.replace('\n','').replace(' ','').replace('\t',''))
     
    85268528        iline=0
    85278529        for line in objasciif:
    8528             val = (line.replace('\n','').replace(' ','').replace('\t',''))
    8529             valfinal[0] = retype(val, vartype)
    8530             if it <= values.shape[0]-1:
    8531                 values[iline,it] = retype(valfinal[0], vartype)
    8532                 it = it +1
     8530            vals = line.replace('\n','').replace('\t','').split(' ')
     8531            if len(vals) != values.shape[1]:
     8532                print errormsg
     8533                print '  ' + fname + ': given: ',len(vals),' but variable reaquires: ',values.shape[1],'!!!'
     8534                exit(-1)
     8535            for i1 in range(len(vals)):
     8536                values[iline,i1] = retype(vals[i1], vartype)
    85338537            iline=iline+1
    85348538    else:
Note: See TracChangeset for help on using the changeset viewer.