32 #define LAST_ELEMENT(buf) ( (buf)[XLAL_NUM_ELEM(buf) - 1] )
34 #define STRCPYCHK(name, dest, src) do { \
35 const char *const STRCPYCHK_p = (src); \
36 XLAL_CHECK( strlen(STRCPYCHK_p) < sizeof(dest), XLAL_ESIZE, "%s '%s' does not fit in a buffer of size %zu", name, STRCPYCHK_p, sizeof(dest) ); \
37 strncpy((dest), STRCPYCHK_p, sizeof(dest)); \
50 { .window_type =
"unknown", .short_name =
"UNKN", .B = 0 },
51 { .window_type =
"rectangular", .short_name =
"RECT", .B = 1 },
52 { .window_type =
"hann", .short_name =
"HANN", .B = 2 },
54 { .window_type =
"tukey", .short_name =
"TKEY", .A = 1 },
84 "Special CW detector prefix '%s' must start with one of [XYZ]", specialDetector->
frDetector.
prefix );
88 "Special CW detector prefix '%s' must end with one of [0123456789]", specialDetector->
frDetector.
prefix );
90 const int index = 10 * index_1 + index_2;
125 for (
UINT4 i = 0;
i < numSpecialDetectors;
i ++ ) {
127 if ( strncmp( prefix_i,
name, 2 ) == 0 ) {
128 if ( exactMatch && strcmp(
name + strlen( prefix_i ),
"" ) != 0 ) {
134 if ( lalCachedIndex != NULL ) {
135 ( *lalCachedIndex ) = -1;
143 for (
UINT4 i = 0;
i < numLALDetectors;
i ++ ) {
146 if ( strncmp( prefix_i,
name, 2 ) == 0 ) {
147 if ( exactMatch && strcmp(
name + strlen( prefix_i ),
"" ) != 0 ) {
153 if ( lalCachedIndex != NULL ) {
154 ( *lalCachedIndex ) =
i;
158 if ( strncmp(
name, name_i, strlen( name_i ) ) == 0 ) {
159 if ( exactMatch && strcmp(
name + strlen( name_i ),
"" ) != 0 ) {
165 if ( lalCachedIndex != NULL ) {
166 ( *lalCachedIndex ) =
i;
225 INT4 lalCachedIndex = -1;
231 if ( strchr(
"XYZ",
prefix[0] ) != NULL ) {
232 const int index_1 = ( (
int )
prefix[0] ) - ( (
int )
'X' );
235 const int index_2 = ( (
int )
prefix[1] ) - ( (
int )
'0' );
237 "Special CW detector prefix '%s' must be of the form [XYZ][0123456789]",
prefix );
239 const int index = 10 * index_1 + index_2;
263 const CHAR *privMisc,
264 const CHAR *pubObsKind,
265 const CHAR *pubChannel
273 if (
path != NULL ) {
276 if ( extn != NULL ) {
285 if ( privMisc != NULL ) {
288 if ( pubObsKind != NULL ) {
291 if ( pubChannel != NULL ) {
312 "'path' is not a null-terminated string" );
314 "'extn' is not a null-terminated string" );
316 "'numSFTs' must be strictly positive" );
318 "'detector' is not a null-terminated string" );
320 "'%s' is not a valid 2-character detector prefix", spec->
detector );
322 "'SFTtimebase' must be strictly positive" );
324 "'window_type' is not a null-terminated string" );
326 "'privMisc' is not a null-terminated string" );
328 "Public SFTs (with pubObsRun=%u) cannot include a private description '%s'",
331 "Private description '%s' contains disallowed characters", spec->
privMisc );
333 "'pubObsKind' is not a null-terminated string" );
339 "'pubObsKind=%s' must be one of 'RUN'|'AUX'|'SIM'|'DEV'", spec->
pubObsKind );
341 "Public SFTs (with pubObsRun=%u) must include a positive revision 'pubRevision'",
344 "'pubChannel' is not a null-terminated string" );
346 "Public SFTs (with pubObsRun=%u) must include a channel name 'pubChannel'",
349 "Public SFTs (with pubObsRun=%u) must include a window function 'window_type'",
352 "Narrow-band SFTs (with nbFirstBinFreq>0) must have nbBinWidthFreq>0 or nbBinWidthRem>0" );
354 "'gpsStart' must be strictly positive" );
356 "'SFTspan' must be strictly positive" );
358 char windowspec_str[9];
361 "'%s' is not a valid SFT window function", spec->
window_type );
368 if ( strlen( spec->
path ) > 0 ) {
391 if ( strlen( spec->
privMisc ) > 0 ) {
408 char *pubChannel_no_prefix = strchr( pubChannel,
':' );
409 if ( !pubChannel_no_prefix ) {
410 pubChannel_no_prefix = pubChannel;
418 "_O%d%s+R%d+C%s+W%s",
422 pubChannel_no_prefix,
435 "_NBF%04dHz%dW%04dHz%d",
451 strlen( spec->
extn ) > 0 ? spec->
extn :
"sft"
476 memset( spec, 0,
sizeof( *spec ) );
479 char localSFTpath[8192];
480 STRCPYCHK(
"SFT filename and path", localSFTpath, SFTpath );
483 char *SFTfname = strrchr( localSFTpath,
'/' );
485 SFTfname = localSFTpath;
499 "SFT file path '%s' contains no <S> field", SFTpath );
502 "SFT file path '%s' contains no <D> field", SFTpath );
505 "SFT file path '%s' contains no <G> field", SFTpath );
508 "SFT file path '%s' contains no <T> field", SFTpath );
509 XLALPrintInfo(
"%s(): S='%s' D='%s' G='%s' T='%s' extn='%s'\n",
515 char *D1, *
D2, *D3, *D4, *D5;
520 "SFT file path '%s' contains no <D1> field", SFTpath );
523 "SFT file path '%s' contains no <D2> field", SFTpath );
526 "SFT file path '%s' contains no <D3> field", SFTpath );
530 }
else if ( strncmp(
p,
"NBF", 3 ) == 0 ) {
538 for (
char *
q =
p; *
q !=
'\0'; ++
q ) {
543 if ( underscores > 1 ) {
554 XLALPrintInfo(
"%s(): D1='%s' D2='%s' D3='%s' D4='%s' D5='%s' p='%s'\n",
560 "Could not parse 'numSFTs' from field D1='%s'", D1 );
562 "'numSFTs' must be strictly positive" );
565 "'%s' is not a valid 2-character detector prefix", spec->
detector );
567 "Inconsistent site/detector fields S='%s' and D2='%s'", S,
D2 );
569 "Could not parse 'SFTtimebase' from field D3='%s'", D3 );
571 "'SFTtimebase' must be strictly positive" );
573 "Could not parse 'gpsStart' from field G='%s'", G );
575 "'gpsStart' must be strictly positive" );
577 "Could not parse 'SFTspan' from field T='%s'",
T );
579 "'SFTspan' must be strictly positive" );
583 if ( strchr( D4,
'+' ) ) {
584 char *D41, *D42, *D43, *D44;
588 "SFT file path '%s' contains no <D41> field", SFTpath );
591 "SFT file path '%s' contains no <D42> field", SFTpath );
594 "SFT file path '%s' contains no <D43> field", SFTpath );
597 "SFT file path '%s' contains no <D44> field", SFTpath );
598 XLALPrintInfo(
"%s(): D41='%s' D42='%s' D43='%s' D44='%s' p='%s'\n",
602 "Could not parse public SFT fields 'pubObsRun' and 'pubObsKind' from field D41='%s'", D41 );
605 "Could not parse public SFT field 'pubRevision' from field D42='%s'", D42 );
607 "Could not parse public SFT field 'pubChannel' from field D43='%s'", D43 );
610 "Could not parse public SFT fields 'window_type' and 'window_param' from field D44='%s'", D44 );
612 "'%s' does not specify a valid SFT window function", buf );
615 "Private description '%s' contains disallowed characters", D4 );
626 "Could not parse narrow-band SFT field D5='%s'", D5 );
643 size_t len = strlen(
desc );
645 if ( len == 1 && isupper(
desc[0] ) ) {
649 for (
UINT4 i = 0;
i < len;
i ++ ) {
652 XLAL_CHECK( isascii(
c ) && isalnum(
c ),
XLAL_EINVAL,
"Invalid chacter '%c' found, only ASCII alphanumeric are allowed\n",
c );
701 if ( windowspec_str ) {
718 if ( windowspec_str ) {
724 REAL8 Breal = window_param * 5000;
725 long B = lrint( Breal );
726 XLAL_CHECK(
B == ( (
long ) Breal ),
XLAL_ETOL,
"SFT window_param=%0.10g cannot be exactly represented by an integer [0,5000]", window_param );
727 XLAL_CHECK( 0 <=
B &&
B <= 5000,
XLAL_ERANGE,
"SFT window_param=%0.10g is out of range [0.0,1.0] (B=%ld)", window_param,
B );
733 if ( windowspec_str ) {
756 const UINT2 A = windowspec / 5001;
757 const UINT2 B = windowspec - 5001 *
A;
770 if ( window_param ) {
776 }
else if (
A > 0 ) {
782 if ( window_param ) {
783 *window_param = ( (
REAL8 )
B ) / 5000;
811 int parsed = sscanf( windowspec_str,
"%4s%li",
short_name, &
B );
812 XLAL_CHECK( 0 < parsed,
XLAL_EINVAL,
"Could not parse SFT filename field windowspec_str='%s'", windowspec_str );
825 if ( window_param ) {
829 *window_param = ( (
REAL8 )
B ) / 5000;
#define __func__
log an I/O error, i.e.
INT4 D2(REAL8 *f, REAL8 dx, INT4 n, REAL8 *d2f)
Internal SFT types and functions.
#define LAST_ELEMENT(buf)
#define STRCPYCHK(name, dest, src)
static LALDetector SpecialDetectorRegistry[30]
static const struct @6 windowspec_table[]
SFT window specification; see .
const LALDetector lalCachedDetectors[LAL_NUM_DETECTORS]
int XLALStringCaseCompare(const char *s1, const char *s2)
char char * XLALStringDuplicate(const char *s)
char * XLALStringKeepChars(char *s, int(*f)(int))
char * XLALStringAppendFmt(char *s, const char *fmt,...) _LAL_GCC_PRINTF_FORMAT_(2
char * XLALStringToken(char **s, const char *delim, int empty)
int parse_sft_windowspec(const UINT2 windowspec, const char **window_type, REAL8 *window_param)
Parse an SFT 2-byte 'windowspec' into a window name 'window_type' and possible parameter 'window_para...
const LALDetector * XLALGetSiteInfo(const CHAR *name)
Find the site geometry-information 'LALDetector' for given a detector name (or prefix).
int XLALRegisterSpecialCWDetector(const LALDetector *specialDetector)
Register a special detector for use with CW codes.
CHAR * XLALGetChannelPrefix(const CHAR *name)
Find the valid CW detector prefix.
int build_sft_windowspec(UINT2 *windowspec, CHAR(*windowspec_str)[9], const char *window_type, REAL8 window_param)
Build an SFT 2-byte 'windowspec' or filename field 'windowspec_str' for the window given by 'window_t...
int XLALCompareSFTWindows(const CHAR *type1, const REAL8 param1, const CHAR *type2, const REAL8 param2)
Check whether two SFT windows, each defined by a type name and parameter value, match.
char * XLALBuildSFTFilenameFromSpec(const SFTFilenameSpec *spec)
Build an SFT file name from the given specification.
int XLALFindCWDetector(CHAR **prefix, INT4 *lalCachedIndex, const CHAR *name, const BOOLEAN exactMatch)
Parses valid CW detector names and prefixes.
int XLALCheckValidDescriptionField(const char *desc)
Check whether given string qualifies as a valid 'description' field of a FRAME filename (per ) or SFT...
int XLALParseSFTFilenameIntoSpec(SFTFilenameSpec *spec, const char *SFTpath)
Parse a SFT file path and return its specification.
int parse_sft_windowspec_str(const CHAR *windowspec_str, CHAR(*window_type)[32], REAL8 *window_param)
Parse an SFT filename field 'windowspec_str' into a window name 'window_type' and possible parameter ...
int XLALFillSFTFilenameSpecStrings(SFTFilenameSpec *spec, const CHAR *path, const CHAR *extn, const CHAR *detector, const CHAR *window_type, const CHAR *privMisc, const CHAR *pubObsKind, const CHAR *pubChannel)
Convenience function for filling out the string fields in a SFTFilenameSpec.
BOOLEAN XLALIsValidCWDetector(const CHAR *name)
Determine if 'name' is a valid detector name or prefix.
#define XLAL_TRY_SILENT(statement, errnum)
int int int XLALPrintInfo(const char *fmt,...) _LAL_GCC_PRINTF_FORMAT_(1
#define XLAL_CHECK(assertion,...)
#define XLAL_CHECK_NULL(assertion,...)
p
RUN ANALYSIS SCRIPT ###.
Structure specifying an SFT file name, following the convention in .
UINT4 pubRevision
For public SFTs: revision number of SFT production.
UINT4 SFTtimebase
Timebase in seconds of the SFT; set by XLALWriteSFT[Vector]2StandardFile()
UINT4 SFTspan
Total time interval in seconds covered by SFT file; set by XLALWriteSFT[Vector]2StandardFile()
UINT4 nbBinWidthRem
For narrow-band SFTs: remainder of division of SFT bandwidth by SFT time base.
UINT4 gpsStart
GPS time in seconds at the beginning of the first SFT in the file; set by XLALWriteSFT[Vector]2Standa...
CHAR pubChannel[256]
For public SFTs: channel name of data used to make SFTs.
UINT4 nbBinWidthFreq
For narrow-band SFTs: SFT bandwidth divided by SFT time base, rounded down.
CHAR detector[3]
2-character detector prefix (e.g.
CHAR pubObsKind[4]
For public SFTs: kind of data ('RUN', 'AUX', 'SIM', 'DEV')
UINT4 nbFirstBinRem
For narrow-band SFTs: remainder of division of SFT first bin frequency by SFT time base.
UINT4 numSFTs
Number of SFTs in the file; set by XLALWriteSFT[Vector]2StandardFile()
UINT4 pubObsRun
For public SFTs: observing run number.
CHAR extn[32]
Extension of the SFT file; defaults to 'sft'.
CHAR window_type[32]
window function applied to SFT
CHAR path[4096]
Path to the SFT file.
UINT4 nbFirstBinFreq
For narrow-band SFTs: SFT first bin frequency divided by SFT time base, rounded down.
REAL8 window_param
parameter of window function, if required
CHAR privMisc[256]
For private SFTs: miscellaneous description field.