def tsXML_to_psdXML(inxmlpath,outxmldir): """ Not too nice function for opening a TDIsignal xml file, reading the time-series' inside, calculate the PSDs for each, and then saving them in a similar xml file, but with the PSDs saved as lisaxml's TimeSeries objects. Will have to do for now. """ inxml = lisaxml.readXML(inxmlpath) sources = inxml.SourceData lisa = inxml.LISAData tdiobs = inxml.TDIData[0] inxml.close() segduration = 2*60.0**2 patches = int(tdiobs.TimeSeries.Duration/segduration) specAA = synthlisa.spect(tdiobs.A,tdiobs.TimeSeries.Cadence,patches) specEE = synthlisa.spect(tdiobs.E,tdiobs.TimeSeries.Cadence,patches) specTT = synthlisa.spect(tdiobs.T,tdiobs.TimeSeries.Cadence,patches) f = specAA[:,0] pAA = specAA[:,1] pEE = specEE[:,1] pTT = specTT[:,1] pobs = lisaxml.Observable('f,pAA,pEE,pTT',DataType = 'FractionalFrequency') pobs.TimeSeries = lisaxml.TimeSeries([f,pAA,pEE,pTT],'f,pAA,pEE,pTT') pobs.TimeSeries.Cadence = f[1] - f[0] pobs.TimeSeries.Cadence_Unit = 'Hertz' pobs.TimeSeries.TimeOffset = 0 pobs.TimeSeries.TimeOffset_Unit = 'Hertz' inxmlname = os.path.basename(inxmlpath) outxmlpath = outxmldir + re.sub('\.xml$','',inxmlname) + '-psd.xml' outxml = lisaxml.lisaXML(outxmlpath,author='J.Yu') outxml.TDIData(pobs) outxml.LISAData(lisa) for source in sources: outxml.SourceData(source) outxml.close() return
def tsXML_to_psdXML(inxmlpath, outxmldir): ''' Not too nice function for opening a TDIsignal xml file, reading the time-series' inside, calculate the PSDs for each, and then saving them in a similar xml file, but with the time-series replaced by PSDs. Will have to do for now. ''' inxml = lisaxml.readXML(inxmlpath) source = inxml.SourceData[0] lisa = inxml.LISAData tdiobs = inxml.TDIData[0] inxml.close() hr = 60.0**2 patches = int(tdiobs.TimeSeries.Duration / hr) specAA = synthlisa.spect(tdiobs.A, tdiobs.TimeSeries.Cadence, patches) specEE = synthlisa.spect(tdiobs.E, tdiobs.TimeSeries.Cadence, patches) specTT = synthlisa.spect(tdiobs.T, tdiobs.TimeSeries.Cadence, patches) f = specAA[:, 0] pAA = specAA[:, 1] pEE = specEE[:, 1] pTT = specTT[:, 1] pobs = lisaxml.Observable('f,pAA,pEE,pTT', DataType='FractionalFrequency') pobs.TimeSeries = lisaxml.TimeSeries([f, pAA, pEE, pTT], 'f,pAA,pEE,pTT') pobs.TimeSeries.Cadence = f[1] - f[0] pobs.TimeSeries.Cadence_Unit = 'Hertz' pobs.TimeSeries.TimeOffset = 0 pobs.TimeSeries.TimeOffset_Unit = 'Hertz' inxmlname = os.path.basename(inxmlpath) outxmlpath = outxmldir + re.sub('\.xml$', '', inxmlname) + '-psd.xml' outxml = lisaxml.lisaXML(outxmlpath, author='J.Yu') outxml.TDIData(pobs) outxml.LISAData(lisa) outxml.SourceData(source) outxml.close() return
def avg_psdXML_avg(day,psdlxmlpath,psdrxmlpath,psddir): xmll = lisaxml.readXML(psdlxmlpath) xmlr = lisaxml.readXML(psdrxmlpath) sources = xmll.SourceData lisa = xmll.LISAData pobsl = xmll.TDIData[0] pobsr = xmlr.TDIData[0] xmll.close() xmlr.close() pAAl, pEEl, pTTl = pobsl.pAA, pobsl.pEE, pobsl.pTT pAAr, pEEr, pTTr = pobsr.pAA, pobsr.pEE, pobsr.pTT f = pobsl.f pAA, pEE, pTT = (pAAl + pAAr)/2, (pEEl + pEEr)/2, (pTTl + pTTr)/2 pobs = lisaxml.Observable('f,pAA,pEE,pTT', DataType = 'FractionalFrequency') pobs.TimeSeries = lisaxml.TimeSeries([f,pAA,pEE,pTT],'f,pAA,pEE,pTT') pobs.TimeSeries.Cadence = pobsl.TimeSeries.Cadence pobs.TimeSeries.Cadence_Unit = pobsl.TimeSeries.Cadence_Unit pobs.TimeSeries.TimeOffset = pobsl.TimeSeries.TimeOffset pobs.TimeSeries.TimeOffset_Unit = pobsl.TimeSeries.TimeOffset_Unit psdlxmlname = os.path.basename(psdlxmlpath) psdxmlname = re.split('-',psdlxmlname,1)[0] + '-s%03d-psd.xml' % day psdxmlpath = psddir + psdxmlname psdxml = lisaxml.lisaXML(psdxmlpath,author='J.Yu') psdxml.TDIData(pobs) psdxml.LISAData(lisa) for source in sources: psdxml.SourceData(source) psdxml.close() return
def avg_psdXML_avg(day, psdlxmlpath, psdrxmlpath, psddir): xmll = lisaxml.readXML(psdlxmlpath) xmlr = lisaxml.readXML(psdrxmlpath) sources = xmll.SourceData lisa = xmll.LISAData pobsl = xmll.TDIData[0] pobsr = xmlr.TDIData[0] xmll.close() xmlr.close() pAAl, pEEl, pTTl = pobsl.pAA, pobsl.pEE, pobsl.pTT pAAr, pEEr, pTTr = pobsr.pAA, pobsr.pEE, pobsr.pTT f = pobsl.f pAA, pEE, pTT = (pAAl + pAAr) / 2, (pEEl + pEEr) / 2, (pTTl + pTTr) / 2 pobs = lisaxml.Observable('f,pAA,pEE,pTT', DataType='FractionalFrequency') pobs.TimeSeries = lisaxml.TimeSeries([f, pAA, pEE, pTT], 'f,pAA,pEE,pTT') pobs.TimeSeries.Cadence = pobsl.TimeSeries.Cadence pobs.TimeSeries.Cadence_Unit = pobsl.TimeSeries.Cadence_Unit pobs.TimeSeries.TimeOffset = pobsl.TimeSeries.TimeOffset pobs.TimeSeries.TimeOffset_Unit = pobsl.TimeSeries.TimeOffset_Unit psdlxmlname = os.path.basename(psdlxmlpath) psdxmlname = re.split('-', psdlxmlname, 1)[0] + '-s%03d-psd.xml' % day psdxmlpath = psddir + psdxmlname psdxml = lisaxml.lisaXML(psdxmlpath, author='J.Yu') psdxml.TDIData(pobs) psdxml.LISAData(lisa) for source in sources: psdxml.SourceData(source) psdxml.close() return
or newer(xmlfile, lstdifile)): prun('%s/makeTDIsignals-Galaxy3.py %s %s %s' % (execdir, xmlfile, sltdifile, lstdifile)) pwait() for xmlfile in glob.glob('Galaxy/*.xml'): sltdifile = 'TDI/' + re.sub('.xml', '-tdi-frequency.xml', os.path.basename(xmlfile)) lctdifile = 'TDI/' + re.sub('.xml', '-tdi-lisacode.xml', os.path.basename(xmlfile)) if (not makemode) or (newer(xmlfile, sltdifile) or newer(xmlfile, lstdifile)): lisaxml.lisaXML( lctdifile, author="MLDC Task Force", comments='Galaxy dataset for %s (lisacode version)' % (challengename)).close() run('%(execdir)s/mergeXML.py %(lctdifile)s %(sltdifile)s') # in challenge 3.2, the Galaxy is noise, so merge it with the instrument noise # this is a hack that should be later changed with something more systematic if 'challenge3.2' in challengename: if dosynthlisa: run('%s/mergeXML.py %s %s' % (execdir, noisefile, 'TDI/TheGalaxy-tdi-frequency.xml')) run('rm TDI/TheGalaxy-tdi-frequency.xml TDI/TheGalaxy-tdi-frequency-0.bin' ) if dolisasim:
run('ln -s %s Data/Galaxy_%s.dat' % (stream,streamseed),quiet=True) print >> open('Data/count_%s.dat' % streamseed,'w'), ("%s 0" % streamlen) if galaxywhich == 1: run('./Fast_Response %s' % streamseed) run('./Fast_XML_LS TheGalaxy Data/Sources_LS.txt') run('./Fast_XML_SL TheGalaxy Data/Sources_SL.txt') elif galaxywhich == 3: run('./Fast_Response3 %s' % streamseed) run('./Fast_XML_LS3 TheGalaxy Data/Sources_LS.txt') run('./Fast_XML_SL3 TheGalaxy Data/Sources_SL.txt') print './Fast_Response3 %s' % streamseed print './Fast_XML_LS3 TheGalaxy Data/Sources_LS.txt' print './Fast_XML_SL3 TheGalaxy Data/Sources_SL.txt' sltdiobj = lisaxml.lisaXML(sltdifile) sltdiobj.close() run('%s/mergeXML.py %s XML/TheGalaxy_synthLISA_noisefree.xml %s' % (mydir,sltdifile,galaxyfile)) lstdiobj = lisaxml.lisaXML(lstdifile) lstdiobj.close() run('%s/mergeXML.py %s XML/TheGalaxy_LISAsim_noisefree.xml %s' % (mydir,lstdifile,galaxyfile)) os.chdir(here) # ...remove the tmp dir run('rm -rf %s' % workdir,quiet=True)
LCinputXML = cname + '-input.xml' ## Merge with source data into a single lisacode input file basefile = lisaxml.readXML(LCinputXML) lisa = basefile.getLISAgeometry() sourcesLC = basefile.getLISASources() extrasecs = [] for sec in ['Simulate','LISACode','NoiseData']: if basefile.getExtraSection(sec): extrasecs.append(basefile.getExtraSection(sec)) author = "Antoine Petiteau and Michele Vallisneri" comments = basefile.Comment basefile.close() newbasefile = lisaxml.lisaXML(LCinputXML,author=author,comments=comments) for source in sourcesLC: if hasattr(source,'TimeSeries') and hasattr(source,'Polarization'): source.Polarization = 0.0 newbasefile.SourceData(source) for source in sources: if hasattr(source,'TimeSeries') and hasattr(source,'Polarization'): source.Polarization = 0.0 newbasefile.SourceData(source) if not lisa: lisa = inputsrc.getLISAgeometry() newbasefile.LISAData(lisa) for sec in extrasecs: newbasefile.ExtraSection(sec) newbasefile.close()
parser.error("You must specify an input file and an output file!") (inputfile,outputfile) = args # cycle through all the sources in the file inputXML = lisaxml.readXML(inputfile) allsystems = inputXML.getLISASources() if options.sourcename: chosensources = map(string.strip,options.sourcename.split(',')) allsystems = [x for x in allsystems if x.name in chosensources] if options.singleOutput or len(allsystems) == 1: outputXML = lisaxml.lisaXML(outputfile,author='Michele Vallisneri') for cnt,mysystem in zip(range(len(allsystems)),allsystems): # print out parameters if options.verbose: for p in mysystem.parameters: print p, ':', mysystem.parstr(p) # we are going to override IntegrationStep, if defined by the source, with # our own options.timestep. In the future it may be nice to provide for # interpolation... if ( hasattr(mysystem,'IntegrationStep') and convertUnit(mysystem.IntegrationStep,mysystem.IntegrationStep_Unit,'Second') != (options.timestep,'Second') ): print >> sys.stderr, "Overriding source IntegrationStep (%s) with our own timestep (%s s)" % (mysystem.parstr('IntegrationStep'),
parser.error("You must specify an input file and an output file!") (inputfile, outputfile) = args # cycle through all the sources in the file inputXML = lisaxml.readXML(inputfile) allsystems = inputXML.getLISASources() if options.sourcename: chosensources = map(string.strip, options.sourcename.split(',')) allsystems = [x for x in allsystems if x.name in chosensources] if options.singleOutput or len(allsystems) == 1: outputXML = lisaxml.lisaXML(outputfile, author='Michele Vallisneri') for cnt, mysystem in zip(range(len(allsystems)), allsystems): # print out parameters if options.verbose: for p in mysystem.parameters: print p, ':', mysystem.parstr(p) # we are going to override IntegrationStep, if defined by the source, with # our own options.timestep. In the future it may be nice to provide for # interpolation... if (hasattr(mysystem, 'IntegrationStep') and convertUnit(mysystem.IntegrationStep, mysystem.IntegrationStep_Unit, 'Second') !=
#print "Tend = ", Tend #print 30*"=" mysystem.InitialAzimuthalOrbitalFrequency = nu_in # initial azimuthal orbital frequecy in Hz mysystem.InitialEccentricity = e_in # initial orbital eccentricity mysystem.InitialAzimuthalOrbitalPhase = phi_in # initial azimuthal orbital phase in Rad mysystem.InitialTildeGamma = gam_in # initial position of pericenter, as angle between LxS and pericenter mysystem.InitialAlphaAngle = al_in # initial azimuthal direction of L (in the orbital plane) # save also the final parameters (Units must be given for the parameters to be written to XML) mysystem.PlungeTime = Tend ; mysystem.PlungeTime_Unit = 'Second' mysystem.FinalEccentricity = e_lso ; mysystem.FinalEccentricity_Unit = '1' mysystem.FinalTildeGamma = GammaAtPlunge; mysystem.FinalTildeGamma_Unit = 'Radian' mysystem.FinalAzimuthalOrbitalPhase = PhiAtPlunge ; mysystem.FinalAzimuthalOrbitalPhase_Unit = 'Radian' mysystem.FinalAlphaAngle = AlphaAtPlunge; mysystem.FinalAlphaAngle_Unit = 'Radian' extraparcomment = """The parameters at plunge (PlungeTime, FinalEccentricity, FinalTildeGamma, FinalAzimuthalOrbitalPhase, FinalAlphaAngle) are redundant and are provided only for convenience in checking search codes against training sets.""" if options.verbose: for p in mysystem.parameters: print p, ':', mysystem.parstr(p) # write out the XML file outputXML = lisaxml.lisaXML(outXMLfile,author='Stas Babak') outputXML.SourceData(mysystem,name=options.sourceName,comments=extraparcomment) outputXML.close()
## Extract informations from SyntheticLISA XML noise file SLinputXML = 'SLnoise.xml' SLbasefile = lisaxml.readXML(SLinputXML) SLlisa = SLbasefile.getLISAgeometry() SLsources = SLbasefile.getLISASources() SLextrasecs = [] for sec in ['Simulate', 'LISACode', 'NoiseData']: if SLbasefile.getExtraSection(sec): SLextrasecs.append(SLbasefile.getExtraSection(sec)) author = "Antoine Petiteau and Michele Vallisneri" comments = SLbasefile.Comment SLbasefile.close() LCinputXML = cname + '-input.xml' LCOutputXML = cname + '.xml' newbasefile = lisaxml.lisaXML(LCinputXML, author=author, comments=comments) newbasefile.LISAData(LClisa) for sec in LCextrasecs: newbasefile.ExtraSection(sec) for sec in SLextrasecs: newbasefile.ExtraSection(sec) newbasefile.close() if options.verbose: run('%s %s-input.xml' % (lisacode.lisacode, cname)) else: run('%s %s-input.xml > LogLC-%s' % (lisacode.lisacode, cname, cname)) ## Include informations in XML output file if detailXMLout: outputXML = lisaxml.readXML(LCOutputXML)
readgalaxy.close() galaxyfile = os.path.abspath(galaxyfile) sltdifile = os.path.abspath(sltdifile) lstdifile = os.path.abspath(lstdifile) os.chdir(workdir) run('ln -s %s Data/Galaxy_%s.dat' % (stream, streamseed), quiet=True) print >> open('Data/count_%s.dat' % streamseed, 'w'), ("%s 0" % streamlen) run('./Fast_Response %s' % streamseed) run('./Fast_XML_LS TheGalaxy Data/Sources_LS.txt') run('./Fast_XML_SL TheGalaxy Data/Sources_SL.txt') sltdiobj = lisaxml.lisaXML(sltdifile) sltdiobj.close() run('%s/bin/mergeXML.py %s XML/TheGalaxy_synthLISA_noisefree.xml %s' % (here, sltdifile, galaxyfile)) lstdiobj = lisaxml.lisaXML(lstdifile) lstdiobj.close() run('%s/bin/mergeXML.py %s XML/TheGalaxy_LISAsim_noisefree.xml %s' % (here, lstdifile, galaxyfile)) os.chdir(here) # ...remove the tmp dir
# run LISA simulator... run('./GWconverter %s' % xmlname) run('./Vertex1Signals') run('./Vertex2Signals') run('./Vertex3Signals') run('echo "%s" > sources.txt' % xmlname) run('./Package %s sources.txt 0' % xmlname) outxml = 'XML/' + xmlname + '.xml' outbin = 'XML/' + xmlname + '.bin' # create an empty XML file... sourcefileobj = lisaxml.lisaXML(here + '/' + tdifile) sourcefileobj.close() # then add the TDI data from the LISA Simulator output run('%s/bin/mergeXML.py %s %s %s' % (here,here + '/' + tdifile,here + '/Template/StandardLISA.xml',outxml)) # then add the modified Source data included in the Barycentric file run('%s/bin/mergeXML.py -k %s %s' % (here,here + '/' + tdifile,here + '/' + xmlfile)) run('rm -f %s' % outxml) run('rm -f %s' % outbin) run('rm -f %s' % xmldest) run('rm -f %s' % bindest) run('rm -f Binary/*.bin') run('rm -f Binary/GW*.dat') run('rm -f Binary/SourceParameters.dat')
(inputfile, outputfile) = args if (inputfile[-4:] != '.xml') or (outputfile[-4:] != '.xml'): parser.error("Sorry to be pedantic, but the files should end in .xml!") # make a temporary directory here = os.getcwd() workdir = os.path.abspath(tempfile.mkdtemp(dir='.')) # XML and binary filenames for the input (source or barycentric) file xmlfile = os.path.abspath(inputfile) binfile = re.sub('.xml', '-0.bin', xmlfile) # XML filename for output (TDI) file; create empty tdifile = os.path.abspath(outputfile) sourcefileobj = lisaxml.lisaXML(tdifile).close() if options.immediate: # process sources in source file, one by one copylisasim(lisasimdir, workdir) # make virtual LISAsim environment inputxml = lisaxml.readXML(xmlfile) for src in inputxml.getLISASources(): sourcefilename = workdir + '/XML/tmpsource.xml' baryfilename = workdir + '/XML/tmpbary_Barycenter.xml' sourcefile = lisaxml.lisaXML(sourcefilename) sourcefile.SourceData(src) sourcefile.close() if options.debug:
tdifile = os.path.abspath(outputfile) # make noise! os.chdir(workdir) run('./Noise_Maker %(seednoise)s') run('rm -f sources.txt; touch sources.txt',quiet=True) run('./Package noise-only sources.txt %(seednoise)s') outxml = os.path.abspath('XML/noise-only.xml') # remove temporary files run('rm -f Binary/AccNoise*.dat Binary/ShotNoise*.dat Binary/XNoise*.bin Binary/YNoise*.bin Binary/ZNoise*.bin',quiet=True) run('rm -f Binary/M1Noise*.bin Binary/M2Noise*.bin Binary/M3Noise*.bin',quiet=True) noisefileobj = lisaxml.lisaXML(tdifile) noisefileobj.close() run('%s/mergeXML.py %s %s %s' % (execdir,tdifile,execdir + '/../Template/StandardLISA.xml',outxml),quiet=True) run('rm -f XML/noise-only.xml',quiet=True) run('rm -f XML/noise-only.bin',quiet=True) run('rm -f Data/*.txt',quiet=True) os.chdir(here) # ...remove the tmp dir run('rm -rf %s' % workdir,quiet=True) sys.exit(0)
nonoisefile = 'Dataset/'+ "Training_" + sourcename + '-frequency-nonoise-training.xml' withnoisefile = 'Dataset/' + "Training_" + sourcename + '-frequency-training.xml' keyfile = 'Dataset/' + sourcename + '-key-training.xml' # nonoisetar = challengename + '-frequency-nonoise-training.tar.gz' # withnoisetar = challengename + '-frequency-training.tar.gz' else: nonoisefile = 'Dataset/' + "Blind_" + sourcename + '-frequency-nonoise.xml' withnoisefile = 'Dataset/' + "Blind_" + sourcename + '-frequency.xml' keyfile = 'Dataset/' + sourcename + '-key.xml' # nonoisetar = challengename + '-frequency-nonoise.tar.gz' # withnoisetar = challengename + '-frequency.tar.gz' # create empty files lisaxml.lisaXML(nonoisefile,\ author="MLDC Task Force",\ comments='No-noise dataset for challenge 1.3 (synthlisa version)' + globalseed).close() lisaxml.lisaXML(withnoisefile,\ author="MLDC Task Force",\ comments=sourcename+' dataset for challenge 1.3 (synthlisa version)' + globalseed).close() lisaxml.lisaXML(keyfile,\ author="MLDC Task Force",\ comments='XML key for challenge 1.3' + globalseed).close() # add signals and noise to the with-noise file if options.istraining: run('bin/mergeXML.py %(nonoisefile)s %(tdifile)s') run('bin/mergeXML.py %(withnoisefile)s %(nonoisefile)s %(noisefile)s')
if glob.glob('Galaxy/*.xml'): for xmlfile in glob.glob('Galaxy/*.xml'): sltdifile = 'TDI/' + re.sub('.xml','-tdi-frequency.xml',os.path.basename(xmlfile)) lstdifile = 'TDI/' + re.sub('.xml','-tdi-strain.xml',os.path.basename(xmlfile)) if (not makemode) or (newer(xmlfile,sltdifile) or newer(xmlfile,lstdifile)): prun('%s/makeTDIsignals-Galaxy3.py %s %s %s' % (execdir,xmlfile,sltdifile,lstdifile)) pwait() for xmlfile in glob.glob('Galaxy/*.xml'): sltdifile = 'TDI/' + re.sub('.xml','-tdi-frequency.xml',os.path.basename(xmlfile)) lctdifile = 'TDI/' + re.sub('.xml','-tdi-lisacode.xml',os.path.basename(xmlfile)) if (not makemode) or (newer(xmlfile,sltdifile) or newer(xmlfile,lstdifile)): lisaxml.lisaXML(lctdifile, author="MLDC Task Force", comments='Galaxy dataset for %s (lisacode version)' % (challengename)).close() run('%(execdir)s/mergeXML.py %(lctdifile)s %(sltdifile)s') # in challenge 3.2, the Galaxy is noise, so merge it with the instrument noise # this is a hack that should be later changed with something more systematic if 'challenge3.2' in challengename: if dosynthlisa: run('%s/mergeXML.py %s %s' % (execdir,noisefile ,'TDI/TheGalaxy-tdi-frequency.xml')) run('rm TDI/TheGalaxy-tdi-frequency.xml TDI/TheGalaxy-tdi-frequency-0.bin') if dolisasim: run('%s/mergeXML.py %s %s' % (execdir,slnoisefile,'TDI/TheGalaxy-tdi-strain.xml')) run('rm TDI/TheGalaxy-tdi-strain.xml TDI/TheGalaxy-tdi-strain-0.bin')
parser.error("You must specify the seed!") if options.PSD == None: parser.error("You must specify the PSD!") if len(args) < 1: parser.error("I need the output file!") # get the name of the output file if options.nproc == 1: outputfilenames = [args[0]] else: outputfilenames = [re.sub('.xml','',args[0]) + ('-%s.xml' % str(i)) for i in range(options.nproc)] outputfiles = [lisaxml.lisaXML(filename,author='M. Vallisneri') for filename in outputfilenames] npixels = healpix.nside2npix(2**options.refine) random.seed(options.seed) PSD = options.PSD * (1.0 + random.uniform(-options.randomizePSD,options.randomizePSD)) whichfile = 0 for i in range(npixels): mysystem = Stochastic.Stochastic(options.sourceName + ' pseudosource #%s' % i) mysystem.EclipticLatitude, mysystem.EclipticLongitude = healpix.pix2ang_ring(2**options.refine,i) mysystem.Polarization = 0
os.chdir(workdir) run('./Noise_Maker %(seednoise)s') run('rm -f sources.txt; touch sources.txt', quiet=True) run('./Package noise-only sources.txt %(seednoise)s') outxml = os.path.abspath('XML/noise-only.xml') # remove temporary files run('rm -f Binary/AccNoise*.dat Binary/ShotNoise*.dat Binary/XNoise*.bin Binary/YNoise*.bin Binary/ZNoise*.bin', quiet=True) run('rm -f Binary/M1Noise*.bin Binary/M2Noise*.bin Binary/M3Noise*.bin', quiet=True) noisefileobj = lisaxml.lisaXML(tdifile) noisefileobj.close() run('%s/mergeXML.py %s %s %s' % (execdir, tdifile, execdir + '/../Template/StandardLISA.xml', outxml), quiet=True) run('rm -f XML/noise-only.xml', quiet=True) run('rm -f XML/noise-only.bin', quiet=True) run('rm -f Data/*.txt', quiet=True) os.chdir(here) # ...remove the tmp dir run('rm -rf %s' % workdir, quiet=True) sys.exit(0)
# define physical parameters of the system mysystem.Mass1 = 1.0e6 * random.uniform(1.0, 5.0) # m1 in SolarMass mysystem.Mass2 = mysystem.Mass1 / random.uniform(1.0, 4.0) # m2 in SolarMass mysystem.CoalescenceTime = ( options.Tc + random.uniform(-options.deltaTc, options.deltaTc) ) * 24 * 3600 # coalescence time in Second (from command-line parameter) mysystem.InitialAngularOrbitalPhase = random.uniform( 0.0, 2.0 * math.pi) # initial orbital phase in Radian # integration parameters mysystem.IntegrationStep = 15.0 # integration timestep in seconds mysystem.TruncationTime = 0.0 # truncation time removed from end of waveform (in sec) mysystem.TaperApplied = 7.0 # tapering radius (total masses) if options.RequestSN: mysystem.RequestSN = options.RequestSN mysystem.RequestSN_Unit = '1' if options.verbose: for p in mysystem.parameters: print p, ':', mysystem.parstr(p) # write out the XML file outputXML = lisaxml.lisaXML(outXMLfile, author='Stas Babak') outputXML.SourceData(mysystem, name=options.sourceName) outputXML.close()
#!/usr/bin/env python import sys import lisaxml infile = sys.argv[1] outfile = sys.argv[2] inputXML = lisaxml.readXML(infile) outputXML = lisaxml.lisaXML(outfile) allsources = inputXML.getLISASources() for source in allsources: newsource = lisaxml.InteractiveMakeSource(source) outputXML.SourceData(newsource)
else: synthlisafile = basename + '-frequency.xml' noiseOnly = options.noiseOnly and '-n' or '' combinedSNR = options.combinedSNR and '-c' or '' run('%s/makeTDIsignal-synthlisa.py %s %s %s %s' % (mydir,noiseOnly,combinedSNR,barycentricfile,synthlisafile)) # make synthlisa noise if not options.nonoise: synthlisanoisefile = basename + '-noiseonly-frequency.xml' run('%s/makeTDInoise-synthlisa.py -T 62914560.0 -s %s %s' % (mydir,options.seed,synthlisanoisefile)) mergedfile = basename + '-frequency.xml' lisaxml.lisaXML(mergedfile,author = 'Michele Vallisneri',comments='quicksource SBBH file, seed = %s' % options.seed).close() run('%s/mergeXML.py %s %s %s' % (mydir,mergedfile,synthlisafile,synthlisanoisefile)) if not options.synthlisaonly: if not options.nonoise: lisasimfile = basename + '-nonoise-strain.xml' else: lisasimfile = basename + '-strain.xml' run('%s/makeTDIsignal-lisasim.py %s %s' % (mydir,barycentricfile,lisasimfile)) if not options.nonoise: lisasimnoisefile = basename + '-noiseonly-strain.xml' run('%s/makeTDInoise-lisasim.py -T 62914560.0 -n %s %s' % (mydir,options.seed,lisasimnoisefile))
sources = inputtdifile.getLISASources() tdi = inputtdifile.getTDIObservables()[0] # take author and comments, if any, from MERGED.xml author = inputtdifile.Author if not author: author = 'Michele Vallisneri (through mergeXML.py)' comments = inputtdifile.Comment inputtdifile.close() outputtdifile = lisaxml.lisaXML(outputfile, author=author, comments=comments) if lisa: outputtdifile.LISAData(lisa) if sources: for source in sources: outputtdifile.SourceData(source) # this is rough, and probably not very general... datalen = len(tdi.t) t = tdi.TimeSeries.Cadence * numpy.arange(0, datalen) Xf = numpy.zeros(datalen, 'd')
factor = ReqSN / SNR print "makeTDIsignal-synthlisa.py: satisfying RequestSN=%s by rescaling by %s" % (ReqSN,factor) ts.Arrays[0] *= factor ts.Arrays[1] *= factor if hasattr(waveforms, 'Distance'): waveforms.Distance /= factor elif hasattr(waveforms, 'Amplitude'): waveforms.Amplitude *= factor # remove the RequestSN param from the source del waveforms.RequestSN outputXML = lisaxml.lisaXML(inputfile, author='makeTDIsignal-synthlisa.py, MV/SB 20061129') outputXML.SourceData(waveforms) outputXML.close() X *= factor Y *= factor Z *= factor if options.rawMeasurements: y123 *= factor; y231 *= factor; y312 *= factor; y321 *= factor; y132 *= factor; y213 *= factor z123 *= factor; z231 *= factor; z312 *= factor; z321 *= factor; z132 *= factor; z213 *= factor tdiobs = lisaxml.Observable(obsstr) tdiobs.TimeSeries = lisaxml.TimeSeries([t,X,Y,Z],obsstr) tdiobs.DataType = 'FractionalFrequency'
except: print 'Script %s failed at command "%s".' % (sys.argv[0],commandline) sys.exit(1) # only one argument, and it's the seed... seed = int(sys.argv[1]) here = os.getcwd() os.chdir('../MLDCwaveforms/Galaxy') # compute the instrument response (takes a couple of hours) run('./Fast_Response %s' % seed) run('./Fast_XML_LS TheGalaxy Data/Sources_LS.txt') run('./Fast_XML_SL TheGalaxy Data/Sources_SL.txt') sltdiobj = lisaxml.lisaXML(here + '/TDI/Galaxy-tdi-frequency.xml') sltdiobj.close() run('%s/bin/mergeXML.py %s/TDI/Galaxy-tdi-frequency.xml XML/TheGalaxy_synthLISA_noisefree.xml %s/Galaxy/Galaxy.xml' % (here,here,here)) lstdiobj = lisaxml.lisaXML(here + '/TDI/Galaxy-tdi-strain.xml') lstdiobj.close() run('%s/bin/mergeXML.py %s/TDI/Galaxy-tdi-strain.xml XML/TheGalaxy_LISAsim_noisefree.xml %s/Galaxy/Galaxy.xml' % (here,here,here)) run('rm XML/TheGalaxy_*.xml') run('rm Binary/*.bin') run('rm Data/Sources_LS.txt') run('rm Data/Sources_SL.txt')
# run LISA simulator... run('./GWconverter %s' % xmlname) run('./Vertex1Signals') run('./Vertex2Signals') run('./Vertex3Signals') run('echo "%s" > sources.txt' % xmlname) run('./Package %s sources.txt 0' % xmlname) outxml = 'XML/' + xmlname + '.xml' outbin = 'XML/' + xmlname + '.bin' # create an empty XML file... sourcefileobj = lisaxml.lisaXML(here + '/' + tdifile) sourcefileobj.close() # then add the TDI data from the LISA Simulator output run('%s/bin/mergeXML.py %s %s %s' % (here, here + '/' + tdifile, here + '/Template/StandardLISA.xml', outxml)) # then add the modified Source data included in the Barycentric file run('%s/bin/mergeXML.py -k %s %s' % (here, here + '/' + tdifile, here + '/' + xmlfile)) run('rm -f %s' % outxml) run('rm -f %s' % outbin) run('rm -f %s' % xmldest) run('rm -f %s' % bindest)
def AngleToVector(theta,phi): return [ sin(theta)*cos(phi), sin(theta)*sin(phi), cos(theta) ] def VectorToAngle(v): theta = acos(v[2]) phi = atan2(v[1],v[0]) return (theta,phi) # begin the main code... infile = sys.argv[1] outfile = sys.argv[2] inputXML = lisaxml.readXML(infile) outputXML = lisaxml.lisaXML(outfile,comments='Updated Apr 2007 to fix timestamps and EMRI parameters, no changes to signals') outputXML.LISAData(inputXML.getLISAgeometry()) allsources = inputXML.getLISASources() for source in allsources: if hasattr(source,'xmltype') and source.xmltype == 'ExtremeMassRatioInspiral': print "---- Analyzing source %s ----" % source.name thetas = 0.5*pi - source.EclipticLatitude phis = source.EclipticLongitude pol = source.Polarization # this should be fixed lam = source.LambdaAngle
mysystem.Amplitude = options.A if options.inclination == None: mysystem.Inclination = math.acos(random.uniform(-1.0,1.0)) else: mysystem.Inclination = options.inclination if options.polarization == None: mysystem.Polarization = random.uniform(0.0,2.0*math.pi) else: mysystem.Polarization = options.polarization if options.initialPhase == None: mysystem.InitialPhase = random.uniform(0.0,2.0*math.pi) else: mysystem.InitialPhase = options.initialPhase if options.RequestSN: mysystem.RequestSN = options.RequestSN mysystem.RequestSN_Unit = '1' if options.verbose: for p in mysystem.parameters: print p, ':', mysystem.parstr(p) # write out the XML file outputXML = lisaxml.lisaXML(outXMLfile,author='M. Vallisneri') outputXML.SourceData(mysystem,name=options.sourceName) outputXML.close()
mysystem.Amplitude = options.A if options.inclination == None: mysystem.Inclination = math.acos(random.uniform(-1.0, 1.0)) else: mysystem.Inclination = options.inclination if options.polarization == None: mysystem.Polarization = random.uniform(0.0, 2.0 * math.pi) else: mysystem.Polarization = options.polarization if options.initialPhase == None: mysystem.InitialPhase = random.uniform(0.0, 2.0 * math.pi) else: mysystem.InitialPhase = options.initialPhase if options.RequestSN: mysystem.RequestSN = options.RequestSN mysystem.RequestSN_Unit = '1' if options.verbose: for p in mysystem.parameters: print p, ':', mysystem.parstr(p) # write out the XML file outputXML = lisaxml.lisaXML(outXMLfile, author='M. Vallisneri') outputXML.SourceData(mysystem, name=options.sourceName) outputXML.close()
def makedataset(simulator, dokey=True, hifreq=False): theoutputfile = 'Dataset/' + outputfile comment = '%s (%s)' % (challengename, simulator) if hifreq: theoutputfile += '-hifreq' comment += ', high-frequency version' if istraining: theoutputfile += '-training' # include seeds only if we're training comment += ', source seed = %s, noise seed = %s' % (seed, seednoise) comment += ', LISAtools SVN revision %s' % lisatoolsrevision.lisatoolsrevision merger = execdir + '/mergeXML.py' if not istraining: merger += ' --noKey' # include keys only if we're training if hifreq: # --conserveMemory is still experimental, disable it by default merger += ' --upsample' # instruct mergeXML.py to upsample for hi-freq dataset if 'challenge4.0' in challengename: merger += ' --cadence=1.875' thenoisefile = 'TDI/tdi-' + simulator + '-noise.xml' tdifiles = 'TDI/*-tdi-' + simulator + '.xml' # make the noiseless dataset noiselessdataset = theoutputfile + '-nonoise-' + simulator + '.xml' lisaxml.lisaXML(noiselessdataset, author="MLDC Task Force", comments=comment).close() if glob.glob(tdifiles): run('%s --tdiName=%s %s %s' % (merger, challengename, noiselessdataset, tdifiles)) # make the noisy dataset if donoise: noisydataset = theoutputfile + '-' + simulator + '.xml' lisaxml.lisaXML(noisydataset, author="MLDC Task Force", comments=comment).close() run('%s --tdiName=%s %s %s %s' % (merger, challengename, noisydataset, noiselessdataset, thenoisefile)) # make the key if dokey: keyfile = theoutputfile + '-key-' + simulator + '.xml' lisaxml.lisaXML(keyfile, author="MLDC Task Force", comments=comment).close() # is there something strange here with the 3.2 key, which used to be done in one step, TDI + noise? # yes, I think the point was that the source info would be only picked up from the first file? run('%s/mergeXML.py --keyOnly %s %s' % (execdir, keyfile, thenoisefile)) if glob.glob(tdifiles): run('%s/mergeXML.py --keyOnly %s %s' % (execdir, keyfile, tdifiles)) # tar up the noiseless dataset (or destroy if not training) if istraining: run('tar zcf %s %s %s Dataset/lisa-xml.*' % (re.sub('\.xml', '.tar.gz', noiselessdataset), noiselessdataset, re.sub('\.xml', '-[0-9].bin', noiselessdataset))) else: run('%s/rmXML.py %s' % (execdir, noiselessdataset)) # tar up the noisy dataset if donoise: run('tar zcf %s %s %s Dataset/lisa-xml.*' % (re.sub('\.xml', '.tar.gz', noisydataset), noisydataset, re.sub('\.xml', '-[0-9].bin', noisydataset)))
#!/usr/bin/env python __version__='$Id: $' import lisaxml from optparse import OptionParser # note that correct management of the Id string requires issuing the command # svn propset svn:keywords Id FILENAME parser = OptionParser(usage="usage: %prog [options] XMLFILES... will create empty lisaXML files", version="$Id: $") parser.add_option("-a", "--author", type="string", dest="author", default='MLDC task force', help="set author field [default: 'MLDC task force']") parser.add_option("-c", "--comment", type="string", dest="comment", default='', help="set comment [default: none]") (options, args) = parser.parse_args() if len(args) < 1: parser.error("Need at least one file to touch/reset!") for filename in args: lisaxml.lisaXML(filename,author=options.author,comments=options.comment).close()
(inputfile,outputfile) = args if (inputfile[-4:] != '.xml') or (outputfile[-4:] != '.xml'): parser.error("Sorry to be pedantic, but the files should end in .xml!") # make a temporary directory here = os.getcwd() workdir = os.path.abspath(tempfile.mkdtemp(dir='.')) # XML and binary filenames for the input (source or barycentric) file xmlfile = os.path.abspath(inputfile) binfile = re.sub('.xml','-0.bin',xmlfile) # XML filename for output (TDI) file; create empty tdifile = os.path.abspath(outputfile) sourcefileobj = lisaxml.lisaXML(tdifile).close() if options.immediate: # process sources in source file, one by one copylisasim(lisasimdir,workdir) # make virtual LISAsim environment inputxml = lisaxml.readXML(xmlfile) for src in inputxml.getLISASources(): sourcefilename = workdir + '/XML/tmpsource.xml' baryfilename = workdir + '/XML/tmpbary_Barycenter.xml' sourcefile = lisaxml.lisaXML(sourcefilename) sourcefile.SourceData(src) sourcefile.close() if options.debug: print "---> Generating barycentric file for source", src.name
__version__ = '$Id: $' import lisaxml from lisaxml.convertunit import convertUnit import sys, re import math import synthlisa if (len(sys.argv) < 2): print "missing name of xml file: usage create_quadratures.py XMLFILE" sys.exit(1) xmlInput = sys.argv[1] outputname1 = xmlInput[:-4] + "_0.xml" inputXML = lisaxml.readXML(xmlInput) mysystems = inputXML.getLISASources() inputXML.close() outputXML1 = lisaxml.lisaXML(outputname1, author='Stas Babak') Zerosystems = mysystems for system in Zerosystems: system.InitialAngularOrbitalPhase = 0.0 outputXML1.SourceData(system) outputXML1.close()
def makedataset(simulator,dokey=True,hifreq=False): theoutputfile = 'Dataset/' + outputfile comment = '%s (%s)' % (challengename,simulator) if hifreq: theoutputfile += '-hifreq' comment += ', high-frequency version' if istraining: theoutputfile += '-training' # include seeds only if we're training comment += ', source seed = %s, noise seed = %s' % (seed,seednoise) comment += ', LISAtools SVN revision %s' % lisatoolsrevision.lisatoolsrevision merger = execdir + '/mergeXML.py' if not istraining: merger += ' --noKey' # include keys only if we're training if hifreq: # --conserveMemory is still experimental, disable it by default merger += ' --upsample' # instruct mergeXML.py to upsample for hi-freq dataset if 'challenge4.0' in challengename: merger += ' --cadence=1.875' thenoisefile = 'TDI/tdi-' + simulator + '-noise.xml' tdifiles = 'TDI/*-tdi-' + simulator + '.xml' # make the noiseless dataset noiselessdataset = theoutputfile + '-nonoise-' + simulator + '.xml' lisaxml.lisaXML(noiselessdataset,author="MLDC Task Force",comments=comment).close() if glob.glob(tdifiles): run('%s --tdiName=%s %s %s' % (merger,challengename,noiselessdataset,tdifiles)) # make the noisy dataset if donoise: noisydataset = theoutputfile + '-' + simulator + '.xml' lisaxml.lisaXML(noisydataset,author="MLDC Task Force",comments=comment).close() run('%s --tdiName=%s %s %s %s' % (merger,challengename,noisydataset,noiselessdataset,thenoisefile)) # make the key if dokey: keyfile = theoutputfile + '-key-' + simulator + '.xml' lisaxml.lisaXML(keyfile,author="MLDC Task Force",comments=comment).close() # is there something strange here with the 3.2 key, which used to be done in one step, TDI + noise? # yes, I think the point was that the source info would be only picked up from the first file? run('%s/mergeXML.py --keyOnly %s %s' % (execdir,keyfile,thenoisefile)) if glob.glob(tdifiles): run('%s/mergeXML.py --keyOnly %s %s' % (execdir,keyfile,tdifiles)) # tar up the noiseless dataset (or destroy if not training) if istraining: run('tar zcf %s %s %s Dataset/lisa-xml.*' % (re.sub('\.xml','.tar.gz',noiselessdataset), noiselessdataset, re.sub('\.xml','-[0-9].bin',noiselessdataset))) else: run('%s/rmXML.py %s' % (execdir,noiselessdataset)) # tar up the noisy dataset if donoise: run('tar zcf %s %s %s Dataset/lisa-xml.*' % (re.sub('\.xml','.tar.gz',noisydataset), noisydataset, re.sub('\.xml','-[0-9].bin',noisydataset)))
import lisaxml from lisaxml.convertunit import convertUnit import sys, re import math import synthlisa if (len(sys.argv) < 2): print "missing name of xml file: usage create_quadratures.py XMLFILE" sys.exit(1) xmlInput = sys.argv[1] outputname1 = xmlInput[:-4]+"_0.xml" inputXML = lisaxml.readXML(xmlInput) mysystems = inputXML.getLISASources() inputXML.close() outputXML1 = lisaxml.lisaXML(outputname1,author='Stas Babak') Zerosystems = mysystems for system in Zerosystems: system.InitialAngularOrbitalPhase = 0.0 outputXML1.SourceData(system) outputXML1.close()
factor = ReqSN / SNR print "makeTDIsignal-synthlisa.py: satisfying RequestSN=%s by rescaling by %s" % ( ReqSN, factor) ts.Arrays[0] *= factor ts.Arrays[1] *= factor if hasattr(waveforms, 'Distance'): waveforms.Distance /= factor elif hasattr(waveforms, 'Amplitude'): waveforms.Amplitude *= factor # remove the RequestSN param from the source del waveforms.RequestSN outputXML = lisaxml.lisaXML( inputfile, author='makeTDIsignal-synthlisa.py, MV/SB 20061129') outputXML.SourceData(waveforms) outputXML.close() X *= factor Y *= factor Z *= factor if options.rawMeasurements: y123 *= factor y231 *= factor y312 *= factor y321 *= factor y132 *= factor y213 *= factor z123 *= factor
# note that correct management of the Id string requires issuing the command # svn propset svn:keywords Id FILENAME parser = OptionParser( usage="usage: %prog [options] XMLFILES... will create empty lisaXML files", version="$Id: $") parser.add_option("-a", "--author", type="string", dest="author", default='MLDC task force', help="set author field [default: 'MLDC task force']") parser.add_option("-c", "--comment", type="string", dest="comment", default='', help="set comment [default: none]") (options, args) = parser.parse_args() if len(args) < 1: parser.error("Need at least one file to touch/reset!") for filename in args: lisaxml.lisaXML(filename, author=options.author, comments=options.comment).close()
mysystem.CoalescenceTime = pars[5] mysystem.InitialAngularOrbitalPhase = pars[6] mysystem.Distance = pars[7] mysystem.Inclination = pars[8] if len(pars) > 9: print "--> Ignoring extra params %s in line \n %s" % (pars[8:],line), mysystem.IntegrationStep = 15.0 mysystem.TruncationTime = 0.0 mysystem.TaperApplied = 7.0 if options.verbose: print "--> System %s:" % srcfilenum for p in mysystem.parameters: print ' ', p, ':', mysystem.parstr(p) outputXML = lisaxml.lisaXML(outXMLroot + str(srcfilenum) + '.xml') outputXML.SourceData(mysystem,name=('BBH binary %s' % srcfilenum)) outputXML.close() srcfilenum += 1 except: if line.split(): print "--> Hm, some problems in processing line \n %s I'll drop it!" % line pass print "Successfully processed %s BBH sources" % srcfilenum
noiseOnly = options.noiseOnly and '-n' or '' combinedSNR = options.combinedSNR and '-c' or '' run('%s/makeTDIsignal-synthlisa.py %s %s %s %s' % (mydir, noiseOnly, combinedSNR, barycentricfile, synthlisafile)) # make synthlisa noise if not options.nonoise: synthlisanoisefile = basename + '-noiseonly-frequency.xml' run('%s/makeTDInoise-synthlisa.py -T 62914560.0 -s %s %s' % (mydir, options.seed, synthlisanoisefile)) mergedfile = basename + '-frequency.xml' lisaxml.lisaXML(mergedfile, author='Michele Vallisneri', comments='quicksource SBBH file, seed = %s' % options.seed).close() run('%s/mergeXML.py %s %s %s' % (mydir, mergedfile, synthlisafile, synthlisanoisefile)) if not options.synthlisaonly: if not options.nonoise: lisasimfile = basename + '-nonoise-strain.xml' else: lisasimfile = basename + '-strain.xml' run('%s/makeTDIsignal-lisasim.py %s %s' % (mydir, barycentricfile, lisasimfile)) if not options.nonoise: