/* parse command line arguments using LALgetopt_long to get ring params */ int coh_PTF_parse_options(struct coh_PTF_params *params,int argc,char **argv ) { CHAR ifo[LIGOMETA_IFO_MAX]; UINT4 ifoNumber; static struct coh_PTF_params localparams; memset( &localparams.haveTrig, 0, LAL_NUM_IFO * sizeof(int) ); struct LALoption long_options[] = { { "verbose", no_argument, &vrbflg, 1 }, { "strain-data", no_argument, &localparams.strainData, 1 }, { "zero-data", no_argument, &localparams.zeroData, 1 }, { "theoretical-spectrum", no_argument, &localparams.whiteSpectrum, 1 }, { "write-raw-data", no_argument, &localparams.writeRawData, 1 }, { "write-data", no_argument, &localparams.writeProcessedData, 1 }, { "write-inv-spectrum", no_argument, &localparams.writeInvSpectrum, 1 }, { "write-segment", no_argument, &localparams.writeSegment, 1 }, { "write-filter-output",no_argument, &localparams.writeFilterOutput, 1 }, { "analyze-inj-segs-only",no_argument, &localparams.analyzeInjSegsOnly, 1 }, { "do-null-stream", no_argument, &localparams.doNullStream, 1 }, { "do-trace-snr", no_argument, &localparams.doTraceSNR, 1 }, { "do-bank-veto", no_argument, &localparams.doBankVeto, 1 }, { "do-auto-veto", no_argument, &localparams.doAutoVeto, 1 }, { "do-chi-square", no_argument, &localparams.doChiSquare, 1 }, { "do-sngl-chi-tests", no_argument, &localparams.doSnglChiSquared, 1}, { "do-clustering", no_argument, &localparams.clusterFlag, 1}, /* {"g1-data", no_argument, &(haveTrig[LAL_IFO_G1]), 1 },*/ {"h1-data", no_argument, &(localparams.haveTrig[LAL_IFO_H1]),1}, {"h2-data", no_argument, &(localparams.haveTrig[LAL_IFO_H2]),1}, {"l1-data", no_argument, &(localparams.haveTrig[LAL_IFO_L1]),1}, /* {"t1-data", no_argument, &(haveTrig[LAL_IFO_T1]), 1 },*/ {"v1-data", no_argument, &(localparams.haveTrig[LAL_IFO_V1]),1}, {"face-on-analysis", no_argument, &(localparams.faceOnAnalysis),1}, {"face-away-analysis", no_argument, &(localparams.faceAwayAnalysis),1}, {"dynamic-template-length",no_argument, &(localparams.dynTempLength),1}, {"store-amplitude-params",no_argument, &(localparams.storeAmpParams),1}, {"analyse-segment-end", no_argument, &(localparams.analSegmentEnd),1}, {"do-short-slides", no_argument, &(localparams.doShortSlides),1}, { "write-sngl-inspiral-table", no_argument, &(localparams.writeSnglInspiralTable),1}, { "help", no_argument, 0, 'h' }, { "version", no_argument, 0, 'V' }, { "simulated-data", required_argument, 0, '6' }, { "gps-start-time", required_argument, 0, 'a' }, { "gps-start-time-ns", required_argument, 0, 'A' }, { "gps-end-time", required_argument, 0, 'b' }, { "gps-end-time-ns", required_argument, 0, 'B' }, { "trigger-time", required_argument, 0, '<' }, { "trigger-time-ns", required_argument, 0, '>' }, { "h1-channel-name", required_argument, 0, 'c' }, { "h1-frame-cache", required_argument, 0, 'D' }, { "h2-channel-name", required_argument, 0, 'x' }, { "h2-frame-cache", required_argument, 0, 'X' }, { "l1-channel-name", required_argument, 0, 'y' }, { "l1-frame-cache", required_argument, 0, 'Y' }, { "v1-channel-name", required_argument, 0, 'z' }, { "v1-frame-cache", required_argument, 0, 'Z' }, { "low-template-freq", required_argument, 0, 'e' }, { "low-filter-freq", required_argument, 0, 'H' }, { "high-filter-freq", required_argument, 0, 'I' }, { "highpass-frequency", required_argument, 0, 'E' }, { "injection-file", required_argument, 0, 'i' }, { "snr-threshold", required_argument, 0, 'j' }, { "spin-snr-threshold", required_argument, 0, '2' }, { "sngl-snr-threshold", required_argument, 0, '1' }, { "trig-time-window", required_argument, 0, 'J' }, { "user-tag", required_argument, 0, 'k' }, { "ifo-tag", required_argument, 0, 'K' }, { "non-spin-snr2-threshold", required_argument, 0, 'l' }, { "spin-snr2-threshold", required_argument, 0, 'L' }, { "spin-bank", required_argument, 0, 'm' }, { "non-spin-bank", required_argument, 0, 'M' }, { "only-segment-numbers", required_argument, 0, 'n' }, { "only-template-numbers", required_argument, 0, 'N' }, { "output-file", required_argument, 0, 'o' }, { "bank-file", required_argument, 0, 'O' }, { "num-auto-chisq-points", required_argument, 0, 'p' }, { "auto-veto-time-step", required_argument, 0, 'P' }, { "num-chi-square-bins", required_argument, 0, 'q' }, { "chi-square-threshold", required_argument, 0, 'Q' }, { "random-seed", required_argument, 0, 'r' }, { "dynamic-range-factor", required_argument, 0, 'R' }, { "sample-rate", required_argument, 0, 's' }, { "segment-duration", required_argument, 0, 'S' }, { "psd-segment-duration", required_argument, 0, '9' }, { "bank-veto-templates", required_argument, 0, 't' }, { "inverse-spec-length", required_argument, 0, 'T' }, { "trig-start-time", required_argument, 0, 'u' }, { "trig-end-time", required_argument, 0, 'U' }, { "block-duration", required_argument, 0, 'w' }, { "pad-data", required_argument, 0, 'W' }, { "right-ascension", required_argument, 0, 'f' }, { "declination", required_argument, 0, 'F' }, { "sky-error", required_argument, 0, 'g' }, { "timing-accuracy", required_argument, 0, 'G' }, { "approximant", required_argument, 0, 'C' }, { "order", required_argument, 0, 'v' }, { "h1-slide-segment", required_argument, 0, '!' }, { "h2-slide-segment", required_argument, 0, '&' }, { "l1-slide-segment", required_argument, 0, '(' }, { "v1-slide-segment", required_argument, 0, ')' }, { "sky-positions-file", required_argument, 0, '#' }, { "fft-level", required_argument, 0, '|' }, { "cluster-window", required_argument, 0, '4' }, { "inj-search-window", required_argument, 0, '3' }, { "inj-mchirp-window", required_argument, 0, '5' }, { "ligo-calibrated-data", required_argument, 0, '7' }, { "virgo-calibrated-data", required_argument, 0, '8' }, { "short-slide-offset", required_argument, 0, '@' }, { 0, 0, 0, 0 } }; char args[] = "a:A:b:B:c:C:D:e:E:f:F:g:G:h:H:i:I:j:J:k:K:l:L:m:M:n:N:o:O:p:P:q:Q:r:R:s:S:t:T:u:U:v:V:w:W:x:X:y:Y:z:Z:1:2:3:4:5:6:7:8:9:<:>:!:&:(:):#:|:@"; char *program = argv[0]; /* set default values for parameters before parsing arguments */ coh_PTF_default_params( &localparams ); while ( 1 ) { int option_index = 0; int c; c = LALgetopt_long_only( argc, argv, args, long_options, &option_index ); if ( c == -1 ) /* end of options */ break; switch ( c ) { case 0: /* if option set a flag, nothing else to do */ if ( long_options[option_index].flag ) break; else error( "error parsing option %s with argument %s\n", long_options[option_index].name, LALoptarg ); case 'a': /* gps-start-time */ localparams.startTime.gpsSeconds = atol( LALoptarg ); break; case 'A': /* gps-start-time-ns */ localparams.startTime.gpsNanoSeconds = atol( LALoptarg ); break; case 'b': /* gps-end-time */ localparams.endTime.gpsSeconds = atol( LALoptarg ); break; case 'B': /* gps-end-time-ns */ localparams.endTime.gpsNanoSeconds = atol( LALoptarg ); break; case '<': /* trigger-time */ localparams.trigTime.gpsSeconds = atol( LALoptarg ); break; case '>': /* trigger-time-ns */ localparams.trigTime.gpsNanoSeconds = atol( LALoptarg ); break; case 'c': /* h1 channel-name */ localparams.channel[LAL_IFO_H1] = LALoptarg; break; case 'D': /* h1 frame-cache */ localparams.dataCache[LAL_IFO_H1] = LALoptarg; break; case 'y': /* l1 channel-name */ localparams.channel[LAL_IFO_L1] = LALoptarg; break; case 'Y': /* l1 frame-cache */ localparams.dataCache[LAL_IFO_L1] = LALoptarg; break; case 'z': /* v1 channel-name */ localparams.channel[LAL_IFO_V1] = LALoptarg; break; case 'Z': /* v1 frame-cache */ localparams.dataCache[LAL_IFO_V1] = LALoptarg; break; case 'x': /* h2 channel-name */ localparams.channel[LAL_IFO_H2] = LALoptarg; break; case 'X': /* h2 frame-cache */ localparams.dataCache[LAL_IFO_H2] = LALoptarg; break; case 'e': /* start frequency of template generation */ localparams.lowTemplateFrequency = atof( LALoptarg ); break; case 'H': /* start frequency of matched filter */ localparams.lowFilterFrequency = atof( LALoptarg ); break; case 'I': /* End frequency of matched filter */ localparams.highFilterFrequency = atof( LALoptarg ); break; case 'E': /* highpass-frequency */ localparams.highpassFrequency = atof( LALoptarg ); break; case 'C': /* waveform approximant */ /* This will directly fail if the approximant is not a valid one. However the user may get to a call to FindChirpTDTemplate and find out only then that the approximant is not supported in there. */ localparams.approximant = XLALSimInspiralGetApproximantFromString(LALoptarg); break; case '6': /* Simulated data option */ localparams.simData = 1; if ( ! strcmp( "WhiteNoise",LALoptarg)) { localparams.simDataType = WHITE_PSD; } else if ( ! strcmp( "ILIGONoise",LALoptarg)) { localparams.simDataType = ILIGO_PSD; } else if ( ! strcmp( "ALIGONoise",LALoptarg)) { localparams.simDataType = ALIGO_PSD; } else { fprintf( stderr, "invalid argument to --%s:\n" "unknown data type specified:" "%s valid options are WhiteNoise, ILIGONoise or ALIGONoise", long_options[option_index].name, LALoptarg ); exit(1); } break; case 'v': /* PN order of waveform */ if ( ! strcmp( "twoPN", LALoptarg ) ) { localparams.order = LAL_PNORDER_TWO; } else if ( ! strcmp( "twoPointFivePN", LALoptarg ) ) { localparams.order = LAL_PNORDER_TWO_POINT_FIVE; } else if ( ! strcmp( "threePN", LALoptarg ) ) { localparams.order = LAL_PNORDER_THREE; } else if ( ! strcmp( "threePointFivePN", LALoptarg ) ) { localparams.order = LAL_PNORDER_THREE_POINT_FIVE; } else if ( ! strcmp( "pseudoFourPN", LALoptarg ) ) { localparams.order = LAL_PNORDER_PSEUDO_FOUR; } else { fprintf( stderr, "invalid argument to --%s:\n" "unknown order specified: " "%s (must be one of twoPN, twoPointFivePN, threePN, threePointFivePN, pseudoFourPN)\n", long_options[option_index].name, LALoptarg ); exit( 1 ); } break; case 'f': /* right-ascension */ localparams.rightAscension = atof( LALoptarg ) * LAL_PI_180; break; case 'F': /* Declination */ localparams.declination = atof( LALoptarg ) * LAL_PI_180; break; case 'g': /* Error in declination */ localparams.skyError = atof( LALoptarg ) * LAL_PI_180; break; case 'G': /* timing accuracy of network */ localparams.timingAccuracy = atof( LALoptarg ); break; case 'h': /* help */ coh_PTF_usage( program ); exit( 0 ); case 'i': /* injection-file */ localparams.injectFile = LALoptarg; break; case 'j': localparams.threshold = atof(LALoptarg); break; case '2': localparams.spinThreshold = atof(LALoptarg); break; case '1': localparams.snglSNRThreshold = atof(LALoptarg); break; case 'J': localparams.timeWindow = atof(LALoptarg); break; case 'k': /* user-tag */ strncpy( localparams.userTag, LALoptarg, sizeof( localparams.userTag ) - 1 ); break; case 'K': /* ifo-tag */ strncpy( localparams.ifoTag, LALoptarg, sizeof( localparams.ifoTag ) - 1 ); break; case 'l': localparams.nonspinSNR2threshold = atof(LALoptarg); break; case 'L': localparams.spinSNR2threshold = atof(LALoptarg); break; case 'm': /* spin bank */ localparams.spinBank = 1; strncpy( localparams.spinBankName, LALoptarg, sizeof( localparams.spinBankName ) - 1 ); break; case 'M': /* non spin bank */ localparams.noSpinBank = 1; strncpy( localparams.noSpinBankName, LALoptarg, sizeof( localparams.noSpinBankName ) - 1 ); break; case 'n': /* only-segment-numbers */ localparams.segmentsToDoList = LALoptarg; break; case 'N': /* only-template-number */ localparams.templatesToDoList = LALoptarg; break; case 'o': /* output-file */ strncpy( localparams.outputFile, LALoptarg, sizeof( localparams.outputFile ) - 1 ); break; case 'O': /* bank-file */ localparams.bankFile = LALoptarg; break; case 'p': /* num auto chisq points */ localparams.numAutoPoints = atoi( LALoptarg ); break; case 'P': /* Auto veto time step */ localparams.autoVetoTimeStep = atof( LALoptarg ); break; case 'q': /* num chi square bins */ localparams.numChiSquareBins = atoi( LALoptarg ); break; case 'Q': localparams.chiSquareCalcThreshold = atof( LALoptarg ); break; case 'r': /* random seed */ localparams.randomSeed = atoi( LALoptarg ); break; case 'R': /* dynamic range factor */ localparams.dynRangeFac = atof( LALoptarg ); break; case 's': /* sample rate */ localparams.sampleRate = atof( LALoptarg ); break; case 'S': /* segment-duration */ localparams.segmentDuration = atof( LALoptarg ); break; case '9': /* PSD segment-duration */ localparams.psdSegmentDuration = atof( LALoptarg ); break; case 't': /* bank veto template bank */ localparams.bankVetoBankName = LALoptarg; break; case 'T': /* inverse-spec-length */ localparams.truncateDuration = atof( LALoptarg ); break; case 'u': /* trig-start-time */ localparams.trigStartTimeNS = (INT8) atol( LALoptarg ) * LAL_INT8_C(1000000000); break; case 'U': /* trig-end-time */ localparams.trigEndTimeNS = (INT8) atol( LALoptarg ) * LAL_INT8_C(1000000000); break; case 'w': /* block-duration */ localparams.duration = atof( LALoptarg ); break; case 'W': /* pad-data */ localparams.padData = atof( LALoptarg ); break; case '!': /* h1-slide-segment */ localparams.slideSegments[LAL_IFO_H1] = atoi( LALoptarg ); break; case '&': /* h2-slide-segments */ localparams.slideSegments[LAL_IFO_H2] = atoi( LALoptarg ); break; case '(': /* l1-slide-segments */ localparams.slideSegments[LAL_IFO_L1] = atoi( LALoptarg ); break; case ')': /* v1-slide-segments */ localparams.slideSegments[LAL_IFO_V1] = atoi( LALoptarg ); break; case '@': /* Short slide offset time */ localparams.shortSlideOffset = atoi( LALoptarg ); break; case 'V': /* version */ XLALOutputVersionString(stderr, 0); exit( 0 ); case '#': /* sky grid file */ localparams.skyPositionsFile = LALoptarg; break; case '|': /* FFT-level for plans */ localparams.fftLevel = atoi( LALoptarg ); break; case '4': /* Cluster window */ localparams.clusterWindow = atof(LALoptarg); break; case '3': /* Injection search window */ localparams.injSearchWindow = atof( LALoptarg ); break; case '5': /* Injection search window */ localparams.injMchirpWindow = atof( LALoptarg ); break; case '7': if (!strcmp("real_4", LALoptarg)) { localparams.ligoDoubleData = 0; } else if (!strcmp("real_8", LALoptarg)) { localparams.ligoDoubleData = 1; } else { fprintf(stderr, "invalid argument to --%s:\n" "unknown data type specified;\n" "%s (must be one of: real_4, real_8)\n", long_options[option_index].name, LALoptarg); } break; case '8': if (!strcmp("real_4", LALoptarg)) { localparams.virgoDoubleData = 0; } else if (!strcmp("real_8", LALoptarg)) { localparams.virgoDoubleData = 1; } else { fprintf(stderr, "invalid argument to --%s:\n" "unknown data type specified;\n" "%s (must be one of: real_4, real_8)\n", long_options[option_index].name, LALoptarg); } break; case '?': error( "unknown error while parsing options\n" ); default: error( "unknown error while parsing options\n" ); } } if ( LALoptind < argc ) { fprintf( stderr, "extraneous command line arguments:\n" ); while ( LALoptind < argc ) fprintf( stderr, "%s\n", argv[LALoptind++] ); exit( 1 ); } /* set number of ifos */ localparams.numIFO = 0; for ( ifoNumber = 0; ifoNumber < LAL_NUM_IFO; ifoNumber++ ) { if ( localparams.haveTrig[ifoNumber] ) { XLALReturnIFO(ifo,ifoNumber); snprintf( localparams.ifoName[localparams.numIFO], LIGOMETA_IFO_MAX,\ "%s", ifo ); localparams.numIFO++; } } /* check for H1H2 */ if (localparams.numIFO == 2) { if (! strcmp(localparams.ifoName[0],"H1")) { if (! strcmp(localparams.ifoName[1],"H2")) { localparams.singlePolFlag = 1; } } } /* Set the faceOn-faceAway flag */ /* Otherwise it takes default value of 0 */ if (localparams.faceOnAnalysis) { localparams.faceOnStatistic = 1; } else if (localparams.faceAwayAnalysis) { localparams.faceOnStatistic = 2; } /* Set the number of points in the time arrays */ localparams.numTimePoints = floor(\ localparams.segmentDuration * localparams.sampleRate + 0.5); /* Set the number of points in the frequency arrays */ localparams.numFreqPoints = localparams.numTimePoints / 2 + 1; /* For now we stick to only analysing half of each segment */ localparams.strideDuration = 0.5 * localparams.segmentDuration; /* FIXME: Hardcoded to 1s */ localparams.numBufferPoints = floor(localparams.sampleRate + 0.5); /* Choose the start and end point of each segment for analysis */ if (localparams.analSegmentEnd) { /* Want to analyse from the end of the segment */ /* Start from the end */ localparams.analEndPoint = localparams.numTimePoints; /* Remove the spectrum truncation */ localparams.analEndPoint -= floor(\ 0.5 * localparams.truncateDuration * localparams.sampleRate + 0.5); /* Remove the buffer points */ localparams.analEndPoint -= localparams.numBufferPoints; /* And set the start point */ localparams.analStartPoint = localparams.analEndPoint - \ 0.5*localparams.numTimePoints; } else { /* DEFAULT: Analyse the middle of the segment */ localparams.analStartPoint = 1*localparams.numTimePoints/4; localparams.analEndPoint = (3*localparams.numTimePoints)/4; } localparams.analStartTime = localparams.analStartPoint / \ localparams.sampleRate; localparams.analStartPointBuf = localparams.analStartPoint\ - localparams.numBufferPoints; localparams.analEndTime = localparams.analEndPoint / \ localparams.sampleRate; localparams.analEndPointBuf = localparams.analEndPoint\ + localparams.numBufferPoints; localparams.numAnalPoints = localparams.analEndPoint\ - localparams.analStartPoint; localparams.numAnalPointsBuf = localparams.analEndPointBuf\ - localparams.analStartPointBuf; /* Max template length is start length minus PSD truncation */ localparams.maxTempLength = localparams.analStartTime; localparams.maxTempLength -= localparams.truncateDuration/2.; /* Determine the number of short slides */ if (localparams.doShortSlides) { localparams.numShortSlides = 1 + localparams.numIFO * (int) floor( \ localparams.strideDuration / \ (localparams.shortSlideOffset * (localparams.numIFO-1)) ); } else { localparams.numShortSlides = 1; } /* Set the template correction factor */ if ( localparams.approximant == FindChirpSP) { /* Most of this gets stored in fcTmplt->fcTmpltNorm which is computed on * the fly. This is the correction needed to that. */ /* First need to add ( (df)**-7./6. )**2 */ localparams.tempCorrFac = pow(localparams.segmentDuration,14./6.); /* For some reason FindChirp multiplies by a dt factor, take this out */ localparams.tempCorrFac *= pow(localparams.sampleRate,2./6.); } else { /* Sigmasq factors are not yet available for all approximants */ /* Set values to 1 (so this factor has no effect) and warn user */ verbose("warning: Sigmasq correction factor is not yet available for this approximant: setting it to 1.\n"); localparams.tempCorrFac = 1.0; } *params = localparams; return 0; }
/* sets params to default values and parses the command line arguments */ struct params parseargs(int argc, char **argv) { int degrees = 1; int phaseO; char *inclination_string = NULL; char *phiRef_string = NULL; char *meanPerAno_string = NULL; char *longAscNodes_string = NULL; char *kv; struct params p = { .verbose = 0, .approx = XLALSimInspiralGetApproximantFromString(DEFAULT_APPROX), .condition = 0, .freq_dom = 0, .amp_phase = 0, .domain = DEFAULT_DOMAIN, .phiRef = DEFAULT_PHIREF * LAL_PI_180, .meanPerAno = DEFAULT_MEANPERANO * LAL_PI_180, .longAscNodes = DEFAULT_LONGASCNODE * LAL_PI_180, .eccentricity = DEFAULT_ECCENTRICITY, .fRef = DEFAULT_FREF, .srate = DEFAULT_SRATE, .m1 = DEFAULT_M1 * LAL_MSUN_SI, .m2 = DEFAULT_M2 * LAL_MSUN_SI, .f_min = DEFAULT_F_MIN, .distance = DEFAULT_DISTANCE * 1e6 * LAL_PC_SI, .inclination = DEFAULT_INCLINATION * LAL_PI_180, .s1x = DEFAULT_S1X, .s1y = DEFAULT_S1Y, .s1z = DEFAULT_S1Z, .s2x = DEFAULT_S2X, .s2y = DEFAULT_S2Y, .s2z = DEFAULT_S2Z, .params = NULL }; struct LALoption long_options[] = { {"help", no_argument, 0, 'h'}, {"verbose", no_argument, 0, 'v'}, {"radians", no_argument, 0, 'C'}, {"frequency-domain", no_argument, 0, 'F'}, {"condition-waveform", no_argument, 0, 'c'}, {"amp-phase", no_argument, 0, 'P'}, {"approximant", required_argument, 0, 'a'}, {"waveform", required_argument, 0, 'w'}, {"domain", required_argument, 0, 'D'}, {"phase-order", required_argument, 0, 'O'}, {"amp-order", required_argument, 0, 'o'}, {"phiRef", required_argument, 0, 'u'}, {"periastron-anomaly", required_argument, 0, 'U'}, {"longitude-ascending-node", required_argument, 0, 'W'}, {"eccentricity", required_argument, 0, 'e'}, {"fRef", required_argument, 0, 'r'}, {"sample-rate", required_argument, 0, 'R'}, {"m1", required_argument, 0, 'M'}, {"m2", required_argument, 0, 'm'}, {"spin1x", required_argument, 0, 'X'}, {"spin1y", required_argument, 0, 'Y'}, {"spin1z", required_argument, 0, 'Z'}, {"spin2x", required_argument, 0, 'x'}, {"spin2y", required_argument, 0, 'y'}, {"spin2z", required_argument, 0, 'z'}, {"tidal-lambda1", required_argument, 0, 'L'}, {"tidal-lambda2", required_argument, 0, 'l'}, {"delta-quad-mon1", required_argument, 0, 'q'}, {"delta-quad-mon2", required_argument, 0, 'Q'}, {"spin-order", required_argument, 0, 's'}, {"tidal-order", required_argument, 0, 't'}, {"f-min", required_argument, 0, 'f'}, {"f-max", required_argument, 0, 'F'}, {"distance", required_argument, 0, 'd'}, {"inclination", required_argument, 0, 'i'}, {"axis", required_argument, 0, 'A'}, {"modes", required_argument, 0, 'n'}, {"params", required_argument, 0, 'p'}, {0, 0, 0, 0} }; char args[] = "hvCFcPa:w:D:O:o:u:U:W:e:r:R:M:m:X:x:Y:y:Z:z:L:l:q:Q:s:t:f:d:i:A:n:p:"; while (1) { int option_index = 0; int c; c = LALgetopt_long_only(argc, argv, args, long_options, &option_index); if (c == -1) /* end of options */ break; switch (c) { case 0: /* if option set a flag, nothing else to do */ if (long_options[option_index].flag) break; else { fprintf(stderr, "error parsing option %s with argument %s\n", long_options[option_index].name, LALoptarg); exit(1); } case 'h': /* help */ usage(argv[0]); exit(0); case 'v': /* verbose */ p.verbose = 1; break; case 'C': /* radians */ degrees = 0; break; case 'F': /* frequency-domain */ p.freq_dom = 1; break; case 'c': /* condition-waveform */ p.condition = 1; break; case 'P': /* amp-phase */ p.amp_phase = 1; break; case 'a': /* approximant */ p.approx = XLALSimInspiralGetApproximantFromString(LALoptarg); if ((int)p.approx == XLAL_FAILURE) { fprintf(stderr, "error: invalid value %s for %s\n", LALoptarg, long_options[option_index].name); exit(1); } break; case 'w': /* waveform */ p.approx = XLALSimInspiralGetApproximantFromString(LALoptarg); if ((int)p.approx == XLAL_FAILURE) { fprintf(stderr, "error: could not parse approximant from %s for %s\n", LALoptarg, long_options[option_index].name); exit(1); } phaseO = XLALSimInspiralGetPNOrderFromString(LALoptarg); if ((int)phaseO == XLAL_FAILURE) { fprintf(stderr, "error: could not parse order from %s for %s\n", LALoptarg, long_options[option_index].name); exit(1); } if (p.params == NULL) p.params = XLALCreateDict(); XLALSimInspiralWaveformParamsInsertPNPhaseOrder(p.params, phaseO); break; case 'D': /* domain */ switch (*LALoptarg) { case 'T': case 't': p.domain = LAL_SIM_DOMAIN_TIME; break; case 'F': case 'f': p.domain = LAL_SIM_DOMAIN_FREQUENCY; break; default: fprintf(stderr, "error: invalid value %s for %s\n", LALoptarg, long_options[option_index].name); exit(1); } case 'O': /* phase-order */ if (p.params == NULL) p.params = XLALCreateDict(); XLALSimInspiralWaveformParamsInsertPNPhaseOrder(p.params, atoi(LALoptarg)); break; case 'o': /* amp-order */ if (p.params == NULL) p.params = XLALCreateDict(); XLALSimInspiralWaveformParamsInsertPNAmplitudeOrder(p.params, atoi(LALoptarg)); break; case 'u': /* phiRef */ phiRef_string = LALoptarg; break; case 'U': /* mean-periastron-anomaly */ meanPerAno_string = LALoptarg; break; case 'W': /* longitude-ascending-node */ longAscNodes_string = LALoptarg; break; case 'e': /* eccentricity */ p.eccentricity = atof(LALoptarg); break; case 'r': /* fRef */ p.fRef = atof(LALoptarg); break; case 'R': /* sample-rate */ p.srate = atof(LALoptarg); break; case 'M': /* m1 */ p.m1 = atof(LALoptarg) * LAL_MSUN_SI; break; case 'm': /* m2 */ p.m2 = atof(LALoptarg) * LAL_MSUN_SI; break; case 'X': /* spin1x */ p.s1x = atof(LALoptarg); break; case 'Y': /* spin1y */ p.s1y = atof(LALoptarg); break; case 'Z': /* spin1z */ p.s1z = atof(LALoptarg); break; case 'x': /* spin2x */ p.s2x = atof(LALoptarg); break; case 'y': /* spin2y */ p.s2y = atof(LALoptarg); break; case 'z': /* spin2z */ p.s2z = atof(LALoptarg); break; case 'L': /* tidal-lambda1 */ if (p.params == NULL) p.params = XLALCreateDict(); XLALSimInspiralWaveformParamsInsertTidalLambda1(p.params, atoi(LALoptarg)); break; case 'l': /* tidal-lambda2 */ if (p.params == NULL) p.params = XLALCreateDict(); XLALSimInspiralWaveformParamsInsertTidalLambda2(p.params, atoi(LALoptarg)); break; case 'q': /* diff-quad-mon1 */ if (p.params == NULL) p.params = XLALCreateDict(); XLALSimInspiralWaveformParamsInsertdQuadMon1(p.params, atoi(LALoptarg)); break; case 'Q': /* diff-quad-mon2 */ if (p.params == NULL) p.params = XLALCreateDict(); XLALSimInspiralWaveformParamsInsertdQuadMon2(p.params, atoi(LALoptarg)); break; case 's': /* spin-order */ if (p.params == NULL) p.params = XLALCreateDict(); XLALSimInspiralWaveformParamsInsertPNSpinOrder(p.params, atoi(LALoptarg)); break; case 't': /* tidal-order */ if (p.params == NULL) p.params = XLALCreateDict(); XLALSimInspiralWaveformParamsInsertPNTidalOrder(p.params, atoi(LALoptarg)); break; case 'f': /* f-min */ p.f_min = atof(LALoptarg); break; case 'd': /* distance */ p.distance = atof(LALoptarg) * 1e6 * LAL_PC_SI; break; case 'i': /* inclination */ inclination_string = LALoptarg; break; case 'A': /* axis */ if (p.params == NULL) p.params = XLALCreateDict(); XLALSimInspiralWaveformParamsInsertFrameAxis(p.params, XLALSimInspiralGetFrameAxisFromString(LALoptarg)); break; case 'n': /* modes */ if (p.params == NULL) p.params = XLALCreateDict(); XLALSimInspiralWaveformParamsInsertModesChoice(p.params, XLALSimInspiralGetHigherModesFromString(LALoptarg)); break; case 'p': /* params */ if (p.params == NULL) p.params = XLALCreateDict(); while ((kv = XLALStringToken(&LALoptarg, ",", 0))) { char *key = XLALStringToken(&kv, "=", 0); if (kv == NULL || key == NULL || *key == '\0') { fprintf(stderr, "error: invalid key-value pair for %s\n", long_options[option_index].name); exit(1); } XLALDictInsertREAL8Value(p.params, key, atof(kv)); } break; case '?': default: fprintf(stderr, "unknown error while parsing options\n"); exit(1); } } if (LALoptind < argc) { fprintf(stderr, "extraneous command line arguments:\n"); while (LALoptind < argc) fprintf(stderr, "%s\n", argv[LALoptind++]); exit(1); } /* set angles, converting to degrees to radians if needed */ if (phiRef_string) { p.phiRef = atof(phiRef_string); if (degrees) p.phiRef *= LAL_PI_180; } if (inclination_string) { p.inclination = atof(inclination_string); if (degrees) p.inclination *= LAL_PI_180; } if (meanPerAno_string) { p.meanPerAno = atof(meanPerAno_string); if (degrees) p.meanPerAno *= LAL_PI_180; } if (longAscNodes_string) { p.longAscNodes = atof(longAscNodes_string); if (degrees) p.longAscNodes *= LAL_PI_180; } return p; }
/* Parse command line, sanity check arguments, and return a newly * allocated GSParams object */ static GSParams *parse_args(ssize_t argc, char **argv) { ssize_t i; GSParams *params; params = (GSParams *) XLALMalloc(sizeof(GSParams)); memset(params, 0, sizeof(GSParams)); /* Set default values to the arguments */ params->waveFlags = XLALSimInspiralCreateWaveformFlags(); params->nonGRparams = NULL; params->approximant = TaylorT1; params->domain = LAL_SIM_DOMAIN_TIME; params->phaseO = 7; params->ampO = 0; params->phiRef = 0.; params->deltaT = 1./4096.; params->deltaF = 0.125; params->m1 = 10. * LAL_MSUN_SI; params->m2 = 1.4 * LAL_MSUN_SI; params->f_min = 40.; params->fRef = 0.; params->f_max = 0.; /* Generate as much as possible */ params->distance = 100. * 1e6 * LAL_PC_SI; params->inclination = 0.; params->s1x = 0.; params->s1y = 0.; params->s1z = 0.; params->s2x = 0.; params->s2y = 0.; params->s2z = 0.; params->lambda1 = 0.; params->lambda2 = 0.; strncpy(params->outname, "simulation.dat", 256); /* output to this file */ params->ampPhase = 0; /* output h+ and hx */ params->verbose = 0; /* No verbosity */ /* consume command line */ for (i = 1; i < argc; ++i) { if ((strcmp(argv[i], "-h") == 0) || (strcmp(argv[i], "--help") == 0)) { printf("%s", usage); XLALFree(params); exit(0); } else if (strcmp(argv[i], "--verbose") == 0) { params->verbose = 1; } else if (strcmp(argv[i], "--amp-phase") == 0) { params->ampPhase = 1; } else if ( ( i == argc ) || ( !argv[i+1] ) ) { XLALPrintError("Error: value required for option %s\n", argv[i]); } else if (strcmp(argv[i], "--approximant") == 0) { params->approximant = XLALSimInspiralGetApproximantFromString(argv[++i]); if ( (int) params->approximant == XLAL_FAILURE) { XLALPrintError("Error: invalid value %s for --interaction-flag\n", argv[i]); goto fail; } } else if (strcmp(argv[i], "--domain") == 0) { i++; if (strcmp(argv[i], "TD") == 0) params->domain = LAL_SIM_DOMAIN_TIME; else if (strcmp(argv[i], "FD") == 0) params->domain = LAL_SIM_DOMAIN_FREQUENCY; else { XLALPrintError("Error: Unknown domain\n"); goto fail; } } else if (strcmp(argv[i], "--phase-order") == 0) { params->phaseO = atoi(argv[++i]); } else if (strcmp(argv[i], "--amp-order") == 0) { params->ampO = atoi(argv[++i]); } else if (strcmp(argv[i], "--phiRef") == 0) { params->phiRef = atof(argv[++i]); } else if (strcmp(argv[i], "--fRef") == 0) { params->fRef = atof(argv[++i]); } else if (strcmp(argv[i], "--sample-rate") == 0) { params->deltaT = 1./atof(argv[++i]); } else if (strcmp(argv[i], "--deltaF") == 0) { params->deltaF = atof(argv[++i]); } else if (strcmp(argv[i], "--m1") == 0) { params->m1 = atof(argv[++i]) * LAL_MSUN_SI; } else if (strcmp(argv[i], "--m2") == 0) { params->m2 = atof(argv[++i]) * LAL_MSUN_SI; } else if (strcmp(argv[i], "--spin1x") == 0) { params->s1x = atof(argv[++i]); } else if (strcmp(argv[i], "--spin1y") == 0) { params->s1y = atof(argv[++i]); } else if (strcmp(argv[i], "--spin1z") == 0) { params->s1z = atof(argv[++i]); } else if (strcmp(argv[i], "--spin2x") == 0) { params->s2x = atof(argv[++i]); } else if (strcmp(argv[i], "--spin2y") == 0) { params->s2y = atof(argv[++i]); } else if (strcmp(argv[i], "--spin2z") == 0) { params->s2z = atof(argv[++i]); } else if (strcmp(argv[i], "--tidal-lambda1") == 0) { params->lambda1 = atof(argv[++i]); } else if (strcmp(argv[i], "--tidal-lambda2") == 0) { params->lambda2 = atof(argv[++i]); } else if (strcmp(argv[i], "--spin-order") == 0) { XLALSimInspiralSetSpinOrder( params->waveFlags, atoi(argv[++i]) ); } else if (strcmp(argv[i], "--tidal-order") == 0) { XLALSimInspiralSetTidalOrder( params->waveFlags, atoi(argv[++i]) ); } else if (strcmp(argv[i], "--f-min") == 0) { params->f_min = atof(argv[++i]); } else if (strcmp(argv[i], "--f-max") == 0) { params->f_max = atof(argv[++i]); } else if (strcmp(argv[i], "--distance") == 0) { params->distance = atof(argv[++i]) * 1e6 * LAL_PC_SI; } else if (strcmp(argv[i], "--inclination") == 0) { params->inclination = atof(argv[++i]); } else if (strcmp(argv[i], "--axis") == 0) { XLALSimInspiralSetFrameAxis( params->waveFlags, XLALGetFrameAxisFromString(argv[++i]) ); if ( (int) XLALSimInspiralGetFrameAxis(params->waveFlags) == (int) XLAL_FAILURE) { XLALPrintError("Error: invalid value %s for --axis\n", argv[i]); goto fail; } } else if (strcmp(argv[i], "--modes") == 0) { XLALSimInspiralSetModesChoice( params->waveFlags, XLALGetHigherModesFromString(argv[++i]) ); if ( (int) XLALSimInspiralGetModesChoice(params->waveFlags) == (int) XLAL_FAILURE) { XLALPrintError("Error: invalid value %s for --modes\n", argv[i]); goto fail; } } else if (strcmp(argv[i], "--nonGRpar") == 0) { char name[100]; strcpy(name,argv[++i]); if ( ( i == argc ) || ( !argv[i+1] ) ) { XLALPrintError("Error: 'name value' pair required for option %s\n", argv[i-1]); } else if (params->nonGRparams==NULL) { params->nonGRparams=XLALSimInspiralCreateTestGRParam(name,atof(argv[++i])); } else { XLALSimInspiralAddTestGRParam(¶ms->nonGRparams,name,atof(argv[++i])); } } else if (strcmp(argv[i], "--outname") == 0) { strncpy(params->outname, argv[++i], 256); } else { XLALPrintError("Error: invalid option: %s\n", argv[i]); goto fail; } } return params; fail: printf("%s", usage); XLALFree(params); exit(1); }