73842f0a9f6b19a46071396aa400ac31ca2fc691
[debian/gnuradio] / gr-noaa / oct / frames_to_ppm.m
1 % -*- octave -*-
2 %
3 % Copyright 2009 Free Software Foundation, Inc.
4
5 % This file is part of GNU Radio
6
7 % GNU Radio is free software; you can redistribute it and/or modify
8 % it under the terms of the GNU General Public License as published by
9 % the Free Software Foundation; either version 3, or (at your option)
10 % any later version.
11
12 % GNU Radio is distributed in the hope that it will be useful,
13 % but WITHOUT ANY WARRANTY; without even the implied warranty of
14 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 % GNU General Public License for more details.
16
17 % You should have received a copy of the GNU General Public License
18 % along with GNU Radio; see the file COPYING.  If not, write to
19 % the Free Software Foundation, Inc., 51 Franklin Street,
20 % Boston, MA 02110-1301, USA.
21
22
23 % Extract AVHRR images from HRPT frames.dat
24 clear
25
26 fid = fopen('frames.hrpt');
27 dat = fread(fid, 'uint16');
28
29 frame_len = 11090;
30
31 len = floor(length(dat) / frame_len);
32
33 chan1 = zeros(len, 2048);
34
35 start = 751;
36 stop = 10986;
37
38 for line = 1:len
39   chan1(line, 1:2048) = dat(start:5:stop)';
40   start = start + frame_len;
41   stop = stop + frame_len;
42 end
43  
44 start = 752;
45 stop = 10987;
46
47 for line = 1:len
48   chan2(line, 1:2048) = dat(start:5:stop)';
49 start = start + frame_len;
50 stop = stop + frame_len;
51 end
52  
53 start = 753;
54 stop = 10988;
55
56 for line = 1:len
57   chan3(line, 1:2048) = dat(start:5:stop)';
58   start = start + frame_len;
59   stop = stop + frame_len;
60 end
61  
62 start = 754;
63 stop = 10989;
64
65 for line = 1:len
66   chan4(line, 1:2048) = dat(start:5:stop)';
67 start = start + frame_len;
68 stop = stop + frame_len;
69 end
70  
71 start = 755;
72 stop = 10990;
73
74 for line = 1:len
75   chan5(line, 1:2048) = dat(start:5:stop)';
76   start = start + frame_len;
77   stop = stop + frame_len;
78 end
79
80 colormap(gray) 
81 saveimage("chan1.ppm", chan1/4, 'ppm')
82 saveimage("chan2.ppm", chan2/4, 'ppm')
83 saveimage("chan3.ppm", chan3/4, 'ppm')
84 saveimage("chan4.ppm", chan4/4, 'ppm')
85 saveimage("chan5.ppm", chan5/4, 'ppm')