close all
clear all

CLEO=202;
CH=52;
CLNS=40;

MVT_SOL = 1; % solid
MVT_OUT = 2; % out
MVT_E = 4; % east
MVT_O = 8; % west
MVT_B = 16; % down
MVT_H = 32; % up
MVT_EB = 64; % east & down
MVT_EH = 128; % east & up
MVT_OB = 256; % west & down
MVT_OH = 512; % west & up

% depth of the vertical plane
depth=floor(CLNS/2);

% open HPP binary file
fid=fopen('HPP0016.bin','r');

% read HPP data
a=fread(fid,CLNS*CH*CLEO,'short');

% close file
fclose(fid);

% reshape data
mvt=reshape(a,CLNS,CH,CLEO);

% extract slow particles towards east direction in vertical plane
slow_e=bitand(mvt(depth,:,:),MVT_E);

% extract fast particles towards east & down direction
fast_eb=bitand(mvt(depth,:,:),MVT_EB);

% display particles
figure
imagesc(reshape(slow_e,CH,CLEO))
daspect([1 1 1])
title('slow east particles')

figure
imagesc(reshape(fast_eb,CH,CLEO))
daspect([1 1 1])
title('fast east & down particles')

