comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Extracting bits with IDL
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Extracting bits with IDL [message #2588] Mon, 18 July 1994 15:32 Go to previous message
dball is currently offline  dball
Messages: 4
Registered: June 1994
Junior Member
In article <Ct2GM1.1780@yuma.ACNS.ColoState.EDU>, dean@phobos.cira.colostate.edu writes:
> We are set up to routinely collect GOES-8 GVAR data. Like with most data
> from satellites, they put information in the individual bits. Below is a C
> structure that extracts the individual bits from part of the data header which
> contains some time information. Extracting individual bits from data with IDL
> is difficult. At first I consider building an IDL structure, but IDL is
> unable to break down to bits.
>
> The information can fit into LONARR(2). If anyone has any suggestion that
> would allow IDL to extract the information from these LONARR(2), please
> forward your comments to me or post them. I hope to use this information to
> build a widget to navigate through this new and fine data set coming from
> GOES-8.
>
> ============================================================ ===================
>
> typedef struct
> {
> unsigned year_100 : 4;
> unsigned year_1000 : 4;
>
> unsigned year_1 : 4;
> unsigned year_10 : 4;
>
> unsigned day_10 : 4;
> unsigned day_100 : 3;
> unsigned time_code : 1;
>
> unsigned hour_10 : 4;
> unsigned day_1 : 4;
>
> unsigned min_10 : 4;
> unsigned hour_1 : 4;
>
> unsigned sec_10 : 4;
> unsigned min_1 : 4;
>
> unsigned msec_100 : 4;
> unsigned sec_1 : 4;
>
> unsigned msec_1 : 4;
> unsigned msec_10 : 4;
> } BCD_TIME_T;
>
> ********************************************************** \ *****
> Kelly Dean \
> E-MAIL: DEAN@PHOBOS.CIRA.COLOSTATE.EDU | \
> ************************************************************ **************

You can use a combination of AND (which is a bitwise logical operator) and
ISHFT (which shifts bits left or right) to extract these values.
Its probably easier if you read it into a BYTE array. e.g.:

b=BYTARR(8)
READU,1,b
year_100 = ISHFT( b(0), -4 ) ; shift top 4 bits down
year_1000 = b(0) AND 'F'XB ; mask off bottom 4 bits
day_100 = ISHFT( b(2), -1 ) AND '7'XB ; shift bits down one, and mask off 3



'n'XB is just a byte size hex constant. 'F'XB = 15B and '7'XB = 7B

-- Dave
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: DRAW_MOTION_EVENTS
Next Topic: translating an image....

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Thu Oct 09 22:49:07 PDT 2025

Total time taken to generate the page: 0.88051 seconds