- Timestamp:
- Apr 12, 2017, 8:21:00 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/nc_var_tools.py
r1522 r1523 18677 18677 gen.check_arguments(fname,values,expectargs,'|') 18678 18678 18679 dnames = values.split('|')[0].split(',')18679 dnames = gen.str_list(values.split('|')[0],',') 18680 18680 attributes = values.split('|')[1].replace('!',' ') 18681 18681 kind = values.split('|')[2] … … 18694 18694 quit(-1) 18695 18695 18696 if values.split('|')[0].find(',') != -1: 18696 if values.split('|')[0] == 'scalar': 18697 print ' ' + fname + ': creation of scalar variable !!' 18698 18699 # Variable 18700 if kind == 'c': 18701 newvar = onc.createVariable(varn, 'c') 18702 # newvar[:] = np.zeros(tuple(dsize), dtype=np.float) 18703 elif kind == 'f' or kind == 'f4': 18704 newvar = onc.createVariable(varn, 'f4') 18705 newvar[:] = np.float(0.) 18706 elif kind == 'f8': 18707 newvar = onc.createVariable(varn, 'f8') 18708 newvar[:] = np.float64(0.) 18709 elif kind == 'i': 18710 newvar = onc.createVariable(varn, 'i') 18711 newvar[:] = int(0) 18712 else: 18713 print errormsg 18714 print ' ' + fname + ": variable kind '" + kind + "' not ready!!" 18715 quit(-1) 18716 elif type(dnames) == type([1,2]): 18697 18717 # Checking dimensions 18698 18718 dsize = [] … … 18728 18748 quit(-1) 18729 18749 18730 elif values.split('|')[0] == 'scalar':18731 print ' ' + fname + ': creation of scalar variable !!'18732 18733 # Variable18734 if kind == 'c':18735 newvar = onc.createVariable(varn, 'c')18736 # newvar[:] = np.zeros(tuple(dsize), dtype=np.float)18737 elif kind == 'f' or kind == 'f4':18738 newvar = onc.createVariable(varn, 'f4')18739 newvar[:] = np.float(0.)18740 elif kind == 'f8':18741 newvar = onc.createVariable(varn, 'f8')18742 newvar[:] = np.float64(0.)18743 elif kind == 'i':18744 newvar = onc.createVariable(varn, 'i')18745 newvar[:] = int(0)18746 else:18747 print errormsg18748 print ' ' + fname + ": variable kind '" + kind + "' not ready!!"18749 quit(-1)18750 18750 else: 18751 18751 print errormsg 18752 print ' ' + fname + ": wrong dimension values: '" + dnames + "'!!"18752 print ' ' + fname + ": wrong dimension values:", dnames, " !!" 18753 18753 quit(-1) 18754 18754
Note: See TracChangeset
for help on using the changeset viewer.