67#include <lal/LALFrameU.h>
70#define PATH_MAX FILENAME_MAX
76#define FAILURE(...) do { fprintf(stderr, __VA_ARGS__); exit(1); } while (0)
78int charcmp(
const void *c1,
const void *c2);
81int main(
int argc,
char *argv[])
84 char *defaultfilev[1] = { stdio };
85 int filec = (argc == 1 ? 1 : argc - 1);
86 char **filev = (argc == 1 ? defaultfilev : &argv[1]);
89 for (f = 0; f < filec; ++f) {
90 char *fname = filev[f];
92 LALFrameUFrFile *frfile;
103 double t0min = +1.0 /
H0;
104 double t1max = -1.0 /
H0;
109 FAILURE(
"file %s not found\n", fname);
116 if ((
int)(nframe) <= 0)
124 for (det = 0; det < ndet; ++det) {
125 LALFrameUFrDetector *detector;
132 if (prefix && isupper(*prefix))
133 if (strchr(sites, *prefix) == NULL)
134 strncat(sites, prefix, 1);
139 qsort(sites, strlen(sites),
sizeof(*sites),
charcmp);
143 for (pos = 0; pos < nframe; ++pos) {
158 for (chan = 0; chan < nadc; ++chan) {
166 if (
t0 + toff < t0min)
168 if (t1 + toff > t1max)
173 for (chan = 0; chan < nsim; ++chan) {
181 if (
t0 + toff < t0min)
183 if (t1 + toff > t1max)
188 for (chan = 0; chan < nproc; ++chan) {
196 if (
t0 + toff < t0min)
198 if (t1 + toff > t1max)
205 if (!realpath(fname,
path))
207 dt = ceil(t1max) - floor(t0min);
210 printf(
"\t%d", (
int)floor(t0min));
211 printf(
"\t%d",
dt > 0 ?
dt : 1);
212 if (strcmp(
path,
"-") == 0)
215 printf(
"\tfile://%s",
path);
228 char a = *((
const char *)c1);
229 char b = *((
const char *)c2);
230 return (
a > b) - (
a < b);
235 if (fname && *fname && strcmp(fname,
"-") && strlen(fname) < FILENAME_MAX) {
236 char src[FILENAME_MAX];
237 char dsc[FILENAME_MAX];
245 base = strrchr(fname,
'/');
246 base = base ? base + 1 : fname;
249 n = sscanf(base,
"%[A-Z]-%[a-zA-Z0-9_+#]-%u-%u.gwf",
src, dsc, &
t0,
255 base = strrchr(fname,
'/');
256 base = base ? base + 1 : fname;
260 while (*base && *base !=
'.')
const char * XLALFrameUFrTOCQuerySimName(const LALFrameUFrTOC *toc, size_t sim)
Query FrTOC structure for the name of a FrSimData structure.
size_t XLALFrameUFrTOCQueryNFrame(const LALFrameUFrTOC *toc)
Query FrTOC structure for number of FrameH structures contained.
void XLALFrameUFrTOCFree(LALFrameUFrTOC *toc)
Free a FrTOC structure.
LALFrameUFrChan * XLALFrameUFrChanRead(LALFrameUFrFile *stream, const char *name, size_t pos)
Read a channel FrChan structure from a FrFile stream.
size_t XLALFrameUFrTOCQuerySimN(const LALFrameUFrTOC *toc)
Query FrTOC structure for number of FrSimData structures.
void XLALFrameUFrChanFree(LALFrameUFrChan *channel)
Free a FrChan structure.
const char * XLALFrameUFrDetectorQueryPrefix(const LALFrameUFrDetector *detector)
Query FrDetector structure for the detector prefix.
double XLALFrameUFrChanQueryTimeOffset(const LALFrameUFrChan *channel)
Query FrChan structure for time offset for this channel.
LALFrameUFrTOC * XLALFrameUFrTOCRead(LALFrameUFrFile *stream)
Read the table of contents FrTOC structure for a FrFile stream.
size_t XLALFrameUFrTOCQueryProcN(const LALFrameUFrTOC *toc)
Query FrTOC structure for number of FrProcData structures.
const char * XLALFrameUFrTOCQueryProcName(const LALFrameUFrTOC *toc, size_t proc)
Query FrTOC structure for the name of a FrProcData structure.
double XLALFrameUFrTOCQueryGTimeModf(double *iptr, const LALFrameUFrTOC *toc, size_t pos)
Query FrTOC structure for start time of a FrameH structure.
void XLALFrameUFrDetectorFree(LALFrameUFrDetector *detector)
Free a FrDetector structure.
const char * XLALFrameUFrTOCQueryAdcName(const LALFrameUFrTOC *toc, size_t adc)
Query FrTOC structure for the name of a FrAdcData structure.
LALFrameUFrFile * XLALFrameUFrFileOpen(const char *filename, const char *mode)
Open a frame file FrFile stream.
struct tagLALFrameUFrTOC LALFrameUFrTOC
Incomplete type for a table of contents FrTOC structure.
double XLALFrameUFrTOCQueryDt(const LALFrameUFrTOC *toc, size_t pos)
Query FrTOC structure for duration of a FrameH structure.
void XLALFrameUFrFileClose(LALFrameUFrFile *stream)
Close a FrFile stream.
size_t XLALFrameUFrTOCQueryAdcN(const LALFrameUFrTOC *toc)
Query FrTOC structure for number of FrAdcData structures.
size_t XLALFrameUFrTOCQueryDetectorN(const LALFrameUFrTOC *toc)
Query FrTOC structure for number of FrDetector structures.
LALFrameUFrDetector * XLALFrameUFrDetectorRead(LALFrameUFrFile *stream, const char *name)
Read a detector FrDetector structure from a FrFile stream.
const char * XLALFrameUFrTOCQueryDetectorName(const LALFrameUFrTOC *toc, size_t det)
Query FrTOC structure for the name of a FrDetector structure.
int main(int argc, char *argv[])
char * fnametodsc(const char *fname)
int charcmp(const void *c1, const void *c2)