Changeset 939 in lmdz_wrf for trunk/tools
- Timestamp:
- Jun 24, 2016, 12:27:49 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/nc_var_tools.py
r929 r939 5683 5683 # Creating dimensions 5684 5684 ## 5685 5686 dimsecslice = {} 5685 5687 for dims in nciobj.dimensions: 5688 ibegv = begv 5689 iendv = endv 5690 iintv = intv 5686 5691 objdim = nciobj.dimensions[dims] 5687 5692 5688 5693 if objdim.isunlimited(): 5689 5694 dimsize = None 5695 5696 if dims == dimn: 5697 if begv != -9: 5698 if begv > len(objdim): 5699 print errormsg 5700 print ' ' + fname + ': beginning value' ,begv, \ 5701 'is larger than dimension (', len(objdim), ')!!!!' 5702 quit(-1) 5703 if endv > len(objdim): 5704 print errormsg 5705 print ' ' + fname + ': endining value' ,endv, \ 5706 'is larger than dimension (', len(objdim), ')!!!!' 5707 quit(-1) 5708 5709 if endv == -1: iendv = len(objdim) 5710 print 'Lluis endv, begv, intv:', ibegv, iendv, iintv,':', begv, endv, intv 5711 dimsize = (iendv - ibegv + 1)/iintv - 1 5712 else: 5713 dimsize == 0 5714 if begv == -9: 5715 ibegv = len(objdim) - 1 5716 iendv = len(objdim) - 1 5717 iintv = 0 5718 print fname + '; Lluis dimn beg end int:', ibegv, iendv, iintv 5690 5719 else: 5691 if dims == dimn: 5692 if begv != -9 and begv != 0: 5693 if begv > len(objdim): 5694 print errormsg 5695 print ' ' + fname + ': beginning value' ,begv, \ 5696 'is larger than dimension (', len(objdim), ')!!!!' 5697 quit(-1) 5698 if endv > len(objdim): 5699 print errormsg 5700 print ' ' + fname + ': endining value' ,endv, \ 5701 'is larger than dimension (', len(objdim), ')!!!!' 5702 quit(-1) 5703 5704 if endv == -1: endv = len(objdim) 5705 dimsize = (endv - begv + 1)/intv - 1 5706 else: 5707 dimsize == 0 5708 if begv == 0: 5709 begv = 0 5710 endv = 0 5711 intv = 0 5712 elif begv == -9: 5713 begv = len(objdim) 5714 endv = len(objdim) 5715 intv = 0 5716 5720 if len(objdim) > 1: 5721 dimsize = len(objdim) 5722 ibegv = 0 5723 iendv = dimsize - 1 5724 iintv = 1 5717 5725 else: 5718 dimsize = len(objdim) 5719 5720 print ' ' + fname + ': adding dimension: ' + dims + ' size:',dimsize 5726 dimsize = 0 5727 ibegv = 0 5728 iendv = 0 5729 iintv = 0 5730 5731 print fname + '; Lluis begv, endv:', ibegv, iendv, iintv, '<>', begv, endv, intv 5732 if ibegv != iendv: 5733 dimsecslice[dims] = slice(ibegv,iendv,iintv) 5734 else: 5735 dimsecslice[dims] = ibegv 5736 5721 5737 if dimsize != 0: 5722 if begv != -9 and begv != 0:5738 if begv != -9: 5723 5739 dim = ncoobj.createDimension(dims, dimsize) 5740 print ' ' + fname + ': adding dimension: ' + dims + ' size:',dimsize 5724 5741 else: 5725 5742 if dims != dimn: 5726 5743 dim = ncoobj.createDimension(dims, dimsize) 5744 print ' ' + fname + ': adding dimension: ' + dims + ' size:',dimsize 5727 5745 5728 5746 ncoobj.sync() 5747 print fname + '; Lluis: dimsecslice:', dimsecslice 5729 5748 # Creating variables 5730 5749 ## 5750 filedims = ncoobj.dimensions 5731 5751 for varns in nciobj.variables: 5732 5752 print ' ' + fname + ': adding variable "' + varns + '"...' … … 5736 5756 5737 5757 if not gen.searchInlist(list(vardims),dimn): 5738 varvals = varobj[:] 5739 filevardims = list(vardims) 5758 # removing monotones 5759 print fname + '; Lluis looking for monotones!' 5760 varslice = [] 5761 filevardims = [] 5762 for dimname in varobj.dimensions: 5763 lendim = len(nciobj.dimensions[dimname]) 5764 print fname + '; Lluis monotone?:', dimname,' len;', lendim 5765 if lendim > 1: 5766 varslice.append(slice(0, lendim)) 5767 filevardims.append(dimname) 5768 else: 5769 varslice.append(0) 5770 5771 varvals = varobj[tuple(varslice)] 5740 5772 else: 5741 5773 varslice = [] … … 5743 5775 for dimname in varobj.dimensions: 5744 5776 if dimname == dimn: 5745 if begv != -9 and begv != 0: 5746 varslice.append(slice(begv,endv,intv)) 5777 varslice.append(dimsecslice[dimn]) 5778 filevardims.append(dimname) 5779 else: 5780 Ldim = len(nciobj.dimensions[dimname]) 5781 if Ldim > 1: 5782 varslice.append(slice(0,Ldim)) 5747 5783 filevardims.append(dimname) 5748 5784 else: 5749 if begv == -9: 5750 varslice.append(len(nciobj.dimensions[dimn])-1) 5751 elif begv == 0: 5752 varslice.append(0) 5753 5754 else: 5755 Ldim = len(nciobj.dimensions[dimname]) 5756 varslice.append(slice(0,Ldim)) 5757 filevardims.append(dimname) 5758 5785 varslice.append(0) 5786 5787 print fname + '; Lluis varslice:', varslice,' filevardims:', filevardims 5759 5788 varvals = varobj[tuple(varslice)] 5760 5789 5790 print fname + ': Lluis filevardims:', filevardims 5761 5791 # Adding fill value attribute 5762 5792 ##
Note: See TracChangeset
for help on using the changeset viewer.