GWOLLUM 4.2.0
Tools for gravitational-wave analyses
Loading...
Searching...
No Matches
CUtils.cc File Reference

See CUtils.h. More...

#include "CUtils.h"
Include dependency graph for CUtils.cc:

Functions

bool CopyFile (error_code &aErrorCode, const string aFrom, const string aTo, const bool aOverwrite)
 Copy a file to a destination.
 
double GetMedian (const unsigned int aSize, double *aVect)
 Returns the median value of an array of doubles.
 
double * GetTukeyWindow (const unsigned int aSize, const double aAlpha)
 Returns a Tukey window.
 
vector< string > Glob (const char *pattern)
 C utility to extract a list of files.
 
int GwlPrintVersion (void)
 Prints the version.
 
bool ListDirectories (vector< string > &subdir, const string maindir)
 Returns a list of sub-directories.
 
void MakeStereoSoundFile (const string aFileName, const unsigned int aN, const unsigned int aSamplingRate, double *aAmplitudeLeft, double *aAmplitudeRight, const double aScale, const int aOffset)
 C utility to generate a WAV file.
 
double medianbiasfactor (const unsigned int nn)
 Returns the bias factor when computing a median with a finite number of samples.
 
string ReplaceAll (string str, const string &from, const string &to)
 Replaces all occurences of a sub-string by another sub-string.
 
vector< string > SplitString (const string stringtodivide, const char separator)
 Splits a string into sub-strings.
 
string StringToUpper (string stringtoconvert)
 Transforms a string to uppercase.
 
template<typename Word >
std::ostream & write_word (std::ostream &outs, Word value, unsigned size=sizeof(Word))
 

Detailed Description

See CUtils.h.

Author
Florent Robinet - florent.robinet@ijclab.in2p3.fr

Function Documentation

◆ CopyFile()

bool CopyFile ( error_code &  aErrorCode,
const string  aFrom,
const string  aTo,
const bool  aOverwrite = false 
)

Copy a file to a destination.

Returns
true if the copy operation is successful, false otherwise.
Parameters
[out]aErrorCodePlatform-dependent error code: see std::error_code.
[in]aFromPath to the original file. It must exist.
[in]aToPath to destination. This can be either a directory or a file path.
[in]aOverwriteSet this flag to true to overwrite the destimation if the file already exists.

◆ GetMedian()

double GetMedian ( const unsigned int  aSize,
double *  aVect 
)

Returns the median value of an array of doubles.

The input vector is sorted. Then the median value is returned.

Parameters
[in]aSizeArray size.
[in,out]aVectPointer to the input array. The array values are sorted after calling this function.
Precondition
The size of the input vector is expected to be non 0.

◆ GetTukeyWindow()

double * GetTukeyWindow ( const unsigned int  aSize,
const double  aAlpha 
)

Returns a Tukey window.

Parameters
[in]aSizeWindow size.
[in]aAlphaTotal fraction of the window used to transition from 0 to 1 and 1 to 0. =0: rectangle, =1: HAnn window.

◆ Glob()

vector< string > Glob ( const char *  pattern)

C utility to extract a list of files.

Returns
A list of sorted files matching a pattern.
Parameters
[in]patternFile pattern.

◆ GwlPrintVersion()

int GwlPrintVersion ( void  )

Prints the version.

This function also checks the GWOLLUM environment:

  • A temp directory must esist.
  • $GWOLLUM_DATA must point to an existing directory.
  • $GWOLLUM_PIX must point to an existing directory.
Returns
0 if the environment is correctly set.

◆ ListDirectories()

bool ListDirectories ( vector< string > &  subdir,
const string  maindir 
)

Returns a list of sub-directories.

The vector 'subdir' is filled with directories contained in 'maindir'

Note
The returned list of directories includes the main directory path.
Returns
false if the main directory does not exist.
Parameters
[out]subdirList of sub-directories.
[in]maindirPath to the main directory.

◆ MakeStereoSoundFile()

void MakeStereoSoundFile ( const string  aFileName,
const unsigned int  aN,
const unsigned int  aSamplingRate,
double *  aAmplitudeLeft,
double *  aAmplitudeRight,
const double  aScale = 1.0,
const int  aOffset = 0 
)

C utility to generate a WAV file.

Parameters
[in]aFileNameOutput .wav file name.
[in]aNNumber of samples.
[in]aSamplingRateSampling rate [Hz].
[in]aAmplitudeLeftAmplitudes for left audio.
[in]aAmplitudeRightAmplitudes for right audio.
[in]aScaleScale factor ("volume") applied to amplitudes.
[in]aOffsetOffset applied to the number of samples.
Precondition
The size of the amplitude array should match the number of samples.

◆ medianbiasfactor()

double medianbiasfactor ( const unsigned int  nn)

Returns the bias factor when computing a median with a finite number of samples.

The bias factor is (see Eq. B12 in gr-qc/0509116):

\[ \alpha = \sum_{l=1}^{n}{\frac{(-1)^{l+1}}{l}}. \]

Parameters
[in]nnNumber of samples \(n\).

◆ ReplaceAll()

string ReplaceAll ( string  str,
const string &  from,
const string &  to 
)

Replaces all occurences of a sub-string by another sub-string.

All occurences of substring 'from' are replaced by 'to'.

Returns
The modified string is returned.
Parameters
[in]strString to modify.
[in]fromSubstring to replace from.
[in]toSubstring to replace to.

◆ SplitString()

vector< string > SplitString ( const string  stringtodivide,
const char  separator = ' ' 
)

Splits a string into sub-strings.

A string is divided into an array of words. The separator defines where to break the string. The separator should be a single character.

Returns
A vector of string.
Parameters
[in]stringtodivideString to divide.
[in]separatorSeparator.

◆ StringToUpper()

string StringToUpper ( string  stringtoconvert)

Transforms a string to uppercase.

Parameters
[in]stringtoconvertString to transform.

◆ write_word()

template<typename Word >
std::ostream & write_word ( std::ostream &  outs,
Word  value,
unsigned  size = sizeof( Word ) 
)