forked from scottransom/psrfits2psrfits
-
Notifications
You must be signed in to change notification settings - Fork 1
/
psrfits.h
171 lines (154 loc) · 7.82 KB
/
psrfits.h
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
/* psrfits.h */
#ifndef _PSRFITS_H
#define _PSRFITS_H
#include "fitsio.h"
#include "polyco.h"
// number of shorts in 1 status block dump for pdev spectrometer.
#define AO_NUM_SH_STAT_1DMP 10
// The following is the max file length in GB
#define PSRFITS_MAXFILELEN 10L
// The following is the max file length in GB, different for fold/search
#define PSRFITS_MAXFILELEN_SEARCH 10L
// The following is the template file to use to create a PSRFITS file.
#define PSRFITS_SEARCH_TEMPLATE "WAPP_PSRFITS_v3.4_search_template.txt"
struct hdrinfo {
char obs_mode[8]; // Observing mode (SEARCH, PSR, CAL)
char telescope[24]; // Telescope used
char observer[24]; // Observer's name
char source[24]; // Source name
char frontend[24]; // Frontend used
char backend[24]; // Backend or instrument used
char project_id[24]; // Project identifier
char date_obs[24]; // Start of observation (YYYY-MM-DDTHH:MM:SS.SSS)
char ra_str[16]; // Right Ascension string (HH:MM:SS.SSSS)
char dec_str[16]; // Declination string (DD:MM:SS.SSSS)
char poln_type[8]; // Polarization recorded (LIN or CIRC)
char poln_order[16]; // Order of polarizations (i.e. XXYYXYYX)
char track_mode[16]; // Track mode (TRACK, SCANGC, SCANLAT)
char cal_mode[8]; // Cal mode (OFF, SYNC, EXT1, EXT2
char feed_mode[8]; // Feed track mode (FA, CPA, SPA, TPA)
long double MJD_epoch; // Starting epoch in MJD
double dt; // Sample duration (s)
double fctr; // Center frequency of the observing band (MHz)
double orig_df; // Original frequency spacing between the channels (MHz)
double df; // Frequency spacing between the channels (MHz)
double BW; // Bandwidth of the observing band (MHz)
double ra2000; // RA of observation (deg, J2000) at obs start
double dec2000; // Dec of observation (deg, J2000) at obs start
double azimuth; // Azimuth (commanded) at the start of the obs (deg)
double zenith_ang; // Zenith angle (commanded) at the start of the obs (deg)
double beam_FWHM; // Beam FWHM (deg)
double cal_freq; // Cal modulation frequency (Hz)
double cal_dcyc; // Cal duty cycle (0-1)
double cal_phs; // Cal phase (wrt start time)
double feed_angle; // Feed/Posn angle requested (deg)
double scanlen; // Requested scan length (sec)
double start_lst; // Start LST (sec past 00h)
double start_sec; // Start time (sec past UTC 00h)
double chan_dm; // DM that each channel was de-dispersed at (pc/cm^3)
double fd_sang; // Reference angle for feed rotation (deg)
double fd_xyph; // Cal signal poln cross-term phase (deg)
int start_day; // Start MJD (UTC days) (J - long integer)
int scan_number; // Number of scan
int nbits; // Number of bits per data sample
int nbin; // Number of bins per period in fold mode
int nchan; // Number of channels
int npol; // Number of polarizations to be stored (1 for summed)
int nsblk; // Number of spectra per row
int orig_nchan; // Number of spectral channels per sample
int summed_polns; // Are polarizations summed? (1=Yes, 0=No)
int rcvr_polns; // Number of polns provided by the receiver
int offset_subint; // Offset subint number for first row in the file
int ds_time_fact; // Software downsampling factor in time (1 if none)
int ds_freq_fact; // Software downsampling factor in freq (1 if none)
int onlyI; // 1 if the software will only record Stokes I
int fd_hand; // Receiver "handedness" or X/Y swap (+/-1)
int be_phase; // Backend poln cross-term phase convention (+/-1)
// ao additions for mock pdev spectrometer
int fftAccum; // default fftaccum if no blanking;
int blankingOn; // if adc or other blanking enabled
int numBlksTot; // requested number of valid spectra
};
struct subint {
double tsubint; // Length of subintegration (sec)
double offs; // Offset from Start of subint centre (sec)
double lst; // LST at subint centre (sec)
double ra; // RA (J2000) at subint centre (deg)
double dec; // Dec (J2000) at subint centre (deg)
double glon; // Gal longitude at subint centre (deg)
double glat; // Gal latitude at subint centre (deg)
double feed_ang; // Feed angle at subint centre (deg)
double pos_ang; // Position angle of feed at subint centre (deg)
double par_ang; // Parallactic angle at subint centre (deg)
double tel_az; // Telescope azimuth at subint centre (deg)
double tel_zen; // Telescope zenith angle at subint centre (deg)
int bytes_per_subint; // Number of bytes for one row of raw data
int FITS_typecode; // FITS data typecode as per CFITSIO
float *dat_freqs; // Ptr to array of Centre freqs for each channel (MHz)
float *dat_weights; // Ptr to array of Weights for each channel
float *dat_offsets; // Ptr to array of offsets for each chan * pol
float *dat_scales; // Ptr to array of scalings for each chan * pol
/*
float dat_freqs[16384]; // Ptr to array of Centre freqs for each channel (MHz)
float dat_weights[16384];// Ptr to array of Weights for each channel
float dat_offsets[16384];// Ptr to array of offsets for each chan * pol
float dat_scales[16384]; // Ptr to array of Centre freqs for each channel (MHz)
*/
unsigned char *data; // Ptr to the raw data itself
int statbytes_per_subint; // Number of ao pdev stat bytes in 1 row
int typecode; // type of data: TBYTE,TSHORT,TINT32BIT,TLONG,TFLOAT,TDOUBLE
int dataBytesAlloced; // after we've done the malloc
long bytesPerDatum; // if not byte data
unsigned short *stat; // Ptr to the status block: 10shorts*numberOfDumps
};
typedef struct {
int tsubint;
int offs_sub;
int lst_sub;
int ra_sub;
int dec_sub;
int glon_sub;
int glat_sub;
int fd_ang;
int pos_ang;
int par_ang;
int tel_az;
int tel_zen;
int dat_freq;
int dat_wts;
int dat_offs;
int dat_scl;
int data;
int stat; // ao pdev stat array (10,nsamples) as shorts
} SUBINT_COLS;
struct psrfits {
int initialized;
char basefilename[200]; // The base filename from which to build the true filename
int fnamedigits; // how many digits in filename
char filename[200]; // Filename of the current PSRFITs file
long long N; // Current number of spectra written
double T; // Current duration of the observation written
int filenum; // The current number of the file in the scan (1-offset)
int rownum; // The current subint number to be written (1-offset)
int tot_rows; // The total number of subints written so far
int rows_per_file; // The maximum number of rows (subints) per file
int status; // The CFITSIO status value
fitsfile *fptr; // The CFITSIO file structure
int multifile; // Write multiple output files
int quiet; // Be quiet about writing each subint
char mode; // Read (r) or write (w).
struct hdrinfo hdr;
struct subint sub;
SUBINT_COLS subcols; // column numbers for subint data;
};
// In write_psrfits.c
int psrfits_create(struct psrfits *pf);
int psrfits_write_subint(struct psrfits *pf);
int psrfits_close(struct psrfits *pf);
#define SEARCH_MODE 1
#define FOLD_MODE 2
int psrfits_obs_mode(const char *obs_mode);
// In read_psrfits.c
int psrfits_open(struct psrfits *pf, int iomode);
int psrfits_read_subint(struct psrfits *pf,int first);
#endif