;*********************************************** ; ; 2010-jun-09 Modified version of delete_VarAtts ; from NCL 5.2.0 distribution. ; Disable warnings for atts not found. ; Modified by Dave Allured, NOAA/PSD/CIRES. ; Original version by D. Shea, NCAR/CGD. ; Usage is identical to delete_VarAtts. ; ; Delete one or more attributes of a variable. ; This checks to see if the attribute exists and ; if it does, it deletes it. ; ; Sample usage: ; x = 0 ; x@apple = 5 ; x@orange = 81. ; x@peach = (/ "a", "b"/) ; ; strip_VarAtts(x, "apple") ) ; strip_VarAtts(x, (/ "apple", "peach", "plum" /) ) ; ; x@orange remains ;*********************************************** undef("strip_VarAtts") procedure strip_VarAtts (x, ATTS) local n, atts, nAtts begin typeATTS = typeof(ATTS) if (.not.(typeATTS.eq."string" .or. typeATTS.eq."integer")) then print("strip_VarAtts: argument must be string or integer: type="+typeATTS) print("strip_VarAtts: nothing deleted") return end if if (typeATTS.eq."integer") then atts = getvaratts(x) end if if (typeof(ATTS).eq."string") then atts = ATTS end if nAtts = dimsizes(atts) do n=0,nAtts-1 if (isatt(x, atts(n)) ) then delete(x@$atts(n)$) end if end do end