[ncl-talk] Extracting bit information using 'dim_gbits'..
qudsia zafar
missquaddus at gmail.com
Thu May 4 03:05:59 MDT 2017
Thanx alot Dennis. That really helped.
Sincerely,
qudsia
On Wed, May 3, 2017 at 9:08 PM, Dennis Shea <shea at ucar.edu> wrote:
> I am not sure I understand but ...
> Let us(226,4350) be of type unsigned short
>
> [1] step-by-step
>
> us = f->UnsignedShort
> printVarSummary(us)
>
> dim_us = *dimsizes*(us)
> nleft = dim_us(0) ; 226
> nright = dim_us(1) ; 4350
>
> ibit = 9 ; skip 9 bits
> nbit = 3 ; 10-12
> nskip = 16 ; all 'short' are 16 bits
> N = nleft*nright
>
> us_1d = *ndtooned*(us),
> ubit_1d = *dim_gbits*(us_1d, ibit, nbit, nskip, N)
> ubit = *reshape*(ubit_1d, (/nleft,nright/) )
> *delete*(us_1d, ubit_1d) ; clean up; not really necessary
>
>
> [2} slicker but less clear
>
> ubit = reshape( *dim_gbits(**ndtooned*(us), ibit, nbit, nskip, N),
> *product*(*dimsizes*(us)) )
>
> [3] As always
>
> * printVarSummary*(ubit)
> *printMinMax*(ubit, 0)
>
> Good Luck
>
> On Wed, May 3, 2017 at 2:19 AM, qudsia zafar <missquaddus at gmail.com>
> wrote:
>
>> Hi,
>>
>> I am working with a 2-D array [226 x 4350] of type 'ushort' consisting of
>> 16-bit integers. I want to extract bits 1-3 in correspondence with bits
>> 10-12 from the array. i have seen the function 'dim_gbits' but am confused
>> in setting the function parameters such as *ibit*, *nbits *and *nskip. *
>>
>> Would very much appreciate the help in this regard.
>>
>> Sincerely,
>> qudsia
>>
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170504/a3be93cb/attachment.html
More information about the ncl-talk
mailing list