-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfilhead.c
81 lines (58 loc) · 2.1 KB
/
filhead.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#include "filhead.h"
#include <string.h>
/*
This part of the code is based on sigproc program by Duncan Lorimer.
*/
void send_string(FILE *outfile, char *string){
int len;
len = strlen(string);
fwrite(&len, sizeof(int), 1, outfile);
fwrite(string, sizeof(char), len, outfile);
}
void send_float(FILE *outfile, char *name, float number){
send_string(outfile, name);
fwrite(&number, sizeof(float), 1, outfile);
}
void send_double(FILE *outfile, char *name, double number){
send_string(outfile, name);
fwrite(&number, sizeof(double), 1, outfile);
}
void send_int(FILE *outfile, char *name, int number){
send_string(outfile, name);
fwrite(&number, sizeof(int), 1, outfile);
}
void send_long(FILE *outfile, char *name, long number){
send_string(outfile, name);
fwrite(&number, sizeof(long), 1, outfile);
}
void filterbank_header(FILE *outfile, char *infilename, char *jname, double mjd, double freq, double bw, int nchan, double tsmpl){
int nbits = 16;
int nbeams = 1;
int ibeam = 1;
int nifs = 1;
int machine_id = 14;
int telescope_id = 7;
/* broadcast the header parameters to the output stream */
send_string(outfile, "HEADER_START");
send_string(outfile, "rawdatafile");
send_string(outfile, infilename);
//send_string(outfile, "source_name");
//send_string(outfile, jname);
send_int(outfile, "machine_id", machine_id);
send_int(outfile, "telescope_id", telescope_id);
send_double(outfile, "src_raj", 0);
send_double(outfile, "src_dej", 0);
send_double(outfile, "az_start", 0);
send_double(outfile, "za_start", 0);
send_int(outfile, "data_type", 1);
send_double(outfile, "fch1", freq);
send_double(outfile, "foff", bw);
send_int(outfile, "nchans", nchan);
send_int(outfile, "nbeams", nbeams);
send_int(outfile, "ibeam", ibeam);
send_int(outfile, "nbits", nbits);
send_double(outfile, "tstart", mjd);
send_double(outfile, "tsamp", tsmpl);
send_int(outfile, "nifs", nifs);
send_string(outfile, "HEADER_END");
}