Loading [MathJax]/extensions/TeX/AMSsymbols.js
LALPulsar 7.1.1.1-b246709
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
SFTnamingTest.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2022 Karl Wette
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with with program; see the file COPYING. If not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301 USA
18 */
19
20/**
21 * \file
22 * \ingroup SFTfileIO_h
23 * \author K. Wette
24 *
25 * \brief Test the SFT file naming routines
26 */
27
28#include <lal/SFTfileIO.h>
29
30int main( void )
31{
32
33 const char *SFT_filenames[] = {
34 // A 30-minute private H2 SFT
35 "/path/to/H-1_H2_1800SFT-735627918-1800.sft",
36 // A 30-minute private L1 SFT with the description "S2"
37 "L-1_L1_1800SFT_S2-733467931-1800.sft",
38 // A private file with 1887 30-minute H1 SFTs with gaps in time
39 "H-1887_H1_1800SFT-733467931-4622400.sft",
40 // A 60-second private GEO SFT with the description "S3hot"
41 "G-1_G1_60SFT_S3hot-732465218-60.sft",
42 // 5 public broad-band H1 SFTs from the O2 observing run; revision 1 of the public SFTs were
43 // created from the H1:DCH-CLEAN_STRAIN_C02 channel, Tukey-windowed with parameter = 0.001
44 "H-1_H1_1800SFT_O2RUN+R1+CDCHCLEANSTRAINC02+WTKEY5-1257800000-1800.sft",
45 "H-1_H1_1800SFT_O2RUN+R1+CDCHCLEANSTRAINC02+WTKEY5-1257801800-1800.sft",
46 "H-1_H1_1800SFT_O2RUN+R1+CDCHCLEANSTRAINC02+WTKEY5-1257803600-1800.sft",
47 "H-1_H1_1800SFT_O2RUN+R1+CDCHCLEANSTRAINC02+WTKEY5-1257805400-1800.sft",
48 "H-1_H1_1800SFT_O2RUN+R1+CDCHCLEANSTRAINC02+WTKEY5-1257807200-1800.sft",
49 // The equivalent narrow-band SFTs over the frequency range 10–95.5 Hz, each SFT
50 // containing 8 Hz of data except the last SFT which contains 5.5 Hz of data
51 "H-5_H1_1800SFT_O2RUN+R1+CDCHCLEANSTRAINC02+WTKEY5_NBF0010Hz0W0008Hz0-1257800000-9000.sft",
52 "H-5_H1_1800SFT_O2RUN+R1+CDCHCLEANSTRAINC02+WTKEY5_NBF0018Hz0W0008Hz0-1257800000-9000.sft",
53 "H-5_H1_1800SFT_O2RUN+R1+CDCHCLEANSTRAINC02+WTKEY5_NBF0026Hz0W0008Hz0-1257800000-9000.sft",
54 "H-5_H1_1800SFT_O2RUN+R1+CDCHCLEANSTRAINC02+WTKEY5_NBF0034Hz0W0008Hz0-1257800000-9000.sft",
55 "H-5_H1_1800SFT_O2RUN+R1+CDCHCLEANSTRAINC02+WTKEY5_NBF0042Hz0W0008Hz0-1257800000-9000.sft",
56 "H-5_H1_1800SFT_O2RUN+R1+CDCHCLEANSTRAINC02+WTKEY5_NBF0050Hz0W0008Hz0-1257800000-9000.sft",
57 "H-5_H1_1800SFT_O2RUN+R1+CDCHCLEANSTRAINC02+WTKEY5_NBF0058Hz0W0008Hz0-1257800000-9000.sft",
58 "H-5_H1_1800SFT_O2RUN+R1+CDCHCLEANSTRAINC02+WTKEY5_NBF0066Hz0W0008Hz0-1257800000-9000.sft",
59 "H-5_H1_1800SFT_O2RUN+R1+CDCHCLEANSTRAINC02+WTKEY5_NBF0074Hz0W0008Hz0-1257800000-9000.sft",
60 "H-5_H1_1800SFT_O2RUN+R1+CDCHCLEANSTRAINC02+WTKEY5_NBF0082Hz0W0008Hz0-1257800000-9000.sft",
61 "H-5_H1_1800SFT_O2RUN+R1+CDCHCLEANSTRAINC02+WTKEY5_NBF0090Hz0W0005Hz900-1257800000-9000.sft",
62 // Old style SFT names from before the naming convention in the v3 SFT specification
63 "L-1_L1_1800SFT_old_style_SFT_name-1238239230-1800.sft",
64 "L-1_L1_1800SFT_NBF0010Hz0W0008Hz0_old_style_SFT_name-1238239230-1800.sft",
65 };
66
67 const SFTFilenameSpec SFT_spec[] = {
68 // A 30-minute private H2 SFT
69 { .path = "/path/to", .numSFTs = 1, .detector = "H2", .SFTtimebase = 1800, .gpsStart = 735627918, .SFTspan = 1800 },
70 // A 30-minute private L1 SFT with the description "S2"
71 { .numSFTs = 1, .detector = "L1", .SFTtimebase = 1800, .privMisc = "S2", .gpsStart = 733467931, .SFTspan = 1800 },
72 // A private file with 1887 30-minute H1 SFTs with gaps in time
73 { .numSFTs = 1887, .detector = "H1", .SFTtimebase = 1800, .gpsStart = 733467931, .SFTspan = 4622400 },
74 // A 60-second private GEO SFT with the description "S3hot"
75 { .numSFTs = 1, .detector = "G1", .SFTtimebase = 60, .privMisc = "S3hot", .gpsStart = 732465218, .SFTspan = 60 },
76 // 5 public broad-band H1 SFTs from the O2 observing run; revision 1 of the public SFTs were created from the H1:DCH-CLEAN_STRAIN_C02 channel, Tukey-windowed with parameter = 0.001
77 {
78 .numSFTs = 1, .detector = "H1", .SFTtimebase = 1800, .window_type = "tukey", .window_param = 0.001, .gpsStart = 1257800000, .SFTspan = 1800,
79 .pubObsRun = 2, .pubObsKind = "RUN", .pubRevision = 1, .pubChannel = "H1:DCH-CLEAN_STRAIN_C02"
80 },
81 {
82 .numSFTs = 1, .detector = "H1", .SFTtimebase = 1800, .window_type = "tukey", .window_param = 0.001, .gpsStart = 1257801800, .SFTspan = 1800,
83 .pubObsRun = 2, .pubObsKind = "RUN", .pubRevision = 1, .pubChannel = "H1:DCH-CLEAN_STRAIN_C02"
84 },
85 {
86 .numSFTs = 1, .detector = "H1", .SFTtimebase = 1800, .window_type = "tukey", .window_param = 0.001, .gpsStart = 1257803600, .SFTspan = 1800,
87 .pubObsRun = 2, .pubObsKind = "RUN", .pubRevision = 1, .pubChannel = "H1:DCH-CLEAN_STRAIN_C02"
88 },
89 {
90 .numSFTs = 1, .detector = "H1", .SFTtimebase = 1800, .window_type = "tukey", .window_param = 0.001, .gpsStart = 1257805400, .SFTspan = 1800,
91 .pubObsRun = 2, .pubObsKind = "RUN", .pubRevision = 1, .pubChannel = "H1:DCH-CLEAN_STRAIN_C02"
92 },
93 {
94 .numSFTs = 1, .detector = "H1", .SFTtimebase = 1800, .window_type = "tukey", .window_param = 0.001, .gpsStart = 1257807200, .SFTspan = 1800,
95 .pubObsRun = 2, .pubObsKind = "RUN", .pubRevision = 1, .pubChannel = "H1:DCH-CLEAN_STRAIN_C02"
96 },
97 // The equivalent narrow-band SFTs over the frequency range 10–95 Hz, each SFT containing 8 Hz of data except the last SFT which contains 5 Hz of data
98 {
99 .numSFTs = 5, .detector = "H1", .SFTtimebase = 1800, .window_type = "tukey", .window_param = 0.001, .gpsStart = 1257800000, .SFTspan = 9000,
100 .pubObsRun = 2, .pubObsKind = "RUN", .pubRevision = 1, .pubChannel = "H1:DCH-CLEAN_STRAIN_C02",
101 .nbFirstBinFreq = 10, .nbFirstBinRem = 0, .nbBinWidthFreq = 8, .nbBinWidthRem = 0
102 },
103 {
104 .numSFTs = 5, .detector = "H1", .SFTtimebase = 1800, .window_type = "tukey", .window_param = 0.001, .gpsStart = 1257800000, .SFTspan = 9000,
105 .pubObsRun = 2, .pubObsKind = "RUN", .pubRevision = 1, .pubChannel = "H1:DCH-CLEAN_STRAIN_C02",
106 .nbFirstBinFreq = 18, .nbFirstBinRem = 0, .nbBinWidthFreq = 8, .nbBinWidthRem = 0
107 },
108 {
109 .numSFTs = 5, .detector = "H1", .SFTtimebase = 1800, .window_type = "tukey", .window_param = 0.001, .gpsStart = 1257800000, .SFTspan = 9000,
110 .pubObsRun = 2, .pubObsKind = "RUN", .pubRevision = 1, .pubChannel = "H1:DCH-CLEAN_STRAIN_C02",
111 .nbFirstBinFreq = 26, .nbFirstBinRem = 0, .nbBinWidthFreq = 8, .nbBinWidthRem = 0
112 },
113 {
114 .numSFTs = 5, .detector = "H1", .SFTtimebase = 1800, .window_type = "tukey", .window_param = 0.001, .gpsStart = 1257800000, .SFTspan = 9000,
115 .pubObsRun = 2, .pubObsKind = "RUN", .pubRevision = 1, .pubChannel = "H1:DCH-CLEAN_STRAIN_C02",
116 .nbFirstBinFreq = 34, .nbFirstBinRem = 0, .nbBinWidthFreq = 8, .nbBinWidthRem = 0
117 },
118 {
119 .numSFTs = 5, .detector = "H1", .SFTtimebase = 1800, .window_type = "tukey", .window_param = 0.001, .gpsStart = 1257800000, .SFTspan = 9000,
120 .pubObsRun = 2, .pubObsKind = "RUN", .pubRevision = 1, .pubChannel = "H1:DCH-CLEAN_STRAIN_C02",
121 .nbFirstBinFreq = 42, .nbFirstBinRem = 0, .nbBinWidthFreq = 8, .nbBinWidthRem = 0
122 },
123 {
124 .numSFTs = 5, .detector = "H1", .SFTtimebase = 1800, .window_type = "tukey", .window_param = 0.001, .gpsStart = 1257800000, .SFTspan = 9000,
125 .pubObsRun = 2, .pubObsKind = "RUN", .pubRevision = 1, .pubChannel = "H1:DCH-CLEAN_STRAIN_C02",
126 .nbFirstBinFreq = 50, .nbFirstBinRem = 0, .nbBinWidthFreq = 8, .nbBinWidthRem = 0
127 },
128 {
129 .numSFTs = 5, .detector = "H1", .SFTtimebase = 1800, .window_type = "tukey", .window_param = 0.001, .gpsStart = 1257800000, .SFTspan = 9000,
130 .pubObsRun = 2, .pubObsKind = "RUN", .pubRevision = 1, .pubChannel = "H1:DCH-CLEAN_STRAIN_C02",
131 .nbFirstBinFreq = 58, .nbFirstBinRem = 0, .nbBinWidthFreq = 8, .nbBinWidthRem = 0
132 },
133 {
134 .numSFTs = 5, .detector = "H1", .SFTtimebase = 1800, .window_type = "tukey", .window_param = 0.001, .gpsStart = 1257800000, .SFTspan = 9000,
135 .pubObsRun = 2, .pubObsKind = "RUN", .pubRevision = 1, .pubChannel = "H1:DCH-CLEAN_STRAIN_C02",
136 .nbFirstBinFreq = 66, .nbFirstBinRem = 0, .nbBinWidthFreq = 8, .nbBinWidthRem = 0
137 },
138 {
139 .numSFTs = 5, .detector = "H1", .SFTtimebase = 1800, .window_type = "tukey", .window_param = 0.001, .gpsStart = 1257800000, .SFTspan = 9000,
140 .pubObsRun = 2, .pubObsKind = "RUN", .pubRevision = 1, .pubChannel = "H1:DCH-CLEAN_STRAIN_C02",
141 .nbFirstBinFreq = 74, .nbFirstBinRem = 0, .nbBinWidthFreq = 8, .nbBinWidthRem = 0
142 },
143 {
144 .numSFTs = 5, .detector = "H1", .SFTtimebase = 1800, .window_type = "tukey", .window_param = 0.001, .gpsStart = 1257800000, .SFTspan = 9000,
145 .pubObsRun = 2, .pubObsKind = "RUN", .pubRevision = 1, .pubChannel = "H1:DCH-CLEAN_STRAIN_C02",
146 .nbFirstBinFreq = 82, .nbFirstBinRem = 0, .nbBinWidthFreq = 8, .nbBinWidthRem = 0
147 },
148 {
149 .numSFTs = 5, .detector = "H1", .SFTtimebase = 1800, .window_type = "tukey", .window_param = 0.001, .gpsStart = 1257800000, .SFTspan = 9000,
150 .pubObsRun = 2, .pubObsKind = "RUN", .pubRevision = 1, .pubChannel = "H1:DCH-CLEAN_STRAIN_C02",
151 .nbFirstBinFreq = 90, .nbFirstBinRem = 0, .nbBinWidthFreq = 5, .nbBinWidthRem = 900
152 },
153 // Old style SFT names from before the naming convention in the v3 SFT specification
154 { .numSFTs = 1, .detector = "L1", .SFTtimebase = 1800, .privMisc = "oldstyleSFTname", .gpsStart = 1238239230, .SFTspan = 1800 },
155 {
156 .numSFTs = 1, .detector = "L1", .SFTtimebase = 1800, .privMisc = "oldstyleSFTname", .gpsStart = 1238239230, .SFTspan = 1800,
157 .nbFirstBinFreq = 10, .nbFirstBinRem = 0, .nbBinWidthFreq = 8, .nbBinWidthRem = 0
158 },
159 };
160
161 for ( size_t i = 0; i < XLAL_NUM_ELEM( SFT_spec ); ++i ) {
162 if ( strcmp( SFT_spec[i].privMisc, "oldstyleSFTname" ) != 0 ) {
163 char *fname = XLALBuildSFTFilenameFromSpec( &SFT_spec[i] );
164 XLAL_CHECK_MAIN( fname != NULL, XLAL_EFUNC );
165 XLAL_CHECK_MAIN( strcmp( fname, SFT_filenames[i] ) == 0, XLAL_EFAILED, "SFT filename '%s' should be '%s'", fname, SFT_filenames[i] );
166 XLALFree( fname );
167 }
168 }
169
170 for ( size_t i = 0; i < XLAL_NUM_ELEM( SFT_spec ); ++i ) {
171 SFTFilenameSpec spec;
173 XLAL_CHECK_MAIN( strcmp( spec.path, SFT_spec[i].path ) == 0, XLAL_EFAILED, "path '%s' should be '%s'", spec.path, SFT_spec[i].path );
174 XLAL_CHECK_MAIN( spec.numSFTs == SFT_spec[i].numSFTs, XLAL_EFAILED, "numSFTs '%d' should be '%d'", spec.numSFTs, SFT_spec[i].numSFTs );
175 XLAL_CHECK_MAIN( strcmp( spec.detector, SFT_spec[i].detector ) == 0, XLAL_EFAILED, "detector '%s' should be '%s'", spec.detector, SFT_spec[i].detector );
176 XLAL_CHECK_MAIN( spec.SFTtimebase == SFT_spec[i].SFTtimebase, XLAL_EFAILED, "SFTtimebase '%d' should be '%d'", spec.SFTtimebase, SFT_spec[i].SFTtimebase );
177 XLAL_CHECK_MAIN( strcmp( spec.window_type, SFT_spec[i].window_type ) == 0, XLAL_EFAILED, "window_type '%s' should be '%s'", spec.window_type, SFT_spec[i].window_type );
178 XLAL_CHECK_MAIN( spec.window_param == SFT_spec[i].window_param, XLAL_EFAILED, "window_param '%g' should be '%g'", spec.window_param, SFT_spec[i].window_param );
179 XLAL_CHECK_MAIN( spec.gpsStart == SFT_spec[i].gpsStart, XLAL_EFAILED, "gpsStart '%d' should be '%d'", spec.gpsStart, SFT_spec[i].gpsStart );
180 XLAL_CHECK_MAIN( spec.SFTspan == SFT_spec[i].SFTspan, XLAL_EFAILED, "SFTspan '%d' should be '%d'", spec.SFTspan, SFT_spec[i].SFTspan );
181 XLAL_CHECK_MAIN( strcmp( spec.privMisc, SFT_spec[i].privMisc ) == 0, XLAL_EFAILED, "privMisc '%s' should be '%s'", spec.privMisc, SFT_spec[i].privMisc );
182 XLAL_CHECK_MAIN( spec.pubObsRun == SFT_spec[i].pubObsRun, XLAL_EFAILED, "pubObsRun '%d' should be '%d'", spec.pubObsRun, SFT_spec[i].pubObsRun );
183 XLAL_CHECK_MAIN( strcmp( spec.pubObsKind, SFT_spec[i].pubObsKind ) == 0, XLAL_EFAILED, "pubObsKind '%s' should be '%s'", spec.pubObsKind, SFT_spec[i].pubObsKind );
184 XLAL_CHECK_MAIN( spec.pubRevision == SFT_spec[i].pubRevision, XLAL_EFAILED, "pubRevision '%d' should be '%d'", spec.pubRevision, SFT_spec[i].pubRevision );
185 if ( strlen( spec.pubChannel ) > 0 ) {
186 const char *SFT_spec_pubChannel_stripped = "DCHCLEANSTRAINC02";
187 XLAL_CHECK_MAIN( strcmp( spec.pubChannel, SFT_spec_pubChannel_stripped ) == 0, XLAL_EFAILED, "pubChannel '%s' should be '%s'", spec.pubChannel, SFT_spec_pubChannel_stripped );
188 }
189 XLAL_CHECK_MAIN( spec.nbFirstBinFreq == SFT_spec[i].nbFirstBinFreq, XLAL_EFAILED, "nbFirstBinFreq '%d' should be '%d'", spec.nbFirstBinFreq, SFT_spec[i].nbFirstBinFreq );
190 XLAL_CHECK_MAIN( spec.nbFirstBinRem == SFT_spec[i].nbFirstBinRem, XLAL_EFAILED, "nbFirstBinRem '%d' should be '%d'", spec.nbFirstBinRem, SFT_spec[i].nbFirstBinRem );
191 XLAL_CHECK_MAIN( spec.nbBinWidthFreq == SFT_spec[i].nbBinWidthFreq, XLAL_EFAILED, "nbBinWidthFreq '%d' should be '%d'", spec.nbBinWidthFreq, SFT_spec[i].nbBinWidthFreq );
192 XLAL_CHECK_MAIN( spec.nbBinWidthRem == SFT_spec[i].nbBinWidthRem, XLAL_EFAILED, "nbBinWidthRem '%d' should be '%d'", spec.nbBinWidthRem, SFT_spec[i].nbBinWidthRem );
193 }
194
196
197}
void LALCheckMemoryLeaks(void)
int main(void)
Definition: SFTnamingTest.c:30
#define XLAL_NUM_ELEM(x)
void XLALFree(void *p)
char * XLALBuildSFTFilenameFromSpec(const SFTFilenameSpec *spec)
Build an SFT file name from the given specification.
Definition: SFTnaming.c:302
int XLALParseSFTFilenameIntoSpec(SFTFilenameSpec *spec, const char *SFTpath)
Parse a SFT file path and return its specification.
Definition: SFTnaming.c:463
#define XLAL_CHECK_MAIN(assertion,...)
XLAL_SUCCESS
XLAL_EFUNC
XLAL_EFAILED
Structure specifying an SFT file name, following the convention in .
Definition: SFTfileIO.h:266
UINT4 pubRevision
For public SFTs: revision number of SFT production.
Definition: SFTfileIO.h:279
UINT4 SFTtimebase
Timebase in seconds of the SFT; set by XLALWriteSFT[Vector]2StandardFile()
Definition: SFTfileIO.h:271
UINT4 SFTspan
Total time interval in seconds covered by SFT file; set by XLALWriteSFT[Vector]2StandardFile()
Definition: SFTfileIO.h:275
UINT4 nbBinWidthRem
For narrow-band SFTs: remainder of division of SFT bandwidth by SFT time base.
Definition: SFTfileIO.h:284
UINT4 gpsStart
GPS time in seconds at the beginning of the first SFT in the file; set by XLALWriteSFT[Vector]2Standa...
Definition: SFTfileIO.h:274
CHAR pubChannel[256]
For public SFTs: channel name of data used to make SFTs.
Definition: SFTfileIO.h:280
UINT4 nbBinWidthFreq
For narrow-band SFTs: SFT bandwidth divided by SFT time base, rounded down.
Definition: SFTfileIO.h:283
CHAR detector[3]
2-character detector prefix (e.g.
Definition: SFTfileIO.h:270
CHAR pubObsKind[4]
For public SFTs: kind of data ('RUN', 'AUX', 'SIM', 'DEV')
Definition: SFTfileIO.h:278
UINT4 nbFirstBinRem
For narrow-band SFTs: remainder of division of SFT first bin frequency by SFT time base.
Definition: SFTfileIO.h:282
UINT4 numSFTs
Number of SFTs in the file; set by XLALWriteSFT[Vector]2StandardFile()
Definition: SFTfileIO.h:269
UINT4 pubObsRun
For public SFTs: observing run number.
Definition: SFTfileIO.h:277
CHAR window_type[32]
window function applied to SFT
Definition: SFTfileIO.h:272
CHAR path[4096]
Path to the SFT file.
Definition: SFTfileIO.h:267
UINT4 nbFirstBinFreq
For narrow-band SFTs: SFT first bin frequency divided by SFT time base, rounded down.
Definition: SFTfileIO.h:281
REAL8 window_param
parameter of window function, if required
Definition: SFTfileIO.h:273
CHAR privMisc[256]
For private SFTs: miscellaneous description field.
Definition: SFTfileIO.h:276