(* ::Package:: *) (************************************************************************) (* This file was generated automatically by the Mathematica front end. *) (* It contains Initialization cells from a Notebook file, which *) (* typically will have the same name as this file except ending in *) (* ".nb" instead of ".m". *) (* *) (* This file is intended to be loaded into the Mathematica kernel using *) (* the package loading commands Get or Needs. Doing so is equivalent *) (* to using the Evaluate Initialization Cells menu command in the front *) (* end. *) (* *) (* DO NOT EDIT THIS FILE. This entire file is regenerated *) (* automatically each time the parent Notebook file is saved in the *) (* Mathematica front end. Any changes you make to this file will be *) (* overwritten. *) (************************************************************************) (* ::Subsubtitle:: *) (*Definitions*) lisaXML[filename_]:= Cases[Import[filename],XMLElement["XSIL",___]][[1]]/. XMLElement[head_,attrs_,content_]-> XMLElement[head,attrs,Join[content,{XMLElement["Filename",{},filename]}]]; getLISASources[lisaxml_]:=Map[ Function[src, LISASource[Join[ Cases[src,{"Name"->srcname_,___}->("Name"->srcname)], Cases[src[[3]],XMLElement["Param",{"Name"->parname_,___},{parval_}]->(parname->parval)] ]] ], Cases[lisaxml[[3]],XMLElement["XSIL",{"Type"->"SourceData",___},sources___]->sources][[1]] ]; convertNumber[x_]:=StringReplace[x,RegularExpression["([+\-0-9\.]*)[eE]([+\-0-9]*)"]->"$1*10^$2"]; LISASource[rules_][par_]:=ToExpression[convertNumber[par/.rules]]; LISASource[rules_][par_,String]:=par/.rules; LISASource/:Print[LISASource[rules_]]:=TableForm[Map[{#[[1]],#[[2]]}&,rules]]; sortTimes[srcs_]:=Sort[srcs,#1["CoalescenceTime"]<#2["CoalescenceTime"]&]; sortCentralTimes[srcs_]:=Sort[srcs,#1["CentralTime"]<#2["CentralTime"]&]; parDiff[str1_,str2_]:=str1-str2; fracDiff[str1_,str2_]:=ToString[PaddedForm[100*(str1-str2)/str2,{5,2}]]<>"%"; fracDiff[str1_,str2_,par_]:= ToString[PaddedForm[100* If[par=="EclipticLongitude", (str1-str2)/(2Pi), If[par=="EclipticLatitude" || par=="Polarization", (str1-str2)/Pi, (str1-str2)/str2] ], {5,2}]]<>"%"; LISASource/:Diff[LISASource[rules1_],LISASource[rules2_],vars_]:=TableForm[ Map[{#[[1]],#[[2]],LISASource[rules2][#[[1]],String], parDiff[LISASource[rules2][#[[1]]],ToExpression[convertNumber[#[[2]]]]], fracDiff[LISASource[rules2][#[[1]]],ToExpression[convertNumber[#[[2]]]],#[[1]]]}&, Select[rules1,MemberQ[vars,#[[1]]]&] ] ]; (* ::Input:: *) (**) (* ::Subsubtitle::Closed:: *) (*Load TDI files*) parseTDIObservable[{tdiname_,tdiobs_},file_]:=Module[{pars1,timeseries,pars2,array,dims,stream}, pars1=Cases[tdiobs,XMLElement["Param",{"Name"->parname_,___},{parval_}]->(parname->parval)]; timeseries=Cases[tdiobs,XMLElement["XSIL",{"Name"->name_,"Type"->"TimeSeries"},content___]->content][[1]]; pars2=Cases[timeseries,XMLElement["Param",{"Name"->parname_,___},{parval_}]->(parname->parval)]; array=Cases[timeseries,XMLElement["Array",{"Name"->name_,___},content___]->content][[1]]; dims=Cases[array,XMLElement["Dim",{"Name"->dimname_},{dimval_}]->(dimname->dimval)]; stream=Cases[array,XMLElement["Stream",{"Type"->type_,"Encoding"->encoding_},{filename_}]->("Stream"->{filename,type,encoding})]; TDIObservable[Join[{"Name"->tdiname},pars1,pars2,dims,stream,{file}]] ]; getTDIData[lisaxml_]:=Module[{filename,tdidata,tdiobs}, filename=Cases[lisaxml[[3]],XMLElement["Filename",{},file_]->("Filename"->file)][[1]]; tdidata=Cases[lisaxml[[3]],XMLElement["XSIL",{"Type"->"TDIData",___},content___]->content][[1]]; tdiobs=Cases[tdidata,XMLElement["XSIL",{"Name"->name_,"Type"->"TDIObservable"},content___]->{name,content}]; Map[parseTDIObservable[#,filename]&,tdiobs] ]; TDIObservable[rules_][par_]:=ToExpression[convertNumber[par]/.rules]; TDIObservable[rules_][par_,String]:=par/.rules; TDIObservable[rules_]["Data"]:=Module[{filename,type,encoding,data}, {filename,type,encoding}=TDIObservable[rules]["Stream",String]; filename=DirectoryName[TDIObservable[rules]["Filename",String]]<>filename; data=If[StringFreeQ[encoding,"BigEndian"], (* LittleEndian *) Import[filename,"Real64",ByteOrdering->-1], Import[filename,"Real64",ByteOrdering->1] ]; Transpose[Partition[data,TDIObservable[rules]["Records"]]] ]; (* ::Input:: *) (**) (* ::Input:: *) (*ch32=lisaXML["/Users/vallis/Desktop/training-3/challenge3.2-training-nonoise-frequency.xml"];*) (* ::Input:: *) (*Timing[a=tdi1["Data"];]*) (* ::Input:: *) (*ListPlot[a[[2,Range[100000]]],PlotJoined->True]*) (* ::Input:: *) (**) (* ::Subsubtitle::Closed:: *) (*Load parameter sets (SMBH)*) (* ::Input:: *) (*sol32=getLISASources[lisaXML["http://www.tapir.caltech.edu/~mldc/results3/challenge3.2-key.xml"]];*) (* ::Input:: *) (*MapThread[Set[#1,getLISASources[lisaXML[#2]]]&,*) (*{{jpl32,cam32,cam32b,gsfc32,mt32},*) (*{"http://www.tapir.caltech.edu/~mldc/results3/JPLCITNWU-3.2-090430-230756.xml",*) (*"http://www.tapir.caltech.edu/~mldc/results3/AEICamb-3.2-090430-110034.xml",*) (*"http://www.tapir.caltech.edu/~mldc/results3/CambAEI-3.2-090430-064232.xml",*) (*"http://www.tapir.caltech.edu/~mldc/results3/GSFC-3.2-090430-170214.xml",*) (*"http://www.tapir.caltech.edu/~mldc/results3/MTGWAGAPC-3.2-090430-230137.xml"}}];*) (* ::Text:: *) (*Note the last two are Galaxy entries*) (* ::Input:: *) (*sol32=sortTimes[sol32];*) (*Map[#["CoalescenceTime"]&,sol32][[Range[5]]]*) (* ::Input:: *) (*vars={"EclipticLatitude","EclipticLongitude","PolarAngleOfSpin1","PolarAngleOfSpin2","AzimuthalAngleOfSpin1","AzimuthalAngleOfSpin2","Spin1","Spin2","Mass1","Mass2","CoalescenceTime","PhaseAtCoalescence","InitialPolarAngleL","InitialAzimuthalAngleL","Distance"};*) (* ::Input:: *) (**) (* ::Subsubtitle::Closed:: *) (*Evaluate parameter errors (SMBH)*) (* ::Input:: *) (*vars={"EclipticLatitude","EclipticLongitude","Mass1","Mass2"};*) (* ::Section:: *) (*JPL*) (* ::Input:: *) (*jpl32=sortTimes[jpl32];*) (*Map[#["CoalescenceTime"]&,jpl32]*) (* ::Subsection:: *) (*MLDC 3.2.1-3.2.4 (sources sorted by CoalescenceTime)*) (* ::Input:: *) (*Do[Print[Diff[sol32[[i]],jpl32[[i]],vars]],{i,4}]*) (* ::Section:: *) (*CAM*) (* ::Input:: *) (*cam32=sortTimes[cam32];*) (*Map[#["CoalescenceTime"]&,cam32]*) (* ::Input:: *) (*Map[#["Probability"]&,cam32]*) (* ::Subsection:: *) (*MLDC 3.2.1*) (* ::Input:: *) (*Do[Print[Diff[sol32[[1]],cam32[[i]],vars]],{i,1,5}]*) (* ::Subsection:: *) (*MLDC 3.2.2*) (* ::Input:: *) (*Do[Print[Diff[sol32[[2]],cam32[[i]],vars]],{i,6,9}]*) (* ::Subsection:: *) (*MLDC 3.2.3*) (* ::Input:: *) (*Do[Print[Diff[sol32[[3]],cam32[[i]],vars]],{i,10,15}]*) (* ::Subsection:: *) (*MLDC 3.2.4*) (* ::Input:: *) (*Do[Print[Diff[sol32[[4]],cam32[[i]],vars]],{i,16,19}]*) (* ::Subsection:: *) (*MLDC 3.2.5*) (* ::Input:: *) (*Do[Print[Diff[sol32[[5]],cam32[[i]],vars]],{i,20,21}]*) (* ::Section:: *) (*CAMb*) (* ::Input:: *) (*cam32b=sortTimes[cam32b];*) (*Map[#["CoalescenceTime"]&,cam32b]*) (* ::Input:: *) (*Map[#["Probability"]&,cam32b]*) (* ::Subsection:: *) (*MLDC 3.2.1*) (* ::Input:: *) (*Do[Print[Diff[sol32[[1]],cam32b[[i]],vars]],{i,1,4}]*) (* ::Subsection:: *) (*MLDC 3.2.2*) (* ::Input:: *) (*Do[Print[Diff[sol32[[2]],cam32b[[i]],vars]],{i,5,6}]*) (* ::Subsection:: *) (*MLDC 3.2.3*) (* ::Input:: *) (*Do[Print[Diff[sol32[[3]],cam32b[[i]],vars]],{i,7,8}]*) (* ::Subsection:: *) (*MLDC 3.2.4*) (* ::Input:: *) (*Do[Print[Diff[sol32[[4]],cam32b[[i]],vars]],{i,9,10}]*) (* ::Subsection:: *) (*MLDC 3.2.5*) (* ::Input:: *) (*Do[Print[Diff[sol32[[5]],cam32b[[i]],vars]],{i,11,12}]*) (* ::Section:: *) (*GSFC*) (* ::Input:: *) (*gsfc32=sortTimes[gsfc32];*) (*Map[#["CoalescenceTime"]&,gsfc32]*) (* ::Subsection:: *) (*MLDC 3.2.1-3.2.3*) (* ::Input:: *) (*Do[Print[Diff[sol32[[i]],gsfc32[[i]],vars]],{i,1,3}]*) (* ::Section:: *) (*MT*) (* ::Input:: *) (*mt32=sortTimes[mt32];*) (*Map[#["CoalescenceTime"]&,mt32]*) (* ::Input:: *) (*Map[#["Probability"]&,mt32]*) (* ::Subsection:: *) (*MLDC 3.2.1*) (* ::Input:: *) (*Do[Print[Diff[sol32[[1]],mt32[[i]],vars]],{i,1}]*) (* ::Subsection:: *) (*MLDC 3.2.2*) (* ::Input:: *) (*Do[Print[Diff[sol32[[2]],mt32[[i]],vars]],{i,2,3}]*) (* ::Subsection:: *) (*MLDC 3.2.3-3.2.5*) (* ::Input:: *) (*Do[Print[Diff[sol32[[i-1]],mt32[[i]],vars]],{i,4,6}]*) (* ::Subsubtitle:: *) (*Load parameter sets (Cosmic Strings)*) (* ::Input:: *) (*sol34=getLISASources[lisaXML["http://www.tapir.caltech.edu/~mldc/results3/challenge3.4-key.xml"]];*) (* ::Input:: *) (*MapThread[Set[#1,getLISASources[lisaXML[#2]]]&,*) (*{{cam34,can34,jpl34,mt34},*) (*{"http://www.tapir.caltech.edu/~mldc/results3/CAM-3.4-090430-102839.xml",*) (*"http://www.tapir.caltech.edu/~mldc/results3/CaNoE-3.4-090430-172929.xml",*) (*"http://www.tapir.caltech.edu/~mldc/results3/JPLCIT-3.4-090430-225154.xml",*) (*"http://www.tapir.caltech.edu/~mldc/results3/MTGWAG-3.4-090427-135814.xml"}}];*) (* ::Text:: *) (*Note the last two are Galaxy entries*) (* ::Input:: *) (*sol34=sortCentralTimes[sol34];*) (*Map[#["CentralTime"]&,sol34]*) (* ::Input:: *) (*vars={"Name","SourceType","EclipticLatitude","EclipticLongitude","Polarization","Amplitude","CentralTime","MaximumFrequency"};*) (* ::Input:: *) (**) (* ::Subsubtitle:: *) (*Evaluate parameter errors (Cosmic Strings)*) (* ::Input:: *) (*vars={"EclipticLatitude","EclipticLongitude","Polarization","Amplitude","CentralTime"};*) (* ::Section:: *) (*CAM*) (* ::Input:: *) (*cam34=sortCentralTimes[cam34];*) (*Map[#["CentralTime"]&,cam34]*) (* ::Subsection:: *) (*MLDC 3.4.1*) (* ::Input:: *) (*Do[Print[Diff[sol34[[1]],cam34[[i]],vars]],{i,1,3}]*) (* ::Subsection:: *) (*MLDC 3.4.2*) (* ::Input:: *) (*Do[Print[Diff[sol34[[2]],cam34[[i]],vars]],{i,4,4}]*) (* ::Subsection:: *) (*MLDC 3.4.3*) (* ::Input:: *) (*Do[Print[Diff[sol34[[3]],cam34[[i]],vars]],{i,5,6}]*) (* ::Section:: *) (*CAN*) (* ::Input:: *) (*vars={"Amplitude","CentralTime"};*) (* ::Input:: *) (*can34=sortCentralTimes[can34];*) (*Map[#["CentralTime"]&,can34]*) (* ::Subsection:: *) (*MLDC 3.4.1*) (* ::Input:: *) (*Do[Print[Diff[sol34[[1]],can34[[i]],vars]],{i,1,1}]*) (* ::Subsection:: *) (*MLDC 3.4.2*) (* ::Input:: *) (*Do[Print[Diff[sol34[[2]],can34[[i]],vars]],{i,2,2}]*) (* ::Subsection:: *) (*MLDC 3.4.3*) (* ::Input:: *) (*Do[Print[Diff[sol34[[3]],can34[[i]],vars]],{i,3,3}]*) (* ::Input:: *) (*vars={"EclipticLatitude","EclipticLongitude","Polarization","Amplitude","CentralTime"};*) (* ::Section:: *) (*JPL*) (* ::Input:: *) (*jpl34=sortCentralTimes[jpl34];*) (*Map[#["CentralTime"]&,jpl34]*) (* ::Subsection:: *) (*MLDC 3.4.1*) (* ::Input:: *) (*Do[Print[Diff[sol34[[1]],jpl34[[i]],vars]],{i,1,2}]*) (* ::Subsection:: *) (*MLDC 3.4.2*) (* ::Input:: *) (*Do[Print[Diff[sol34[[2]],jpl34[[i]],vars]],{i,3,4}]*) (* ::Subsection:: *) (*MLDC 3.4.3*) (* ::Input:: *) (*Do[Print[Diff[sol34[[3]],jpl34[[i]],vars]],{i,5,6}]*) (* ::Section:: *) (*MT*) (* ::Input:: *) (*mt34=sortCentralTimes[mt34];*) (*Map[#["CentralTime"]&,mt34]*) (* ::Subsection:: *) (*MLDC 3.4.1*) (* ::Input:: *) (*Do[Print[Diff[sol34[[1]],mt34[[i]],vars]],{i,1,1}]*) (* ::Subsection:: *) (*MLDC 3.4.2*) (* ::Input:: *) (*Do[Print[Diff[sol34[[2]],mt34[[i]],vars]],{i,2,2}]*) (* ::Subsection:: *) (*MLDC 3.4.3*) (* ::Input:: *) (*Do[Print[Diff[sol34[[3]],mt34[[i]],vars]],{i,3,3}]*)