Changeset 921 in lmdz_wrf for trunk/tools
- Timestamp:
- Jun 21, 2016, 4:14:42 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/nc_var_tools.py
r918 r921 5641 5641 [beg],[end],[int]: beginning, end and interval along the dimension-axis 5642 5642 [end] = -1, values until the end 5643 [beg] = -9, last value 5643 5644 filen= netCDF with the data-set 5644 5645 DataSetSection('time,3,15,1','test.nc') … … 5671 5672 else: 5672 5673 if dims == dimn: 5673 if begv > len(objdim): 5674 print errormsg 5675 print ' ' + fname + ': beginning value' ,begv, \ 5676 'is larger than dimension (', len(objdim), ')!!!!' 5677 quit(-1) 5678 if endv > len(objdim): 5679 print errormsg 5680 print ' ' + fname + ': endining value' ,endv, \ 5681 'is larger than dimension (', len(objdim), ')!!!!' 5682 quit(-1) 5683 5684 if endv == -1: endv = len(objdim) 5685 dimsize = (endv - begv + 1)/intv - 1 5674 if begv != -9 and begv != 0: 5675 if begv > len(objdim): 5676 print errormsg 5677 print ' ' + fname + ': beginning value' ,begv, \ 5678 'is larger than dimension (', len(objdim), ')!!!!' 5679 quit(-1) 5680 if endv > len(objdim): 5681 print errormsg 5682 print ' ' + fname + ': endining value' ,endv, \ 5683 'is larger than dimension (', len(objdim), ')!!!!' 5684 quit(-1) 5685 5686 if endv == -1: endv = len(objdim) 5687 dimsize = (endv - begv + 1)/intv - 1 5688 else: 5689 dimsize == 0 5690 if begv == 0: 5691 begv = 0 5692 endv = 0 5693 intv = 0 5694 elif begv == -9: 5695 begv = len(objdim) 5696 endv = len(objdim) 5697 intv = 0 5698 5686 5699 else: 5687 5700 dimsize = len(objdim) 5688 5701 5689 5702 print ' ' + fname + ': adding dimension: ' + dims + ' size:',dimsize 5690 dim = ncoobj.createDimension(dims, dimsize) 5703 if dimsize != 0: 5704 if begv != -9 and begv != 0: 5705 dim = ncoobj.createDimension(dims, dimsize) 5706 else: 5707 if dims != dimn: 5708 dim = ncoobj.createDimension(dims, dimsize) 5691 5709 5692 5710 ncoobj.sync() … … 5701 5719 if not gen.searchInlist(list(vardims),dimn): 5702 5720 varvals = varobj[:] 5721 filevardims = list(vardims) 5703 5722 else: 5704 5723 varslice = [] 5724 filevardims = [] 5705 5725 for dimname in varobj.dimensions: 5706 5726 if dimname == dimn: 5707 varslice.append(slice(begv,endv,intv)) 5727 if begv != -9 and begv != 0: 5728 varslice.append(slice(begv,endv,intv)) 5729 filevardims.append(dimname) 5730 else: 5731 if begv == -9: 5732 varslice.append(len(nciobj.dimensions[dimn])-1) 5733 elif begv == 0: 5734 varslice.append(0) 5735 5708 5736 else: 5709 5737 Ldim = len(nciobj.dimensions[dimname]) 5710 5738 varslice.append(slice(0,Ldim)) 5739 filevardims.append(dimname) 5711 5740 5712 5741 varvals = varobj[tuple(varslice)] … … 5721 5750 vartype = varobj.dtype 5722 5751 5723 newvar = ncoobj.createVariable(varns, vartype, vardims, fill_value=varfil) 5752 newvar = ncoobj.createVariable(varns, vartype, tuple(filevardims), \ 5753 fill_value=varfil) 5724 5754 newvar[:] = varvals 5725 5755
Note: See TracChangeset
for help on using the changeset viewer.