[Thread Prev][Thread Next][Index]

Re: [ferret_users] salinity at the shallowest profile depth

Hi Billy,
How about making a mask based on the minimum ZEDZT?

let zmin=zedzt[k=@min]
let zedzero =zedzt-zmin  ! Zero at shallowest point in profile
let mask=if ( zedzero EQ 0 ) then 1

you can then use the mask to get 1 value per profile which be extracted
with whatever method you like. 

let saltmask = if ( mask ) then salt
let saltatmin=saltmask[k=@ave]  


On Fri, 2012-09-28 at 08:35 +1000, William S. Kessler wrote:
> Hi all -
> This seems simple but the only way I could figure out how to do seems  
> outrageously baroque. Anybody have a cleaner way to do it?
> I have a series of profiles of T and S from an instrument that goes up  
> and down repeatedly. It comes to me on a  
> (vertical_index,profile_number) grid, with same-shape grids of depth,  
> temperature and salinity. The depths typically start shortly before  
> the instrument reaches the top, and end shortly after it reaches the  
> bottom: thus it's a series of profiles with a few extra values at each  
> end that make it non-monotonic. (And there may be wiggles in each  
> direction near the top and bottom).
> I would like to find the salinity at the shallowest depth of each  
> profile.
> This seems at first made for @WEQ. But while I could easily find the  
> salinity at a particular depth with WEQ, it requires a constant  
> argument, not a variable one like ZED[K=@MIN]. I could similarly find  
> the index K of the shallowest depth with WEQ, but again there is no  
> way I can see to put that variable back into WEQ.
> I have a solution using SORTK/SAMPLEK, but because there is also a  
> time-index the output of this is an LxL grid, with the desired values  
> along the diagonal! As I said, I have a solution but it is really  
> ugly. My script is below. Is this really the only solution to this  
> seemingly-simple problem?
> Billy K
> --------------------
> ! Variable names are: ZEDZT, TEMPZT, SALTZT (obviously-named). All  
> have the same shape in (K,L)
> let ksortind = sortk(zedzt)       ! sort depths
> let kind1 = ksortind[k=1]         ! index of shallowest. One value for  
> each L.
> let kind1_1d = reshape(kind1,t[gt=kind1])    ! force index to be 1-d  
> for input to SAMPLEK
> ! sample depths, temps, salinity according to the depth indices
> let sortedzed = samplek(zedzt,kind1_1d)
> let sortedtemp = samplek(tempzt,kind1_1d)
> let sortedsalt = samplek(saltzt,kind1_1d)
> ! results of the above need to be re-sampled ALONG THE DIAGONAL!
> ! the grid out of SAMPLEK is inherited from the original T, while Z  
> has # of pts of argument 2.
> ! since that argument is effectively along L, and the other dimension  
> of sorted* is also L,
> ! the resulting grid is LxL, with the desired elements on the diagonal.
> ! extract the diagonal elements:
> let ll = l[gt=zedzt]; let kk = zsequence(l[gt=zedzt])   ! define  
> indices of the diagonal
> let zed1 = if kk eq ll then sortedzed          ! extract for depth
> let sst1 = if kk eq ll then sortedtemp             ! for temp
> let sss1 = if kk eq ll then sortedsalt             ! for salt
> ! now have a diagonal-only grid. Use FNR to find them on a single line
> let zed2 = zed1[k=1:75@fnr]
> let sst2 = sst1[k=1:75@fnr]
> let sss2 = sss1[k=1:75@fnr]
> let shallow=zed2[k=1]
> let sst=sst2[k=1]
> let sss=sss2[k=1]

[Thread Prev][Thread Next][Index]
Contact Us
Dept of Commerce / NOAA / OAR / PMEL / Ferret

Privacy Policy | Disclaimer | Accessibility Statement