Skip to content
Snippets Groups Projects
Select Git revision
  • c190f53fae4318cf714535a81bf4eae7273728cf
  • master default
  • trunk
  • RELEASE_6_5_DRIVEDB
  • RELEASE_6_6_DRIVEDB
  • RELEASE_7_0_DRIVEDB
  • RELEASE_7_2_DRIVEDB
  • RELEASE_7_3_DRIVEDB
  • RELEASE_6_0_DRIVEDB
  • RELEASE_6_1_DRIVEDB
  • RELEASE_6_2_DRIVEDB
  • RELEASE_6_3_DRIVEDB
  • RELEASE_6_4_DRIVEDB
  • tags/RELEASE_7_4
  • tags/RELEASE_7_3
  • RELEASE_5_41_DRIVEDB
  • RELEASE_5_42_DRIVEDB
  • RELEASE_5_43_DRIVEDB
  • tags/RELEASE_7_2
  • tags/RELEASE_7_1
  • tags/RELEASE_7_0
  • RELEASE_5_40_DRIVEDB
22 results

os_linux.h

Blame
  • RDown.nb 241.51 KiB
    (* Content-type: application/vnd.wolfram.mathematica *)
    
    (*** Wolfram Notebook File ***)
    (* http://www.wolfram.com/nb *)
    
    (* CreatedBy='Mathematica 11.3' *)
    
    (*CacheID: 234*)
    (* Internal cache information:
    NotebookFileLineBreakTest
    NotebookFileLineBreakTest
    NotebookDataPosition[       158,          7]
    NotebookDataLength[    247147,       6166]
    NotebookOptionsPosition[    239606,       6043]
    NotebookOutlinePosition[    239980,       6059]
    CellTagsIndexPosition[    239937,       6056]
    WindowFrame->Normal*)
    
    (* Beginning of Notebook Content *)
    Notebook[{
    
    Cell[CellGroupData[{
    Cell["RDown Package", "Title",
     CellChangeTimes->{{3.747969475841448*^9, 3.747969478495125*^9}, 
       3.7479695552006407`*^9, {3.7999761494035053`*^9, 
       3.7999761534214697`*^9}},ExpressionUUID->"412e446d-949d-4a39-ab8f-\
    2e74aab963be"],
    
    Cell["XJ 2020", "Subtitle",
     CellChangeTimes->{{3.523020346046398*^9, 3.523020387550603*^9}, {
      3.7479695097873077`*^9, 3.747969513767797*^9}, {3.799118844355177*^9, 
      3.799118844758204*^9}},
     FontSize->18,ExpressionUUID->"03c7a68d-9296-477d-858e-f28f41a96ef7"],
    
    Cell["\<\
    Provide functions to compute Ringdown related quantities in GR:\
    \>", "Subsubtitle",
     CellChangeTimes->{{3.5230204030134068`*^9, 3.523020425030308*^9}, {
      3.5230265395509644`*^9, 3.523026547108094*^9}, {3.747969524970929*^9, 
      3.747969552823316*^9}, {3.799118855009379*^9, 
      3.799118862349341*^9}},ExpressionUUID->"1dd49449-a8ac-466f-9155-\
    195dee63ff9f"],
    
    Cell[CellGroupData[{
    
    Cell["Compute frequencies and damping times.. ", "Item",
     CellChangeTimes->{{3.522998382463629*^9, 3.5229984147045593`*^9}, {
      3.523020439792676*^9, 3.523020517729113*^9}, {3.747969559579624*^9, 
      3.7479695758881598`*^9}, {3.747969685164095*^9, 3.7479697066498737`*^9}, {
      3.799118866559821*^9, 
      3.799118871846408*^9}},ExpressionUUID->"5790c103-deb7-4616-bb6c-\
    3201fb52dcfe"],
    
    Cell["Compute RDown models.", "Item",
     CellChangeTimes->{{3.522998382463629*^9, 3.5229984147045593`*^9}, 
       3.523020439792676*^9, {3.523020524113278*^9, 3.523020543890162*^9}, {
       3.747969712073694*^9, 3.7479697210241117`*^9}, {3.799118874899969*^9, 
       3.799118881800928*^9}},ExpressionUUID->"44de3030-71f6-405b-999e-\
    75aa76f5f611"]
    }, Open  ]],
    
    Cell["still incomplete", "Text",
     CellChangeTimes->{{3.5230265802866173`*^9, 3.5230265869424953`*^9}},
     FontWeight->"Bold",ExpressionUUID->"9611da95-c63f-4174-ad5e-d05a8caf1d44"],
    
    Cell["TODO: Improve and improve", "Text",
     CellChangeTimes->{{3.525272085056192*^9, 3.52527217803032*^9}, {
      3.747969747116612*^9, 
      3.7479697512991533`*^9}},ExpressionUUID->"d61a9f74-a8b4-4661-9a96-\
    0aec3ba57e56"],
    
    Cell[CellGroupData[{
    
    Cell["Begin Package", "Section",
     CellChangeTimes->{{3.526304277369893*^9, 
      3.526304293712488*^9}},ExpressionUUID->"d1f4fc7b-0fc3-4dfa-87e1-\
    5cab3334f1ef"],
    
    Cell[BoxData[
     RowBox[{
      RowBox[{"(*", " ", 
       RowBox[{
       "Probably", " ", "not", " ", "all", " ", "the", " ", "extra", " ", 
        "packages", " ", "are", " ", "really", " ", "needed"}], " ", "*)"}], "\n", 
      RowBox[{
       RowBox[{"BeginPackage", "[", 
        RowBox[{"\"\<RDown`\>\"", ",", 
         RowBox[{"{", "\"\<HypothesisTesting`\>\"", "}"}]}], "]"}], 
       ";"}]}]], "Code",
     CellChangeTimes->{{3.526314579837529*^9, 3.526314746283765*^9}, {
       3.526314906743479*^9, 3.526314927567987*^9}, {3.5265719878947163`*^9, 
       3.526571995104267*^9}, {3.7479693011702957`*^9, 3.7479693395418663`*^9}, {
       3.751977582079381*^9, 3.7519775867970133`*^9}, {3.795343151330058*^9, 
       3.795343151662513*^9}, {3.799118908111803*^9, 3.799118912156425*^9}, {
       3.799119869643715*^9, 3.799119869915152*^9}, 3.799978302275337*^9, {
       3.803797543007461*^9, 3.803797552776443*^9}, {3.803797660099887*^9, 
       3.8037976619859037`*^9}},ExpressionUUID->"73646baf-e1d8-48be-b891-\
    b1d31c1d0092"]
    }, Open  ]],
    
    Cell[CellGroupData[{
    
    Cell["Definitions", "Section",
     CellChangeTimes->{{3.797832428103478*^9, 
      3.797832433936167*^9}},ExpressionUUID->"62bc7e4c-e5f8-44b8-8aaf-\
    b650c91c7ebe"],
    
    Cell[BoxData[{
     RowBox[{
      RowBox[{
       RowBox[{"EasyMatchT", "::", "usage"}], "=", 
       "\"\<EasyMatchT[h1_,h2_,tMin_,tMax_]. Time domain version of the match as \
    in eq. (2) of 1903.08284. tMin and tMax are the time interval where to \
    compute the match.\>\""}], ";"}], "\n", 
     RowBox[{
      RowBox[{
       RowBox[{"PlanckTaper", "::", "usage"}], "=", 
       "\"\<PlanckTaper[t,t1,t2] is the one-sided version of the tapering \
    function described in CQG27:084020, arXiv:1003.2939 [gr-qc].\>\""}], 
      ";"}], "\n", 
     RowBox[{
      RowBox[{
       RowBox[{"TimeOfMaximum", "::", "usage"}], "=", 
       "\"\<TimeOfMaximum[list_?ListQ] determines the time at which a time series \
    reaches the absolute maximum of the modulus.\>\""}], ";"}], "\n", 
     RowBox[{
      RowBox[{
       RowBox[{"GetAsymptoticMultiMode", "::", "usage"}], "=", 
       "\"\<GetAsymptoticMode[h5file_,order_,modes_list,OptionsPattern[{\\\"\
    Verbose\\\"\[Rule]False}]].\>\""}], ";"}], "\n", 
     RowBox[{
      RowBox[{
       RowBox[{"EradUIB2017", "::", "usage"}], "=", 
       "\"\<EradUIB2017[\[Eta]_,\[Chi]1_,\[Chi]2_] is fit for the energy radiated \
    of the coalescence of 2 non-precessing quasicurcular BHs as in \
    PRD:DY11536\>\""}], ";"}], "\n", 
     RowBox[{
      RowBox[{
       RowBox[{"FinalSpinUIB2017", "::", "usage"}], "=", 
       "\"\<FinalSpinUIB2017[\[Eta]_,\[Chi]1_,\[Chi]2_] is fit for the final spin \
    of the coalescence of 2 non-precessing quasicurcular BHs as in \
    PRD:DY11536\>\""}], ";"}], "\n", 
     RowBox[{
      RowBox[{
       RowBox[{"IsFPNumberQ", "::", "usage"}], "=", 
       "\"\<IsFPNumberQ[str_String] checks whether a string represents a real \
    Number.\>\""}], ";"}], "\n", 
     RowBox[{
      RowBox[{
       RowBox[{"ReadFloatingPointNumbers", "::", "usage"}], "=", 
       "\"\<ReadFloatingPointNumbers[line_String, matchAnyFP_:True] converts \
    string that contains a Fortran or C-style floating point number to a \
    Mathematica Number.\>\""}], ";"}], "\n", 
     RowBox[{
      RowBox[{
       RowBox[{"StringToNumber", "::", "usage"}], "=", 
       "\"\<StringToNumber[x_] converts a String x to a number, allowing more \
    general number formats than ToExpression.\>\""}], ";"}], "\n", 
     RowBox[{
      RowBox[{
       RowBox[{"SXSMetaFilesToRules", "::", "usage"}], "=", 
       "\"\<SXSMetaFilesToRules[filename_String] converts a SXS metadata.txt file \
    to a list of rules.\>\""}], ";"}], "\n", 
     RowBox[{
      RowBox[{
       RowBox[{"SXSParClassification", "::", "usage"}], "=", 
       "\"\<SXSParClassification[sxsdir_,ClassStr_]. Given a list of SXS NR. data \
    folders 'sxsdir', it returns all the cases that match a certain criterion \
    'ClassStr' (MassRatio range, Precessing or not, Initial Distance, Orbits \
    Number)taking as reference the SXS metadata.txt files. If it is used \
    iteratively, one could do different classifications \>\""}], ";"}], "\n", 
     RowBox[{
      RowBox[{
       RowBox[{"TakeColumn", "::", "usage"}], "=", 
       "\"\<TakeColumn[list1_?ListQ,columns]. Given a list, take the columns \
    specified by 'columns'. \>\""}], ";"}], "\n", 
     RowBox[{
      RowBox[{
       RowBox[{"ReSampleTD", "::", "usage"}], "=", 
       "\"\<ReSampleTD[data_,sample_]. Resample your data with step-size \
    'sample'.\>\""}], ";"}], "\n", 
     RowBox[{
      RowBox[{
       RowBox[{"AtomsList", "::", "usage"}], "=", 
       "\"\<AtomsList[expr_]. Split your expression in elements\>\""}], 
      ";"}], "\n", 
     RowBox[{
      RowBox[{
       RowBox[{"InterpolationDomain", "::", "usage"}], "=", 
       "\"\<InterpolationDomain[IntFunction]. Outputs the domain of your \
    interpolated function IntFunction\>\""}], ";"}], "\n", 
     RowBox[{
      RowBox[{
       RowBox[{"positionDuplicates", "::", "usage"}], "=", 
       "\"\<positionDuplicates[list_]. Finds the duplicate elements in your \
    list\>\""}], ";"}], "\n", 
     RowBox[{
      RowBox[{
       RowBox[{"\[Omega]lmn", "::", "usage"}], "=", 
       "\"\<\[Omega]lmn[l_,m_,n_,\[Eta]_,\[Chi]1_,\[Chi]2_,ModesData\[Rule]{}]. \
    It computes the lmn frequency and damping time for a BBH with parameters {\
    \[Eta],\[Chi]1,\[Chi]2}. ModesData can be feed with a datafile containing the \
    modes data, which it speeds up the computation. \>\""}], ";"}], "\n", 
     RowBox[{
      RowBox[{
       RowBox[{"DetectConvergence", "::", "usage"}], "=", 
       "\"\<DetectConvergence[dampsignal_,\[Tau]_,OptionsPattern[{Test\[Rule]\
    FindMaximum}]]. Given a damped signal and a damping time, it estimaes a time \
    t0 where the decay is order 1%\>\""}], ";"}], "\n", 
     RowBox[{
      RowBox[{
       RowBox[{"OvertoneModel", "::", "usage"}], "=", 
       "\"\<OvertoneModelV[overtones_,pars_,OptionsPattern[]]. It provides a \
    RDown ansatz for the desired number 'overtones' with parameters \
    {\[Eta],\[Chi]1,\[Chi]2}.\>\""}], ";"}], "\n", 
     RowBox[{
      RowBox[{
       RowBox[{"OvertoneModelV2", "::", "usage"}], "=", 
       "\"\<OvertoneModelV2[overtones_,pars_,ti_,OptionsPattern[]]. Upgraged \
    version of OvertoneModelV2\>\""}], ";"}], "\n", 
     RowBox[{
      RowBox[{
       RowBox[{"AICcRes", "::", "usage"}], "=", 
       "\"\<AICRes[residuals_,coeff_]. It computes the AICc value from the \
    residuals given the number of coefficients 'coeff' \>\""}], ";"}], "\n", 
     RowBox[{
      RowBox[{
       RowBox[{"BICRes", "::", "usage"}], "=", 
       "\"\<BICRes[residuals_,coeff_]. It computes the BIC value from the \
    residuals given the number of coefficients 'coeff' \>\""}], ";"}], "\n", 
     RowBox[{
      RowBox[{
       RowBox[{"PValueTest", "::", "usage"}], "=", 
       "\"\<PValueTest[residuals_,coeff_]. It computes the P value from the \
    residuals given the number of coefficients 'coeff' \>\""}], ";"}], "\n", 
     RowBox[{
      RowBox[{
       RowBox[{"CNMinimize", "::", "usage"}], "=", 
       "\"\<CNMinimize[data_,ansatz_,coeffs_,{x_,xlist_},OptionsPattern[]]. \
    Minimizator for complex data where coeffs are the free coefficients to \
    adjust, x is coordinate variable and x_list its values\>\""}], ";"}], "\n", 
     RowBox[{
      RowBox[{
       RowBox[{"Arg0DStructs", "::", "usage"}], "=", 
       "\"\<Arg0DStructs[re_,im_] and Arg0DStructs[reim_] computes the phase \
    angle of complex data. the two-argument version is significantly slower, the \
    one-argument version is just a  backwards compatibility interface to \
    UnwrappedPhase.\>\""}], ";"}], "\n", 
     RowBox[{
      RowBox[{
       RowBox[{"Abs0DStructs", "::", "usage"}], "=", 
       "\"\<Abs0DStructs[re_,im_] computes the absolute value of complex \
    data.\>\""}], ";"}], "\n", 
     RowBox[{
      RowBox[{
       RowBox[{"UnwrapPhaseVector", "::", "usage"}], "=", 
       "\"\<UnwrapPhaseVector[x_?VectorQ] unwraps the phase of a real vector \
    representing a phase angle.\>\""}], ";"}], "\n", 
     RowBox[{
      RowBox[{
       RowBox[{"UnwrapPhaseMatrix", "::", "usage"}], "=", 
       "\"\<UnwrapPhaseMatrix[x_?MatrixQ] unwraps the phase of a real time series \
    where the values represent a phase angle.\>\""}], ";"}], "\n", 
     RowBox[{
      RowBox[{
       RowBox[{"UnwrappedPhase", "::", "usage"}], "=", 
       "\"\<UnwrapPhase[x_?VectorQ] computes the unwrapped phase of a complex \
    vector representing time series values; UnwrapPhase[x_?MatrixQ] computes the \
    unwrapped phase of a complex time series.\>\""}], ";"}], "\n", 
     RowBox[{
      RowBox[{
       RowBox[{"CombineColumns", "::", "usage"}], "=", 
       "\"\<CombineColumns[list1_,list2_] combines columns from two lists in into \
    a single list, e.g. CombineColumns[{1,2,3},{4,5,6}] will yield \
    {{1,4},{2,5},{3,6}}.\>\""}], ";"}], "\n", 
     RowBox[{
      RowBox[{
       RowBox[{"fH", "::", "usage"}], "=", "\"\<fH[f,M]\>\""}], ";"}], "\n", 
     RowBox[{
      RowBox[{
       RowBox[{"fNU", "::", "usage"}], "=", "\"\<fNU[f,M]\>\""}], ";"}], "\n", 
     RowBox[{
      RowBox[{"HessianH", "::", "usage"}], "=", 
      "\"\<HessianH[f_,t_List?VectorQ]. f is the function you want to compute the \
    Hessian and t the list of parameters.\>\""}], "\n", 
     RowBox[{
      RowBox[{"CovarianceMatrix", "::", "usage"}], "=", 
      "\"\<CovarianceMatrix[res_,vars_,pars_]. It computes the convarianc:e \
    matrix from the residuals and the list of parameters.\>\""}], "\n", 
     RowBox[{
      RowBox[{"CorrelationMatrix", "::", "usage"}], "=", 
      "\"\<CovarianceMatrix[res_,vars_,pars]. It computes the correlation matrix \
    from the residuals and the list of parameters.\>\""}], "\n", 
     RowBox[{
      RowBox[{"LogLikelihoodDist", "::", "usage"}], "=", 
      "\"\<Likelihood[data_,ansatz_,vars_,x_]. It computes the \
    likelihood.\>\""}], "\n", 
     RowBox[{
      RowBox[{
       RowBox[{"ComputeFitBands", "::", "usage"}], "=", 
       "\"\<ComputeFitBands[data_,ansatz_,vars_,pars_,ConfidenceLevel\[Rule]val]. \
    It computes the fit ConfidentBands at the val confidence level.\>\""}], 
      "\n"}], "\n", 
     RowBox[{
      RowBox[{
       RowBox[{"tPhys", "::", "usage"}], "=", "\"\<tPhys[t,M]\>\""}], ";"}], "\n", 
     RowBox[{
      RowBox[{
       RowBox[{"tNR", "::", "usage"}], "=", "\"\<tNR[t,M]\>\""}], ";"}]}], "Code",\
    
     CellChangeTimes->{{3.799119367757831*^9, 3.799119370727601*^9}, {
       3.799119425119421*^9, 3.799119468059894*^9}, {3.799119540306013*^9, 
       3.7991195410743237`*^9}, {3.7991195943946466`*^9, 3.799119615858921*^9}, {
       3.7991196598152943`*^9, 3.7991196880685*^9}, {3.79911977377913*^9, 
       3.799119773989429*^9}, {3.7991199640273333`*^9, 3.799120400863236*^9}, {
       3.7991204569861593`*^9, 3.79912047055744*^9}, {3.799120536430793*^9, 
       3.799120848554914*^9}, 3.799120881845118*^9, {3.799123121037919*^9, 
       3.799123156521628*^9}, {3.7991232269158897`*^9, 3.799123284155274*^9}, {
       3.799978488566208*^9, 3.799978497181219*^9}, {3.799978607022449*^9, 
       3.799978607292985*^9}, {3.799978881613402*^9, 3.799978889625503*^9}, {
       3.7999789536495247`*^9, 3.799978955112865*^9}, {3.7999873901986847`*^9, 
       3.799987390449601*^9}, {3.8027571423730392`*^9, 3.802757209815549*^9}, {
       3.8027574185918016`*^9, 3.802757461209832*^9}, {3.8027668692062798`*^9, 
       3.8027668914442787`*^9}, {3.803266060464444*^9, 3.8032660869620733`*^9}, {
       3.803266341142159*^9, 3.803266356367859*^9}, {3.803794099154674*^9, 
       3.803794158595541*^9}},ExpressionUUID->"efab591e-4b89-4ab2-bcfe-\
    eef66d3d6303"],
    
    Cell[BoxData[
     RowBox[{"Begin", "[", "\"\<`Private`\>\"", "]"}]], "Code",
     CellChangeTimes->{{3.7991222310109053`*^9, 
      3.799122239994329*^9}},ExpressionUUID->"ee552dc2-de40-46d1-94d7-\
    658affe7b6fa"]
    }, Open  ]],
    
    Cell[CellGroupData[{
    
    Cell["Functions", "Section",
     CellChangeTimes->{{3.717145410089053*^9, 3.71714541312827*^9}, {
       3.7172172325438833`*^9, 3.71721723694738*^9}, 3.717232740150098*^9, {
       3.762577892524047*^9, 3.7625778953915577`*^9}, {3.762578513931449*^9, 
       3.76257851577108*^9}, 
       3.7625796797321777`*^9},ExpressionUUID->"ce20086e-e551-498e-b1a1-\
    dd3723b02cc4"],
    
    Cell[CellGroupData[{
    
    Cell["Match function", "Subsection",
     CellChangeTimes->{{3.7625779093082952`*^9, 3.7625779171097937`*^9}, {
      3.799119165688805*^9, 
      3.799119168368228*^9}},ExpressionUUID->"964e5ea4-c776-451f-948b-\
    bb9802afe3ef"],
    
    Cell[BoxData[{
     RowBox[{
      RowBox[{
       RowBox[{"Options", "[", "EasyMatchT", "]"}], "=", 
       RowBox[{"{", 
        RowBox[{
         RowBox[{"PadRight", "->", "7"}], ",", " ", 
         RowBox[{"Listable", "->", "True"}], ",", " ", 
         RowBox[{"FreqFormat", "->", 
          RowBox[{"{", 
           RowBox[{"\"\<Mf\>\"", ",", "\"\<Index\>\"", ",", "\"\<Index\>\""}], 
           "}"}]}], ",", 
         RowBox[{"DisableChecks", "->", "False"}]}], "}"}]}], ";"}], "\n", 
     RowBox[{
      RowBox[{
       RowBox[{"Options", "[", "EasyMatchT", "]"}], "=", 
       RowBox[{"Options", "[", "EasyMatchT", "]"}]}], ";"}], "\n", 
     RowBox[{
      RowBox[{
       RowBox[{"EasyMatchT", "[", 
        RowBox[{
         RowBox[{"h1_", "?", "ListQ"}], ",", 
         RowBox[{"h2_", "?", "ListQ"}], ",", "tMin_", ",", "tMax_", ",", 
         RowBox[{"OptionsPattern", "[", "]"}]}], "]"}], ":=", 
       RowBox[{"Module", "[", 
        RowBox[{
         RowBox[{"{", 
          RowBox[{
          "t", ",", "fHz", ",", "scale", ",", "h1red", ",", "h2red", ",", 
           "tableS", ",", "norm1", ",", "norm2", ",", "myTable", ",", "myTable2", 
           ",", "prod", ",", "psddat", ",", "fMinInd", ",", "fMaxInd", ",", 
           "dt"}], "}"}], ",", "\n", "\n", 
         RowBox[{
          RowBox[{"h1red", "=", 
           RowBox[{
            RowBox[{"Select", "[", 
             RowBox[{"h1", ",", 
              RowBox[{
               RowBox[{"tMin", "<=", 
                RowBox[{"#", "[", 
                 RowBox[{"[", "1", "]"}], "]"}], "<=", "tMax"}], "&"}]}], "]"}], 
            "[", 
            RowBox[{"[", 
             RowBox[{"All", ",", "2"}], "]"}], "]"}]}], ";", "\n", 
          RowBox[{"h2red", "=", 
           RowBox[{
            RowBox[{"Select", "[", 
             RowBox[{"h2", ",", 
              RowBox[{
               RowBox[{"tMin", "<=", 
                RowBox[{"#", "[", 
                 RowBox[{"[", "1", "]"}], "]"}], "<=", "tMax"}], "&"}]}], "]"}], 
            "[", 
            RowBox[{"[", 
             RowBox[{"All", ",", "2"}], "]"}], "]"}]}], ";", "\n", "\n", 
          RowBox[{"norm1", "=", 
           RowBox[{"Total", "[", 
            RowBox[{
             RowBox[{"(", 
              RowBox[{"Abs", "@", "h1red"}], ")"}], "^", "2"}], "]"}]}], ";", 
          "\n", 
          RowBox[{"norm2", "=", 
           RowBox[{"Total", "[", 
            RowBox[{
             RowBox[{"(", 
              RowBox[{"Abs", "@", "h2red"}], ")"}], "^", "2"}], "]"}]}], ";", 
          "\n", "\n", 
          RowBox[{"myTable", "=", 
           RowBox[{"h1red", " ", 
            RowBox[{"Conjugate", "@", "h2red"}]}]}], ";", "\n", 
          RowBox[{
           RowBox[{"Re", "@", 
            RowBox[{"Total", "[", "myTable", "]"}]}], "/", 
           RowBox[{"Sqrt", "[", 
            RowBox[{"norm1", " ", "norm2"}], "]"}]}]}]}], "\n", "]"}]}], 
      ";"}]}], "Code",
     CellChangeTimes->{{3.7991141779587927`*^9, 3.799114180293796*^9}, {
      3.799118956311602*^9, 
      3.7991189618936243`*^9}},ExpressionUUID->"acd9a80b-e291-43b4-8ff4-\
    1cf9230d8178"]
    }, Closed]],
    
    Cell[CellGroupData[{
    
    Cell["Auxiliary functions", "Subsection",
     CellChangeTimes->{{3.7625779093082952`*^9, 3.7625779171097937`*^9}, {
      3.799119165688805*^9, 
      3.799119185871924*^9}},ExpressionUUID->"356b8483-9e89-4e97-a126-\
    f1f283137492"],
    
    Cell[BoxData[
     RowBox[{
      RowBox[{"IsFPNumberQ", "[", "str_String", "]"}], ":=", 
      RowBox[{
       RowBox[{"StringMatchQ", "[", 
        RowBox[{
         RowBox[{"StringTrim", "@", "str"}], ",", 
         RowBox[{
         "RegularExpression", "[", "\"\<[+-]?\\\\d+\\\\.?\\\\d*$\>\"", "]"}]}], 
        "]"}], " ", "||", " ", "\n", "                         ", 
       RowBox[{"StringMatchQ", "[", 
        RowBox[{
         RowBox[{"StringTrim", "@", "str"}], ",", 
         RowBox[{
         "RegularExpression", "[", 
          "\"\<[-+]?\\\\d*\\\\.\\\\d+([eE][-+]?\\\\d+)?\>\"", "]"}]}], 
        "]"}]}]}]], "Code",
     CellLabel->"In[81]:=",ExpressionUUID->"1d7c374f-07e5-4e30-96cb-5384d03c28d7"],
    
    Cell[BoxData[
     RowBox[{
      RowBox[{
       RowBox[{"TimeOfMaximum", "[", 
        RowBox[{
         RowBox[{"list_", "?", "ListQ"}], ",", 
         RowBox[{"OptionsPattern", "[", 
          RowBox[{"{", 
           RowBox[{"\"\<MinTime\>\"", "->", "\"\<\>\""}], "}"}], "]"}]}], "]"}], ":=", 
       RowBox[{"Module", "[", 
        RowBox[{
         RowBox[{"{", 
          RowBox[{
          "reducedList", ",", "vals", ",", "maxval", ",", "maxpos", ",", 
           "mintime"}], "}"}], ",", "\n", "\n", 
         RowBox[{
          RowBox[{"mintime", "=", 
           RowBox[{"OptionValue", "[", "\"\<MinTime\>\"", "]"}]}], ";", "\n", 
          "\n", 
          RowBox[{"If", "[", 
           RowBox[{
            RowBox[{"NumberQ", "@", "mintime"}], ",", "\n", " ", 
            RowBox[{
             RowBox[{"reducedList", "=", 
              RowBox[{"Select", "[", 
               RowBox[{"list", ",", 
                RowBox[{
                 RowBox[{
                  RowBox[{"#", "[", 
                   RowBox[{"[", "1", "]"}], "]"}], ">=", " ", "mintime"}], 
                 "&"}]}], "]"}]}], ";"}], ",", "\n", " ", 
            RowBox[{
             RowBox[{"reducedList", "=", "list"}], ";"}]}], "\n", "]"}], ";", 
          "\n", "\n", 
          RowBox[{"vals", "=", 
           RowBox[{"Abs", "@", 
            RowBox[{"TakeColumn", "[", 
             RowBox[{"reducedList", ",", "2"}], "]"}]}]}], ";", "\n", 
          RowBox[{"maxval", "=", 
           RowBox[{"Max", "@", "vals"}]}], ";", "\n", "\n", 
          RowBox[{"If", "[", 
           RowBox[{
            RowBox[{
             RowBox[{"Length", "@", 
              RowBox[{"Union", "@", "vals"}]}], ">", "1"}], ",", "\n", 
            RowBox[{
             RowBox[{"maxpos", "=", 
              RowBox[{"First", "@", 
               RowBox[{"First", "@", 
                RowBox[{"Position", "[", 
                 RowBox[{"vals", ",", "maxval"}], "]"}]}]}]}], ";", "\n", 
             RowBox[{"First", "[", 
              RowBox[{"reducedList", "[", 
               RowBox[{"[", "maxpos", "]"}], "]"}], "]"}]}], ",", "\n", 
            "\"\<NOMAX\>\""}], "]"}]}]}], "\n", "]"}]}], ";"}]], "Code",
     CellLabel->"In[82]:=",ExpressionUUID->"44421514-cbe3-43d9-a22a-ae2f79f87679"],
    
    Cell[BoxData[{
     RowBox[{
      RowBox[{
       RowBox[{"PlanckTaper", "[", 
        RowBox[{
         RowBox[{"t_", "?", "VectorQ"}], ",", "t1_", ",", "t2_"}], "]"}], ":=", 
       RowBox[{"Module", "[", 
        RowBox[{
         RowBox[{"{", 
          RowBox[{"tmid", "=", 
           RowBox[{"Select", "[", 
            RowBox[{"t", ",", 
             RowBox[{
              RowBox[{"t1", "<", "#", "<", "t2"}], "&"}]}], "]"}]}], "}"}], ",", 
         RowBox[{"Join", "[", "\[IndentingNewLine]", 
          RowBox[{
           RowBox[{"ConstantArray", "[", 
            RowBox[{"0", ",", 
             RowBox[{"Length", "@", 
              RowBox[{"Select", "[", 
               RowBox[{"t", ",", 
                RowBox[{
                 RowBox[{"#", "\[LessEqual]", "t1"}], "&"}]}], "]"}]}]}], "]"}], 
           ",", "\[IndentingNewLine]", 
           RowBox[{"1", "/", 
            RowBox[{"(", 
             RowBox[{
              RowBox[{"Exp", "[", 
               RowBox[{
                RowBox[{
                 RowBox[{"(", 
                  RowBox[{"t2", "-", "t1"}], ")"}], "/", 
                 RowBox[{"(", 
                  RowBox[{"tmid", "-", "t1"}], ")"}]}], "+", 
                RowBox[{
                 RowBox[{"(", 
                  RowBox[{"t2", "-", "t1"}], ")"}], "/", 
                 RowBox[{"(", 
                  RowBox[{"tmid", "-", "t2"}], ")"}]}]}], "]"}], "+", "1"}], 
             ")"}]}], ",", "\[IndentingNewLine]", 
           RowBox[{"ConstantArray", "[", 
            RowBox[{"1", ",", 
             RowBox[{"Length", "@", 
              RowBox[{"Select", "[", 
               RowBox[{"t", ",", 
                RowBox[{
                 RowBox[{"#", "\[GreaterEqual]", "t2"}], "&"}]}], "]"}]}]}], 
            "]"}]}], "\[IndentingNewLine]", "]"}]}], "]"}]}], 
      ";"}], "\[IndentingNewLine]", 
     RowBox[{
      RowBox[{
       RowBox[{"PlanckTaper", "[", 
        RowBox[{
         RowBox[{"t_", "?", "NumberQ"}], ",", "t1_", ",", "t2_"}], "]"}], ":=", 
       "\[IndentingNewLine]", 
       RowBox[{"Piecewise", "[", 
        RowBox[{"{", 
         RowBox[{
          RowBox[{"{", 
           RowBox[{"0", ",", 
            RowBox[{"t", "\[LessEqual]", "t1"}]}], "}"}], ",", 
          "\[IndentingNewLine]", 
          RowBox[{"{", 
           RowBox[{
            RowBox[{"1", "/", 
             RowBox[{"(", 
              RowBox[{
               RowBox[{"Exp", "[", 
                RowBox[{
                 RowBox[{
                  RowBox[{"(", 
                   RowBox[{"t2", "-", "t1"}], ")"}], "/", 
                  RowBox[{"(", 
                   RowBox[{"t", "-", "t1"}], ")"}]}], "+", 
                 RowBox[{
                  RowBox[{"(", 
                   RowBox[{"t2", "-", "t1"}], ")"}], "/", 
                  RowBox[{"(", 
                   RowBox[{"t", "-", "t2"}], ")"}]}]}], "]"}], "+", "1"}], 
              ")"}]}], ",", 
            RowBox[{"t1", "<", "t", "<", "t2"}]}], "}"}], ",", 
          "\[IndentingNewLine]", 
          RowBox[{"{", 
           RowBox[{"1", ",", 
            RowBox[{"t", "\[GreaterEqual]", " ", "t2"}]}], "}"}]}], 
         "\[IndentingNewLine]", "}"}], "]"}]}], ";"}]}], "Code",
     CellChangeTimes->{{3.509442978376423*^9, 3.509443097806379*^9}},
     CellLabel->"In[73]:=",ExpressionUUID->"2c5ed9b6-4222-400a-b38f-6974d610d5ff"],
    
    Cell[BoxData[
     RowBox[{
      RowBox[{"StringToNumber", "[", "y_", "]"}], ":=", 
      RowBox[{"Module", "[", 
       RowBox[{
        RowBox[{"{", 
         RowBox[{"temp", ",", "x"}], "}"}], ",", "\n", "\n", 
        RowBox[{
         RowBox[{"x", " ", "=", " ", 
          RowBox[{"ToString", "@", "y"}]}], ";", "\n", "\n", 
         RowBox[{"temp", " ", "=", " ", 
          RowBox[{"StringReplace", "[", 
           RowBox[{"x", ",", 
            RowBox[{"\"\< \>\"", "->", "\"\<\>\""}]}], "]"}]}], ";", "\n", "\n", 
         RowBox[{"If", "[", 
          RowBox[{
           RowBox[{"StringMatchQ", "[", 
            RowBox[{"temp", ",", "NumberString"}], "]"}], ",", "\n", "  ", 
           RowBox[{"ToExpression", "@", "temp"}], ",", "\n", "  ", 
           RowBox[{
            RowBox[{"temp", " ", "=", " ", 
             RowBox[{"ReadFloatingPointNumbers", "[", "temp", "]"}]}], ";", " ", 
            "\n", "  ", 
            RowBox[{"If", "[", 
             RowBox[{
              RowBox[{
               RowBox[{"ListQ", "@", "temp"}], " ", "&&", " ", 
               RowBox[{
                RowBox[{"Length", "@", "temp"}], " ", ">", " ", "0"}]}], ",", 
              "\n", "    ", 
              RowBox[{"First", "@", "temp"}], ",", "\n", "    ", 
              "Indeterminate"}], "\n", "  ", "]"}]}]}], "]"}]}]}], "\n", 
       "]"}]}]], "Code",
     CellLabel->"In[83]:=",ExpressionUUID->"4d6816fc-0043-4b06-b78b-bf0c073e819b"],
    
    Cell[BoxData[
     RowBox[{
      RowBox[{
       RowBox[{"ReadFloatingPointNumbers", "[", 
        RowBox[{"lineIn_String", ",", 
         RowBox[{"matchAnyFP_:", "True"}]}], "]"}], ":=", 
       RowBox[{"Module", "[", 
        RowBox[{
         RowBox[{"{", 
          RowBox[{"line", ",", "fpregex", ",", "simpleHackRule", ",", "temp"}], 
          "}"}], ",", "\n", 
         RowBox[{
          RowBox[{"temp", "=", 
           RowBox[{"Map", "[", 
            RowBox[{"ToString", ",", 
             RowBox[{"Range", "[", 
              RowBox[{"0", ",", "9"}], "]"}]}], "]"}]}], ";", "\n", "\n", 
          RowBox[{"simpleHackRule", "=", 
           RowBox[{"temp", "/.", 
            RowBox[{
             RowBox[{"xx_", "/;", 
              RowBox[{"StringQ", "@", "xx"}]}], ":>", 
             RowBox[{"xx", "->", 
              RowBox[{"xx", "<>", "\"\<.0\>\""}]}]}]}]}], ";", "\n", 
          RowBox[{"line", "=", 
           RowBox[{"lineIn", "/.", "simpleHackRule"}]}], ";", "\n", "\n", 
          RowBox[{"simpleHackRule", "=", 
           RowBox[{"temp", "/.", 
            RowBox[{
             RowBox[{"xx_", "/;", 
              RowBox[{"StringQ", "@", "xx"}]}], ":>", 
             RowBox[{
              RowBox[{"xx", "<>", "\"\<.\>\""}], "->", 
              RowBox[{"xx", "<>", "\"\<.0\>\""}]}]}]}]}], ";", "\n", 
          RowBox[{"line", "=", 
           RowBox[{"line", "/.", "simpleHackRule"}]}], ";", "\n", "\n", 
          RowBox[{"If", "[", 
           RowBox[{"matchAnyFP", ",", 
            RowBox[{
             RowBox[{
             "fpregex", "=", "\"\<[-+]?\\\\d*\\\\.\\\\d+([eE][-+]?\\\\d+)?\>\""}],
              ";"}], 
            RowBox[{"(*", 
             RowBox[{
             "matches", " ", "any", " ", "floating", " ", "point", " ", 
              "number"}], "*)"}], ",", 
            RowBox[{
             RowBox[{
             "fpregex", "=", "\"\<[-+]?\\\\d*\\\\.?\\\\d+[eE][-+]?\\\\d+\>\""}], 
             ";"}]}], 
           RowBox[{"(*", 
            RowBox[{
            "matches", " ", "only", " ", "floating", " ", "point", " ", "numbers",
              " ", "in", " ", "exponential", " ", "format"}], "*)"}], "]"}], ";", 
          "\n", 
          RowBox[{"Map", "[", 
           RowBox[{
            RowBox[{
             RowBox[{"Read", "[", 
              RowBox[{
               RowBox[{"StringToStream", "[", "#", "]"}], ",", "Number"}], "]"}], 
             "&"}], ",", 
            RowBox[{"StringCases", "[", 
             RowBox[{"line", ",", 
              RowBox[{"RegularExpression", "[", "fpregex", "]"}]}], "]"}]}], 
           "]"}]}]}], "\n", "]"}]}], ";"}]], "Code",
     CellLabel->"In[84]:=",ExpressionUUID->"eb6e4d3b-ad4a-48e6-bb7d-c0810255f29d"],
    
    Cell[BoxData[
     RowBox[{
      RowBox[{"ReSampleTD", "[", 
       RowBox[{"data_", ",", "sample_"}], "]"}], ":=", 
      RowBox[{"Module", "[", 
       RowBox[{
        RowBox[{"{", 
         RowBox[{"dataInt", ",", "domain", ",", "times"}], "}"}], ",", "\n", "\n", 
        RowBox[{
         RowBox[{"dataInt", "=", 
          RowBox[{"Interpolation", "@", "data"}]}], ";", "\n", 
         RowBox[{"domain", "=", 
          RowBox[{"InterpolationDomain", "@", "dataInt"}]}], ";", "\n", 
         RowBox[{"times", "=", 
          RowBox[{"Range", "[", 
           RowBox[{
            RowBox[{"domain", "[", 
             RowBox[{"[", 
              RowBox[{"1", ",", "1"}], "]"}], "]"}], ",", 
            RowBox[{"domain", "[", 
             RowBox[{"[", 
              RowBox[{"1", ",", "2"}], "]"}], "]"}], ",", "sample"}], "]"}]}], 
         ";", "\n", 
         RowBox[{"Transpose", "[", 
          RowBox[{"{", 
           RowBox[{"times", ",", 
            RowBox[{"dataInt", "@", "times"}]}], "}"}], "]"}]}]}], "\n", 
       "]"}]}]], "Code",
     CellLabel->"In[86]:=",ExpressionUUID->"f6f26bfb-56ea-4ac2-93fe-b97ba55f21e4"],
    
    Cell[BoxData[{
     RowBox[{
      RowBox[{
       RowBox[{"AtomsList", "[", "expr_", "]"}], ":=", 
       RowBox[{"Union", "@", 
        RowBox[{"Select", "[", 
         RowBox[{
          RowBox[{"Level", "[", 
           RowBox[{"expr", ",", 
            RowBox[{"{", 
             RowBox[{"0", ",", "Infinity"}], "}"}]}], "]"}], ",", "AtomQ"}], 
         "]"}]}]}], ";"}], "\n", 
     RowBox[{
      RowBox[{
       RowBox[{"InterpolationDomain", "[", "fun_", "]"}], ":=", 
       RowBox[{"Module", "[", 
        RowBox[{
         RowBox[{"{", 
          RowBox[{"min", ",", "max"}], "}"}], ",", 
         RowBox[{"fun", "[", 
          RowBox[{"[", "1", "]"}], "]"}]}], "]"}]}], ";"}], "\n", 
     RowBox[{
      RowBox[{
       RowBox[{"TakeColumn", "[", 
        RowBox[{
         RowBox[{"list1_", "?", "ListQ"}], ",", 
         RowBox[{"list2_", "?", "ListQ"}]}], "]"}], ":=", 
       RowBox[{"Map", "[", 
        RowBox[{
         RowBox[{
          RowBox[{"Part", "[", 
           RowBox[{"#", ",", "list2"}], "]"}], "&"}], ",", "list1"}], "]"}]}], 
      ";"}], "\n", 
     RowBox[{
      RowBox[{
       RowBox[{"TakeColumn", "[", 
        RowBox[{
         RowBox[{"list1_", "?", "ListQ"}], ",", 
         RowBox[{"n_", "?", "IntegerQ"}]}], "]"}], ":=", 
       RowBox[{
        RowBox[{"(", 
         RowBox[{"list1", "//", "Transpose"}], ")"}], "[", 
        RowBox[{"[", "n", "]"}], "]"}]}], ";"}]}], "Code",
     InitializationCell->True,
     CellChangeTimes->{{3.44498826260142*^9, 3.44498826434814*^9}, 
       3.658227791974455*^9, {3.7953436164167747`*^9, 3.795343616684309*^9}, {
       3.795343704168097*^9, 3.795343718396523*^9}},
     CellLabel->"In[88]:=",ExpressionUUID->"e92bdec3-aab4-44bb-9eb8-e8593dedbc5d"],
    
    Cell[BoxData[
     RowBox[{
      RowBox[{
       RowBox[{"positionDuplicates", "[", "listaux_", "]"}], ":=", 
       RowBox[{"GatherBy", "[", 
        RowBox[{
         RowBox[{"Range", "@", 
          RowBox[{"Length", "[", "listaux", "]"}]}], ",", 
         RowBox[{
          RowBox[{"listaux", "[", 
           RowBox[{"[", "#", "]"}], "]"}], "&"}]}], "]"}]}], ";"}]], "Code",
     CellLabel->"In[92]:=",ExpressionUUID->"468673e1-1d1a-410f-9fbc-3a840631d046"],
    
    Cell[BoxData[
     RowBox[{
      RowBox[{"Arg0DStructs", "[", 
       RowBox[{"reim_", "?", "MatrixQ"}], "]"}], ":=", 
      RowBox[{"UnwrappedPhase", "[", "reim", "]"}]}]], "Code",ExpressionUUID->\
    "66e2ce9e-8bca-4f1a-be52-019a85583e21"],
    
    Cell[BoxData[
     RowBox[{
      RowBox[{"Arg0DStructs", "[", 
       RowBox[{
        RowBox[{"reim_", "?", "MatrixQ"}], ",", 
        RowBox[{"thresh_", "?", "NumberQ"}]}], "]"}], ":=", 
      RowBox[{"Arg0DStructs", "[", "reim", "]"}]}]], "Code",ExpressionUUID->\
    "eb24db11-1413-4288-bb86-fd01706cab41"],
    
    Cell[BoxData[
     RowBox[{
      RowBox[{
       RowBox[{"Arg0DStructs", "[", 
        RowBox[{
         RowBox[{"re_", "?", "MatrixQ"}], ",", 
         RowBox[{"im_", "?", "MatrixQ"}]}], "]"}], ":=", 
       RowBox[{"Module", "[", 
        RowBox[{
         RowBox[{"{", 
          RowBox[{
          "revals", ",", "imvals", ",", "reim", ",", "reimvals", ",", "times", 
           ",", "i", ",", "j", ",", "diff", ",", "\n", "tmp", ",", "twopi", ",", 
           "zero", ",", "test", ",", 
           RowBox[{"thresh", "=", 
            RowBox[{"N", "@", "\[Pi]"}]}]}], "}"}], ",", "\n", "\n", 
         RowBox[{
          RowBox[{"times", "=", 
           RowBox[{"TakeColumn", "[", 
            RowBox[{"re", ",", "1"}], "]"}]}], ";", "\n", 
          RowBox[{"revals", "=", 
           RowBox[{"TakeColumn", "[", 
            RowBox[{"re", ",", "2"}], "]"}]}], ";", "\n", 
          RowBox[{"imvals", "=", 
           RowBox[{"TakeColumn", "[", 
            RowBox[{"im", ",", "2"}], "]"}]}], ";", "\n", 
          RowBox[{"reim", " ", "=", " ", 
           RowBox[{"revals", " ", "+", " ", 
            RowBox[{"I", " ", "imvals"}]}]}], ";", "\n", "\n", 
          RowBox[{"reimvals", "=", 
           RowBox[{"Arg", "@", 
            RowBox[{"TakeColumn", "[", 
             RowBox[{"reim", ",", "2"}], "]"}]}]}], ";", "\n", "\n", 
          RowBox[{"tmp", "=", 
           RowBox[{"N", "[", 
            RowBox[{"2", " ", "\[Pi]"}], "]"}]}], ";", "\n", 
          RowBox[{"twopi", "=", 
           RowBox[{"ConstantArray", "[", 
            RowBox[{"tmp", ",", 
             RowBox[{"Length", "@", "times"}]}], "]"}]}], ";", "\n", 
          RowBox[{"zero", "=", 
           RowBox[{"ConstantArray", "[", 
            RowBox[{"0.", ",", 
             RowBox[{"Length", "@", "times"}]}], "]"}]}], ";", "\n", "\n", 
          RowBox[{"Do", "[", "\n", 
           RowBox[{
            RowBox[{
             RowBox[{"test", "=", 
              RowBox[{"(", 
               RowBox[{
                RowBox[{"reimvals", "[", 
                 RowBox[{"[", 
                  RowBox[{"i", "+", "1"}], "]"}], "]"}], "-", 
                RowBox[{"reimvals", "[", 
                 RowBox[{"[", "i", "]"}], "]"}]}], ")"}]}], ";", "\n", 
             RowBox[{"If", "[", 
              RowBox[{
               RowBox[{"(", 
                RowBox[{"test", ">", "thresh"}], ")"}], ",", "\n", 
               RowBox[{
                RowBox[{"reimvals", "=", 
                 RowBox[{"reimvals", "-", 
                  RowBox[{"Join", "[", 
                   RowBox[{
                    RowBox[{"zero", "[", 
                     RowBox[{"[", 
                      RowBox[{";;", "i"}], "]"}], "]"}], ",", 
                    RowBox[{"twopi", "[", 
                     RowBox[{"[", 
                      RowBox[{
                       RowBox[{"i", "+", "1"}], ";;"}], "]"}], "]"}]}], "]"}]}]}],
                 ";"}]}], "\n", "]"}], ";", "\n", "\n", 
             RowBox[{"If", "[", 
              RowBox[{
               RowBox[{"(", 
                RowBox[{"test", "<", 
                 RowBox[{"-", "thresh"}]}], ")"}], ",", "\n", 
               RowBox[{
                RowBox[{"reimvals", "=", 
                 RowBox[{"reimvals", "+", 
                  RowBox[{"Join", "[", 
                   RowBox[{
                    RowBox[{"zero", "[", 
                     RowBox[{"[", 
                      RowBox[{";;", "i"}], "]"}], "]"}], ",", 
                    RowBox[{"twopi", "[", 
                     RowBox[{"[", 
                      RowBox[{
                       RowBox[{"i", "+", "1"}], ";;"}], "]"}], "]"}]}], "]"}]}]}],
                 ";"}]}], "\n", "]"}], ";"}], ",", "\n", 
            RowBox[{"{", 
             RowBox[{"i", ",", "1", ",", 
              RowBox[{
               RowBox[{"Length", "@", "reimvals"}], "-", "1"}]}], "}"}]}], "\n", 
           "]"}], ";", "\n", 
          RowBox[{"CombineColumns", "[", 
           RowBox[{"times", ",", "reimvals"}], "]"}]}]}], "\n", "]"}]}], 
      ";"}]], "Code",ExpressionUUID->"e0b2f90b-4851-4681-a707-93dfa51b950f"],
    
    Cell[BoxData[
     RowBox[{
      RowBox[{
       RowBox[{"Abs0DStructs", "[", 
        RowBox[{"re_", ",", "im_"}], "]"}], ":=", 
       RowBox[{"Module", "[", 
        RowBox[{
         RowBox[{"{", 
          RowBox[{
          "revals", ",", "imvals", ",", "reimvals", ",", "times", ",", "dt", ",", 
           "result"}], "}"}], ",", "\n", "\n", 
         RowBox[{
          RowBox[{"times", "=", 
           RowBox[{"Map", "[", 
            RowBox[{"First", ",", "re"}], "]"}]}], ";", "\n", 
          RowBox[{"revals", "=", 
           RowBox[{"Map", "[", 
            RowBox[{"Last", ",", "re"}], "]"}]}], ";", "\n", 
          RowBox[{"imvals", "=", 
           RowBox[{"Map", "[", 
            RowBox[{"Last", ",", "im"}], "]"}]}], ";", "\n", "\n", 
          RowBox[{"reimvals", "=", 
           RowBox[{"revals", " ", "+", " ", 
            RowBox[{"I", " ", "imvals"}]}]}], ";", "\n", 
          RowBox[{"reimvals", "=", 
           RowBox[{"Abs", "@", "reimvals"}]}], ";", "\n", "\n", 
          RowBox[{"result", "=", 
           RowBox[{"CombineColumns", "[", 
            RowBox[{"times", ",", "reimvals"}], "]"}]}]}]}], "\n", "]"}]}], 
      ";"}]], "Code",ExpressionUUID->"bc53afdf-e943-48c2-86c7-f6061351661a"],
    
    Cell[BoxData[
     RowBox[{
      RowBox[{
       RowBox[{"Abs0DStructs", "[", "reim_", "]"}], ":=", 
       RowBox[{"Module", "[", 
        RowBox[{
         RowBox[{"{", 
          RowBox[{"reimvals", ",", "times", ",", "dt", ",", "result"}], "}"}], 
         ",", "\n", "\n", 
         RowBox[{
          RowBox[{"times", "=", 
           RowBox[{"Map", "[", 
            RowBox[{"First", ",", "reim"}], "]"}]}], ";", "\n", "\n", 
          RowBox[{"reimvals", "=", 
           RowBox[{"Map", "[", 
            RowBox[{"Last", ",", "reim"}], "]"}]}], ";", "\n", 
          RowBox[{"reimvals", "=", 
           RowBox[{"Abs", "@", "reimvals"}]}], ";", "\n", "\n", 
          RowBox[{"result", "=", 
           RowBox[{"CombineColumns", "[", 
            RowBox[{"times", ",", "reimvals"}], "]"}]}]}]}], "\n", "]"}]}], 
      ";"}]], "Code",ExpressionUUID->"85473fd6-6758-42ab-b08c-9603b15a8b4c"],
    
    Cell[BoxData[
     RowBox[{
      RowBox[{"UnwrapPhaseVector", "=", 
       RowBox[{"Compile", "[", 
        RowBox[{
         RowBox[{"{", 
          RowBox[{"{", 
           RowBox[{"data", ",", "_Real", ",", "1"}], "}"}], "}"}], ",", "\n", 
         RowBox[{"(*", " ", 
          RowBox[{
           RowBox[{"Juergen", " ", "Tischer"}], ",", "\n", 
           RowBox[{
            RowBox[{"http", ":"}], "//", 
            RowBox[{
             RowBox[{
              RowBox[{
               RowBox[{
                RowBox[{
                 RowBox[{"forums", ".", "wolfram", ".", "com"}], "/", 
                 "mathgroup"}], "/", "archive"}], "/", "1998"}], "/", "May"}], 
             "/", 
             RowBox[{"msg00105", ".", "html"}]}]}]}], "*)"}], "\n", 
         RowBox[{"FoldList", "[", 
          RowBox[{
           RowBox[{
            RowBox[{
             RowBox[{
              RowBox[{"Round", "[", 
               RowBox[{
                RowBox[{"(", 
                 RowBox[{"#1", "-", "#2"}], ")"}], "/", 
                RowBox[{"(", 
                 RowBox[{"2", "Pi"}], ")"}]}], "]"}], " ", "2", "Pi"}], "+", 
             "#2"}], "&"}], ",", 
           RowBox[{"First", "[", "data", "]"}], ",", 
           RowBox[{"Rest", "[", "data", "]"}]}], "]"}]}], "\n", "]"}]}], 
      ";"}]], "Code",ExpressionUUID->"e7ae596b-deb7-4f84-9610-9a11170e29df"],
    
    Cell[BoxData[
     RowBox[{
      RowBox[{"UnwrappedPhase", "[", 
       RowBox[{"data_", "?", "VectorQ"}], "]"}], ":=", 
      RowBox[{"UnwrapPhaseVector", "[", 
       RowBox[{"Arg", "@", "data"}], "]"}]}]], "Code",ExpressionUUID->"ac162a9f-\
    c8ea-4b77-b9dd-33728f284915"],
    
    Cell[BoxData[
     RowBox[{
      RowBox[{"UnwrappedPhase", "[", 
       RowBox[{"data_", "?", "MatrixQ"}], "]"}], ":=", 
      RowBox[{"CombineColumns", "[", 
       RowBox[{
        RowBox[{"TakeColumn", "[", 
         RowBox[{"data", ",", "1"}], "]"}], ",", 
        RowBox[{"UnwrapPhaseVector", "[", 
         RowBox[{"Arg", "@", 
          RowBox[{"TakeColumn", "[", 
           RowBox[{"data", ",", "2"}], "]"}]}], "]"}]}], "]"}]}]], "Code",Expressi\
    onUUID->"a7650f1d-49ea-409d-b201-4e28f33d8f17"],
    
    Cell[BoxData[{
     RowBox[{
      RowBox[{
       RowBox[{"CombineColumns", "[", 
        RowBox[{"list1_", ",", "list2_"}], "]"}], ":=", 
       RowBox[{"If", "[", 
        RowBox[{
         RowBox[{
          RowBox[{"Length", "@", "list1"}], "==", 
          RowBox[{"Length", "@", "list2"}]}], ",", " ", 
         RowBox[{
          RowBox[{"{", 
           RowBox[{"list1", ",", "list2"}], "}"}], "//", "Transpose"}], ",", 
         RowBox[{
          RowBox[{"0", 
           RowBox[{"{", 
            RowBox[{"list1", ",", "list1"}], "}"}]}], "//", "Transpose"}]}], 
        "]"}]}], "\n"}], "\n", 
     RowBox[{
      RowBox[{"CombineColumns", "[", "list_", "]"}], ":=", 
      RowBox[{"If", "[", 
       RowBox[{
        RowBox[{
         RowBox[{"Length", "@", 
          RowBox[{"Union", "@", 
           RowBox[{"(", 
            RowBox[{"Length", " ", "/@", " ", "list"}], ")"}]}]}], " ", "==", " ",
          "1"}], ",", " ", 
        RowBox[{"list", "//", "Transpose"}], ",", 
        RowBox[{"{", "}"}]}], "]"}]}]}], "Code",ExpressionUUID->"3c2acbf4-48c7-\
    465c-8286-93552b4d3531"],
    
    Cell[BoxData[{
     RowBox[{
      RowBox[{
       RowBox[{
        RowBox[{"fH", "[", 
         RowBox[{"f_", ",", "M_"}], "]"}], ":=", 
        RowBox[{"Module", "[", 
         RowBox[{
          RowBox[{"{", 
           RowBox[{"c", ",", "G", ",", "MS"}], "}"}], ",", "\n", 
          RowBox[{
           RowBox[{"c", "=", 
            RowBox[{"2.99792458", " ", 
             RowBox[{"10", "^", "8"}]}]}], ";", 
           RowBox[{"G", "=", 
            RowBox[{"6.67259", "*", 
             RowBox[{"10", "^", 
              RowBox[{"-", "11"}]}]}]}], ";", 
           RowBox[{"MS", "=", 
            RowBox[{"1.9885", "*", 
             RowBox[{"10", "^", "30"}]}]}], ";", "\n", 
           RowBox[{
            RowBox[{
             RowBox[{
              RowBox[{"(", "c", ")"}], "^", "3"}], "/", 
             RowBox[{"(", 
              RowBox[{
               RowBox[{"(", "M", ")"}], "MS", 
               RowBox[{"(", "G", ")"}]}], ")"}]}], " ", "f"}]}]}], "]"}]}], ";", 
       RowBox[{"(*", " ", 
        RowBox[{"in", " ", "Solar", " ", "mass", " ", "units"}], " ", "*)"}], 
       "\n", 
       RowBox[{
        RowBox[{"fNU", "[", 
         RowBox[{"f_", ",", "M_"}], "]"}], ":=", 
        RowBox[{"Module", "[", 
         RowBox[{
          RowBox[{"{", 
           RowBox[{"c", ",", "G", ",", "MS"}], "}"}], ",", 
          RowBox[{
           RowBox[{"c", "=", 
            RowBox[{"2.99792458", " ", 
             RowBox[{"10", "^", "8"}]}]}], ";", 
           RowBox[{"G", "=", 
            RowBox[{"6.67259", "*", 
             RowBox[{"10", "^", 
              RowBox[{"-", "11"}]}]}]}], ";", 
           RowBox[{"MS", "=", 
            RowBox[{"1.9885", "*", 
             RowBox[{"10", "^", "30"}]}]}], ";", 
           RowBox[{
            RowBox[{
             RowBox[{"(", 
              RowBox[{
               RowBox[{"(", "M", ")"}], "MS", 
               RowBox[{"(", "G", ")"}]}], ")"}], "/", 
             RowBox[{
              RowBox[{"(", "c", ")"}], "^", "3"}]}], " ", "f"}]}]}], "]"}]}]}], 
      "\n"}], "\n", 
     RowBox[{
      RowBox[{
       RowBox[{"tPhys", "[", 
        RowBox[{"t_", ",", "M_"}], "]"}], ":=", 
       RowBox[{"Module", "[", 
        RowBox[{
         RowBox[{"{", 
          RowBox[{"c", ",", "G", ",", "MS"}], "}"}], ",", 
         RowBox[{
          RowBox[{"c", "=", 
           RowBox[{"2.99792458", " ", 
            RowBox[{"10", "^", "8"}]}]}], ";", 
          RowBox[{"G", "=", 
           RowBox[{"6.67259", "*", 
            RowBox[{"10", "^", 
             RowBox[{"-", "11"}]}]}]}], ";", 
          RowBox[{"MS", "=", 
           RowBox[{"1.9885", "*", 
            RowBox[{"10", "^", "30"}]}]}], ";", "\n", "                     ", 
          RowBox[{
           RowBox[{
            RowBox[{"(", 
             RowBox[{
              RowBox[{"(", "M", ")"}], "MS", 
              RowBox[{"(", "G", ")"}]}], ")"}], "/", 
            RowBox[{
             RowBox[{"(", "c", ")"}], "^", "3"}]}], " ", "t"}]}]}], "]"}]}], 
      "\n"}], "\n", 
     RowBox[{
      RowBox[{"tNR", "[", 
       RowBox[{"t_", ",", "M_"}], "]"}], ":=", 
      RowBox[{"Module", "[", 
       RowBox[{
        RowBox[{"{", 
         RowBox[{"c", ",", "G", ",", "MS"}], "}"}], ",", 
        RowBox[{
         RowBox[{"c", "=", 
          RowBox[{"2.99792458", " ", 
           RowBox[{"10", "^", "8"}]}]}], ";", 
         RowBox[{"G", "=", 
          RowBox[{"6.67259", "*", 
           RowBox[{"10", "^", 
            RowBox[{"-", "11"}]}]}]}], ";", 
         RowBox[{"MS", "=", 
          RowBox[{"1.9885", "*", 
           RowBox[{"10", "^", "30"}]}]}], ";", "\n", "                      ", 
         RowBox[{
          RowBox[{"1", "/", 
           RowBox[{"(", 
            RowBox[{
             RowBox[{"(", 
              RowBox[{
               RowBox[{"(", "M", ")"}], "MS", 
               RowBox[{"(", "G", ")"}]}], ")"}], "/", 
             RowBox[{
              RowBox[{"(", "c", ")"}], "^", "3"}]}], ")"}]}], " ", "t"}]}]}], 
       "]"}]}]}], "Code",ExpressionUUID->"1410a7ff-128b-4a76-b41a-a0f54f55ac65"]
    }, Closed]],
    
    Cell[CellGroupData[{
    
    Cell["CNMinimise", "Subsection",
     CellChangeTimes->{{3.799123097832287*^9, 3.799123100017612*^9}, 
       3.800858891083128*^9},ExpressionUUID->"c6bb24a7-12f8-4cda-bce0-\
    4aa336c33174"],
    
    Cell[BoxData[{
     RowBox[{
      RowBox[{
       RowBox[{"Options", "[", "CNMinimize", "]"}], "=", 
       RowBox[{"Join", "[", 
        RowBox[{
         RowBox[{"Options", "@", "NMinimize"}], ",", 
         RowBox[{"{", 
          RowBox[{"\"\<Method\>\"", "\[Rule]", "Automatic"}], "}"}]}], "]"}]}], 
      ";"}], "\n", 
     RowBox[{
      RowBox[{
       RowBox[{"CNMinimize", "[", 
        RowBox[{"data_", ",", "ansatz_", ",", "vars_", ",", 
         RowBox[{"{", 
          RowBox[{"x_", ",", "xlist_"}], "}"}], ",", 
         RowBox[{"OptionsPattern", "[", "]"}]}], "]"}], ":=", 
       RowBox[{"Module", "[", 
        RowBox[{
         RowBox[{"{", 
          RowBox[{"likelihood", ",", "ansatzlist", ",", "method"}], "}"}], ",", 
         "\n", 
         RowBox[{
          RowBox[{"method", "=", 
           RowBox[{"OptionValue", "[", "\"\<Method\>\"", "]"}]}], ";", "\n", "\n", 
          RowBox[{"ansatzlist", "=", 
           RowBox[{"ansatz", "/.", 
            RowBox[{"x", "->", "xlist"}]}]}], ";", "\[IndentingNewLine]", 
          RowBox[{"likelihood", "=", 
           RowBox[{"Total", "[", 
            RowBox[{"(", 
             RowBox[{
              RowBox[{
               RowBox[{"Re", "[", 
                RowBox[{"ansatzlist", "-", "data"}], "]"}], "^", "2"}], "+", 
              RowBox[{
               RowBox[{"Im", "[", 
                RowBox[{"ansatzlist", "-", "data"}], "]"}], "^", "2"}]}], ")"}], 
            "]"}]}], ";", "\n", 
          RowBox[{"NMinimize", "[", 
           RowBox[{"likelihood", ",", "vars", ",", 
            RowBox[{"Method", "\[Rule]", "method"}]}], "]"}]}]}], 
        "\[IndentingNewLine]", "]"}]}], ";"}]}], "Code",
     CellChangeTimes->{{3.78402618435026*^9, 3.784026247925045*^9}, {
      3.784026366595476*^9, 3.784026386762023*^9}, {3.784034180598002*^9, 
      3.784034206429718*^9}, {3.784034905667307*^9, 3.7840349565768843`*^9}, {
      3.784035131853462*^9, 3.784035138523047*^9}, {3.784035184188199*^9, 
      3.7840353667883053`*^9}, {3.784035603689439*^9, 3.78403563095909*^9}, {
      3.784035765353816*^9, 3.784035774006487*^9}, {3.7840358189607363`*^9, 
      3.784035830385499*^9}, {3.78403601546911*^9, 3.784036067502681*^9}, {
      3.784036120491181*^9, 3.784036190382745*^9}, {3.784036265539901*^9, 
      3.784036297429549*^9}, {3.7840363577050133`*^9, 3.784036361038095*^9}, {
      3.799123323282538*^9, 3.799123362306231*^9}, {3.799123423829391*^9, 
      3.799123426876648*^9}, {3.800088682771699*^9, 3.800088723858489*^9}, {
      3.8000888067634068`*^9, 
      3.8000888190881166`*^9}},ExpressionUUID->"5de50ab8-e5be-4535-9354-\
    434de2836834"]
    }, Open  ]],
    
    Cell[CellGroupData[{
    
    Cell["Load and classify SXS data", "Subsection",
     CellChangeTimes->{{3.7625779093082952`*^9, 3.7625779171097937`*^9}, {
      3.799119165688805*^9, 
      3.7991192225189257`*^9}},ExpressionUUID->"306aaf72-c2ea-46d3-b394-\
    84934dd4014f"],
    
    Cell[BoxData[
     RowBox[{
      RowBox[{"GetAsymptoticMultiMode", "[", 
       RowBox[{"h5file_", ",", "order_", ",", "list_", ",", 
        RowBox[{"OptionsPattern", "[", 
         RowBox[{"{", 
          RowBox[{
           RowBox[{"\"\<Verbose\>\"", "->", "False"}], ",", 
           RowBox[{"\"\<TiReIm\>\"", "->", "True"}], ",", 
           RowBox[{"\"\<ZeroAlign\>\"", "->", "False"}], ",", 
           RowBox[{"\"\<ReSample\>\"", "->", "True"}], ",", 
           RowBox[{"\"\<Sampling\>\"", "->", "0.5"}]}], "}"}], "]"}]}], "]"}], ":=", 
      RowBox[{"Module", "[", 
       RowBox[{
        RowBox[{"{", 
         RowBox[{
         "datasets", ",", "targetstring", ",", "pos", ",", "VPrint", ",", "\n", 
          "l", ",", "m", ",", "positions", ",", "timreim", ",", "tt", ",", "re", 
          ",", "im", ",", "import", ",", "zeroalign", ",", "tmax", ",", 
          "resample", ",", "wave", ",", "sampling"}], "}"}], ",", "\n", 
        RowBox[{
         RowBox[{
          RowBox[{"VPrint", "[", "expr___", "]"}], ":=", 
          RowBox[{"If", "[", 
           RowBox[{
            RowBox[{"OptionValue", "[", "\"\<Verbose\>\"", "]"}], ",", 
            RowBox[{"Print", "[", "expr", "]"}]}], "]"}]}], ";", "\n", 
         RowBox[{"timreim", "=", 
          RowBox[{"OptionValue", "[", "\"\<TiReIm\>\"", "]"}]}], ";", "\n", 
         RowBox[{"zeroalign", "=", 
          RowBox[{"OptionValue", "[", "\"\<ZeroAlign\>\"", "]"}]}], ";", "\n", 
         RowBox[{"resample", "=", 
          RowBox[{"OptionValue", "[", "\"\<ReSample\>\"", "]"}]}], ";", "\n", 
         RowBox[{"sampling", "=", 
          RowBox[{"OptionValue", "[", "\"\<Sampling\>\"", "]"}]}], ";", "\n", 
         "                                                        ", "\n", 
         RowBox[{"datasets", "=", 
          RowBox[{"Import", "[", 
           RowBox[{"h5file", ",", "\"\<Datasets\>\""}], "]"}]}], ";", "\n", "\n", 
         
         RowBox[{"positions", "=", 
          RowBox[{"Table", "[", "\n", "                 ", 
           RowBox[{
            RowBox[{
             RowBox[{"If", "[", 
              RowBox[{
               RowBox[{"NumberQ", "[", "order", "]"}], ",", 
               RowBox[{
                RowBox[{"l", "=", 
                 RowBox[{"list", "[", 
                  RowBox[{"[", 
                   RowBox[{"i", ",", "1"}], "]"}], "]"}]}], ";", "\n", 
                "                  ", 
                RowBox[{"m", "=", 
                 RowBox[{"list", "[", 
                  RowBox[{"[", 
                   RowBox[{"i", ",", "2"}], "]"}], "]"}]}], ";", "\n", 
                "                  ", 
                RowBox[{"targetstring", "=", 
                 RowBox[{"\"\</Extrapolated_N\>\"", "<>", 
                  RowBox[{"ToString", "[", "order", "]"}], "<>", 
                  "\"\<.dir/Y_l\>\"", "<>", 
                  RowBox[{"ToString", "[", "l", "]"}], "<>", "\"\<_m\>\"", "<>", 
                  RowBox[{"ToString", "[", "m", "]"}], "<>", "\"\<.dat\>\""}]}], 
                ";"}], "\n", "                      ", ",", "\n", 
               "                  ", 
               RowBox[{"If", "[", 
                RowBox[{
                 RowBox[{"order", "===", "\"\<outermost\>\""}], ",", 
                 RowBox[{
                  RowBox[{"targetstring", "=", 
                   RowBox[{"\"\</OutermostExtraction.dir/Y_l\>\"", "<>", 
                    RowBox[{"ToString", "[", "l", "]"}], "<>", "\"\<_m\>\"", "<>", 
                    RowBox[{"ToString", "[", "m", "]"}], "<>", "\"\<.dat\>\""}]}],
                   ";"}]}], "]"}]}], "\n", "                 ", "]"}], ";", "\n", 
             
             RowBox[{"VPrint", "[", 
              RowBox[{"\"\<Targeting entry: \>\"", ",", "targetstring"}], "]"}], 
             ";", "\n", 
             RowBox[{"pos", "=", 
              RowBox[{"Flatten", "[", 
               RowBox[{"Position", "[", 
                RowBox[{"datasets", ",", "targetstring"}], "]"}], "]"}]}], ";", 
             RowBox[{"Switch", "[", 
              RowBox[{
               RowBox[{"Length", "[", "pos", "]"}], ",", "\n", "0", ",", 
               RowBox[{
                RowBox[{"Print", "[", "\"\<Data not found\>\"", "]"}], ";", 
                RowBox[{"Return", "[", "Null", "]"}], ";"}], ",", "\n", "1", ",", 
               
               RowBox[{
                RowBox[{"pos", "=", 
                 RowBox[{"pos", "[", 
                  RowBox[{"[", "1", "]"}], "]"}]}], ";"}], ",", "\n", "_", ",", 
               RowBox[{
                RowBox[{
                "Print", "[", "\"\<Error, two entries with this name\>\"", "]"}], 
                ";", "\n", 
                RowBox[{"Return", "[", "Null", "]"}], ";"}]}], "]"}], ";", "\n", 
             RowBox[{"VPrint", "[", 
              RowBox[{"\"\<Annotations: \>\"", ",", 
               RowBox[{"Import", "[", 
                RowBox[{"h5file", ",", 
                 RowBox[{"{", 
                  RowBox[{"\"\<Annotations\>\"", ",", "pos"}], "}"}]}], "]"}]}], 
              "]"}], ";", "\n", 
             RowBox[{"VPrint", "[", 
              RowBox[{"\"\<Data Format: \>\"", ",", 
               RowBox[{"Import", "[", 
                RowBox[{"h5file", ",", 
                 RowBox[{"{", 
                  RowBox[{"\"\<DataFormat\>\"", ",", "pos"}], "}"}]}], "]"}]}], 
              "]"}], ";", "\n", 
             RowBox[{"VPrint", "[", 
              RowBox[{"\"\<Data dimensions: \>\"", ",", 
               RowBox[{"Import", "[", 
                RowBox[{"h5file", ",", 
                 RowBox[{"{", 
                  RowBox[{"\"\<Dimensions\>\"", ",", "pos"}], "}"}]}], "]"}]}], 
              "]"}], ";", "\n", 
             RowBox[{"VPrint", "[", 
              RowBox[{"\"\<Data encoding: \>\"", ",", 
               RowBox[{"Import", "[", 
                RowBox[{"h5file", ",", 
                 RowBox[{"{", 
                  RowBox[{"\"\<DataEncoding\>\"", ",", "pos"}], "}"}]}], "]"}]}], 
              "]"}], ";", "\n", "pos"}], ",", 
            RowBox[{"{", 
             RowBox[{"i", ",", "1", ",", 
              RowBox[{"Length", "[", "list", "]"}]}], "}"}]}], "]"}]}], ";", "\n",
          "\n", 
         RowBox[{"If", "[", 
          RowBox[{
           RowBox[{
            RowBox[{"Length", "[", "list", "]"}], "==", "1"}], ",", "\n", 
           "                 ", 
           RowBox[{
            RowBox[{"import", "=", 
             RowBox[{"{", 
              RowBox[{"Import", "[", 
               RowBox[{"h5file", ",", 
                RowBox[{"{", 
                 RowBox[{"\"\<Data\>\"", ",", "positions"}], "}"}]}], "]"}], 
              "}"}]}], ";"}], ",", "\n", "                 ", 
           RowBox[{
            RowBox[{"import", "=", 
             RowBox[{"Import", "[", 
              RowBox[{"h5file", ",", 
               RowBox[{"{", 
                RowBox[{"\"\<Data\>\"", ",", "positions"}], "}"}]}], "]"}]}], 
            ";"}]}], "\n", "]"}], ";", "\n", "\n", 
         RowBox[{"If", "[", 
          RowBox[{"timreim", ",", 
           RowBox[{
            RowBox[{"wave", "=", 
             RowBox[{
              RowBox[{"(", 
               RowBox[{
                RowBox[{"#1", "/.", " ", 
                 RowBox[{
                  RowBox[{"{", 
                   RowBox[{"tt_", ",", "re_", ",", "im_"}], "}"}], "->", 
                  RowBox[{"{", 
                   RowBox[{"tt", ",", 
                    RowBox[{"re", "+", 
                     RowBox[{"I", " ", "im"}]}]}], "}"}]}]}], "&"}], ")"}], "/@", 
              "import"}]}], ";"}], ",", 
           RowBox[{"wave", "=", "import"}]}], "]"}], ";", "\n", 
         RowBox[{"If", "[", 
          RowBox[{"resample", ",", 
           RowBox[{
            RowBox[{"wave", "=", 
             RowBox[{
              RowBox[{
               RowBox[{"ReSampleTD", "[", 
                RowBox[{"#", ",", "sampling"}], "]"}], "&"}], "/@", "wave"}]}], 
            ";"}]}], "]"}], ";", "\n", 
         RowBox[{"If", "[", 
          RowBox[{"zeroalign", ",", 
           RowBox[{
            RowBox[{"tmax", "=", 
             RowBox[{"TimeOfMaximum", "[", 
              RowBox[{"wave", "[", 
               RowBox[{"[", 
                RowBox[{"1", ",", 
                 RowBox[{
                  RowBox[{"-", 
                   RowBox[{"Round", "[", 
                    RowBox[{
                     RowBox[{"(", 
                      RowBox[{"Length", "@", 
                       RowBox[{"wave", "[", 
                        RowBox[{"[", "1", "]"}], "]"}]}], ")"}], "/", "2"}], 
                    "]"}]}], ";;", 
                  RowBox[{"-", "1"}]}]}], "]"}], "]"}], "]"}]}], ";", 
            RowBox[{"Table", "[", 
             RowBox[{
              RowBox[{
               RowBox[{"wave", "[", 
                RowBox[{"[", 
                 RowBox[{"i", ",", "All", ",", "1"}], "]"}], "]"}], "=", 
               RowBox[{
                RowBox[{"wave", "[", 
                 RowBox[{"[", 
                  RowBox[{"i", ",", "All", ",", "1"}], "]"}], "]"}], "-", 
                "tmax"}]}], ",", 
              RowBox[{"{", 
               RowBox[{"i", ",", 
                RowBox[{"Length", "@", "import"}]}], "}"}]}], "]"}]}]}], "]"}], 
         ";", "\n", "wave"}]}], "\n", "]"}]}]], "Code",
     CellLabel->"In[85]:=",ExpressionUUID->"c03ad841-0c13-4803-9638-d5c9b3a75ca4"],
    
    Cell[BoxData[
     RowBox[{
      RowBox[{"SXSMetaFilesToRules", "[", "filePath_", "]"}], ":=", 
      RowBox[{"Module", "[", 
       RowBox[{
        RowBox[{"{", 
         RowBox[{
         "filepath", ",", "fileList", ",", "meta1", ",", "pos1", ",", "meta2", 
          ",", "meta3", ",", "meta4", ",", "value", ",", "var", ",", "list"}], 
         "}"}], ",", "\n", "\n", "\n", 
        RowBox[{
         RowBox[{"If", "[", 
          RowBox[{
           RowBox[{"ListQ", "@", "filePath"}], ",", 
           RowBox[{"filepath", "=", 
            RowBox[{"filePath", "[", 
             RowBox[{"[", "1", "]"}], "]"}]}], ",", 
           RowBox[{"filepath", "=", "filePath"}]}], "]"}], ";", "\n", 
         RowBox[{"If", "[", 
          RowBox[{
           RowBox[{"Not", "@", 
            RowBox[{"FileExistsQ", "@", "filepath"}]}], ",", 
           RowBox[{
            RowBox[{"Print", "[", "\"\<File not found\>\"", "]"}], ";", 
            RowBox[{"Return", "[", "]"}]}]}], "]"}], ";", "\n", "\n", 
         RowBox[{"(*", 
          RowBox[{"Reading", " ", "the", " ", "file"}], "*)"}], "\n", 
         RowBox[{"fileList", "=", 
          RowBox[{"ReadList", "[", 
           RowBox[{"filepath", ",", "String"}], "]"}]}], ";", "\n", 
         RowBox[{"(*", 
          RowBox[{"Delete", " ", "comments"}], "*)"}], "\n", "\n", 
         RowBox[{"meta1", "=", 
          RowBox[{"Delete", "[", 
           RowBox[{"fileList", ",", 
            RowBox[{"Position", "[", 
             RowBox[{
              RowBox[{"StringMatchQ", "[", 
               RowBox[{"fileList", ",", "\"\<#*\>\""}], "]"}], ",", "True"}], 
             "]"}]}], "]"}]}], ";", "\n", "\n", 
         RowBox[{"(*", 
          RowBox[{"Fix", " ", "eccentricity"}], "*)"}], "\n", 
         RowBox[{
          RowBox[{"meta1", "[", 
           RowBox[{"[", 
            RowBox[{"Flatten", "@", 
             RowBox[{"Position", "[", 
              RowBox[{
               RowBox[{"StringMatchQ", "[", 
                RowBox[{"meta1", ",", "\"\<*<*e-*\>\""}], "]"}], ",", "True"}], 
              "]"}]}], "]"}], "]"}], "=", 
          RowBox[{"StringReplace", "[", 
           RowBox[{
            RowBox[{"meta1", "[", 
             RowBox[{"[", 
              RowBox[{"Flatten", "@", 
               RowBox[{"Position", "[", 
                RowBox[{
                 RowBox[{"StringMatchQ", "[", 
                  RowBox[{"meta1", ",", "\"\<*<*e-*\>\""}], "]"}], ",", "True"}], 
                "]"}]}], "]"}], "]"}], ",", 
            RowBox[{"\"\<<\>\"", "->", "\"\<\>\""}]}], "]"}]}], ";", "\n", "\n", 
         RowBox[{"(*", 
          RowBox[{"Find", " ", "="}], " ", "*)"}], "\n", 
         RowBox[{"meta2", "=", 
          RowBox[{"meta1", "[", 
           RowBox[{"[", 
            RowBox[{"Flatten", "@", 
             RowBox[{"Position", "[", 
              RowBox[{
               RowBox[{"StringMatchQ", "[", 
                RowBox[{"meta1", ",", "\"\<*=*\>\""}], "]"}], ",", "True"}], 
              "]"}]}], "]"}], "]"}]}], ";", "\n", "\n", 
         RowBox[{"meta3", "=", 
          RowBox[{"StringSplit", "[", 
           RowBox[{"meta2", ",", "\"\<=\>\""}], "]"}]}], ";", "\n", "\n", 
         RowBox[{"(*", " ", 
          RowBox[{
           RowBox[{"Select", " ", "non"}], "-", 
           RowBox[{"empty", " ", "fields"}]}], "*)"}], "\n", 
         RowBox[{"meta3", "=", 
          RowBox[{"Select", "[", 
           RowBox[{"meta3", ",", 
            RowBox[{
             RowBox[{
              RowBox[{"Length", "@", "#"}], ">", "1"}], "&"}]}], "]"}]}], ";", 
         "\n", "\n", 
         RowBox[{"(*", 
          RowBox[{"Delete", " ", "spaces"}], "*)"}], "\n", 
         RowBox[{"meta4", "=", 
          RowBox[{"Transpose", "[", 
           RowBox[{"{", 
            RowBox[{
             RowBox[{"StringReplace", "[", 
              RowBox[{
               RowBox[{"meta3", "[", 
                RowBox[{"[", 
                 RowBox[{"All", ",", "1"}], "]"}], "]"}], ",", 
               RowBox[{"\"\< \>\"", "->", "\"\<\>\""}]}], "]"}], ",", 
             RowBox[{"StringReplace", "[", 
              RowBox[{
               RowBox[{"meta3", "[", 
                RowBox[{"[", 
                 RowBox[{"All", ",", "2"}], "]"}], "]"}], ",", 
               RowBox[{"\"\< \>\"", "->", "\"\<\>\""}]}], "]"}]}], "}"}], "]"}]}],
          ";", "\n", "\n", 
         RowBox[{"var", "=", 
          RowBox[{"meta4", "[", 
           RowBox[{"[", 
            RowBox[{"All", ",", "1"}], "]"}], "]"}]}], ";", "\n", 
         RowBox[{"value", "=", 
          RowBox[{"meta4", "[", 
           RowBox[{"[", 
            RowBox[{"All", ",", "2"}], "]"}], "]"}]}], ";", "\n", "\n", 
         RowBox[{"value", "=", 
          RowBox[{
           RowBox[{
            RowBox[{"StringSplit", "[", 
             RowBox[{"#", ",", "\"\<,\>\""}], "]"}], "&"}], "/@", "value"}]}], 
         ";", "\n", 
         RowBox[{"(*", 
          RowBox[{"Delete", " ", "empty", " ", "elements"}], "*)"}], "\n", 
         RowBox[{"(*", 
          RowBox[{
           RowBox[{"value", "=", 
            RowBox[{"Select", "[", 
             RowBox[{"value", ",", " ", 
              RowBox[{
               RowBox[{"UnsameQ", "[", 
                RowBox[{"#", ",", " ", 
                 RowBox[{"{", "}"}]}], "]"}], " ", "&"}]}], "]"}]}], ";"}], 
          "*)"}], "\n", "\n", 
         RowBox[{"list", "=", 
          RowBox[{"{", "}"}]}], ";", "\n", 
         RowBox[{"Do", "[", "\n", 
          RowBox[{
           RowBox[{
            RowBox[{"If", "[", 
             RowBox[{
              RowBox[{
               RowBox[{"Length", "@", 
                RowBox[{"value", "[", 
                 RowBox[{"[", "i", "]"}], "]"}]}], "==", "0"}], ",", "\n", 
              "      ", 
              RowBox[{"{", "}"}], "\n", "     ", ",", "\n", "      ", 
              RowBox[{
               RowBox[{"If", "[", 
                RowBox[{
                 RowBox[{"IsFPNumberQ", "@", 
                  RowBox[{"value", "[", 
                   RowBox[{"[", 
                    RowBox[{"i", ",", "1"}], "]"}], "]"}]}], ",", "\n", "\t  ", 
                 RowBox[{
                  RowBox[{
                   RowBox[{"value", "[", 
                    RowBox[{"[", "i", "]"}], "]"}], "=", 
                   RowBox[{
                    RowBox[{
                     RowBox[{"(", 
                      RowBox[{"StringToNumber", "@", "#"}], ")"}], "&"}], "/@", 
                    RowBox[{"value", "[", 
                     RowBox[{"[", "i", "]"}], "]"}]}]}], ";"}]}], "\n", 
                "        ", "]"}], ";", "\n", "      ", 
               RowBox[{"list", "=", 
                RowBox[{"AppendTo", "[", 
                 RowBox[{"list", ",", 
                  RowBox[{"{", 
                   RowBox[{
                    RowBox[{"var", "[", 
                     RowBox[{"[", "i", "]"}], "]"}], "->", 
                    RowBox[{"value", "[", 
                     RowBox[{"[", "i", "]"}], "]"}]}], "}"}]}], "]"}]}], ";"}]}], 
             "\n", "     ", "]"}], ";"}], "\n", ",", "\n", 
           RowBox[{"{", 
            RowBox[{"i", ",", "1", ",", 
             RowBox[{"Length", "@", "value"}]}], "}"}]}], "]"}], ";", "\n", "\n", 
         
         RowBox[{"Flatten", "@", "list"}]}]}], "\n", "\n", "]"}]}]], "Code",
     CellLabel->"In[87]:=",ExpressionUUID->"924831b0-9d8f-411c-aba6-db1145813b58"],
    
    Cell[BoxData[
     RowBox[{
      RowBox[{"SXSParClassification", "[", 
       RowBox[{
        RowBox[{"sxsdir_", "?", "ListQ"}], ",", 
        RowBox[{"ClassStr_", "?", "ListQ"}], ",", 
        RowBox[{"OptionsPattern", "[", 
         RowBox[{"{", 
          RowBox[{
           RowBox[{"\"\<\[Epsilon]\>\"", "->", "0.001"}], ",", 
           RowBox[{"\"\<HighSpin\>\"", "->", "0.8"}], ",", 
           RowBox[{"\"\<UnRepeated\>\"", "->", "False"}], ",", 
           RowBox[{"\"\<Verbose\>\"", "->", "False"}], ",", 
           RowBox[{"\"\<Mass1-Str\>\"", "->", "\"\<initial-mass1\>\""}], ",", 
           RowBox[{"\"\<Mass2-Str\>\"", "->", "\"\<initial-mass2\>\""}]}], "}"}], 
         "]"}]}], "]"}], ":=", 
      RowBox[{"Module", "[", 
       RowBox[{
        RowBox[{"{", 
         RowBox[{"metafiles", ",", "metadata", ",", "\n", 
          RowBox[{"orbitStr", "=", "\"\<number-of-orbits\>\""}], ",", 
          RowBox[{"dStr", "=", "\"\<initial-separation\>\""}], ",", "mass1Str", 
          ",", "mass2Str", ",", 
          RowBox[{"spin1Str", "=", "\"\<initial-dimensionless-spin1\>\""}], ",", 
          "\n", 
          RowBox[{"spin2Str", "=", "\"\<initial-dimensionless-spin2\>\""}], ",", 
          RowBox[{"eccStr", "=", "\"\<relaxed-eccentricity\>\""}], ",", 
          "spin1Dim", ",", "spin2Dim", ",", "mass1", ",", "mass2", ",", 
          "massratio", ",", "eccentricity", ",", "dist", ",", "orbit", ",", 
          "select", ",", "pos", ",", "condition", ",", "A1", ",", "A2", ",", 
          "precvalue", ",", "precvalueNorm", ",", "\[Epsilon]", ",", "\n", 
          "spin1Norm", ",", "spin2Norm", ",", "highspin", ",", "spintest", ",", 
          "\[Chi]eff", ",", "sxsdirout", ",", "spinz", ",", "spinzDiff", ",", 
          "auxDist", ",", "posdup", ",", "posdupDist", ",", "posdistecc", ",", 
          "unrepeated", ",", "verbose", ",", "sxsdiroutaux", ",", "precvalue1", 
          ",", "precvalue2", ",", "precvalueNorm1", ",", "precvalueNorm2"}], 
         "}"}], ",", "\n", "\n", 
        RowBox[{
         RowBox[{
         "Print", "[", 
          "\"\<Classification Input Variables. Examples: {{'MassRatio', \
    '0.99<#<1.1'}},{{'Distance', '#>16'}},{{'Orbits', '#>25'}},{{'Precessing'}},\n\
    {{'Non-Precessing'}},{{'High-Spin'}},{{'\[Chi]eff','#>0.6'}},{{'\[Chi]1','#>0.\
    6'}},{{'\[Chi]2','#>0.6'}},{{'Unequal'}}\>\"", "]"}], ";", "\n", 
         RowBox[{
         "Print", "[", 
          "\"\<Take care! Some of the sxs file names are not consistent with the \
    metadata files\>\"", "]"}], ";", "\n", 
         RowBox[{
         "Print", "[", 
          "\"\<The spin definition is consitent with 'initial-spin' values and \
    not relaxed ones\>\"", "]"}], ";", "\n", 
         RowBox[{
         "Print", "[", 
          "\"\<The mass definition is consitent with 'initial-mass' values and \
    not relaxed ones\>\"", "]"}], ";", "\n", "\n", 
         RowBox[{"mass1Str", "=", 
          RowBox[{"OptionValue", "[", "\"\<Mass1-Str\>\"", "]"}]}], ";", "\n", 
         RowBox[{"mass2Str", "=", 
          RowBox[{"OptionValue", "[", "\"\<Mass2-Str\>\"", "]"}]}], ";", "\n", 
         "\n", 
         RowBox[{"(*", " ", 
          RowBox[{
          "Kill", " ", "the", " ", "loop", " ", "if", " ", "the", " ", "root", 
           " ", "directory", " ", "is", " ", "wrong"}], " ", "*)"}], "\n", 
         RowBox[{"If", "[", 
          RowBox[{
           RowBox[{"And", "@@", 
            RowBox[{"(", 
             RowBox[{"Not", "/@", 
              RowBox[{"DirectoryQ", "/@", "sxsdir"}]}], ")"}]}], ",", 
           RowBox[{
            RowBox[{"Print", "[", 
             RowBox[{"Style", "[", 
              RowBox[{"\"\<Directory not found\>\"", ",", "Red"}], "]"}], "]"}], 
            ";", 
            RowBox[{"Return", "[", 
             RowBox[{"{", "}"}], "]"}]}]}], "]"}], ";", "\n", "\n", 
         RowBox[{"sxsdirout", "=", "sxsdir"}], ";", "\n", "\n", 
         RowBox[{"\[Epsilon]", "=", 
          RowBox[{"OptionValue", "[", "\"\<\[Epsilon]\>\"", "]"}]}], ";", "\n", 
         RowBox[{"highspin", "=", 
          RowBox[{"OptionValue", "[", "\"\<HighSpin\>\"", "]"}]}], ";", "\n", 
         RowBox[{"unrepeated", "=", 
          RowBox[{"OptionValue", "[", "\"\<UnRepeated\>\"", "]"}]}], ";", "\n", 
         RowBox[{"verbose", "=", 
          RowBox[{"OptionValue", "[", "\"\<Verbose\>\"", "]"}]}], ";", "\n", "\n", 
         RowBox[{"metafiles", "=", 
          RowBox[{"Flatten", "[", 
           RowBox[{
            RowBox[{
             RowBox[{
              RowBox[{"FileNames", "[", 
               RowBox[{"\"\<metadata.txt\>\"", ",", "#", ",", "4"}], "]"}], "&"}],
              "/@", "sxsdirout"}], ",", "1"}], "]"}]}], ";", "\n", 
         RowBox[{"metadata", "=", 
          RowBox[{
           RowBox[{
            RowBox[{"SXSMetaFilesToRules", "[", "#", "]"}], "&"}], "/@", 
           "metafiles"}]}], ";", "\n", 
         RowBox[{"mass1", "=", 
          RowBox[{"Flatten", "@", 
           RowBox[{"(", 
            RowBox[{
             RowBox[{
              RowBox[{"(", 
               RowBox[{"mass1Str", "/.", "#"}], ")"}], "&"}], "/@", "metadata"}], 
            ")"}]}]}], ";", "\n", 
         RowBox[{"mass2", "=", 
          RowBox[{"Flatten", "@", 
           RowBox[{"(", 
            RowBox[{
             RowBox[{
              RowBox[{"(", 
               RowBox[{"mass2Str", "/.", "#"}], ")"}], "&"}], "/@", "metadata"}], 
            ")"}]}]}], ";", "\n", 
         RowBox[{"massratio", "=", 
          RowBox[{"mass1", "/", "mass2"}]}], ";", "\n", 
         RowBox[{"dist", "=", 
          RowBox[{"Flatten", "@", 
           RowBox[{"(", 
            RowBox[{
             RowBox[{
              RowBox[{"(", 
               RowBox[{"dStr", "/.", "#"}], ")"}], "&"}], "/@", "metadata"}], 
            ")"}]}]}], ";", "\n", 
         RowBox[{"orbit", "=", 
          RowBox[{"Flatten", "@", 
           RowBox[{"(", 
            RowBox[{
             RowBox[{
              RowBox[{"(", 
               RowBox[{"orbitStr", "/.", "#"}], ")"}], "&"}], "/@", "metadata"}], 
            ")"}]}]}], ";", "\n", 
         RowBox[{"spin1Dim", "=", 
          RowBox[{"(", 
           RowBox[{
            RowBox[{
             RowBox[{"(", 
              RowBox[{"spin1Str", "/.", "#"}], ")"}], "&"}], "/@", "metadata"}], 
           ")"}]}], ";", "\n", 
         RowBox[{"spin2Dim", "=", 
          RowBox[{"(", 
           RowBox[{
            RowBox[{
             RowBox[{"(", 
              RowBox[{"spin2Str", "/.", "#"}], ")"}], "&"}], "/@", "metadata"}], 
           ")"}]}], ";", "\n", 
         RowBox[{"A1", "=", 
          RowBox[{"(", 
           RowBox[{"1", "+", 
            RowBox[{"3", " ", 
             RowBox[{"massratio", "/", 
              RowBox[{"(", "4.", ")"}]}]}]}], ")"}]}], ";", "\n", 
         RowBox[{"A2", "=", 
          RowBox[{"(", 
           RowBox[{"1", "+", 
            RowBox[{"3", " ", "/", 
             RowBox[{"(", 
              RowBox[{"4.", "*", "massratio"}], ")"}]}]}], " ", ")"}]}], ";", 
         "\n", 
         RowBox[{"\[Chi]eff", "=", 
          RowBox[{
           RowBox[{
            RowBox[{"massratio", "/", 
             RowBox[{"(", 
              RowBox[{"1.", "+", "massratio"}], ")"}]}], "*", "spin1Dim"}], " ", 
           "+", 
           RowBox[{
            RowBox[{"1.", "/", 
             RowBox[{"(", 
              RowBox[{"1", "+", "massratio"}], ")"}]}], "*", "spin2Dim"}]}]}], 
         ";", "\n", 
         RowBox[{"eccentricity", "=", 
          RowBox[{"Flatten", "[", 
           RowBox[{
            RowBox[{
             RowBox[{"(", 
              RowBox[{"eccStr", "/.", "#"}], ")"}], "&"}], "/@", "metadata"}], 
           "]"}]}], ";", "\n", 
         RowBox[{"spinz", "=", 
          RowBox[{"Chop", "/@", 
           RowBox[{"Transpose", "[", 
            RowBox[{"{", 
             RowBox[{
              RowBox[{"TakeColumn", "[", 
               RowBox[{"spin1Dim", ",", "3"}], "]"}], ",", 
              RowBox[{"TakeColumn", "[", 
               RowBox[{"spin2Dim", ",", "3"}], "]"}]}], "}"}], "]"}]}]}], ";", 
         "\n", 
         RowBox[{"spinzDiff", "=", 
          RowBox[{"Abs", "[", 
           RowBox[{
            RowBox[{
             RowBox[{"(", 
              RowBox[{
               RowBox[{"#", "[", 
                RowBox[{"[", "2", "]"}], "]"}], "-", 
               RowBox[{"#", "[", 
                RowBox[{"[", "1", "]"}], "]"}]}], ")"}], "&"}], "/@", "spinz"}], 
           "]"}]}], ";", "\n", 
         RowBox[{"condition", "=", 
          RowBox[{"ClassStr", "[", 
           RowBox[{"[", 
            RowBox[{"All", ",", "1"}], "]"}], "]"}]}], ";", "\n", 
         RowBox[{"select", "=", 
          RowBox[{"Table", "[", 
           RowBox[{
            RowBox[{"If", "[", 
             RowBox[{
              RowBox[{
               RowBox[{"Length", "@", 
                RowBox[{"ClassStr", "[", 
                 RowBox[{"[", "i", "]"}], "]"}]}], "==", "2"}], ",", 
              RowBox[{"ToExpression", "@", 
               RowBox[{"(", 
                RowBox[{"ClassStr", "[", 
                 RowBox[{"[", 
                  RowBox[{"i", ",", "2"}], "]"}], "]"}], ")"}]}], ",", 
              "\"\<Null\>\""}], "]"}], ",", 
            RowBox[{"{", 
             RowBox[{"i", ",", "1", ",", 
              RowBox[{"Length", "@", "ClassStr"}]}], "}"}]}], "]"}]}], ";", "\n", 
         
         RowBox[{"pos", "=", 
          RowBox[{"Table", "[", 
           RowBox[{"i", ",", 
            RowBox[{"{", 
             RowBox[{"i", ",", 
              RowBox[{"Length", "@", "sxsdirout"}]}], "}"}]}], "]"}]}], ";", "\n",
          "\n", 
         RowBox[{"Do", "[", "\n", "\n", 
          RowBox[{
           RowBox[{
            RowBox[{"Which", "[", 
             RowBox[{
              RowBox[{
               RowBox[{"condition", "[", 
                RowBox[{"[", "i", "]"}], "]"}], "==", "\"\<MassRatio\>\""}], ",", 
              "\n", "\n", 
              RowBox[{
               RowBox[{"If", "[", 
                RowBox[{
                 RowBox[{
                  RowBox[{"Length", "@", 
                   RowBox[{"ClassStr", "[", 
                    RowBox[{"[", "i", "]"}], "]"}]}], "!=", " ", "2"}], ",", 
                 RowBox[{
                  RowBox[{"Print", "[", "\"\<Wrong input\>\"", "]"}], ";", 
                  RowBox[{"Break", "[", "]"}]}]}], "]"}], ";", "\n", "\n", 
               RowBox[{"pos", "=", 
                RowBox[{"Flatten", "@", 
                 RowBox[{"Position", "[", 
                  RowBox[{"massratio", ",", 
                   RowBox[{"_", "?", 
                    RowBox[{"(", 
                     RowBox[{
                      RowBox[{"Evaluate", "[", 
                       RowBox[{"select", "[", 
                        RowBox[{"[", "i", "]"}], "]"}], "]"}], "&"}], ")"}]}]}], 
                  "]"}]}]}], ";", "\n", 
               RowBox[{"massratio", "=", 
                RowBox[{"massratio", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"dist", "=", 
                RowBox[{"dist", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"orbit", "=", 
                RowBox[{"orbit", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"spin1Dim", "=", 
                RowBox[{"spin1Dim", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"spin2Dim", "=", 
                RowBox[{"spin2Dim", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"A1", "=", 
                RowBox[{"A1", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"A2", "=", 
                RowBox[{"A2", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"spinzDiff", "=", 
                RowBox[{"spinzDiff", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"eccentricity", "=", 
                RowBox[{"eccentricity", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"\[Chi]eff", "=", 
                RowBox[{"\[Chi]eff", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"sxsdirout", "=", 
                RowBox[{"sxsdirout", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";"}], ",", "\n", "\n", 
              RowBox[{
               RowBox[{"condition", "[", 
                RowBox[{"[", "i", "]"}], "]"}], "==", " ", "\"\<Distance\>\""}], 
              ",", "\n", "\n", 
              RowBox[{
               RowBox[{"If", "[", 
                RowBox[{
                 RowBox[{
                  RowBox[{"Length", "@", 
                   RowBox[{"ClassStr", "[", 
                    RowBox[{"[", "i", "]"}], "]"}]}], "!=", " ", "2"}], ",", 
                 RowBox[{
                  RowBox[{"Print", "[", "\"\<Wrong input\>\"", "]"}], ";", 
                  RowBox[{"Break", "[", "]"}]}]}], "]"}], ";", "\n", "\n", 
               RowBox[{"pos", "=", 
                RowBox[{"Flatten", "@", 
                 RowBox[{"Position", "[", 
                  RowBox[{
                   RowBox[{
                    RowBox[{"sxsdirout", "=", 
                     RowBox[{"sxsdirout", "[", 
                      RowBox[{"[", "pos", "]"}], "]"}]}], ";"}], ",", 
                   RowBox[{"_", "?", 
                    RowBox[{"(", 
                     RowBox[{
                      RowBox[{"Evaluate", "[", 
                       RowBox[{"select", "[", 
                        RowBox[{"[", "i", "]"}], "]"}], "]"}], "&"}], ")"}]}]}], 
                  "]"}]}]}], ";", "\n", 
               RowBox[{"massratio", "=", 
                RowBox[{"massratio", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"dist", "=", 
                RowBox[{"dist", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"orbit", "=", 
                RowBox[{"orbit", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"spin1Dim", "=", 
                RowBox[{"spin1Dim", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"spin2Dim", "=", 
                RowBox[{"spin2Dim", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"A1", "=", 
                RowBox[{"A1", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"A2", "=", 
                RowBox[{"A2", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"spinzDiff", "=", 
                RowBox[{"spinzDiff", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"eccentricity", "=", 
                RowBox[{"eccentricity", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"\[Chi]eff", "=", 
                RowBox[{"\[Chi]eff", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", "\n", 
               RowBox[{"sxsdirout", "=", 
                RowBox[{"sxsdirout", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";"}], ",", "\n", "\n", 
              RowBox[{
               RowBox[{"condition", "[", 
                RowBox[{"[", "i", "]"}], "]"}], "==", " ", "\"\<Orbits\>\""}], 
              ",", "\n", "\n", 
              RowBox[{
               RowBox[{"If", "[", 
                RowBox[{
                 RowBox[{
                  RowBox[{"Length", "@", 
                   RowBox[{"ClassStr", "[", 
                    RowBox[{"[", "i", "]"}], "]"}]}], "!=", " ", "2"}], ",", 
                 RowBox[{
                  RowBox[{"Print", "[", "\"\<Wrong input\>\"", "]"}], ";", 
                  RowBox[{"Break", "[", "]"}]}]}], "]"}], ";", "\n", "\n", 
               RowBox[{"pos", "=", 
                RowBox[{"Flatten", "@", 
                 RowBox[{"Position", "[", 
                  RowBox[{"orbit", ",", 
                   RowBox[{"_", "?", 
                    RowBox[{"(", 
                     RowBox[{
                      RowBox[{"Evaluate", "[", 
                       RowBox[{"select", "[", 
                        RowBox[{"[", "i", "]"}], "]"}], "]"}], "&"}], ")"}]}]}], 
                  "]"}]}]}], ";", "\n", 
               RowBox[{"massratio", "=", 
                RowBox[{"massratio", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"dist", "=", 
                RowBox[{"dist", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"orbit", "=", 
                RowBox[{"orbit", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"spin1Dim", "=", 
                RowBox[{"spin1Dim", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"spin2Dim", "=", 
                RowBox[{"spin2Dim", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"A1", "=", 
                RowBox[{"A1", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"A2", "=", 
                RowBox[{"A2", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"spinzDiff", "=", 
                RowBox[{"spinzDiff", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"eccentricity", "=", 
                RowBox[{"eccentricity", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"\[Chi]eff", "=", 
                RowBox[{"\[Chi]eff", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", "\n", 
               RowBox[{"sxsdirout", "=", 
                RowBox[{"sxsdirout", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";"}], ",", "\n", "\n", 
              RowBox[{
               RowBox[{"condition", "[", 
                RowBox[{"[", "i", "]"}], "]"}], "==", " ", 
               "\"\<Non-Precessing\>\""}], ",", "\n", "\n", 
              RowBox[{"(*", 
               RowBox[{
                RowBox[{"precvalue", "=", 
                 RowBox[{
                  RowBox[{
                   RowBox[{
                    RowBox[{"(", "#", ")"}], "\[Cross]", 
                    RowBox[{"{", 
                     RowBox[{"0", ",", "0", ",", "1"}], "}"}]}], "&"}], "/@", 
                  RowBox[{"(", 
                   RowBox[{
                    RowBox[{
                     RowBox[{"(", "spin1Dim", ")"}], "A1"}], "+", 
                    RowBox[{
                     RowBox[{"(", "spin2Dim", ")"}], "A2"}]}], ")"}]}]}], ";"}], 
               "*)"}], "\n", 
              RowBox[{
               RowBox[{"precvalue1", "=", 
                RowBox[{
                 RowBox[{
                  RowBox[{
                   RowBox[{"(", "#", ")"}], "\[Cross]", 
                   RowBox[{"{", 
                    RowBox[{"0", ",", "0", ",", "1"}], "}"}]}], "&"}], "/@", 
                 RowBox[{"(", 
                  RowBox[{
                   RowBox[{"(", "spin1Dim", ")"}], "A1"}], ")"}]}]}], ";", "\n", 
               RowBox[{"precvalue2", "=", 
                RowBox[{
                 RowBox[{
                  RowBox[{
                   RowBox[{"(", "#", ")"}], "\[Cross]", 
                   RowBox[{"{", 
                    RowBox[{"0", ",", "0", ",", "1"}], "}"}]}], "&"}], "/@", 
                 RowBox[{"(", 
                  RowBox[{
                   RowBox[{"(", "spin2Dim", ")"}], "A2"}], ")"}]}]}], ";", "\n", 
               RowBox[{"precvalueNorm1", "=", 
                RowBox[{
                 RowBox[{
                  RowBox[{"Norm", "[", "#", "]"}], "&"}], "/@", "precvalue1"}]}], 
               ";", "\n", 
               RowBox[{"precvalueNorm2", "=", 
                RowBox[{
                 RowBox[{
                  RowBox[{"Norm", "[", "#", "]"}], "&"}], "/@", "precvalue2"}]}], 
               ";", "\n", 
               RowBox[{"precvalueNorm", "=", 
                RowBox[{
                 RowBox[{"precvalueNorm1", "^", "2"}], "+", 
                 RowBox[{"precvalueNorm2", "^", "2"}]}]}], ";", "\n", 
               RowBox[{"pos", "=", 
                RowBox[{"Flatten", "@", 
                 RowBox[{"Position", "[", 
                  RowBox[{"precvalueNorm", ",", 
                   RowBox[{"_", "?", 
                    RowBox[{"(", 
                     RowBox[{
                      RowBox[{"#", "<", "\[Epsilon]"}], " ", "&"}], ")"}]}]}], 
                  "]"}]}]}], ";", "\n", "\n", 
               RowBox[{"massratio", "=", 
                RowBox[{"massratio", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"dist", "=", 
                RowBox[{"dist", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"orbit", "=", 
                RowBox[{"orbit", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"spin1Dim", "=", 
                RowBox[{"spin1Dim", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"spin2Dim", "=", 
                RowBox[{"spin2Dim", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"A1", "=", 
                RowBox[{"A1", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"A2", "=", 
                RowBox[{"A2", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"spinzDiff", "=", 
                RowBox[{"spinzDiff", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"eccentricity", "=", 
                RowBox[{"eccentricity", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"\[Chi]eff", "=", 
                RowBox[{"\[Chi]eff", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", "\n", 
               RowBox[{"sxsdirout", "=", 
                RowBox[{"sxsdirout", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";"}], ",", "\n", "\n", 
              RowBox[{
               RowBox[{"condition", "[", 
                RowBox[{"[", "i", "]"}], "]"}], "==", " ", "\"\<Unequal\>\""}], 
              ",", "\n", "\n", 
              RowBox[{
               RowBox[{"pos", "=", 
                RowBox[{"Flatten", "@", 
                 RowBox[{"Position", "[", 
                  RowBox[{"spinzDiff", ",", 
                   RowBox[{"_", "?", 
                    RowBox[{"(", 
                     RowBox[{
                      RowBox[{"#", ">", "\[Epsilon]"}], " ", "&"}], ")"}]}]}], 
                  "]"}]}]}], ";", "\n", "\n", 
               RowBox[{"massratio", "=", 
                RowBox[{"massratio", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"dist", "=", 
                RowBox[{"dist", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"orbit", "=", 
                RowBox[{"orbit", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"spin1Dim", "=", 
                RowBox[{"spin1Dim", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"spin2Dim", "=", 
                RowBox[{"spin2Dim", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"A1", "=", 
                RowBox[{"A1", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"A2", "=", 
                RowBox[{"A2", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"spinzDiff", "=", 
                RowBox[{"spinzDiff", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"eccentricity", "=", 
                RowBox[{"eccentricity", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"\[Chi]eff", "=", 
                RowBox[{"\[Chi]eff", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", "\n", 
               RowBox[{"sxsdirout", "=", 
                RowBox[{"sxsdirout", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";"}], ",", "\n", "\n", 
              RowBox[{
               RowBox[{"condition", "[", 
                RowBox[{"[", "i", "]"}], "]"}], "==", "\"\<Precessing\>\""}], ",",
               "\n", "\n", 
              RowBox[{
               RowBox[{"precvalue1", "=", 
                RowBox[{
                 RowBox[{
                  RowBox[{
                   RowBox[{"(", "#", ")"}], "\[Cross]", 
                   RowBox[{"{", 
                    RowBox[{"0", ",", "0", ",", "1"}], "}"}]}], "&"}], "/@", 
                 RowBox[{"(", 
                  RowBox[{
                   RowBox[{"(", "spin1Dim", ")"}], "A1"}], ")"}]}]}], ";", "\n", 
               RowBox[{"precvalue2", "=", 
                RowBox[{
                 RowBox[{
                  RowBox[{
                   RowBox[{"(", "#", ")"}], "\[Cross]", 
                   RowBox[{"{", 
                    RowBox[{"0", ",", "0", ",", "1"}], "}"}]}], "&"}], "/@", 
                 RowBox[{"(", 
                  RowBox[{
                   RowBox[{"(", "spin2Dim", ")"}], "A2"}], ")"}]}]}], ";", "\n", 
               RowBox[{"precvalueNorm1", "=", 
                RowBox[{
                 RowBox[{
                  RowBox[{"Norm", "[", "#", "]"}], "&"}], "/@", "precvalue1"}]}], 
               ";", "\n", 
               RowBox[{"precvalueNorm2", "=", 
                RowBox[{
                 RowBox[{
                  RowBox[{"Norm", "[", "#", "]"}], "&"}], "/@", "precvalue2"}]}], 
               ";", "\n", 
               RowBox[{"precvalueNorm", "=", 
                RowBox[{
                 RowBox[{"precvalueNorm1", "^", "2"}], "+", 
                 RowBox[{"precvalueNorm2", "^", "2"}]}]}], ";", "\n", "\n", 
               RowBox[{"(*", 
                RowBox[{
                 RowBox[{"precvalue", "=", 
                  RowBox[{
                   RowBox[{
                    RowBox[{
                     RowBox[{"(", "#", ")"}], "\[Cross]", 
                     RowBox[{"{", 
                      RowBox[{"0", ",", "0", ",", "1"}], "}"}]}], "&"}], "/@", 
                   RowBox[{"(", 
                    RowBox[{
                     RowBox[{
                      RowBox[{"(", "spin1Dim", ")"}], "A1"}], "+", 
                     RowBox[{
                      RowBox[{"(", "spin2Dim", ")"}], "A2"}]}], ")"}]}]}], ";"}], 
                "*)"}], "\n", "\n", 
               RowBox[{"pos", "=", 
                RowBox[{"Flatten", "@", 
                 RowBox[{"Position", "[", 
                  RowBox[{"precvalueNorm", ",", 
                   RowBox[{"_", "?", 
                    RowBox[{"(", 
                     RowBox[{
                      RowBox[{"#", ">", "\[Epsilon]"}], " ", "&"}], ")"}]}]}], 
                  "]"}]}]}], ";", "\n", 
               RowBox[{"massratio", "=", 
                RowBox[{"massratio", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"dist", "=", 
                RowBox[{"dist", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"orbit", "=", 
                RowBox[{"orbit", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"spin1Dim", "=", 
                RowBox[{"spin1Dim", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"spin2Dim", "=", 
                RowBox[{"spin2Dim", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"A1", "=", 
                RowBox[{"A1", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"A2", "=", 
                RowBox[{"A2", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"spinzDiff", "=", 
                RowBox[{"spinzDiff", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"eccentricity", "=", 
                RowBox[{"eccentricity", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"\[Chi]eff", "=", 
                RowBox[{"\[Chi]eff", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", "\n", 
               RowBox[{"sxsdirout", "=", 
                RowBox[{"sxsdirout", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";"}], ",", "\n", "\n", 
              RowBox[{
               RowBox[{"condition", "[", 
                RowBox[{"[", "i", "]"}], "]"}], "==", " ", "\"\<High-Spin\>\""}], 
              ",", "\n", "\n", 
              RowBox[{
               RowBox[{"spin1Norm", "=", 
                RowBox[{
                 RowBox[{
                  RowBox[{"Norm", "[", "#", "]"}], "&"}], "/@", "spin1Dim"}]}], 
               ";", "\n", 
               RowBox[{"spin2Norm", "=", 
                RowBox[{
                 RowBox[{
                  RowBox[{"Norm", "[", "#", "]"}], "&"}], "/@", "spin2Dim"}]}], 
               ";", "\n", "\n", 
               RowBox[{"spintest", "=", 
                RowBox[{"Table", "[", 
                 RowBox[{
                  RowBox[{"If", "[", 
                   RowBox[{
                    RowBox[{
                     RowBox[{
                      RowBox[{"Abs", "@", 
                       RowBox[{"spin1Norm", "[", 
                        RowBox[{"[", "i", "]"}], "]"}]}], ">=", "highspin"}], " ",
                      "||", " ", 
                     RowBox[{
                      RowBox[{"Abs", "@", 
                       RowBox[{"spin2Norm", "[", 
                        RowBox[{"[", "i", "]"}], "]"}]}], ">=", "highspin"}]}], 
                    ",", "True", ",", "False"}], "]"}], ",", 
                  RowBox[{"{", 
                   RowBox[{"i", ",", "1", ",", 
                    RowBox[{"Length", "@", "spin1Norm"}]}], "}"}]}], "]"}]}], ";",
                "\n", 
               RowBox[{"pos", "=", 
                RowBox[{"Flatten", "@", 
                 RowBox[{"Position", "[", 
                  RowBox[{"spintest", ",", "True"}], "]"}]}]}], ";", "\n", 
               RowBox[{"massratio", "=", 
                RowBox[{"massratio", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"dist", "=", 
                RowBox[{"dist", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"orbit", "=", 
                RowBox[{"orbit", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"spin1Dim", "=", 
                RowBox[{"spin1Dim", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"spin2Dim", "=", 
                RowBox[{"spin2Dim", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"A1", "=", 
                RowBox[{"A1", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"A2", "=", 
                RowBox[{"A2", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"spinzDiff", "=", 
                RowBox[{"spinzDiff", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"eccentricity", "=", 
                RowBox[{"eccentricity", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"\[Chi]eff", "=", 
                RowBox[{"\[Chi]eff", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", "\n", 
               RowBox[{"sxsdirout", "=", 
                RowBox[{"sxsdirout", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";"}], ",", "\n", "\n", 
              RowBox[{
               RowBox[{"condition", "[", 
                RowBox[{"[", "i", "]"}], "]"}], "==", " ", "\"\<\[Chi]eff\>\""}], 
              ",", "\n", "\n", 
              RowBox[{
               RowBox[{"If", "[", 
                RowBox[{
                 RowBox[{
                  RowBox[{"Length", "@", 
                   RowBox[{"ClassStr", "[", 
                    RowBox[{"[", "i", "]"}], "]"}]}], "!=", " ", "2"}], ",", 
                 RowBox[{
                  RowBox[{"Print", "[", "\"\<Wrong input\>\"", "]"}], ";", 
                  RowBox[{"Break", "[", "]"}]}]}], "]"}], ";", "\n", "\n", 
               RowBox[{"pos", "=", 
                RowBox[{"Flatten", "@", 
                 RowBox[{"Position", "[", 
                  RowBox[{
                   RowBox[{
                    RowBox[{
                     RowBox[{"Norm", "[", "#", "]"}], "&"}], "/@", "\[Chi]eff"}], 
                   ",", 
                   RowBox[{"_", "?", 
                    RowBox[{"(", 
                     RowBox[{
                      RowBox[{"Evaluate", "[", 
                       RowBox[{"select", "[", 
                        RowBox[{"[", "i", "]"}], "]"}], "]"}], " ", "&"}], 
                     ")"}]}]}], "]"}]}]}], ";", "\n", 
               RowBox[{"massratio", "=", 
                RowBox[{"massratio", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"dist", "=", 
                RowBox[{"dist", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"orbit", "=", 
                RowBox[{"orbit", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"spin1Dim", "=", 
                RowBox[{"spin1Dim", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"spin2Dim", "=", 
                RowBox[{"spin2Dim", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"A1", "=", 
                RowBox[{"A1", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"A2", "=", 
                RowBox[{"A2", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"spinzDiff", "=", 
                RowBox[{"spinzDiff", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"eccentricity", "=", 
                RowBox[{"eccentricity", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"\[Chi]eff", "=", 
                RowBox[{"\[Chi]eff", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", "\n", 
               RowBox[{"sxsdirout", "=", 
                RowBox[{"sxsdirout", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";"}], ",", "\n", "\n", 
              RowBox[{
               RowBox[{"condition", "[", 
                RowBox[{"[", "i", "]"}], "]"}], "==", " ", "\"\<\[Chi]1\>\""}], 
              ",", "\n", "\n", 
              RowBox[{
               RowBox[{"If", "[", 
                RowBox[{
                 RowBox[{
                  RowBox[{"Length", "@", 
                   RowBox[{"ClassStr", "[", 
                    RowBox[{"[", "i", "]"}], "]"}]}], "!=", " ", "2"}], ",", 
                 RowBox[{
                  RowBox[{"Print", "[", "\"\<Wrong input\>\"", "]"}], ";", 
                  RowBox[{"Break", "[", "]"}]}]}], "]"}], ";", "\n", "\n", 
               RowBox[{"pos", "=", 
                RowBox[{"Flatten", "@", 
                 RowBox[{"Position", "[", 
                  RowBox[{
                   RowBox[{
                    RowBox[{
                     RowBox[{"Norm", "[", "#", "]"}], "&"}], "/@", "spin1Dim"}], 
                   ",", 
                   RowBox[{"_", "?", 
                    RowBox[{"(", 
                     RowBox[{
                      RowBox[{"Evaluate", "[", 
                       RowBox[{"select", "[", 
                        RowBox[{"[", "i", "]"}], "]"}], "]"}], " ", "&"}], 
                     ")"}]}]}], "]"}]}]}], ";", "\n", 
               RowBox[{"massratio", "=", 
                RowBox[{"massratio", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"dist", "=", 
                RowBox[{"dist", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"orbit", "=", 
                RowBox[{"orbit", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"spin1Dim", "=", 
                RowBox[{"spin1Dim", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"spin2Dim", "=", 
                RowBox[{"spin2Dim", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"A1", "=", 
                RowBox[{"A1", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"A2", "=", 
                RowBox[{"A2", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"spinzDiff", "=", 
                RowBox[{"spinzDiff", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"eccentricity", "=", 
                RowBox[{"eccentricity", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"\[Chi]eff", "=", 
                RowBox[{"\[Chi]eff", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", "\n", 
               RowBox[{"sxsdirout", "=", 
                RowBox[{"sxsdirout", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";"}], ",", "\n", "\n", 
              RowBox[{
               RowBox[{"condition", "[", 
                RowBox[{"[", "i", "]"}], "]"}], "==", " ", "\"\<\[Chi]2\>\""}], 
              ",", "\n", "\n", 
              RowBox[{
               RowBox[{"If", "[", 
                RowBox[{
                 RowBox[{
                  RowBox[{"Length", "@", 
                   RowBox[{"ClassStr", "[", 
                    RowBox[{"[", "i", "]"}], "]"}]}], "!=", " ", "2"}], ",", 
                 RowBox[{
                  RowBox[{"Print", "[", "\"\<Wrong input\>\"", "]"}], ";", 
                  RowBox[{"Break", "[", "]"}]}]}], "]"}], ";", "\n", "\n", 
               RowBox[{"pos", "=", 
                RowBox[{"Flatten", "@", 
                 RowBox[{"Position", "[", 
                  RowBox[{
                   RowBox[{
                    RowBox[{
                     RowBox[{"Norm", "[", "#", "]"}], "&"}], "/@", "spin2Dim"}], 
                   ",", 
                   RowBox[{"_", "?", 
                    RowBox[{"(", 
                     RowBox[{
                      RowBox[{"Evaluate", "[", 
                       RowBox[{"select", "[", 
                        RowBox[{"[", "i", "]"}], "]"}], "]"}], " ", "&"}], 
                     ")"}]}]}], "]"}]}]}], ";", "\n", 
               RowBox[{"massratio", "=", 
                RowBox[{"massratio", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"dist", "=", 
                RowBox[{"dist", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"orbit", "=", 
                RowBox[{"orbit", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"spin1Dim", "=", 
                RowBox[{"spin1Dim", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"spin2Dim", "=", 
                RowBox[{"spin2Dim", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"A1", "=", 
                RowBox[{"A1", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"A2", "=", 
                RowBox[{"A2", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"spinzDiff", "=", 
                RowBox[{"spinzDiff", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"eccentricity", "=", 
                RowBox[{"eccentricity", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"\[Chi]eff", "=", 
                RowBox[{"\[Chi]eff", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", "\n", 
               RowBox[{"sxsdirout", "=", 
                RowBox[{"sxsdirout", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";"}], ",", "\n", "\n", "\n", 
              RowBox[{
               RowBox[{"condition", "[", 
                RowBox[{"[", "i", "]"}], "]"}], "==", " ", 
               "\"\<relaxed-eccentricity\>\""}], ",", "\n", "\n", 
              RowBox[{
               RowBox[{"If", "[", 
                RowBox[{
                 RowBox[{
                  RowBox[{"Length", "@", 
                   RowBox[{"ClassStr", "[", 
                    RowBox[{"[", "i", "]"}], "]"}]}], "!=", " ", "2"}], ",", 
                 RowBox[{
                  RowBox[{"Print", "[", "\"\<Wrong input\>\"", "]"}], ";", 
                  RowBox[{"Break", "[", "]"}]}]}], "]"}], ";", "\n", "\n", 
               RowBox[{"pos", "=", 
                RowBox[{"Flatten", "@", 
                 RowBox[{"Position", "[", 
                  RowBox[{"eccentricity", ",", 
                   RowBox[{"_", "?", 
                    RowBox[{"(", 
                     RowBox[{
                      RowBox[{"Evaluate", "[", 
                       RowBox[{"select", "[", 
                        RowBox[{"[", "i", "]"}], "]"}], "]"}], " ", "&"}], 
                     ")"}]}]}], "]"}]}]}], ";", "\n", 
               RowBox[{"massratio", "=", 
                RowBox[{"massratio", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"dist", "=", 
                RowBox[{"dist", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"orbit", "=", 
                RowBox[{"orbit", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"spin1Dim", "=", 
                RowBox[{"spin1Dim", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"spin2Dim", "=", 
                RowBox[{"spin2Dim", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"A1", "=", 
                RowBox[{"A1", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"A2", "=", 
                RowBox[{"A2", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"spinzDiff", "=", 
                RowBox[{"spinzDiff", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"eccentricity", "=", 
                RowBox[{"eccentricity", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", 
               RowBox[{"\[Chi]eff", "=", 
                RowBox[{"\[Chi]eff", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";", "\n", "\n", 
               RowBox[{"sxsdirout", "=", 
                RowBox[{"sxsdirout", "[", 
                 RowBox[{"[", "pos", "]"}], "]"}]}], ";"}], ",", "\n", " ", 
              "True", ",", "\n", 
              RowBox[{
               RowBox[{"Print", "[", 
                RowBox[{"Style", "[", 
                 RowBox[{
                 "\"\<Wrong input\>\"", ",", "Bold", ",", "Red", ",", "16"}], 
                 "]"}], "]"}], ";", "\n", 
               RowBox[{"Break", "[", "]"}], ";"}]}], "\n", "]"}], ";"}], "\n", 
           ",", 
           RowBox[{"{", 
            RowBox[{"i", ",", "1", ",", 
             RowBox[{"Length", "@", "ClassStr"}]}], "}"}]}], "]"}], ";", "\n", 
         "\n", "\n", 
         RowBox[{"If", "[", 
          RowBox[{"unrepeated", ",", "\n", "\n", 
           RowBox[{
            RowBox[{
            "Print", "[", 
             "\"\<Taking among the repeated cases only those with lower \
    eccentricity and larger D (just in case ei=ej)\>\"", "]"}], ";", "\n", "\n", 
            RowBox[{"(*", " ", 
             RowBox[{
             "Selecting", " ", "Case", " ", "with", " ", "lower", " ", "e"}], " ",
              "*)"}], "\n", 
            RowBox[{"auxDist", "=", 
             RowBox[{"Transpose", "[", 
              RowBox[{"{", 
               RowBox[{
                RowBox[{"Round", "[", 
                 RowBox[{
                  RowBox[{
                   RowBox[{"#", "&"}], "/@", "massratio"}], ",", "0.1"}], "]"}], 
                ",", 
                RowBox[{
                 RowBox[{
                  RowBox[{"Round", "[", 
                   RowBox[{
                    RowBox[{"Chop", "[", 
                     RowBox[{"#", ",", 
                      RowBox[{"10", "^", 
                       RowBox[{"(", 
                        RowBox[{"-", "2"}], ")"}]}]}], "]"}], ",", "0.01"}], 
                   "]"}], "&"}], "/@", "spin1Dim"}], ",", 
                RowBox[{
                 RowBox[{
                  RowBox[{"Round", "[", 
                   RowBox[{
                    RowBox[{"Chop", "[", 
                     RowBox[{"#", ",", 
                      RowBox[{"10", "^", 
                       RowBox[{"(", 
                        RowBox[{"-", "2"}], ")"}]}]}], "]"}], ",", "0.01"}], 
                   "]"}], "&"}], "/@", "spin2Dim"}], ",", "dist", ",", 
                "eccentricity"}], "}"}], "]"}]}], ";", "\n", 
            RowBox[{"posdup", "=", 
             RowBox[{"positionDuplicates", "@", 
              RowBox[{"auxDist", "[", 
               RowBox[{"[", 
                RowBox[{"All", ",", 
                 RowBox[{"1", ";;", "3"}]}], "]"}], "]"}]}]}], ";", "\n", 
            RowBox[{"posdistecc", "=", 
             RowBox[{
              RowBox[{
               RowBox[{"Flatten", "[", 
                RowBox[{"#", ",", "1"}], "]"}], "&"}], "/@", 
              RowBox[{"Table", "[", 
               RowBox[{
                RowBox[{"Position", "[", 
                 RowBox[{
                  RowBox[{"auxDist", "[", 
                   RowBox[{"[", 
                    RowBox[{
                     RowBox[{"posdup", "[", 
                      RowBox[{"[", "i", "]"}], "]"}], ",", "5"}], "]"}], "]"}], 
                  ",", 
                  RowBox[{"Min", "@", 
                   RowBox[{"auxDist", "[", 
                    RowBox[{"[", 
                     RowBox[{
                      RowBox[{"posdup", "[", 
                       RowBox[{"[", "i", "]"}], "]"}], ",", "5"}], "]"}], 
                    "]"}]}]}], "]"}], ",", 
                RowBox[{"{", 
                 RowBox[{"i", ",", "1", ",", 
                  RowBox[{"Length", "@", "posdup"}]}], "}"}]}], "]"}]}]}], ";", 
            "\n", 
            RowBox[{"posdistecc", "=", 
             RowBox[{"Flatten", "@", 
              RowBox[{"Table", "[", 
               RowBox[{
                RowBox[{"posdup", "[", 
                 RowBox[{"[", 
                  RowBox[{"i", ",", 
                   RowBox[{"posdistecc", "[", 
                    RowBox[{"[", "i", "]"}], "]"}]}], "]"}], "]"}], ",", 
                RowBox[{"{", 
                 RowBox[{"i", ",", "1", ",", 
                  RowBox[{"Length", "@", "posdup"}]}], "}"}]}], "]"}]}]}], ";", 
            "\n", 
            RowBox[{"sxsdirout", "=", 
             RowBox[{"sxsdirout", "[", 
              RowBox[{"[", "posdistecc", "]"}], "]"}]}], ";", "\n", "\n", 
            RowBox[{"(*", " ", 
             RowBox[{
             "Selecting", " ", "Case", " ", "with", " ", "larger", " ", "D"}], 
             " ", "*)"}], "\n", 
            RowBox[{"auxDist", "=", 
             RowBox[{"auxDist", "[", 
              RowBox[{"[", "posdistecc", "]"}], "]"}]}], ";", "\n", 
            RowBox[{"posdup", "=", 
             RowBox[{"positionDuplicates", "@", 
              RowBox[{"auxDist", "[", 
               RowBox[{"[", 
                RowBox[{"All", ",", 
                 RowBox[{"1", ";;", "3"}]}], "]"}], "]"}]}]}], ";", "\n", 
            RowBox[{"posdistecc", "=", 
             RowBox[{
              RowBox[{
               RowBox[{"Flatten", "[", 
                RowBox[{"#", ",", "1"}], "]"}], "&"}], "/@", 
              RowBox[{"Table", "[", 
               RowBox[{
                RowBox[{"Position", "[", 
                 RowBox[{
                  RowBox[{"auxDist", "[", 
                   RowBox[{"[", 
                    RowBox[{
                     RowBox[{"posdup", "[", 
                      RowBox[{"[", "i", "]"}], "]"}], ",", "4"}], "]"}], "]"}], 
                  ",", 
                  RowBox[{"Max", "@", 
                   RowBox[{"auxDist", "[", 
                    RowBox[{"[", 
                     RowBox[{
                      RowBox[{"posdup", "[", 
                       RowBox[{"[", "i", "]"}], "]"}], ",", "4"}], "]"}], 
                    "]"}]}]}], "]"}], ",", 
                RowBox[{"{", 
                 RowBox[{"i", ",", "1", ",", 
                  RowBox[{"Length", "@", "posdup"}]}], "}"}]}], "]"}]}]}], ";", 
            "\n", 
            RowBox[{"posdistecc", "=", 
             RowBox[{"Flatten", "@", 
              RowBox[{"Table", "[", 
               RowBox[{
                RowBox[{"posdup", "[", 
                 RowBox[{"[", 
                  RowBox[{"i", ",", 
                   RowBox[{"posdistecc", "[", 
                    RowBox[{"[", "i", "]"}], "]"}]}], "]"}], "]"}], ",", 
                RowBox[{"{", 
                 RowBox[{"i", ",", "1", ",", 
                  RowBox[{"Length", "@", "posdup"}]}], "}"}]}], "]"}]}]}], ";", 
            "\n", "\n", 
            RowBox[{"auxDist", "=", 
             RowBox[{"auxDist", "[", 
              RowBox[{"[", "posdistecc", "]"}], "]"}]}], ";", "\n", 
            RowBox[{"sxsdirout", "=", 
             RowBox[{"sxsdirout", "[", 
              RowBox[{"[", "posdistecc", "]"}], "]"}]}], ";", "\n", 
            RowBox[{"sxsdiroutaux", "=", 
             RowBox[{"SortBy", "[", 
              RowBox[{
               RowBox[{"Table", "[", 
                RowBox[{
                 RowBox[{"Join", "[", 
                  RowBox[{
                   RowBox[{"{", 
                    RowBox[{"sxsdirout", "[", 
                     RowBox[{"[", "i", "]"}], "]"}], "}"}], ",", 
                   RowBox[{"auxDist", "[", 
                    RowBox[{"[", "i", "]"}], "]"}]}], "]"}], ",", 
                 RowBox[{"{", 
                  RowBox[{"i", ",", "1", ",", 
                   RowBox[{"Length", "@", "sxsdirout"}]}], "}"}]}], "]"}], ",", 
               RowBox[{
                RowBox[{"#", "[", 
                 RowBox[{"[", "2", "]"}], "]"}], "&"}]}], "]"}]}], ";", "\n", 
            "\n", 
            RowBox[{"If", "[", 
             RowBox[{"verbose", ",", " ", "\n", 
              RowBox[{"Print", "[", 
               RowBox[{
                RowBox[{"Prepend", "[", 
                 RowBox[{
                  RowBox[{"Table", "[", 
                   RowBox[{
                    RowBox[{
                     RowBox[{
                      RowBox[{"ToString", "@", "#"}], "&"}], "/@", 
                     RowBox[{"sxsdiroutaux", "[", 
                      RowBox[{"[", "i", "]"}], "]"}]}], ",", 
                    RowBox[{"{", 
                     RowBox[{"i", ",", "1", ",", 
                      RowBox[{"Length", "@", "sxsdiroutaux"}]}], "}"}]}], "]"}], 
                  ",", 
                  RowBox[{"{", 
                   RowBox[{
                   "\"\<Case\>\"", ",", "\"\<q\>\"", ",", "\"\<\[Chi]1\>\"", ",", 
                    "\"\<\[Chi]2\>\"", ",", "\"\<D\>\"", ",", "\"\<e\>\""}], 
                   "}"}]}], "]"}], "//", "TableForm"}], "]"}]}], "]"}], ";", "\n",
             "\n", 
            RowBox[{"sxsdiroutaux", "[", 
             RowBox[{"[", 
              RowBox[{"All", ",", "1"}], "]"}], "]"}]}], ",", "\n", "\n", 
           RowBox[{
            RowBox[{"auxDist", "=", 
             RowBox[{"Transpose", "[", 
              RowBox[{"{", 
               RowBox[{
                RowBox[{"Round", "[", 
                 RowBox[{
                  RowBox[{
                   RowBox[{"#", "&"}], "/@", "massratio"}], ",", "0.1"}], "]"}], 
                ",", 
                RowBox[{
                 RowBox[{
                  RowBox[{"Round", "[", 
                   RowBox[{
                    RowBox[{"Chop", "[", 
                     RowBox[{"#", ",", 
                      RowBox[{"10", "^", 
                       RowBox[{"(", 
                        RowBox[{"-", "2"}], ")"}]}]}], "]"}], ",", "0.01"}], 
                   "]"}], "&"}], "/@", "spin1Dim"}], ",", 
                RowBox[{
                 RowBox[{
                  RowBox[{"Round", "[", 
                   RowBox[{
                    RowBox[{"Chop", "[", 
                     RowBox[{"#", ",", 
                      RowBox[{"10", "^", 
                       RowBox[{"(", 
                        RowBox[{"-", "2"}], ")"}]}]}], "]"}], ",", "0.01"}], 
                   "]"}], "&"}], "/@", "spin2Dim"}], ",", "dist", ",", 
                "eccentricity"}], "}"}], "]"}]}], ";", "\n", 
            RowBox[{"(*", 
             RowBox[{
              RowBox[{"sxsdiroutaux", "=", 
               RowBox[{"Table", "[", 
                RowBox[{
                 RowBox[{"Join", "[", 
                  RowBox[{
                   RowBox[{"{", 
                    RowBox[{"sxsdirout", "[", 
                     RowBox[{"[", "i", "]"}], "]"}], "}"}], ",", 
                   RowBox[{"auxDist", "[", 
                    RowBox[{"[", "i", "]"}], "]"}]}], "]"}], ",", 
                 RowBox[{"{", 
                  RowBox[{"i", ",", "1", ",", 
                   RowBox[{"Length", "@", "sxsdirout"}]}], "}"}]}], "]"}]}], 
              ";"}], "*)"}], "\n", 
            RowBox[{"sxsdiroutaux", "=", 
             RowBox[{"SortBy", "[", 
              RowBox[{
               RowBox[{"Table", "[", 
                RowBox[{
                 RowBox[{"Join", "[", 
                  RowBox[{
                   RowBox[{"{", 
                    RowBox[{"sxsdirout", "[", 
                     RowBox[{"[", "i", "]"}], "]"}], "}"}], ",", 
                   RowBox[{"auxDist", "[", 
                    RowBox[{"[", "i", "]"}], "]"}]}], "]"}], ",", 
                 RowBox[{"{", 
                  RowBox[{"i", ",", "1", ",", 
                   RowBox[{"Length", "@", "sxsdirout"}]}], "}"}]}], "]"}], ",", 
               RowBox[{
                RowBox[{"#", "[", 
                 RowBox[{"[", "2", "]"}], "]"}], "&"}]}], "]"}]}], ";", "\n", 
            RowBox[{"If", "[", 
             RowBox[{"verbose", ",", " ", "\n", 
              RowBox[{"Print", "[", 
               RowBox[{
                RowBox[{"Prepend", "[", 
                 RowBox[{
                  RowBox[{"Table", "[", 
                   RowBox[{
                    RowBox[{
                     RowBox[{
                      RowBox[{"ToString", "@", "#"}], "&"}], "/@", 
                     RowBox[{"sxsdiroutaux", "[", 
                      RowBox[{"[", "i", "]"}], "]"}]}], ",", 
                    RowBox[{"{", 
                     RowBox[{"i", ",", "1", ",", 
                      RowBox[{"Length", "@", "sxsdiroutaux"}]}], "}"}]}], "]"}], 
                  ",", 
                  RowBox[{"{", 
                   RowBox[{
                   "\"\<Case\>\"", ",", "\"\<q\>\"", ",", "\"\<\[Chi]1\>\"", ",", 
                    "\"\<\[Chi]2\>\"", ",", "\"\<D\>\"", ",", "\"\<e\>\""}], 
                   "}"}]}], "]"}], "//", "TableForm"}], "]"}]}], "]"}], ";", "\n",
             "\n", 
            RowBox[{"sxsdiroutaux", "[", 
             RowBox[{"[", 
              RowBox[{"All", ",", "1"}], "]"}], "]"}]}]}], "]"}]}]}], "\n", 
       "]"}]}]], "Code",
     CellChangeTimes->{{3.799113136734363*^9, 3.79911313895014*^9}},
     CellLabel->"In[93]:=",ExpressionUUID->"53efc507-6a18-4eaf-b317-b615cf672bde"]
    }, Closed]],
    
    Cell[CellGroupData[{
    
    Cell["RDown frequency and damping time", "Subsection",
     CellChangeTimes->{{3.717145410089053*^9, 3.71714541312827*^9}, {
       3.7172172325438833`*^9, 3.71721723694738*^9}, 3.717232740150098*^9, {
       3.719561185753558*^9, 3.71956118876759*^9}, {3.762579157516369*^9, 
       3.7625791630033073`*^9}, {3.762579322938787*^9, 3.7625793374944468`*^9}, {
       3.785052757811619*^9, 3.785052758228941*^9}, {3.799119235050438*^9, 
       3.79911926387778*^9}},ExpressionUUID->"f2291a02-b823-4df6-a581-\
    4fcde9b9eb4e"],
    
    Cell[BoxData[{
     RowBox[{
      RowBox[{
       RowBox[{"Options", "[", "\[Omega]lmn", "]"}], "=", 
       RowBox[{"{", 
        RowBox[{
         RowBox[{"\"\<ModesData\>\"", "\[Rule]", 
          RowBox[{"{", "}"}]}], ",", 
         RowBox[{"\"\<ModesFile\>\"", "\[Rule]", "\"\<\>\""}]}], "}"}]}], 
      ";"}], "\n", 
     RowBox[{
      RowBox[{"\[Omega]lmn", "[", 
       RowBox[{
       "l_", ",", "m_", ",", "n_", ",", "\[Eta]_", ",", "\[Chi]1_", ",", 
        "\[Chi]2_", ",", 
        RowBox[{"OptionsPattern", "[", "]"}]}], "]"}], ":=", 
      RowBox[{"Module", "[", 
       RowBox[{
        RowBox[{"{", 
         RowBox[{
         "file", ",", "data", ",", "modesdata", ",", "modesfile", ",", "mstr", 
          ",", "sp", ",", "fmass", ",", "f\[Chi]", ",", "\[Chi]\[Omega]\[Tau]", 
          ",", "\[Omega]", ",", "\[Tau]", ",", "llim", ",", "ulim"}], "}"}], ",", 
        "\n", 
        RowBox[{
         RowBox[{"modesdata", "=", 
          RowBox[{"OptionValue", "[", "\"\<ModesData\>\"", "]"}]}], ";", "\n", 
         RowBox[{"modesfile", "=", 
          RowBox[{"OptionValue", "[", "\"\<ModesFile\>\"", "]"}]}], ";", "\n", 
         "\n", 
         RowBox[{"If", "[", 
          RowBox[{
           RowBox[{
            RowBox[{"Length", "[", "modesdata", "]"}], "\[Equal]", "0"}], ",", 
           "\n", "    ", 
           RowBox[{
            RowBox[{"If", "[", 
             RowBox[{
              RowBox[{"n", "\[LessEqual]", "7"}], ",", "\n", "       ", 
              RowBox[{
               RowBox[{"If", "[", 
                RowBox[{
                 RowBox[{"m", "\[GreaterEqual]", "0"}], ",", 
                 RowBox[{"mstr", "=", "\"\<m\>\""}], ",", 
                 RowBox[{"mstr", "=", "\"\<mm\>\""}]}], "]"}], ";", "\n", 
               "       ", 
               RowBox[{"file", "=", 
                RowBox[{"modesfile", "<>", "\"\<l\>\"", "<>", 
                 RowBox[{"ToString", "[", "l", "]"}], "<>", "\"\</n\>\"", "<>", 
                 RowBox[{"ToString", "[", 
                  RowBox[{"n", "+", "1"}], "]"}], "<>", "\"\<l\>\"", "<>", 
                 RowBox[{"ToString", "[", "l", "]"}], "<>", "mstr", "<>", 
                 RowBox[{"ToString", "[", 
                  RowBox[{"Abs", "[", "m", "]"}], "]"}], "<>", "\"\<.dat\>\""}]}],
                ";"}], ",", "\n", "       ", 
              RowBox[{"file", "=", 
               RowBox[{"modesfile", "<>", "\"\<l\>\"", "<>", 
                RowBox[{"ToString", "[", "l", "]"}], "<>", "\"\</n7l\>\"", "<>", 
                RowBox[{"ToString", "[", "l", "]"}], "<>", "\"\<m\>\"", "<>", 
                RowBox[{"ToString", "[", 
                 RowBox[{"Abs", "[", "m", "]"}], "]"}], "<>", 
                "\"\<.dat\>\""}]}]}], "]"}], ";", "\n", "       ", 
            RowBox[{"If", "[", 
             RowBox[{
              RowBox[{"Not", "@", 
               RowBox[{"FileExistsQ", "[", "file", "]"}]}], ",", 
              RowBox[{
               RowBox[{"Print", "[", "\"\<File not found\>\"", "]"}], ";", 
               RowBox[{"Return", "[", "]"}], ";"}]}], "]"}], ";", "\n", "       ", 
            RowBox[{"data", "=", 
             RowBox[{"Import", "[", "file", "]"}]}], ";"}], ",", "\n", "       ", 
           "\n", "       ", 
           RowBox[{
            RowBox[{"data", "=", "modesdata"}], ";"}]}], "\n", "       ", "]"}], 
         ";", "\n", "\n", 
         RowBox[{"\[Chi]\[Omega]\[Tau]", "=", 
          RowBox[{"TakeColumn", "[", 
           RowBox[{"data", ",", 
            RowBox[{"{", 
             RowBox[{"1", ",", "2", ",", "3"}], "}"}]}], "]"}]}], ";", "\n", "\n", 
         RowBox[{"fmass", "=", 
          RowBox[{"1", "-", 
           RowBox[{"EradUIB2017", "[", 
            RowBox[{"\[Eta]", ",", "\[Chi]1", ",", "\[Chi]2"}], "]"}]}]}], ";", 
         "\n", 
         RowBox[{"f\[Chi]", "=", 
          RowBox[{"FinalSpinUIB2017", "[", 
           RowBox[{"\[Eta]", ",", "\[Chi]1", ",", "\[Chi]2"}], "]"}]}], ";", "\n",
          "\n", 
         RowBox[{"ulim", "=", 
          RowBox[{"Flatten", "[", 
           RowBox[{"Select", "[", 
            RowBox[{"\[Chi]\[Omega]\[Tau]", ",", 
             RowBox[{
              RowBox[{
               RowBox[{"#", "[", 
                RowBox[{"[", "1", "]"}], "]"}], "\[GreaterEqual]", "f\[Chi]"}], 
              "&"}], ",", "1"}], "]"}], "]"}]}], ";", "\n", 
         RowBox[{"llim", "=", 
          RowBox[{"Flatten", "[", 
           RowBox[{
            RowBox[{"Select", "[", 
             RowBox[{"\[Chi]\[Omega]\[Tau]", ",", 
              RowBox[{
               RowBox[{
                RowBox[{
                 RowBox[{"#", "[", 
                  RowBox[{"[", "1", "]"}], "]"}], "-", 
                 RowBox[{"ulim", "[", 
                  RowBox[{"[", "1", "]"}], "]"}]}], "<", "0"}], "&"}]}], "]"}], 
            "[", 
            RowBox[{"[", 
             RowBox[{"-", "1"}], "]"}], "]"}], "]"}]}], ";", "\n", 
         RowBox[{"\[Omega]", "=", 
          RowBox[{
           RowBox[{
            RowBox[{"Mean", "[", 
             RowBox[{"Join", "[", 
              RowBox[{
               RowBox[{"{", "ulim", "}"}], ",", 
               RowBox[{"{", "llim", "}"}]}], "]"}], "]"}], "[", 
            RowBox[{"[", "2", "]"}], "]"}], "/", "fmass"}]}], ";", "\n", 
         RowBox[{"\[Tau]", "=", 
          RowBox[{
           RowBox[{"Mean", "[", 
            RowBox[{"(", 
             RowBox[{
              RowBox[{"Abs", "[", 
               RowBox[{"1", "/", 
                RowBox[{"Join", "[", 
                 RowBox[{
                  RowBox[{"{", "ulim", "}"}], ",", 
                  RowBox[{"{", "llim", "}"}]}], "]"}]}], "]"}], "*", "fmass"}], 
             ")"}], "]"}], "[", 
           RowBox[{"[", 
            RowBox[{"-", "1"}], "]"}], "]"}]}], ";", "\n", 
         RowBox[{"{", 
          RowBox[{"\[Omega]", ",", "\[Tau]"}], "}"}]}]}], "\n", "]"}]}]}], "Code",\
    
     CellChangeTimes->{{3.7721985476927853`*^9, 3.772198575765624*^9}, {
       3.772198793153981*^9, 3.772198830047464*^9}, {3.7721988895906897`*^9, 
       3.772199562802928*^9}, {3.772199638377646*^9, 3.772200017819154*^9}, {
       3.77771649354319*^9, 3.777716502162915*^9}, {3.777716564048128*^9, 
       3.77771656695885*^9}, {3.7785552708514757`*^9, 3.778555308462579*^9}, {
       3.7785553469471817`*^9, 3.778555403730047*^9}, {3.7785577387693987`*^9, 
       3.778557738901156*^9}, {3.799113284272087*^9, 3.799113285169816*^9}, {
       3.799115766792492*^9, 3.7991157670850153`*^9}, {3.7991164547215643`*^9, 
       3.799116586199287*^9}, {3.799116618186366*^9, 3.7991166756249866`*^9}, {
       3.79911685538968*^9, 3.799116880268477*^9}, 3.799121006420978*^9, {
       3.7991210836378813`*^9, 3.799121172549109*^9}, {3.7991212170706882`*^9, 
       3.799121217898446*^9}, {3.7991213008580313`*^9, 3.7991213613184977`*^9}, {
       3.8012858331477957`*^9, 3.8012858942144833`*^9}, 3.801285933534213*^9, {
       3.803360332032749*^9, 3.80336033784513*^9}, {3.80336042466497*^9, 
       3.80336042565444*^9}},ExpressionUUID->"bc897087-f67b-459c-87a4-\
    ec5ee7ca2ba2"]
    }, Open  ]],
    
    Cell[CellGroupData[{
    
    Cell["Final mass final spin", "Subsection",
     CellChangeTimes->{{3.717145410089053*^9, 3.71714541312827*^9}, {
       3.7172172325438833`*^9, 3.71721723694738*^9}, 3.717232740150098*^9, {
       3.719561185753558*^9, 3.71956118876759*^9}, {3.762579157516369*^9, 
       3.7625791630033073`*^9}, {3.762579322938787*^9, 3.7625793374944468`*^9}, {
       3.785052757811619*^9, 3.785052758228941*^9}, {3.799119235050438*^9, 
       3.799119273795376*^9}},ExpressionUUID->"4969b6f9-be82-4f3e-abc6-\
    45d648828266"],
    
    Cell[BoxData[
     RowBox[{
      RowBox[{"EradUIB2017", "[", 
       RowBox[{"\[Eta]_", ",", "\[Chi]1_", ",", "\[Chi]2_"}], "]"}], ":=", 
      RowBox[{"Module", "[", 
       RowBox[{
        RowBox[{"{", 
         RowBox[{"m1", ",", "m2", ",", "S"}], "}"}], ",", "\n", 
        RowBox[{
         RowBox[{"m1", "=", 
          RowBox[{
           RowBox[{"1", "/", "2"}], " ", 
           RowBox[{"(", 
            RowBox[{"1", "+", 
             RowBox[{"Sqrt", "[", 
              RowBox[{"1", "-", 
               RowBox[{"4", " ", "\[Eta]"}]}], "]"}]}], ")"}]}]}], ";", "\n", 
         RowBox[{"m2", "=", 
          RowBox[{
           RowBox[{"1", "/", "2"}], " ", 
           RowBox[{"(", 
            RowBox[{"1", "-", 
             RowBox[{"Sqrt", "[", 
              RowBox[{"1", "-", 
               RowBox[{"4", " ", "\[Eta]"}]}], "]"}]}], ")"}]}]}], ";", "\n", 
         "\n", 
         RowBox[{"S", "=", " ", 
          RowBox[{
           RowBox[{"(", 
            RowBox[{
             RowBox[{
              RowBox[{"m1", "^", "2"}], " ", "\[Chi]1"}], " ", "+", " ", 
             RowBox[{
              RowBox[{"m2", "^", "2"}], " ", "\[Chi]2"}]}], ")"}], "/", 
           RowBox[{"(", 
            RowBox[{
             RowBox[{"m1", "^", "2"}], " ", "+", " ", 
             RowBox[{"m2", "^", "2"}]}], ")"}]}]}], ";", "\n", "\n", 
         RowBox[{
          RowBox[{
           RowBox[{"(", 
            RowBox[{
             RowBox[{"(", 
              RowBox[{
               RowBox[{
                RowBox[{"(", 
                 RowBox[{"1", "-", 
                  RowBox[{
                   RowBox[{"(", 
                    RowBox[{"2", " ", 
                     RowBox[{"Sqrt", "[", "2", "]"}]}], ")"}], "/", "3"}]}], 
                 ")"}], " ", "\[Eta]"}], "+", 
               RowBox[{"0.5609904135313374`", " ", 
                RowBox[{"\[Eta]", "^", "2"}]}], "-", 
               RowBox[{"0.84667563764404`", " ", 
                RowBox[{"\[Eta]", "^", "3"}]}], "+", 
               RowBox[{"3.145145224278187`", " ", 
                RowBox[{"\[Eta]", "^", "4"}]}]}], ")"}], " ", 
             RowBox[{"(", 
              RowBox[{"1", "+", 
               RowBox[{
                RowBox[{"S", "^", "3"}], " ", 
                RowBox[{"(", 
                 RowBox[{
                  RowBox[{"-", "0.6320191645391563`"}], "+", " ", 
                  RowBox[{"4.952698546796005`", " ", "\[Eta]"}], "-", 
                  RowBox[{"10.023747993978121`", " ", 
                   RowBox[{"\[Eta]", "^", "2"}]}]}], ")"}]}], "+", 
               RowBox[{
                RowBox[{"S", "^", "2"}], " ", 
                RowBox[{"(", 
                 RowBox[{
                  RowBox[{"-", "0.17762802148331427`"}], "+", " ", 
                  RowBox[{"2.176667900182948`", " ", 
                   RowBox[{"\[Eta]", "^", "2"}]}]}], ")"}]}], "+", 
               RowBox[{"S", " ", 
                RowBox[{"(", 
                 RowBox[{
                  RowBox[{"-", "0.13084389181783257`"}], "-", " ", 
                  RowBox[{"1.1387311580238488`", " ", "\[Eta]"}], "+", 
                  RowBox[{"5.49074464410971`", " ", 
                   RowBox[{"\[Eta]", "^", "2"}]}]}], ")"}]}]}], ")"}]}], ")"}], 
           "/", 
           RowBox[{"(", 
            RowBox[{"1", "+", 
             RowBox[{"S", " ", 
              RowBox[{"(", 
               RowBox[{
                RowBox[{"-", "0.9919475346968611`"}], "+", " ", 
                RowBox[{"0.367620218664352`", " ", "\[Eta]"}], "+", 
                RowBox[{"4.274567337924067`", " ", 
                 RowBox[{"\[Eta]", "^", "2"}]}]}], ")"}]}]}], ")"}]}], "\n", "-", 
          
          RowBox[{"0.01978238971523653`", " ", "S", " ", 
           RowBox[{"(", 
            RowBox[{"1", "-", 
             RowBox[{"4.91667749015812`", " ", "\[Eta]"}]}], ")"}], " ", 
           RowBox[{
            RowBox[{"(", 
             RowBox[{"1", "-", 
              RowBox[{"4", " ", "\[Eta]"}]}], ")"}], "^", "0.5`"}], " ", "\[Eta]",
            " ", 
           RowBox[{"(", 
            RowBox[{"\[Chi]1", "-", "\[Chi]2"}], ")"}]}], "-", 
          RowBox[{"0.09803730445895877`", " ", 
           RowBox[{
            RowBox[{"(", 
             RowBox[{"1", "-", 
              RowBox[{"4", " ", "\[Eta]"}]}], ")"}], "^", "0.5`"}], " ", 
           RowBox[{"(", 
            RowBox[{"1", "-", 
             RowBox[{"3.2283713377939134`", " ", "\[Eta]"}]}], ")"}], " ", 
           RowBox[{"\[Eta]", "^", "2"}], " ", 
           RowBox[{"(", 
            RowBox[{"\[Chi]1", "-", "\[Chi]2"}], ")"}]}], "+", 
          RowBox[{"0.01118530335431078`", " ", 
           RowBox[{"\[Eta]", "^", "3"}], " ", 
           RowBox[{
            RowBox[{"(", 
             RowBox[{"\[Chi]1", "-", "\[Chi]2"}], ")"}], "^", "2"}]}]}]}]}], 
       "]"}]}]], "Code",
     CellLabel->"In[95]:=",ExpressionUUID->"eda9a3bd-b2dd-4fe8-9fcb-bd728e8a287d"],
    
    Cell[BoxData[
     RowBox[{
      RowBox[{"FinalSpinUIB2017", "[", 
       RowBox[{"\[Eta]_", ",", "\[Chi]1_", ",", "\[Chi]2_"}], "]"}], ":=", 
      RowBox[{"Module", "[", 
       RowBox[{
        RowBox[{"{", 
         RowBox[{"m1", ",", "m2", ",", "S"}], "}"}], ",", "\n", 
        RowBox[{
         RowBox[{"m1", "=", 
          RowBox[{
           RowBox[{"1", "/", "2"}], " ", 
           RowBox[{"(", 
            RowBox[{"1", "+", 
             RowBox[{"Sqrt", "[", 
              RowBox[{"1", "-", 
               RowBox[{"4", " ", "\[Eta]"}]}], "]"}]}], ")"}]}]}], ";", "\n", 
         RowBox[{"m2", "=", 
          RowBox[{
           RowBox[{"1", "/", "2"}], " ", 
           RowBox[{"(", 
            RowBox[{"1", "-", 
             RowBox[{"Sqrt", "[", 
              RowBox[{"1", "-", 
               RowBox[{"4", " ", "\[Eta]"}]}], "]"}]}], ")"}]}]}], ";", "\n", 
         "\n", 
         RowBox[{"S", "=", " ", 
          RowBox[{
           RowBox[{"(", 
            RowBox[{
             RowBox[{
              RowBox[{"m1", "^", "2"}], " ", "\[Chi]1"}], " ", "+", " ", 
             RowBox[{
              RowBox[{"m2", "^", "2"}], " ", "\[Chi]2"}]}], ")"}], "/", 
           RowBox[{"(", 
            RowBox[{
             RowBox[{"m1", "^", "2"}], " ", "+", " ", 
             RowBox[{"m2", "^", "2"}]}], ")"}]}]}], ";", "\n", "\n", 
         RowBox[{
          RowBox[{"(", 
           RowBox[{
            RowBox[{
             RowBox[{"m1", "^", "2"}], " ", "\[Chi]1"}], " ", "+", " ", 
            RowBox[{
             RowBox[{"m2", "^", "2"}], " ", "\[Chi]2"}]}], ")"}], " ", "+", 
          RowBox[{
           RowBox[{"(", 
            RowBox[{
             RowBox[{"2", " ", 
              RowBox[{"Sqrt", "[", "3", "]"}], " ", "\[Eta]"}], "+", 
             RowBox[{"20.0830030082033`", " ", 
              RowBox[{"\[Eta]", "^", "2"}]}], "-", 
             RowBox[{"12.333573402277912`", " ", 
              RowBox[{"\[Eta]", "^", "3"}]}]}], ")"}], "/", 
           RowBox[{"(", 
            RowBox[{"1", "+", 
             RowBox[{"7.2388440419467335`", " ", "\[Eta]"}]}], ")"}]}], "+", "\n",
           " ", 
          RowBox[{"0.3223660562764661`", " ", 
           RowBox[{
            RowBox[{"(", 
             RowBox[{"1", "-", 
              RowBox[{"4", " ", "\[Eta]"}]}], ")"}], "^", "0.5`"}], " ", 
           RowBox[{"\[Eta]", "^", "2"}], " ", 
           RowBox[{"(", 
            RowBox[{"1", "+", 
             RowBox[{"9.332575956437443`", " ", "\[Eta]"}]}], ")"}], " ", 
           RowBox[{"(", 
            RowBox[{"\[Chi]1", "-", "\[Chi]2"}], ")"}]}], "-", 
          RowBox[{"0.059808322561702126`", " ", 
           RowBox[{"\[Eta]", "^", "3"}], " ", 
           RowBox[{
            RowBox[{"(", 
             RowBox[{"\[Chi]1", "-", "\[Chi]2"}], ")"}], "^", "2"}]}], "+", "\n", 
          
          RowBox[{
           RowBox[{"(", 
            RowBox[{"2.3170397514509933`", " ", 
             RowBox[{
              RowBox[{"(", 
               RowBox[{"1", "-", 
                RowBox[{"4", " ", "\[Eta]"}]}], ")"}], "^", "0.5`"}], " ", 
             RowBox[{"(", 
              RowBox[{"1", "-", 
               RowBox[{"3.2624649875884852`", " ", "\[Eta]"}]}], ")"}], " ", 
             RowBox[{"\[Eta]", "^", "3"}], " ", 
             RowBox[{"(", 
              RowBox[{"\[Chi]1", "-", "\[Chi]2"}], ")"}], " ", 
             RowBox[{"(", 
              RowBox[{
               RowBox[{
                RowBox[{"1", "/", "4"}], " ", 
                RowBox[{
                 RowBox[{"(", 
                  RowBox[{"1", "+", 
                   RowBox[{"Sqrt", "[", 
                    RowBox[{"1", "-", 
                     RowBox[{"4", " ", "\[Eta]"}]}], "]"}]}], ")"}], "^", "2"}], 
                " ", "\[Chi]1"}], "+", 
               RowBox[{
                RowBox[{"1", "/", "4"}], " ", 
                RowBox[{
                 RowBox[{"(", 
                  RowBox[{"1", "-", 
                   RowBox[{"Sqrt", "[", 
                    RowBox[{"1", "-", 
                     RowBox[{"4", " ", "\[Eta]"}]}], "]"}]}], ")"}], "^", "2"}], 
                " ", "\[Chi]2"}]}], ")"}]}], ")"}], "/", 
           RowBox[{"(", 
            RowBox[{
             RowBox[{
              RowBox[{"1", "/", "4"}], " ", 
              RowBox[{
               RowBox[{"(", 
                RowBox[{"1", "-", 
                 RowBox[{"Sqrt", "[", 
                  RowBox[{"1", "-", 
                   RowBox[{"4", " ", "\[Eta]"}]}], "]"}]}], ")"}], "^", "2"}]}], 
             "+", 
             RowBox[{
              RowBox[{"1", "/", "4"}], " ", 
              RowBox[{
               RowBox[{"(", 
                RowBox[{"1", "+", 
                 RowBox[{"Sqrt", "[", 
                  RowBox[{"1", "-", 
                   RowBox[{"4", " ", "\[Eta]"}]}], "]"}]}], ")"}], "^", "2"}]}]}],
             ")"}]}], "+", "\n", 
          RowBox[{
           RowBox[{"(", 
            RowBox[{
             RowBox[{
              RowBox[{"(", 
               RowBox[{
                RowBox[{"(", 
                 RowBox[{"0.`", " ", "-", 
                  RowBox[{"0.8561951310209386`", " ", "\[Eta]"}], "-", 
                  RowBox[{"0.09939065676370885`", " ", 
                   RowBox[{"\[Eta]", "^", "2"}]}], "+", 
                  RowBox[{"1.668810429851045`", " ", 
                   RowBox[{"\[Eta]", "^", "3"}]}]}], ")"}], " ", 
                RowBox[{"(", 
                 RowBox[{
                  RowBox[{
                   RowBox[{"1", "/", "4"}], " ", 
                   RowBox[{
                    RowBox[{"(", 
                     RowBox[{"1", "+", 
                      RowBox[{"Sqrt", "[", 
                       RowBox[{"1", "-", 
                        RowBox[{"4", " ", "\[Eta]"}]}], "]"}]}], ")"}], "^", 
                    "2"}], " ", "\[Chi]1"}], "+", 
                  RowBox[{
                   RowBox[{"1", "/", "4"}], " ", 
                   RowBox[{
                    RowBox[{"(", 
                     RowBox[{"1", "-", 
                      RowBox[{"Sqrt", "[", 
                       RowBox[{"1", "-", 
                        RowBox[{"4", " ", "\[Eta]"}]}], "]"}]}], ")"}], "^", 
                    "2"}], " ", "\[Chi]2"}]}], ")"}]}], ")"}], "/", 
              RowBox[{"(", 
               RowBox[{
                RowBox[{
                 RowBox[{"1", "/", "4"}], " ", 
                 RowBox[{
                  RowBox[{"(", 
                   RowBox[{"1", "-", 
                    RowBox[{"Sqrt", "[", 
                     RowBox[{"1", "-", 
                      RowBox[{"4", " ", "\[Eta]"}]}], "]"}]}], ")"}], "^", 
                  "2"}]}], "+", 
                RowBox[{
                 RowBox[{"1", "/", "4"}], " ", 
                 RowBox[{
                  RowBox[{"(", 
                   RowBox[{"1", "+", 
                    RowBox[{"Sqrt", "[", 
                     RowBox[{"1", "-", 
                      RowBox[{"4", " ", "\[Eta]"}]}], "]"}]}], ")"}], "^", 
                  "2"}]}]}], ")"}]}], "+", 
             RowBox[{
              RowBox[{"(", 
               RowBox[{
                RowBox[{"(", 
                 RowBox[{"0.`", " ", "+", 
                  RowBox[{"0.5881660363307388`", " ", "\[Eta]"}], "-", 
                  RowBox[{"2.149269067519131`", " ", 
                   RowBox[{"\[Eta]", "^", "2"}]}], "+", 
                  RowBox[{"3.4768263932898678`", " ", 
                   RowBox[{"\[Eta]", "^", "3"}]}]}], ")"}], " ", 
                RowBox[{
                 RowBox[{"(", 
                  RowBox[{
                   RowBox[{
                    RowBox[{"1", "/", "4"}], " ", 
                    RowBox[{
                     RowBox[{"(", 
                      RowBox[{"1", "+", 
                       RowBox[{"Sqrt", "[", 
                        RowBox[{"1", "-", 
                        RowBox[{"4", " ", "\[Eta]"}]}], "]"}]}], ")"}], "^", 
                     "2"}], " ", "\[Chi]1"}], "+", 
                   RowBox[{
                    RowBox[{"1", "/", "4"}], " ", 
                    RowBox[{
                     RowBox[{"(", 
                      RowBox[{"1", "-", 
                       RowBox[{"Sqrt", "[", 
                        RowBox[{"1", "-", 
                        RowBox[{"4", " ", "\[Eta]"}]}], "]"}]}], ")"}], "^", 
                     "2"}], " ", "\[Chi]2"}]}], ")"}], "^", "2"}]}], ")"}], "/", 
              RowBox[{
               RowBox[{"(", 
                RowBox[{
                 RowBox[{
                  RowBox[{"1", "/", "4"}], " ", 
                  RowBox[{
                   RowBox[{"(", 
                    RowBox[{"1", "-", 
                     RowBox[{"Sqrt", "[", 
                      RowBox[{"1", "-", 
                       RowBox[{"4", " ", "\[Eta]"}]}], "]"}]}], ")"}], "^", 
                   "2"}]}], "+", 
                 RowBox[{
                  RowBox[{"1", "/", "4"}], " ", 
                  RowBox[{
                   RowBox[{"(", 
                    RowBox[{"1", "+", 
                     RowBox[{"Sqrt", "[", 
                      RowBox[{"1", "-", 
                       RowBox[{"4", " ", "\[Eta]"}]}], "]"}]}], ")"}], "^", 
                   "2"}]}]}], ")"}], "^", "2"}]}], "+", 
             RowBox[{
              RowBox[{"(", 
               RowBox[{
                RowBox[{"(", 
                 RowBox[{"0.`", " ", "+", 
                  RowBox[{"0.142443244743048`", " ", "\[Eta]"}], "-", 
                  RowBox[{"0.9598353840147513`", " ", 
                   RowBox[{"\[Eta]", "^", "2"}]}], "+", 
                  RowBox[{"1.9595643107593743`", " ", 
                   RowBox[{"\[Eta]", "^", "3"}]}]}], ")"}], " ", 
                RowBox[{
                 RowBox[{"(", 
                  RowBox[{
                   RowBox[{
                    RowBox[{"1", "/", "4"}], " ", 
                    RowBox[{
                     RowBox[{"(", 
                      RowBox[{"1", "+", 
                       RowBox[{"Sqrt", "[", 
                        RowBox[{"1", "-", 
                        RowBox[{"4", " ", "\[Eta]"}]}], "]"}]}], ")"}], "^", 
                     "2"}], " ", "\[Chi]1"}], "+", 
                   RowBox[{
                    RowBox[{"1", "/", "4"}], " ", 
                    RowBox[{
                     RowBox[{"(", 
                      RowBox[{"1", "-", 
                       RowBox[{"Sqrt", "[", 
                        RowBox[{"1", "-", 
                        RowBox[{"4", " ", "\[Eta]"}]}], "]"}]}], ")"}], "^", 
                     "2"}], " ", "\[Chi]2"}]}], ")"}], "^", "3"}]}], ")"}], "/", 
              RowBox[{
               RowBox[{"(", 
                RowBox[{
                 RowBox[{
                  RowBox[{"1", "/", "4"}], " ", 
                  RowBox[{
                   RowBox[{"(", 
                    RowBox[{"1", "-", 
                     RowBox[{"Sqrt", "[", 
                      RowBox[{"1", "-", 
                       RowBox[{"4", " ", "\[Eta]"}]}], "]"}]}], ")"}], "^", 
                   "2"}]}], "+", 
                 RowBox[{
                  RowBox[{"1", "/", "4"}], " ", 
                  RowBox[{
                   RowBox[{"(", 
                    RowBox[{"1", "+", 
                     RowBox[{"Sqrt", "[", 
                      RowBox[{"1", "-", 
                       RowBox[{"4", " ", "\[Eta]"}]}], "]"}]}], ")"}], "^", 
                   "2"}]}]}], ")"}], "^", "3"}]}]}], ")"}], "/", 
           RowBox[{"(", 
            RowBox[{"1", "+", 
             RowBox[{
              RowBox[{"(", 
               RowBox[{
                RowBox[{"(", 
                 RowBox[{
                  RowBox[{"-", "0.9142232693081653`"}], "+", " ", 
                  RowBox[{"2.3191363426522633`", " ", "\[Eta]"}], "-", 
                  RowBox[{"9.710576749140989`", " ", 
                   RowBox[{"\[Eta]", "^", "3"}]}]}], ")"}], " ", 
                RowBox[{"(", 
                 RowBox[{
                  RowBox[{
                   RowBox[{"1", "/", "4"}], " ", 
                   RowBox[{
                    RowBox[{"(", 
                     RowBox[{"1", "+", 
                      RowBox[{"Sqrt", "[", 
                       RowBox[{"1", "-", 
                        RowBox[{"4", " ", "\[Eta]"}]}], "]"}]}], ")"}], "^", 
                    "2"}], " ", "\[Chi]1"}], "+", 
                  RowBox[{
                   RowBox[{"1", "/", "4"}], " ", 
                   RowBox[{
                    RowBox[{"(", 
                     RowBox[{"1", "-", 
                      RowBox[{"Sqrt", "[", 
                       RowBox[{"1", "-", 
                        RowBox[{"4", " ", "\[Eta]"}]}], "]"}]}], ")"}], "^", 
                    "2"}], " ", "\[Chi]2"}]}], ")"}]}], ")"}], "/", 
              RowBox[{"(", 
               RowBox[{
                RowBox[{
                 RowBox[{"1", "/", "4"}], " ", 
                 RowBox[{
                  RowBox[{"(", 
                   RowBox[{"1", "-", 
                    RowBox[{"Sqrt", "[", 
                     RowBox[{"1", "-", 
                      RowBox[{"4", " ", "\[Eta]"}]}], "]"}]}], ")"}], "^", 
                  "2"}]}], "+", 
                RowBox[{
                 RowBox[{"1", "/", "4"}], " ", 
                 RowBox[{
                  RowBox[{"(", 
                   RowBox[{"1", "+", 
                    RowBox[{"Sqrt", "[", 
                     RowBox[{"1", "-", 
                      RowBox[{"4", " ", "\[Eta]"}]}], "]"}]}], ")"}], "^", 
                  "2"}]}]}], ")"}]}]}], ")"}]}]}]}]}], "]"}]}]], "Code",
     CellLabel->"In[96]:=",ExpressionUUID->"7c11673b-6e54-49ee-822b-64e19a8a50a6"]
    }, Closed]],
    
    Cell[CellGroupData[{
    
    Cell["Spherical harmonics Yslm", "Subsection",
     CellChangeTimes->{{3.720858744971012*^9, 3.720858745401064*^9}, {
      3.7625786687006273`*^9, 
      3.762578677729886*^9}},ExpressionUUID->"150df7a9-0598-4dbe-b33a-\
    3a640381122d"],
    
    Cell[BoxData[{
     RowBox[{
      RowBox[{"Eth", "[", 
       RowBox[{"n_", ",", "f_"}], "]"}], " ", ":=", " ", 
      RowBox[{
       RowBox[{"-", " ", 
        RowBox[{
         RowBox[{"Sin", "[", "t", "]"}], "^", "n"}]}], " ", 
       RowBox[{"(", 
        RowBox[{
         RowBox[{"D", "[", 
          RowBox[{
           RowBox[{"f", "/", 
            RowBox[{
             RowBox[{"Sin", "[", "t", "]"}], "^", "n"}]}], ",", "t"}], "]"}], "+", 
         RowBox[{"I", " ", 
          RowBox[{
           RowBox[{"D", "[", 
            RowBox[{
             RowBox[{"f", "/", 
              RowBox[{
               RowBox[{"Sin", "[", "t", "]"}], "^", "n"}]}], ",", "p"}], "]"}], 
           "/", 
           RowBox[{"Sin", "[", "t", "]"}]}]}]}], ")"}]}]}], "\[IndentingNewLine]", 
     RowBox[{
      RowBox[{"Yp1", "[", 
       RowBox[{"l_", ",", "m_"}], "]"}], ":=", " ", 
      RowBox[{"FullSimplify", "[", 
       RowBox[{
        RowBox[{"Sqrt", "[", " ", 
         RowBox[{
          RowBox[{
           RowBox[{"(", 
            RowBox[{"l", "-", "1"}], ")"}], "!"}], "/", 
          RowBox[{
           RowBox[{"(", 
            RowBox[{"l", "+", "1"}], ")"}], "!"}]}], "]"}], 
        RowBox[{"Eth", "[", 
         RowBox[{"0", ",", 
          RowBox[{"SphericalHarmonicY", "[", 
           RowBox[{"l", ",", "m", ",", "t", ",", "p"}], "]"}]}], "]"}]}], 
       "]"}]}], "\[IndentingNewLine]", 
     RowBox[{
      RowBox[{
       RowBox[{"Yp2", "[", 
        RowBox[{"l_", ",", "m_"}], "]"}], ":=", " ", 
       RowBox[{"FullSimplify", "[", 
        RowBox[{
         RowBox[{"Sqrt", "[", " ", 
          RowBox[{
           RowBox[{
            RowBox[{"(", 
             RowBox[{"l", "-", "2"}], ")"}], "!"}], "/", 
           RowBox[{
            RowBox[{"(", 
             RowBox[{"l", "+", "2"}], ")"}], "!"}]}], "]"}], 
         RowBox[{"Eth", "[", 
          RowBox[{"1", ",", 
           RowBox[{"Eth", "[", 
            RowBox[{"0", ",", 
             RowBox[{"SphericalHarmonicY", "[", 
              RowBox[{"l", ",", "m", ",", "t", ",", "p"}], "]"}]}], "]"}]}], 
          "]"}]}], "]"}]}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
     RowBox[{
      RowBox[{"Ethbar", "[", 
       RowBox[{"n_", ",", "f_"}], "]"}], " ", ":=", " ", 
      RowBox[{
       RowBox[{"-", " ", 
        RowBox[{
         RowBox[{"Sin", "[", "t", "]"}], "^", 
         RowBox[{"(", 
          RowBox[{"-", "n"}], ")"}]}]}], " ", 
       RowBox[{"(", 
        RowBox[{
         RowBox[{"D", "[", 
          RowBox[{
           RowBox[{"f", " ", 
            RowBox[{
             RowBox[{"Sin", "[", "t", "]"}], "^", "n"}]}], ",", "t"}], "]"}], "-", 
         RowBox[{"I", " ", 
          RowBox[{
           RowBox[{"D", "[", 
            RowBox[{
             RowBox[{"f", " ", 
              RowBox[{
               RowBox[{"Sin", "[", "t", "]"}], "^", "n"}]}], ",", "p"}], "]"}], 
           "/", 
           RowBox[{"Sin", "[", "t", "]"}]}]}]}], ")"}]}]}], "\n", 
     RowBox[{
      RowBox[{"Ym1", "[", 
       RowBox[{"l_", ",", "m_"}], "]"}], ":=", " ", 
      RowBox[{"FullSimplify", "[", 
       RowBox[{
        RowBox[{"Sqrt", "[", " ", 
         RowBox[{
          RowBox[{
           RowBox[{"(", 
            RowBox[{"l", "-", "1"}], ")"}], "!"}], "/", 
          RowBox[{
           RowBox[{"(", 
            RowBox[{"l", "+", "1"}], ")"}], "!"}]}], "]"}], 
        RowBox[{
         RowBox[{"(", 
          RowBox[{"-", "1"}], ")"}], "^", 
         RowBox[{"(", 
          RowBox[{"-", "1"}], ")"}]}], " ", 
        RowBox[{"Ethbar", "[", 
         RowBox[{"0", ",", 
          RowBox[{"SphericalHarmonicY", "[", 
           RowBox[{"l", ",", "m", ",", "t", ",", "p"}], "]"}]}], "]"}]}], 
       "]"}]}], "\n", 
     RowBox[{
      RowBox[{"Ym2", "[", 
       RowBox[{"l_", ",", "m_"}], "]"}], ":=", " ", 
      RowBox[{"FullSimplify", "[", 
       RowBox[{
        RowBox[{"Sqrt", "[", " ", 
         RowBox[{
          RowBox[{
           RowBox[{"(", 
            RowBox[{"l", "-", "2"}], ")"}], "!"}], "/", 
          RowBox[{
           RowBox[{"(", 
            RowBox[{"l", "+", "2"}], ")"}], "!"}]}], "]"}], 
        RowBox[{
         RowBox[{"(", 
          RowBox[{"-", "1"}], ")"}], "^", 
         RowBox[{"(", 
          RowBox[{"-", "2"}], ")"}]}], 
        RowBox[{"Ethbar", "[", 
         RowBox[{
          RowBox[{"-", "1"}], ",", 
          RowBox[{"Ethbar", "[", 
           RowBox[{"0", ",", 
            RowBox[{"SphericalHarmonicY", "[", 
             RowBox[{"l", ",", "m", ",", "t", ",", "p"}], "]"}]}], "]"}]}], 
         "]"}]}], "]"}]}], "\n"}], "Code",
     CellLabel->"In[98]:=",ExpressionUUID->"5a45b164-5323-4cf0-886c-ea802182cb1d"],
    
    Cell[BoxData[
     RowBox[{
      RowBox[{"(*", " ", 
       RowBox[{
        RowBox[{"same", " ", "source"}], ",", " ", 
        RowBox[{
         RowBox[{
         "direct", " ", "formula", " ", "using", " ", "Wigner", " ", "d"}], "-", 
         "functions"}]}], " ", "*)"}], "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{
        RowBox[{"wd", "[", 
         RowBox[{"n_", ",", "l_", ",", "m_"}], "]"}], ":=", 
        RowBox[{"Sum", "[", "\[IndentingNewLine]", 
         RowBox[{
          RowBox[{
           RowBox[{
            RowBox[{"(", 
             RowBox[{"-", "1"}], ")"}], "^", "i"}], "  ", 
           RowBox[{
            RowBox[{"Sqrt", "[", 
             RowBox[{
              RowBox[{
               RowBox[{"(", 
                RowBox[{"l", "+", "m"}], ")"}], "!"}], " ", 
              RowBox[{
               RowBox[{"(", 
                RowBox[{"l", "-", "m"}], ")"}], "!"}], " ", 
              RowBox[{
               RowBox[{"(", 
                RowBox[{"l", "+", "n"}], ")"}], "!"}], " ", 
              RowBox[{
               RowBox[{"(", 
                RowBox[{"l", "-", "n"}], ")"}], "!"}]}], "]"}], " ", "/", " ", 
            RowBox[{"(", 
             RowBox[{
              RowBox[{
               RowBox[{"(", 
                RowBox[{"l", "+", "m", "-", "i"}], ")"}], "!"}], 
              RowBox[{
               RowBox[{"(", 
                RowBox[{"l", "-", "n", "-", "i"}], ")"}], "!"}], 
              RowBox[{"i", "!"}], 
              RowBox[{
               RowBox[{"(", 
                RowBox[{"i", "+", "n", "-", "m"}], ")"}], "!"}]}], ")"}]}], 
           "\[IndentingNewLine]", 
           RowBox[{
            RowBox[{"Cos", "[", 
             RowBox[{"t", "/", "2"}], "]"}], "^", 
            RowBox[{"(", 
             RowBox[{
              RowBox[{"2", "l"}], "+", "m", "-", "n", "-", 
              RowBox[{"2", "i"}]}], ")"}]}], 
           RowBox[{
            RowBox[{"Sin", "[", 
             RowBox[{"t", "/", "2"}], "]"}], "^", 
            RowBox[{"(", 
             RowBox[{
              RowBox[{"2", "i"}], "+", "n", "-", "m"}], ")"}]}]}], ",", 
          "\[IndentingNewLine]", 
          RowBox[{"{", 
           RowBox[{"i", ",", 
            RowBox[{"Max", "[", 
             RowBox[{"0", ",", 
              RowBox[{"m", "-", "n"}]}], "]"}], ",", 
            RowBox[{"Min", "[", 
             RowBox[{
              RowBox[{"l", "+", "m"}], ",", 
              RowBox[{"l", "-", "n"}]}], "]"}]}], "}"}]}], "\[IndentingNewLine]", 
         "]"}]}], "\[IndentingNewLine]", 
       RowBox[{
        RowBox[{"Ydirect", "[", 
         RowBox[{"n_", ",", "l_", ",", "m_"}], "]"}], ":=", 
        RowBox[{"FullSimplify", "[", 
         RowBox[{
          RowBox[{
           RowBox[{"(", 
            RowBox[{"-", "1"}], ")"}], "^", "n"}], "  ", 
          RowBox[{"Sqrt", "[", 
           RowBox[{
            RowBox[{"(", 
             RowBox[{
              RowBox[{"2", "l"}], "+", "1"}], ")"}], "/", 
            RowBox[{"(", 
             RowBox[{"4", "Pi"}], ")"}]}], "]"}], " ", 
          RowBox[{"wd", "[", 
           RowBox[{
            RowBox[{"-", "n"}], ",", "l", ",", "m"}], "]"}], 
          RowBox[{"E", "^", 
           RowBox[{"(", 
            RowBox[{"I", " ", "m", " ", "p"}], ")"}]}]}], "]"}]}]}]}]], "Code",
     CellChangeTimes->{{3.7208588118960876`*^9, 3.720858820698229*^9}, {
      3.720858876003764*^9, 3.720858879267067*^9}},
     CellLabel->
      "In[104]:=",ExpressionUUID->"8b8ec213-3236-4399-a9d4-0d7dbfdcc7e4"]
    }, Closed]],
    
    Cell[CellGroupData[{
    
    Cell["Overtone Fit Functions", "Subsection",
     CellChangeTimes->{{3.719736912552854*^9, 3.719736913643588*^9}, {
      3.720334511498179*^9, 3.720334540714099*^9}, {3.7625796137552156`*^9, 
      3.762579627380604*^9}},ExpressionUUID->"ef40d02e-f487-40e1-b6da-\
    592e7b6c3f02"],
    
    Cell[BoxData[{
     RowBox[{
      RowBox[{
       RowBox[{"Options", "[", "DetectConvergence", "]"}], "=", 
       RowBox[{"{", 
        RowBox[{"\"\<Test\>\"", "\[Rule]", "FindMaximum"}], "}"}]}], 
      ";"}], "\n", 
     RowBox[{
      RowBox[{"DetectConvergence", "[", 
       RowBox[{"res_", ",", "\[Tau]_", ",", 
        RowBox[{"OptionsPattern", "[", "]"}]}], "]"}], ":=", 
      RowBox[{"Module", "[", 
       RowBox[{
        RowBox[{"{", 
         RowBox[{
         "intres", ",", "mins", ",", "tmax", ",", "t", ",", "fits", ",", "a", ",",
           "tol", ",", "tt", ",", "yy", ",", "test"}], "}"}], ",", 
        "\[IndentingNewLine]", "\n", 
        RowBox[{
         RowBox[{"test", "=", 
          RowBox[{"OptionValue", "[", "\"\<Test\>\"", "]"}]}], ";", "\n", "\n", 
         RowBox[{"tmax", "=", " ", 
          RowBox[{"4", " ", "*", " ", "\[Tau]"}]}], ";", "\[IndentingNewLine]", 
         RowBox[{"intres", "=", 
          RowBox[{"Interpolation", "@", "res"}]}], ";", "\n", 
         RowBox[{"mins", "=", 
          RowBox[{"Quiet", "[", 
           RowBox[{
            RowBox[{"Table", "[", 
             RowBox[{
              RowBox[{"test", "[", 
               RowBox[{
                RowBox[{"intres", "@", "t"}], ",", 
                RowBox[{"{", 
                 RowBox[{"t", ",", "i"}], "}"}]}], "]"}], ",", 
              RowBox[{"{", 
               RowBox[{"i", ",", 
                RowBox[{
                 RowBox[{"res", "[", 
                  RowBox[{"[", 
                   RowBox[{"1", ",", "1"}], "]"}], "]"}], "+", "5"}], ",", 
                RowBox[{
                 RowBox[{"res", "[", 
                  RowBox[{"[", 
                   RowBox[{"1", ",", "1"}], "]"}], "]"}], "+", "5", " ", "+", 
                 "tmax"}], ",", "10"}], "}"}]}], "]"}], "/.", 
            RowBox[{
             RowBox[{"{", 
              RowBox[{"yy_", ",", "tt_"}], "}"}], "\[Rule]", 
             RowBox[{"{", 
              RowBox[{
               RowBox[{"t", "/.", "tt"}], ",", "yy"}], "}"}]}]}], "]"}]}], ";", 
         "\[IndentingNewLine]", 
         RowBox[{"mins", "=", 
          RowBox[{"Select", "[", 
           RowBox[{"mins", ",", 
            RowBox[{
             RowBox[{
              RowBox[{"res", "[", 
               RowBox[{"[", 
                RowBox[{"1", ",", "1"}], "]"}], "]"}], "<", 
              RowBox[{"#", "[", 
               RowBox[{"[", "1", "]"}], "]"}], "<", 
              RowBox[{"res", "[", 
               RowBox[{"[", 
                RowBox[{
                 RowBox[{"-", "1"}], ",", "1"}], "]"}], "]"}]}], "&"}]}], "]"}]}],
          ";", "\n", 
         RowBox[{"SortBy", "[", 
          RowBox[{"mins", ",", "First"}], "]"}]}]}], "\n", "]"}]}]}], "Code",
     CellChangeTimes->{{3.720494067863076*^9, 3.720494208843604*^9}, {
       3.720494258516584*^9, 3.720494375002429*^9}, {3.720494525712131*^9, 
       3.72049452659192*^9}, {3.720494651968155*^9, 3.720494864315839*^9}, {
       3.7204949018671427`*^9, 3.7204949244598627`*^9}, {3.7204949958859386`*^9, 
       3.720495006018746*^9}, {3.720495050507967*^9, 3.720495050706203*^9}, {
       3.720495121489184*^9, 3.720495121665111*^9}, {3.720495190623155*^9, 
       3.720495191655134*^9}, {3.720495248928876*^9, 3.720495305263709*^9}, {
       3.7204953535754137`*^9, 3.7204953576205893`*^9}, {3.720495494637003*^9, 
       3.720495505404582*^9}, {3.720496198433455*^9, 3.720496205712208*^9}, {
       3.720496379919685*^9, 3.720496407690078*^9}, {3.76259463168292*^9, 
       3.762594632250791*^9}, {3.799120477600918*^9, 3.799120501971664*^9}, 
       3.800088857280878*^9},ExpressionUUID->"cb69a25b-ca49-41e1-ac39-\
    61c32a4d9fb6"],
    
    Cell[BoxData[{
     RowBox[{
      RowBox[{
       RowBox[{"Options", "[", "OvertoneModel", "]"}], "=", 
       RowBox[{"Join", "[", 
        RowBox[{
         RowBox[{"Options", "[", "\[Omega]lmn", "]"}], ",", 
         RowBox[{"{", 
          RowBox[{
           RowBox[{"\"\<FixExtra\>\"", "\[Rule]", "True"}], ",", 
           RowBox[{"\"\<Fit\[Alpha]\>\"", "\[Rule]", 
            RowBox[{"{", "}"}]}], ",", 
           RowBox[{"\"\<Fit\[Tau]\>\"", "\[Rule]", 
            RowBox[{"{", "}"}]}], ",", 
           RowBox[{"\"\<Mode\>\"", "\[Rule]", 
            RowBox[{"{", 
             RowBox[{"2", ",", "2"}], "}"}]}], ",", 
           RowBox[{"\"\<Vary\[Omega]\>\"", "\[Rule]", "False"}], ",", 
           RowBox[{"\"\<\[Omega]val\>\"", "\[Rule]", 
            RowBox[{"{", 
             RowBox[{
              RowBox[{"-", "0.05"}], ",", "0.05"}], "}"}]}]}], "}"}]}], "]"}]}], 
      ";"}], "\n", 
     RowBox[{
      RowBox[{"OvertoneModel", "[", 
       RowBox[{"overtones_", ",", "pars_", ",", 
        RowBox[{"OptionsPattern", "[", "]"}]}], "]"}], ":=", 
      RowBox[{"Block", "[", 
       RowBox[{
        RowBox[{"{", 
         RowBox[{
         "ansatz", ",", "fixetra", ",", "fit\[Alpha]", ",", "fit\[Tau]", ",", "l",
           ",", "m", ",", "mode", ",", "modesdata", ",", "modesfile", ",", 
          "modto0", ",", "var", ",", "vary\[Omega]", ",", "Global`t", ",", "ti", 
          ",", "\[Tau]s", ",", "\[Alpha]", ",", "\[Beta]", ",", "\[Omega]s", ",", 
          "\[Eta]", ",", "\[Chi]1", ",", "\[Chi]2", ",", "\[Omega]val"}], "}"}], 
        ",", "\[IndentingNewLine]", 
        RowBox[{
         RowBox[{"fixetra", "=", 
          RowBox[{"OptionValue", "[", "\"\<FixExtra\>\"", "]"}]}], ";", "\n", 
         RowBox[{"fit\[Alpha]", "=", 
          RowBox[{"OptionValue", "[", "\"\<Fit\[Alpha]\>\"", "]"}]}], ";", "\n", 
         RowBox[{"fit\[Tau]", "=", 
          RowBox[{"OptionValue", "[", "\"\<Fit\[Tau]\>\"", "]"}]}], ";", "\n", 
         RowBox[{"mode", "=", 
          RowBox[{"OptionValue", "[", "\"\<Mode\>\"", "]"}]}], ";", "\n", 
         RowBox[{"vary\[Omega]", "=", 
          RowBox[{"OptionValue", "[", "\"\<Vary\[Omega]\>\"", "]"}]}], ";", "\n", 
         
         RowBox[{"\[Omega]val", "=", 
          RowBox[{"OptionValue", "[", "\"\<\[Omega]val\>\"", "]"}]}], ";", "\n", 
         RowBox[{"modesdata", "=", 
          RowBox[{"OptionValue", "[", "\"\<ModesData\>\"", "]"}]}], ";", "\n", 
         RowBox[{"modesfile", "=", 
          RowBox[{"OptionValue", "[", "\"\<ModesFile\>\"", "]"}]}], ";", "\n", 
         "\n", 
         RowBox[{"l", "=", 
          RowBox[{"mode", "[", 
           RowBox[{"[", "1", "]"}], "]"}]}], ";", "\n", 
         RowBox[{"m", "=", 
          RowBox[{"mode", "[", 
           RowBox[{"[", "2", "]"}], "]"}]}], ";", "\n", 
         RowBox[{
          RowBox[{"{", 
           RowBox[{"\[Eta]", ",", "\[Chi]1", ",", "\[Chi]2"}], "}"}], "=", 
          RowBox[{"pars", "[", 
           RowBox[{"[", 
            RowBox[{"1", ";;", "3"}], "]"}], "]"}]}], ";", "\n", 
         "\[IndentingNewLine]", 
         RowBox[{"(*", " ", 
          RowBox[{
           RowBox[{
            RowBox[{"Freqs", "."}], " ", "&"}], " ", "damping", " ", "times", " ",
            "from", " ", "Vitor"}], " ", "*)"}], "\[IndentingNewLine]", 
         RowBox[{"If", "[", 
          RowBox[{
           RowBox[{
            RowBox[{"Length", "@", "modesdata"}], "\[Equal]", "0"}], ",", 
           "\[IndentingNewLine]", "\t", 
           RowBox[{
            RowBox[{"\[Omega]s", "=", 
             RowBox[{"Table", "[", 
              RowBox[{
               RowBox[{
                RowBox[{"\[Omega]lmn", "[", 
                 RowBox[{
                 "l", ",", "m", ",", "n", ",", "\[Eta]", ",", "\[Chi]1", ",", 
                  "\[Chi]2", ",", 
                  RowBox[{"\"\<ModesFile\>\"", "->", "modesfile"}]}], "]"}], "[", 
                
                RowBox[{"[", "1", "]"}], "]"}], ",", 
               RowBox[{"{", 
                RowBox[{"n", ",", "0", ",", "overtones"}], "}"}]}], "]"}]}], ";", 
            "\n", "\t", 
            RowBox[{"var", "=", 
             RowBox[{"Range", "[", 
              RowBox[{"0", ",", "7"}], "]"}]}], ";", "\n", "\t", 
            RowBox[{"If", "[", 
             RowBox[{"vary\[Omega]", ",", 
              RowBox[{"\[Omega]s", "=", 
               RowBox[{"Table", "[", 
                RowBox[{
                 RowBox[{
                  RowBox[{"If", "[", 
                   RowBox[{
                    RowBox[{"n", ">", "0"}], ",", 
                    RowBox[{
                     RowBox[{"var", "[", 
                      RowBox[{"[", 
                       RowBox[{"n", "+", "1"}], "]"}], "]"}], "=", 
                     RowBox[{"RandomReal", "[", 
                      RowBox[{"{", 
                       RowBox[{
                        RowBox[{"1", "+", 
                        RowBox[{"\[Omega]val", "[", 
                        RowBox[{"[", "1", "]"}], "]"}]}], ",", 
                        RowBox[{"1", "+", 
                        RowBox[{"\[Omega]val", "[", 
                        RowBox[{"[", "2", "]"}], "]"}]}]}], "}"}], "]"}]}], ",", 
                    RowBox[{
                     RowBox[{"var", "[", 
                      RowBox[{"[", "1", "]"}], "]"}], "=", "1"}]}], "]"}], ";", 
                  RowBox[{
                   RowBox[{"var", "[", 
                    RowBox[{"[", 
                     RowBox[{"n", "+", "1"}], "]"}], "]"}], "*", 
                   RowBox[{
                    RowBox[{"\[Omega]lmn", "[", 
                     RowBox[{
                     "l", ",", "m", ",", "n", ",", "\[Eta]", ",", "\[Chi]1", ",", 
                      "\[Chi]2", ",", 
                      RowBox[{"\"\<ModesFile\>\"", "->", "modesfile"}]}], "]"}], 
                    "[", 
                    RowBox[{"[", "1", "]"}], "]"}]}]}], ",", 
                 RowBox[{"{", 
                  RowBox[{"n", ",", "0", ",", "overtones"}], "}"}]}], "]"}]}]}], 
             "]"}], ";", "\n", "\t", 
            RowBox[{"\[Tau]s", "=", 
             RowBox[{"Table", "[", 
              RowBox[{
               RowBox[{
                RowBox[{"\[Omega]lmn", "[", 
                 RowBox[{
                 "l", ",", "m", ",", "n", ",", "\[Eta]", ",", "\[Chi]1", ",", 
                  "\[Chi]2", ",", 
                  RowBox[{"\"\<ModesFile\>\"", "->", "modesfile"}]}], "]"}], "[", 
                
                RowBox[{"[", "2", "]"}], "]"}], ",", 
               RowBox[{"{", 
                RowBox[{"n", ",", "0", ",", "overtones"}], "}"}]}], "]"}]}], 
            ";"}], "\n", "\t", ",", "\n", "\t", 
           RowBox[{
            RowBox[{"\[Omega]s", "=", 
             RowBox[{"Table", "[", 
              RowBox[{
               RowBox[{
                RowBox[{"\[Omega]lmn", "[", 
                 RowBox[{
                 "l", ",", "m", ",", "n", ",", "\[Eta]", ",", "\[Chi]1", ",", 
                  "\[Chi]2", ",", 
                  RowBox[{"\"\<ModesData\>\"", "->", 
                   RowBox[{"modesdata", "[", 
                    RowBox[{"[", 
                     RowBox[{"n", "+", "1"}], "]"}], "]"}]}]}], "]"}], "[", 
                RowBox[{"[", "1", "]"}], "]"}], ",", 
               RowBox[{"{", 
                RowBox[{"n", ",", "0", ",", "overtones"}], "}"}]}], "]"}]}], ";", 
            "\n", "\t", 
            RowBox[{"var", "=", 
             RowBox[{"Range", "[", 
              RowBox[{"0", ",", "7"}], "]"}]}], ";", "\n", "\t", 
            RowBox[{"If", "[", 
             RowBox[{"vary\[Omega]", ",", 
              RowBox[{"\[Omega]s", "=", 
               RowBox[{"Table", "[", 
                RowBox[{
                 RowBox[{
                  RowBox[{"If", "[", 
                   RowBox[{
                    RowBox[{"n", ">", "0"}], ",", 
                    RowBox[{
                     RowBox[{"var", "[", 
                      RowBox[{"[", 
                       RowBox[{"n", "+", "1"}], "]"}], "]"}], "=", 
                     RowBox[{"RandomReal", "[", 
                      RowBox[{"{", 
                       RowBox[{
                        RowBox[{"1", "+", 
                        RowBox[{"\[Omega]val", "[", 
                        RowBox[{"[", "1", "]"}], "]"}]}], ",", 
                        RowBox[{"1", "+", 
                        RowBox[{"\[Omega]val", "[", 
                        RowBox[{"[", "2", "]"}], "]"}]}]}], "}"}], "]"}]}], ",", 
                    RowBox[{
                     RowBox[{"var", "[", 
                      RowBox[{"[", "1", "]"}], "]"}], "=", "1"}]}], "]"}], ";", 
                  RowBox[{
                   RowBox[{"var", "[", 
                    RowBox[{"[", 
                     RowBox[{"n", "+", "1"}], "]"}], "]"}], "*", 
                   RowBox[{
                    RowBox[{"\[Omega]lmn", "[", 
                     RowBox[{
                     "l", ",", "m", ",", "n", ",", "\[Eta]", ",", "\[Chi]1", ",", 
                      "\[Chi]2", ",", 
                      RowBox[{"\"\<ModesData\>\"", "->", 
                       RowBox[{"modesdata", "[", 
                        RowBox[{"[", 
                        RowBox[{"n", "+", "1"}], "]"}], "]"}]}]}], "]"}], "[", 
                    RowBox[{"[", "1", "]"}], "]"}]}]}], ",", 
                 RowBox[{"{", 
                  RowBox[{"n", ",", "0", ",", "overtones"}], "}"}]}], "]"}]}]}], 
             "]"}], ";", "\n", "\t", 
            RowBox[{"\[Tau]s", "=", 
             RowBox[{"Table", "[", 
              RowBox[{
               RowBox[{
                RowBox[{"\[Omega]lmn", "[", 
                 RowBox[{
                 "l", ",", "m", ",", "n", ",", "\[Eta]", ",", "\[Chi]1", ",", 
                  "\[Chi]2", ",", 
                  RowBox[{"\"\<ModesData\>\"", "->", 
                   RowBox[{"modesdata", "[", 
                    RowBox[{"[", 
                     RowBox[{"n", "+", "1"}], "]"}], "]"}]}]}], "]"}], "[", 
                RowBox[{"[", "2", "]"}], "]"}], ",", 
               RowBox[{"{", 
                RowBox[{"n", ",", "0", ",", "overtones"}], "}"}]}], "]"}]}], 
            ";"}]}], "\n", "\t", "]"}], ";", "\n", "\[IndentingNewLine]", "\n", 
         RowBox[{"ansatz", "=", 
          RowBox[{"Sum", "[", 
           RowBox[{
            RowBox[{
             RowBox[{"ToExpression", "[", 
              RowBox[{"\"\<x\>\"", "<>", 
               RowBox[{"ToString", "[", "n", "]"}]}], "]"}], " ", 
             RowBox[{"Exp", "[", 
              RowBox[{
               RowBox[{"-", 
                RowBox[{"(", 
                 RowBox[{"Global`t", "-", "ti"}], ")"}]}], "/", 
               RowBox[{"(", 
                RowBox[{
                 RowBox[{"\[Tau]s", "[", 
                  RowBox[{"[", 
                   RowBox[{"n", "+", "1"}], "]"}], "]"}], 
                 RowBox[{"(", 
                  RowBox[{"1", "+", 
                   RowBox[{"ToExpression", "[", 
                    RowBox[{"\"\<\[Beta]\>\"", "<>", 
                     RowBox[{"ToString", "[", "n", "]"}]}], "]"}]}], ")"}]}], 
                ")"}]}], "]"}], " ", 
             RowBox[{"(", 
              RowBox[{
               RowBox[{"Cos", "[", 
                RowBox[{
                 RowBox[{"\[Omega]s", "[", 
                  RowBox[{"[", 
                   RowBox[{"n", "+", "1"}], "]"}], "]"}], 
                 RowBox[{"(", 
                  RowBox[{"1", "+", 
                   RowBox[{"ToExpression", "[", 
                    RowBox[{"\"\<\[Alpha]\>\"", "<>", 
                     RowBox[{"ToString", "[", "n", "]"}]}], "]"}]}], ")"}], " ", 
                 RowBox[{"(", "Global`t", ")"}]}], "]"}], "+", 
               RowBox[{"I", " ", 
                RowBox[{"Sin", "[", " ", 
                 RowBox[{
                  RowBox[{"\[Omega]s", "[", 
                   RowBox[{"[", 
                    RowBox[{"n", "+", "1"}], "]"}], "]"}], 
                  RowBox[{"(", 
                   RowBox[{"1", "+", 
                    RowBox[{"ToExpression", "[", 
                     RowBox[{"\"\<\[Alpha]\>\"", "<>", 
                      RowBox[{"ToString", "[", "n", "]"}]}], "]"}]}], ")"}], " ", 
                  
                  RowBox[{"(", "t", ")"}]}], "]"}]}]}], " ", ")"}]}], ",", 
            RowBox[{"{", 
             RowBox[{"n", ",", "0", ",", "overtones"}], "}"}]}], "]"}]}], ";", 
         "\n", 
         RowBox[{"modto0", "=", 
          RowBox[{"Complement", "[", 
           RowBox[{
            RowBox[{"Table", "[", 
             RowBox[{"i", ",", 
              RowBox[{"{", 
               RowBox[{"i", ",", "0", ",", "overtones"}], "}"}]}], "]"}], ",", 
            "fit\[Alpha]"}], "]"}]}], ";", "\n", 
         RowBox[{"modto0", "=", 
          RowBox[{"Table", "[", 
           RowBox[{
            RowBox[{"ToExpression", "[", 
             RowBox[{"\"\<\[Alpha]\>\"", "<>", 
              RowBox[{"ToString", "[", 
               RowBox[{"modto0", "[", 
                RowBox[{"[", "i", "]"}], "]"}], "]"}]}], "]"}], ",", 
            RowBox[{"{", 
             RowBox[{"i", ",", 
              RowBox[{"Length", "@", "modto0"}]}], "}"}]}], "]"}]}], ";", "\n", 
         RowBox[{"ansatz", "=", 
          RowBox[{"ansatz", "/.", 
           RowBox[{"(", 
            RowBox[{"Table", "[", 
             RowBox[{
              RowBox[{
               RowBox[{"modto0", "[", 
                RowBox[{"[", "i", "]"}], "]"}], "->", "0"}], ",", 
              RowBox[{"{", 
               RowBox[{"i", ",", 
                RowBox[{"Length", "@", "modto0"}]}], "}"}]}], "]"}], ")"}]}]}], 
         ";", "\n", "\n", 
         RowBox[{"modto0", "=", 
          RowBox[{"Complement", "[", 
           RowBox[{
            RowBox[{"Table", "[", 
             RowBox[{"i", ",", 
              RowBox[{"{", 
               RowBox[{"i", ",", "0", ",", "overtones"}], "}"}]}], "]"}], ",", 
            "fit\[Tau]"}], "]"}]}], ";", "\n", 
         RowBox[{"modto0", "=", 
          RowBox[{"Table", "[", 
           RowBox[{
            RowBox[{"ToExpression", "[", 
             RowBox[{"\"\<\[Beta]\>\"", "<>", 
              RowBox[{"ToString", "[", 
               RowBox[{"modto0", "[", 
                RowBox[{"[", "i", "]"}], "]"}], "]"}]}], "]"}], ",", 
            RowBox[{"{", 
             RowBox[{"i", ",", 
              RowBox[{"Length", "@", "modto0"}]}], "}"}]}], "]"}]}], ";", "\n", 
         RowBox[{"ansatz", "=", 
          RowBox[{"ansatz", "/.", 
           RowBox[{"(", 
            RowBox[{"Table", "[", 
             RowBox[{
              RowBox[{
               RowBox[{"modto0", "[", 
                RowBox[{"[", "i", "]"}], "]"}], "->", "0"}], ",", 
              RowBox[{"{", 
               RowBox[{"i", ",", 
                RowBox[{"Length", "@", "modto0"}]}], "}"}]}], "]"}], 
            ")"}]}]}]}]}], "\[IndentingNewLine]", "]"}]}], "\n"}], "Code",
     CellChangeTimes->{{3.771677386705565*^9, 3.771677432575967*^9}, {
       3.771677478692521*^9, 3.7716776974786987`*^9}, {3.771677749156809*^9, 
       3.771677749245604*^9}, {3.771678368242831*^9, 3.77167855802042*^9}, {
       3.7719072251494093`*^9, 3.771907227456575*^9}, {3.7719072710256453`*^9, 
       3.771907398091879*^9}, {3.771907458458599*^9, 3.771907471104031*^9}, {
       3.771907535295508*^9, 3.771907567230341*^9}, {3.771907597432748*^9, 
       3.771907629986505*^9}, {3.77190871277954*^9, 3.771908761390111*^9}, {
       3.771908813523059*^9, 3.7719089729431467`*^9}, {3.771909004206633*^9, 
       3.77190900469588*^9}, {3.771909058496481*^9, 3.771909075189431*^9}, {
       3.771909162367087*^9, 3.7719093135594387`*^9}, {3.7719093472737703`*^9, 
       3.7719094536444597`*^9}, {3.771909485309827*^9, 3.7719096216321917`*^9}, {
       3.771911525736096*^9, 3.771911555269594*^9}, {3.771911592383946*^9, 
       3.771911650727923*^9}, {3.7719119344490023`*^9, 3.771911934634461*^9}, {
       3.772193444179907*^9, 3.7721934684908667`*^9}, 3.7721935063709593`*^9, {
       3.7721935368526163`*^9, 3.77219366166796*^9}, {3.77219642009752*^9, 
       3.772196501577361*^9}, {3.772196556744199*^9, 3.7721965582919827`*^9}, {
       3.772196623495311*^9, 3.772196703653275*^9}, {3.772196842685261*^9, 
       3.772196859406479*^9}, {3.772196988080412*^9, 3.7721970025950603`*^9}, {
       3.7722478303251*^9, 3.772247831532436*^9}, {3.77658033668747*^9, 
       3.776580348028509*^9}, {3.7765809639728327`*^9, 3.77658097177113*^9}, {
       3.776581457080768*^9, 3.776581475487019*^9}, {3.776581515046463*^9, 
       3.77658160150498*^9}, {3.7765817333625803`*^9, 3.7765817752553797`*^9}, {
       3.7765860616001368`*^9, 3.776586064674204*^9}, {3.776586100742178*^9, 
       3.776586185337967*^9}, {3.776586259954899*^9, 3.776586260329609*^9}, {
       3.776586308985792*^9, 3.776586326416067*^9}, {3.776586370893306*^9, 
       3.7765863790338497`*^9}, {3.7765864409394817`*^9, 3.776586462208321*^9}, {
       3.776586494448669*^9, 3.776586550379714*^9}, {3.776588773375059*^9, 
       3.776588777468933*^9}, {3.778555556406411*^9, 3.778555568824278*^9}, {
       3.778565526517099*^9, 3.778565530554241*^9}, {3.7785655639133472`*^9, 
       3.7785656183907623`*^9}, {3.778565653049898*^9, 3.7785657064928303`*^9}, {
       3.778565785975872*^9, 3.7785657961721077`*^9}, {3.778565857608344*^9, 
       3.778565859731264*^9}, 3.77856591349852*^9, {3.778566191886526*^9, 
       3.778566193930477*^9}, 3.778566246778599*^9, {3.778566363118126*^9, 
       3.77856640048003*^9}, {3.778566501309498*^9, 3.778566501907134*^9}, {
       3.778567075366261*^9, 3.7785670782516212`*^9}, {3.788525124836349*^9, 
       3.78852523359028*^9}, {3.788526641416211*^9, 3.788526680332898*^9}, {
       3.799116938155278*^9, 3.799117020249506*^9}, {3.799117305780458*^9, 
       3.799117312403159*^9}, 3.799117651387577*^9, 3.7991177458618393`*^9, {
       3.799118148609033*^9, 3.7991181589312077`*^9}, {3.7991214823848133`*^9, 
       3.799121543688567*^9}, {3.7991219304672318`*^9, 
       3.7991219484319696`*^9}},ExpressionUUID->"2820b72e-3d09-4482-8e84-\
    0d295d489fa4"],
    
    Cell[BoxData[{
     RowBox[{
      RowBox[{
       RowBox[{"Options", "[", "OvertoneModelV2", "]"}], "=", 
       RowBox[{"Join", "[", 
        RowBox[{
         RowBox[{"Options", "[", "\[Omega]lmn", "]"}], ",", 
         RowBox[{"{", 
          RowBox[{
           RowBox[{"\"\<FixExtra\>\"", "\[Rule]", "True"}], ",", 
           RowBox[{"\"\<Fit\[Alpha]\>\"", "\[Rule]", 
            RowBox[{"{", "}"}]}], ",", 
           RowBox[{"\"\<Fit\[Tau]\>\"", "\[Rule]", 
            RowBox[{"{", "}"}]}], ",", 
           RowBox[{"\"\<Mode\>\"", "\[Rule]", 
            RowBox[{"{", 
             RowBox[{"2", ",", "2"}], "}"}]}], ",", 
           RowBox[{"\"\<Vary\[Omega]\>\"", "\[Rule]", "False"}], ",", 
           RowBox[{"\"\<Mixing\>\"", "\[Rule]", 
            RowBox[{"{", 
             RowBox[{"False", ",", 
              RowBox[{"{", 
               RowBox[{"2", ",", "2"}], "}"}]}], "}"}]}], ",", 
           RowBox[{"\"\<ReIm\>\"", "\[Rule]", "False"}], ",", 
           RowBox[{"\"\<AmpPhase\>\"", "\[Rule]", "False"}], ",", 
           RowBox[{"\"\<AmpPhaseShift\>\"", "\[Rule]", "False"}], ",", 
           RowBox[{"\"\<QualityFactor\>\"", "\[Rule]", "False"}], ",", 
           RowBox[{"\"\<ParameterValues\>\"", "\[Rule]", 
            RowBox[{"{", "}"}]}], ",", 
           RowBox[{"\"\<\[Omega]val\>\"", "\[Rule]", 
            RowBox[{"{", 
             RowBox[{
              RowBox[{"-", "0.05"}], ",", "0.05"}], "}"}]}], ",", 
           RowBox[{"\"\<Export_\[Omega]val\>\"", "\[Rule]", "False"}]}], "}"}]}], 
        "]"}]}], ";"}], "\n", 
     RowBox[{
      RowBox[{"OvertoneModelV2", "[", 
       RowBox[{"overtones_", ",", "pars_", ",", "ti_", ",", 
        RowBox[{"OptionsPattern", "[", "]"}]}], "]"}], ":=", 
      RowBox[{"Block", "[", 
       RowBox[{
        RowBox[{"{", 
         RowBox[{
         "ansatz", ",", "ampansatz", ",", "amphase", ",", "amphaseshift", ",", 
          "ex\[Omega]val", ",", "fixetra", ",", "fit\[Alpha]", ",", "fit\[Tau]", 
          ",", "im", ",", "imm", ",", "l", ",", "m", ",", "lm", ",", "modesdata", 
          ",", "modesfile", ",", "mm", ",", "mixing", ",", "mode", ",", "modto0", 
          ",", "parvals", ",", "phaseansatz", ",", "qfact", ",", "qfactm", ",", 
          "qualfactorQ", ",", "re", ",", "reim", ",", "rem", ",", "Global`t", ",",
           "var", ",", "vary\[Omega]", ",", "x", ",", "y", ",", "\[Tau]s", ",", 
          "\[Tau]sm", ",", "\[Alpha]", ",", "\[Beta]", ",", "\[Omega]m", ",", 
          "\[Omega]s", ",", "\[Omega]m\[Tau]sm", ",", "\[Eta]", ",", "\[Chi]1", 
          ",", "\[Chi]2", ",", "mixmode", ",", "\[Omega]val"}], "}"}], ",", 
        "\[IndentingNewLine]", 
        RowBox[{
         RowBox[{"fixetra", "=", 
          RowBox[{"OptionValue", "[", "\"\<FixExtra\>\"", "]"}]}], ";", "\n", 
         RowBox[{"fit\[Alpha]", "=", 
          RowBox[{"OptionValue", "[", "\"\<Fit\[Alpha]\>\"", "]"}]}], ";", "\n", 
         RowBox[{"fit\[Tau]", "=", 
          RowBox[{"OptionValue", "[", "\"\<Fit\[Tau]\>\"", "]"}]}], ";", "\n", 
         RowBox[{"mode", "=", 
          RowBox[{"OptionValue", "[", "\"\<Mode\>\"", "]"}]}], ";", "\n", 
         RowBox[{"vary\[Omega]", "=", 
          RowBox[{"OptionValue", "[", "\"\<Vary\[Omega]\>\"", "]"}]}], ";", "\n", 
         
         RowBox[{"mixing", "=", 
          RowBox[{"OptionValue", "[", "\"\<Mixing\>\"", "]"}]}], ";", "\n", 
         RowBox[{"reim", "=", 
          RowBox[{"OptionValue", "[", "\"\<ReIm\>\"", "]"}]}], ";", "\n", 
         RowBox[{"amphase", "=", 
          RowBox[{"OptionValue", "[", "\"\<AmpPhase\>\"", "]"}]}], ";", "\n", 
         RowBox[{"amphaseshift", "=", 
          RowBox[{"OptionValue", "[", "\"\<AmpPhaseShift\>\"", "]"}]}], ";", "\n", 
         RowBox[{"parvals", "=", 
          RowBox[{"OptionValue", "[", "\"\<ParameterValues\>\"", "]"}]}], ";", 
         "\n", 
         RowBox[{"\[Omega]val", "=", 
          RowBox[{"OptionValue", "[", "\"\<\[Omega]val\>\"", "]"}]}], ";", "\n", 
         RowBox[{"ex\[Omega]val", "=", 
          RowBox[{"OptionValue", "[", "\"\<Export_\[Omega]val\>\"", "]"}]}], ";", 
         "\n", 
         RowBox[{"modesdata", "=", 
          RowBox[{"OptionValue", "[", "\"\<ModesData\>\"", "]"}]}], ";", "\n", 
         RowBox[{"modesfile", "=", 
          RowBox[{"OptionValue", "[", "\"\<ModesFile\>\"", "]"}]}], ";", "\n", 
         RowBox[{"qualfactorQ", "=", 
          RowBox[{"OptionValue", "[", "\"\<QualityFactor\>\"", "]"}]}], ";", "\n", 
         RowBox[{
          RowBox[{"{", 
           RowBox[{"lm", ",", "mm"}], "}"}], "=", 
          RowBox[{"mixing", "[", 
           RowBox[{"[", "2", "]"}], "]"}]}], ";", "\n", "\n", 
         RowBox[{"l", "=", 
          RowBox[{"mode", "[", 
           RowBox[{"[", "1", "]"}], "]"}]}], ";", "\n", 
         RowBox[{"m", "=", 
          RowBox[{"mode", "[", 
           RowBox[{"[", "2", "]"}], "]"}]}], ";", "\n", 
         RowBox[{
          RowBox[{"{", 
           RowBox[{"\[Eta]", ",", "\[Chi]1", ",", "\[Chi]2"}], "}"}], "=", 
          RowBox[{"pars", "[", 
           RowBox[{"[", 
            RowBox[{"1", ";;", "3"}], "]"}], "]"}]}], ";", "\n", 
         "\[IndentingNewLine]", 
         RowBox[{"(*", " ", 
          RowBox[{
           RowBox[{
            RowBox[{"Freqs", "."}], " ", "&"}], " ", "damping", " ", "times", " ",
            "from", " ", "Vitor"}], " ", "*)"}], "\n", 
         RowBox[{"If", "[", 
          RowBox[{
           RowBox[{
            RowBox[{"Length", "@", "modesdata"}], "\[Equal]", "0"}], ",", 
           "\[IndentingNewLine]", "\t", 
           RowBox[{
            RowBox[{"\[Omega]s", "=", 
             RowBox[{"Table", "[", 
              RowBox[{
               RowBox[{
                RowBox[{"\[Omega]lmn", "[", 
                 RowBox[{
                 "l", ",", "m", ",", "n", ",", "\[Eta]", ",", "\[Chi]1", ",", 
                  "\[Chi]2", ",", 
                  RowBox[{"\"\<ModesFile\>\"", "->", "modesfile"}]}], "]"}], "[", 
                
                RowBox[{"[", "1", "]"}], "]"}], ",", 
               RowBox[{"{", 
                RowBox[{"n", ",", "0", ",", "overtones"}], "}"}]}], "]"}]}], ";", 
            "\n", "\t", 
            RowBox[{"var", "=", 
             RowBox[{"Range", "[", 
              RowBox[{"0", ",", "7"}], "]"}]}], ";", "\n", "\t", 
            RowBox[{"If", "[", 
             RowBox[{"vary\[Omega]", ",", 
              RowBox[{"\[Omega]s", "=", 
               RowBox[{"Table", "[", 
                RowBox[{
                 RowBox[{
                  RowBox[{"If", "[", 
                   RowBox[{
                    RowBox[{"n", ">", "0"}], ",", 
                    RowBox[{
                     RowBox[{"var", "[", 
                      RowBox[{"[", 
                       RowBox[{"n", "+", "1"}], "]"}], "]"}], "=", 
                     RowBox[{"RandomReal", "[", 
                      RowBox[{"{", 
                       RowBox[{
                        RowBox[{"1", "+", 
                        RowBox[{"\[Omega]val", "[", 
                        RowBox[{"[", "1", "]"}], "]"}]}], ",", 
                        RowBox[{"1", "+", 
                        RowBox[{"\[Omega]val", "[", 
                        RowBox[{"[", "2", "]"}], "]"}]}]}], "}"}], "]"}]}], ",", 
                    RowBox[{
                     RowBox[{"var", "[", 
                      RowBox[{"[", "1", "]"}], "]"}], "=", "1"}]}], "]"}], ";", 
                  RowBox[{
                   RowBox[{"var", "[", 
                    RowBox[{"[", 
                     RowBox[{"n", "+", "1"}], "]"}], "]"}], "*", 
                   RowBox[{
                    RowBox[{"\[Omega]lmn", "[", 
                     RowBox[{
                     "l", ",", "m", ",", "n", ",", "\[Eta]", ",", "\[Chi]1", ",", 
                      "\[Chi]2", ",", 
                      RowBox[{"\"\<ModesFile\>\"", "->", "modesfile"}]}], "]"}], 
                    "[", 
                    RowBox[{"[", "1", "]"}], "]"}]}]}], ",", 
                 RowBox[{"{", 
                  RowBox[{"n", ",", "0", ",", "overtones"}], "}"}]}], "]"}]}]}], 
             "]"}], ";", "\n", "\t", 
            RowBox[{"\[Tau]s", "=", 
             RowBox[{"Table", "[", 
              RowBox[{
               RowBox[{
                RowBox[{"\[Omega]lmn", "[", 
                 RowBox[{
                 "l", ",", "m", ",", "n", ",", "\[Eta]", ",", "\[Chi]1", ",", 
                  "\[Chi]2", ",", 
                  RowBox[{"\"\<ModesFile\>\"", "->", "modesfile"}]}], "]"}], "[", 
                
                RowBox[{"[", "2", "]"}], "]"}], ",", 
               RowBox[{"{", 
                RowBox[{"n", ",", "0", ",", "overtones"}], "}"}]}], "]"}]}], ";", 
            "\n", "\t", 
            RowBox[{"qfact", "=", 
             RowBox[{"\[Omega]s", "*", "\[Tau]s"}]}], ";"}], "\n", "\t", ",", 
           "\n", "\t", 
           RowBox[{
            RowBox[{"\[Omega]s", "=", 
             RowBox[{"Table", "[", 
              RowBox[{
               RowBox[{
                RowBox[{"\[Omega]lmn", "[", 
                 RowBox[{
                 "l", ",", "m", ",", "n", ",", "\[Eta]", ",", "\[Chi]1", ",", 
                  "\[Chi]2", ",", 
                  RowBox[{"\"\<ModesData\>\"", "->", 
                   RowBox[{"modesdata", "[", 
                    RowBox[{"[", 
                     RowBox[{"n", "+", "1"}], "]"}], "]"}]}]}], "]"}], "[", 
                RowBox[{"[", "1", "]"}], "]"}], ",", 
               RowBox[{"{", 
                RowBox[{"n", ",", "0", ",", "overtones"}], "}"}]}], "]"}]}], ";", 
            "\n", "\t", 
            RowBox[{"var", "=", 
             RowBox[{"Range", "[", 
              RowBox[{"0", ",", "7"}], "]"}]}], ";", "\n", "\t", 
            RowBox[{"If", "[", 
             RowBox[{"vary\[Omega]", ",", 
              RowBox[{"\[Omega]s", "=", 
               RowBox[{"Table", "[", 
                RowBox[{
                 RowBox[{
                  RowBox[{"If", "[", 
                   RowBox[{
                    RowBox[{"n", ">", "0"}], ",", 
                    RowBox[{
                     RowBox[{"var", "[", 
                      RowBox[{"[", 
                       RowBox[{"n", "+", "1"}], "]"}], "]"}], "=", 
                     RowBox[{"RandomReal", "[", 
                      RowBox[{"{", 
                       RowBox[{
                        RowBox[{"1", "+", 
                        RowBox[{"\[Omega]val", "[", 
                        RowBox[{"[", "1", "]"}], "]"}]}], ",", 
                        RowBox[{"1", "+", 
                        RowBox[{"\[Omega]val", "[", 
                        RowBox[{"[", "2", "]"}], "]"}]}]}], "}"}], "]"}]}], ",", 
                    RowBox[{
                     RowBox[{"var", "[", 
                      RowBox[{"[", "1", "]"}], "]"}], "=", "1"}]}], "]"}], ";", 
                  RowBox[{
                   RowBox[{"var", "[", 
                    RowBox[{"[", 
                     RowBox[{"n", "+", "1"}], "]"}], "]"}], "*", 
                   RowBox[{
                    RowBox[{"\[Omega]lmn", "[", 
                     RowBox[{
                     "l", ",", "m", ",", "n", ",", "\[Eta]", ",", "\[Chi]1", ",", 
                      "\[Chi]2", ",", 
                      RowBox[{"\"\<ModesData\>\"", "->", 
                       RowBox[{"modesdata", "[", 
                        RowBox[{"[", 
                        RowBox[{"n", "+", "1"}], "]"}], "]"}]}]}], "]"}], "[", 
                    RowBox[{"[", "1", "]"}], "]"}]}]}], ",", 
                 RowBox[{"{", 
                  RowBox[{"n", ",", "0", ",", "overtones"}], "}"}]}], "]"}]}]}], 
             "]"}], ";", "\n", "\t", 
            RowBox[{"\[Tau]s", "=", 
             RowBox[{"Table", "[", 
              RowBox[{
               RowBox[{
                RowBox[{"\[Omega]lmn", "[", 
                 RowBox[{
                 "l", ",", "m", ",", "n", ",", "\[Eta]", ",", "\[Chi]1", ",", 
                  "\[Chi]2", ",", 
                  RowBox[{"\"\<ModesData\>\"", "->", 
                   RowBox[{"modesdata", "[", 
                    RowBox[{"[", 
                     RowBox[{"n", "+", "1"}], "]"}], "]"}]}]}], "]"}], "[", 
                RowBox[{"[", "2", "]"}], "]"}], ",", 
               RowBox[{"{", 
                RowBox[{"n", ",", "0", ",", "overtones"}], "}"}]}], "]"}]}], ";", 
            "\n", "\t", 
            RowBox[{"qfact", "=", 
             RowBox[{"\[Omega]s", "*", "\[Tau]s"}]}], ";"}]}], "\n", "\t", "]"}], 
         ";", "\n", "\n", "\n", 
         RowBox[{"If", "[", 
          RowBox[{
           RowBox[{"Not", "@", "amphase"}], ",", "\n", "    ", 
           RowBox[{
            RowBox[{"If", "[", 
             RowBox[{"qualfactorQ", ",", "\n", "\t", 
              RowBox[{
               RowBox[{"ansatz", "=", 
                RowBox[{"Sum", "[", 
                 RowBox[{
                  RowBox[{
                   RowBox[{"If", "[", 
                    RowBox[{
                     RowBox[{"Not", "@", "reim"}], ",", 
                     RowBox[{"x", "=", 
                      RowBox[{"ToExpression", "[", 
                       RowBox[{"\"\<x\>\"", "<>", 
                        RowBox[{"ToString", "[", "n", "]"}]}], "]"}]}], ",", 
                     RowBox[{"x", "=", 
                      RowBox[{
                       RowBox[{"ToExpression", "[", 
                        RowBox[{"(", 
                        RowBox[{"\"\<x\>\"", "<>", 
                        RowBox[{"ToString", "[", "n", "]"}]}], ")"}], "]"}], "+", 
                       
                       RowBox[{"I", " ", 
                        RowBox[{"ToExpression", "[", 
                        RowBox[{"(", 
                        RowBox[{"\"\<y\>\"", "<>", 
                        RowBox[{"ToString", "[", "n", "]"}]}], ")"}], 
                        "]"}]}]}]}]}], "]"}], ";", " ", 
                   RowBox[{"x", " ", 
                    RowBox[{"Exp", "[", 
                     RowBox[{
                      RowBox[{"-", 
                       RowBox[{"(", 
                        RowBox[{"Global`t", "-", "ti"}], ")"}]}], 
                      RowBox[{"(", 
                       RowBox[{
                        RowBox[{"\[Omega]s", "[", 
                        RowBox[{"[", 
                        RowBox[{"n", "+", "1"}], "]"}], "]"}], 
                        RowBox[{
                        RowBox[{"(", 
                        RowBox[{"1", "+", 
                        RowBox[{"ToExpression", "[", 
                        RowBox[{"\"\<\[Alpha]\>\"", "<>", 
                        RowBox[{"ToString", "[", "n", "]"}]}], "]"}]}], ")"}], 
                        "/", 
                        RowBox[{"(", 
                        RowBox[{
                        RowBox[{"qfact", "[", 
                        RowBox[{"[", 
                        RowBox[{"n", "+", "1"}], "]"}], "]"}], 
                        RowBox[{"(", 
                        RowBox[{"1", "+", 
                        RowBox[{"ToExpression", "[", 
                        RowBox[{"\"\<\[Beta]\>\"", "<>", 
                        RowBox[{"ToString", "[", "n", "]"}]}], "]"}]}], ")"}]}], 
                        ")"}]}]}], ")"}]}], "]"}], " ", 
                    RowBox[{"(", 
                     RowBox[{
                      RowBox[{"Cos", "[", 
                       RowBox[{
                        RowBox[{"\[Omega]s", "[", 
                        RowBox[{"[", 
                        RowBox[{"n", "+", "1"}], "]"}], "]"}], 
                        RowBox[{"(", 
                        RowBox[{"1", "+", 
                        RowBox[{"ToExpression", "[", 
                        RowBox[{"\"\<\[Alpha]\>\"", "<>", 
                        RowBox[{"ToString", "[", "n", "]"}]}], "]"}]}], ")"}], 
                        " ", 
                        RowBox[{"(", "Global`t", ")"}]}], "]"}], "+", 
                      RowBox[{"I", " ", 
                       RowBox[{"Sin", "[", " ", 
                        RowBox[{
                        RowBox[{"\[Omega]s", "[", 
                        RowBox[{"[", 
                        RowBox[{"n", "+", "1"}], "]"}], "]"}], 
                        RowBox[{"(", 
                        RowBox[{"1", "+", 
                        RowBox[{"ToExpression", "[", 
                        RowBox[{"\"\<\[Alpha]\>\"", "<>", 
                        RowBox[{"ToString", "[", "n", "]"}]}], "]"}]}], ")"}], 
                        " ", 
                        RowBox[{"(", "Global`t", ")"}]}], "]"}]}]}], " ", 
                     ")"}]}]}], ",", 
                  RowBox[{"{", 
                   RowBox[{"n", ",", "0", ",", "overtones"}], "}"}]}], "]"}]}], 
               ";", "\n", "\t\t", 
               RowBox[{"If", "[", 
                RowBox[{
                 RowBox[{"mixing", "[", 
                  RowBox[{"[", "1", "]"}], "]"}], ",", "\n", "\t\t", 
                 RowBox[{
                  RowBox[{"\[Omega]m\[Tau]sm", "=", 
                   RowBox[{"Table", "[", 
                    RowBox[{
                     RowBox[{"\[Omega]lmn", "[", 
                      RowBox[{
                      "lm", ",", "mm", ",", "n", ",", "\[Eta]", ",", "\[Chi]1", 
                       ",", "\[Chi]2", ",", 
                       RowBox[{"\"\<ModesFile\>\"", "->", "modesfile"}]}], "]"}], 
                     ",", 
                     RowBox[{"{", 
                      RowBox[{"n", ",", "0", ",", "overtones"}], "}"}]}], "]"}]}],
                   ";", "\n", "\t\t", 
                  RowBox[{"\[Omega]m", "=", 
                   RowBox[{"\[Omega]m\[Tau]sm", "[", 
                    RowBox[{"[", 
                     RowBox[{"All", ",", "1"}], "]"}], "]"}]}], ";", "\n", "\t\t", 
                  RowBox[{"\[Tau]sm", "=", 
                   RowBox[{"\[Omega]m\[Tau]sm", "[", 
                    RowBox[{"[", 
                     RowBox[{"All", ",", "2"}], "]"}], "]"}]}], ";", "\n", "\t\t", 
                  RowBox[{"qfactm", "=", 
                   RowBox[{"\[Omega]m", "*", "\[Tau]sm"}]}], ";", "\n", "\t\t", 
                  RowBox[{"ansatz", "=", 
                   RowBox[{"ansatz", "+", 
                    RowBox[{"Sum", "[", 
                     RowBox[{
                      RowBox[{
                       RowBox[{"If", "[", 
                        RowBox[{
                        RowBox[{"Not", "@", "reim"}], ",", 
                        RowBox[{"x", "=", 
                        RowBox[{"ToExpression", "[", 
                        RowBox[{"\"\<xm\>\"", "<>", 
                        RowBox[{"ToString", "[", "n", "]"}]}], "]"}]}], ",", 
                        RowBox[{"x", "=", 
                        RowBox[{
                        RowBox[{"ToExpression", "[", 
                        RowBox[{"\"\<xm\>\"", "<>", 
                        RowBox[{"ToString", "[", "n", "]"}]}], "]"}], "+", 
                        RowBox[{"I", " ", 
                        RowBox[{"ToExpression", "[", 
                        RowBox[{"\"\<ym\>\"", "<>", 
                        RowBox[{"ToString", "[", "n", "]"}]}], "]"}]}]}]}]}], 
                        "]"}], ";", 
                       RowBox[{"x", " ", 
                        RowBox[{"Exp", "[", 
                        RowBox[{
                        RowBox[{"-", 
                        RowBox[{"(", 
                        RowBox[{"Global`t", "-", "ti"}], ")"}]}], 
                        RowBox[{"(", 
                        RowBox[{
                        RowBox[{"\[Omega]s", "[", 
                        RowBox[{"[", 
                        RowBox[{"n", "+", "1"}], "]"}], "]"}], 
                        RowBox[{
                        RowBox[{"(", 
                        RowBox[{"1", "+", 
                        RowBox[{"ToExpression", "[", 
                        RowBox[{"\"\<\[Alpha]\>\"", "<>", 
                        RowBox[{"ToString", "[", "n", "]"}]}], "]"}]}], ")"}], 
                        "/", 
                        RowBox[{"(", 
                        RowBox[{
                        RowBox[{"qfactm", "[", 
                        RowBox[{"[", 
                        RowBox[{"n", "+", "1"}], "]"}], "]"}], 
                        RowBox[{"(", 
                        RowBox[{"1", "+", 
                        RowBox[{"ToExpression", "[", 
                        RowBox[{"\"\<\[Beta]\>\"", "<>", 
                        RowBox[{"ToString", "[", "n", "]"}]}], "]"}]}], ")"}]}], 
                        ")"}]}]}], ")"}]}], "]"}], " ", 
                        RowBox[{"(", 
                        RowBox[{
                        RowBox[{"Cos", "[", 
                        RowBox[{
                        RowBox[{"\[Omega]m", "[", 
                        RowBox[{"[", 
                        RowBox[{"n", "+", "1"}], "]"}], "]"}], " ", 
                        RowBox[{"(", "Global`t", ")"}]}], "]"}], "+", 
                        RowBox[{"I", " ", 
                        RowBox[{"Sin", "[", " ", 
                        RowBox[{
                        RowBox[{"\[Omega]m", "[", 
                        RowBox[{"[", 
                        RowBox[{"n", "+", "1"}], "]"}], "]"}], " ", 
                        RowBox[{"(", "Global`t", ")"}]}], "]"}]}]}], " ", 
                        ")"}]}]}], ",", 
                      RowBox[{"{", 
                       RowBox[{"n", ",", "0", ",", "overtones"}], "}"}]}], 
                     "]"}]}]}]}]}], "]"}], ";"}], "\n", "\t", ",", "\n", "\t", 
              RowBox[{
               RowBox[{"ansatz", "=", 
                RowBox[{"Sum", "[", 
                 RowBox[{
                  RowBox[{
                   RowBox[{"If", "[", 
                    RowBox[{
                     RowBox[{"Not", "@", "reim"}], ",", 
                     RowBox[{"If", "[", 
                      RowBox[{"amphaseshift", ",", 
                       RowBox[{"x", "=", 
                        RowBox[{
                        RowBox[{"ToExpression", "[", 
                        RowBox[{"\"\<x\>\"", "<>", 
                        RowBox[{"ToString", "[", "n", "]"}]}], "]"}], "*", 
                        RowBox[{"Exp", "[", 
                        RowBox[{"I", " ", 
                        RowBox[{"ToExpression", "[", 
                        RowBox[{"\"\<y\>\"", "<>", 
                        RowBox[{"ToString", "[", "n", "]"}]}], "]"}]}], "]"}]}]}],
                        ",", 
                       RowBox[{"x", "=", 
                        RowBox[{"ToExpression", "[", 
                        RowBox[{"\"\<x\>\"", "<>", 
                        RowBox[{"ToString", "[", "n", "]"}]}], "]"}]}]}], "]"}], 
                     ",", 
                     RowBox[{"x", "=", 
                      RowBox[{
                       RowBox[{"ToExpression", "[", 
                        RowBox[{"(", 
                        RowBox[{"\"\<x\>\"", "<>", 
                        RowBox[{"ToString", "[", "n", "]"}]}], ")"}], "]"}], "+", 
                       
                       RowBox[{"I", " ", 
                        RowBox[{"ToExpression", "[", 
                        RowBox[{"(", 
                        RowBox[{"\"\<y\>\"", "<>", 
                        RowBox[{"ToString", "[", "n", "]"}]}], ")"}], 
                        "]"}]}]}]}]}], "]"}], ";", " ", 
                   RowBox[{"x", " ", 
                    RowBox[{"Exp", "[", 
                     RowBox[{
                      RowBox[{"-", 
                       RowBox[{"(", 
                        RowBox[{"Global`t", "-", "ti"}], ")"}]}], 
                      RowBox[{"(", 
                       RowBox[{"1", "/", 
                        RowBox[{"(", 
                        RowBox[{
                        RowBox[{"\[Tau]s", "[", 
                        RowBox[{"[", 
                        RowBox[{"n", "+", "1"}], "]"}], "]"}], 
                        RowBox[{"(", 
                        RowBox[{"1", "+", 
                        RowBox[{"ToExpression", "[", 
                        RowBox[{"\"\<\[Beta]\>\"", "<>", 
                        RowBox[{"ToString", "[", "n", "]"}]}], "]"}]}], ")"}]}], 
                        ")"}]}], ")"}]}], "]"}], " ", 
                    RowBox[{"(", 
                     RowBox[{
                      RowBox[{"Cos", "[", 
                       RowBox[{
                        RowBox[{"\[Omega]s", "[", 
                        RowBox[{"[", 
                        RowBox[{"n", "+", "1"}], "]"}], "]"}], 
                        RowBox[{"(", 
                        RowBox[{"1", "+", 
                        RowBox[{"ToExpression", "[", 
                        RowBox[{"\"\<\[Alpha]\>\"", "<>", 
                        RowBox[{"ToString", "[", "n", "]"}]}], "]"}]}], ")"}], 
                        " ", 
                        RowBox[{"(", "Global`t", ")"}]}], "]"}], "+", 
                      RowBox[{"I", " ", 
                       RowBox[{"Sin", "[", " ", 
                        RowBox[{
                        RowBox[{"\[Omega]s", "[", 
                        RowBox[{"[", 
                        RowBox[{"n", "+", "1"}], "]"}], "]"}], 
                        RowBox[{"(", 
                        RowBox[{"1", "+", 
                        RowBox[{"ToExpression", "[", 
                        RowBox[{"\"\<\[Alpha]\>\"", "<>", 
                        RowBox[{"ToString", "[", "n", "]"}]}], "]"}]}], ")"}], 
                        " ", 
                        RowBox[{"(", "Global`t", ")"}]}], "]"}]}]}], " ", 
                     ")"}]}]}], ",", 
                  RowBox[{"{", 
                   RowBox[{"n", ",", "0", ",", "overtones"}], "}"}]}], "]"}]}], 
               ";", "\n", "\t\t", 
               RowBox[{"If", "[", 
                RowBox[{
                 RowBox[{"mixing", "[", 
                  RowBox[{"[", "1", "]"}], "]"}], ",", "\n", "\t\t", 
                 RowBox[{
                  RowBox[{"\[Omega]m\[Tau]sm", "=", 
                   RowBox[{"Table", "[", 
                    RowBox[{
                     RowBox[{"\[Omega]lmn", "[", 
                      RowBox[{
                      "lm", ",", "mm", ",", "n", ",", "\[Eta]", ",", "\[Chi]1", 
                       ",", "\[Chi]2", ",", 
                       RowBox[{"\"\<ModesFile\>\"", "->", "modesfile"}]}], "]"}], 
                     ",", 
                     RowBox[{"{", 
                      RowBox[{"n", ",", "0", ",", "overtones"}], "}"}]}], "]"}]}],
                   ";", "\n", "\t\t", 
                  RowBox[{"\[Omega]m", "=", 
                   RowBox[{"\[Omega]m\[Tau]sm", "[", 
                    RowBox[{"[", 
                     RowBox[{"All", ",", "1"}], "]"}], "]"}]}], ";", "\n", "\t\t", 
                  RowBox[{"\[Tau]sm", "=", 
                   RowBox[{"\[Omega]m\[Tau]sm", "[", 
                    RowBox[{"[", 
                     RowBox[{"All", ",", "2"}], "]"}], "]"}]}], ";", "\n", "\t\t", 
                  RowBox[{"ansatz", "=", 
                   RowBox[{"ansatz", "+", 
                    RowBox[{"Sum", "[", 
                     RowBox[{
                      RowBox[{
                       RowBox[{"If", "[", 
                        RowBox[{
                        RowBox[{"Not", "@", "reim"}], ",", 
                        RowBox[{"x", "=", 
                        RowBox[{"ToExpression", "[", 
                        RowBox[{"\"\<xm\>\"", "<>", 
                        RowBox[{"ToString", "[", "n", "]"}]}], "]"}]}], ",", 
                        RowBox[{"x", "=", 
                        RowBox[{
                        RowBox[{"ToExpression", "[", 
                        RowBox[{"\"\<xm\>\"", "<>", 
                        RowBox[{"ToString", "[", "n", "]"}]}], "]"}], "+", 
                        RowBox[{"I", " ", 
                        RowBox[{"ToExpression", "[", 
                        RowBox[{"\"\<ym\>\"", "<>", 
                        RowBox[{"ToString", "[", "n", "]"}]}], "]"}]}]}]}]}], 
                        "]"}], ";", 
                       RowBox[{"x", " ", 
                        RowBox[{"Exp", "[", 
                        RowBox[{
                        RowBox[{"-", 
                        RowBox[{"(", 
                        RowBox[{"Global`t", "-", "ti"}], ")"}]}], "/", 
                        RowBox[{"(", 
                        RowBox[{"\[Tau]sm", "[", 
                        RowBox[{"[", 
                        RowBox[{"n", "+", "1"}], "]"}], "]"}], ")"}]}], "]"}], 
                        " ", 
                        RowBox[{"(", 
                        RowBox[{
                        RowBox[{"Cos", "[", 
                        RowBox[{
                        RowBox[{"\[Omega]m", "[", 
                        RowBox[{"[", 
                        RowBox[{"n", "+", "1"}], "]"}], "]"}], " ", 
                        RowBox[{"(", "Global`t", ")"}]}], "]"}], "+", 
                        RowBox[{"I", " ", 
                        RowBox[{"Sin", "[", " ", 
                        RowBox[{
                        RowBox[{"\[Omega]m", "[", 
                        RowBox[{"[", 
                        RowBox[{"n", "+", "1"}], "]"}], "]"}], " ", 
                        RowBox[{"(", "Global`t", ")"}]}], "]"}]}]}], " ", 
                        ")"}]}]}], ",", 
                      RowBox[{"{", 
                       RowBox[{"n", ",", "0", ",", "overtones"}], "}"}]}], 
                     "]"}]}]}]}]}], "]"}], ";"}]}], "\t", "\n", "\t", "]"}], 
            ";"}], "\n", "\t", ",", "\n", "\t", 
           RowBox[{
            RowBox[{"If", "[", 
             RowBox[{"qualfactorQ", ",", "\n", "\t", 
              RowBox[{
               RowBox[{"re", "=", 
                RowBox[{"Sum", "[", 
                 RowBox[{
                  RowBox[{
                   RowBox[{"ToExpression", "[", 
                    RowBox[{"\"\<x\>\"", "<>", 
                     RowBox[{"ToString", "[", "n", "]"}]}], "]"}], " ", 
                   RowBox[{"Exp", "[", 
                    RowBox[{
                     RowBox[{"-", 
                      RowBox[{"(", 
                       RowBox[{"Global`t", "-", "ti"}], ")"}]}], 
                     RowBox[{"(", 
                      RowBox[{
                       RowBox[{"\[Omega]s", "[", 
                        RowBox[{"[", 
                        RowBox[{"n", "+", "1"}], "]"}], "]"}], 
                       RowBox[{
                        RowBox[{"(", 
                        RowBox[{"1", "+", 
                        RowBox[{"ToExpression", "[", 
                        RowBox[{"\"\<\[Alpha]\>\"", "<>", 
                        RowBox[{"ToString", "[", "n", "]"}]}], "]"}]}], ")"}], 
                        "/", 
                        RowBox[{"(", 
                        RowBox[{
                        RowBox[{"qfact", "[", 
                        RowBox[{"[", 
                        RowBox[{"n", "+", "1"}], "]"}], "]"}], 
                        RowBox[{"(", 
                        RowBox[{"1", "+", 
                        RowBox[{"ToExpression", "[", 
                        RowBox[{"\"\<\[Beta]\>\"", "<>", 
                        RowBox[{"ToString", "[", "n", "]"}]}], "]"}]}], ")"}]}], 
                        ")"}]}]}], ")"}]}], "]"}], 
                   RowBox[{"Cos", "[", 
                    RowBox[{
                     RowBox[{
                      RowBox[{"\[Omega]s", "[", 
                       RowBox[{"[", 
                        RowBox[{"n", "+", "1"}], "]"}], "]"}], 
                      RowBox[{"(", 
                       RowBox[{"1", "+", 
                        RowBox[{"ToExpression", "[", 
                        RowBox[{"\"\<\[Alpha]\>\"", "<>", 
                        RowBox[{"ToString", "[", "n", "]"}]}], "]"}]}], ")"}], 
                      " ", 
                      RowBox[{"(", "Global`t", ")"}]}], "+", 
                     RowBox[{"ToExpression", "[", 
                      RowBox[{"\"\<\[Phi]\>\"", "<>", 
                       RowBox[{"ToString", "[", "n", "]"}]}], "]"}]}], "]"}]}], 
                  ",", 
                  RowBox[{"{", 
                   RowBox[{"n", ",", "0", ",", "overtones"}], "}"}]}], "]"}]}], 
               ";", "\n", "\t", 
               RowBox[{"im", "=", 
                RowBox[{"Sum", "[", 
                 RowBox[{
                  RowBox[{
                   RowBox[{"ToExpression", "[", 
                    RowBox[{"\"\<x\>\"", "<>", 
                     RowBox[{"ToString", "[", "n", "]"}]}], "]"}], " ", 
                   RowBox[{"Exp", "[", 
                    RowBox[{
                     RowBox[{"-", 
                      RowBox[{"(", 
                       RowBox[{"Global`t", "-", "ti"}], ")"}]}], 
                     RowBox[{"(", 
                      RowBox[{
                       RowBox[{"\[Omega]s", "[", 
                        RowBox[{"[", 
                        RowBox[{"n", "+", "1"}], "]"}], "]"}], 
                       RowBox[{
                        RowBox[{"(", 
                        RowBox[{"1", "+", 
                        RowBox[{"ToExpression", "[", 
                        RowBox[{"\"\<\[Alpha]\>\"", "<>", 
                        RowBox[{"ToString", "[", "n", "]"}]}], "]"}]}], ")"}], 
                        "/", 
                        RowBox[{"(", 
                        RowBox[{
                        RowBox[{"qfact", "[", 
                        RowBox[{"[", 
                        RowBox[{"n", "+", "1"}], "]"}], "]"}], 
                        RowBox[{"(", 
                        RowBox[{"1", "+", 
                        RowBox[{"ToExpression", "[", 
                        RowBox[{"\"\<\[Beta]\>\"", "<>", 
                        RowBox[{"ToString", "[", "n", "]"}]}], "]"}]}], ")"}]}], 
                        ")"}]}]}], ")"}]}], "]"}], 
                   RowBox[{"Sin", "[", 
                    RowBox[{
                     RowBox[{
                      RowBox[{"\[Omega]s", "[", 
                       RowBox[{"[", 
                        RowBox[{"n", "+", "1"}], "]"}], "]"}], 
                      RowBox[{"(", 
                       RowBox[{"1", "+", 
                        RowBox[{"ToExpression", "[", 
                        RowBox[{"\"\<\[Alpha]\>\"", "<>", 
                        RowBox[{"ToString", "[", "n", "]"}]}], "]"}]}], ")"}], 
                      " ", 
                      RowBox[{"(", "Global`t", ")"}]}], "+", 
                     RowBox[{"ToExpression", "[", 
                      RowBox[{"\"\<\[Phi]\>\"", "<>", 
                       RowBox[{"ToString", "[", "n", "]"}]}], "]"}]}], "]"}]}], 
                  ",", 
                  RowBox[{"{", 
                   RowBox[{"n", ",", "0", ",", "overtones"}], "}"}]}], "]"}]}], 
               ";", "\n", "\n", "\t\t", 
               RowBox[{"If", "[", 
                RowBox[{
                 RowBox[{"mixing", "[", 
                  RowBox[{"[", "1", "]"}], "]"}], ",", "\n", "\t\t\t", 
                 RowBox[{
                  RowBox[{"\[Omega]m\[Tau]sm", "=", 
                   RowBox[{"Table", "[", 
                    RowBox[{
                     RowBox[{"\[Omega]lmn", "[", 
                      RowBox[{
                      "lm", ",", "mm", ",", "n", ",", "\[Eta]", ",", "\[Chi]1", 
                       ",", "\[Chi]2", ",", 
                       RowBox[{"\"\<ModesFile\>\"", "->", "modesfile"}]}], "]"}], 
                     ",", 
                     RowBox[{"{", 
                      RowBox[{"n", ",", "0", ",", "overtones"}], "}"}]}], "]"}]}],
                   ";", "\n", "\t\t\t", 
                  RowBox[{"\[Omega]m", "=", 
                   RowBox[{"\[Omega]m\[Tau]sm", "[", 
                    RowBox[{"[", 
                     RowBox[{"All", ",", "1"}], "]"}], "]"}]}], ";", "\n", 
                  "\t\t\t", 
                  RowBox[{"\[Tau]sm", "=", 
                   RowBox[{"\[Omega]m\[Tau]sm", "[", 
                    RowBox[{"[", 
                     RowBox[{"All", ",", "2"}], "]"}], "]"}]}], ";", "\n", 
                  "\t\t\t", 
                  RowBox[{"qfactm", "=", 
                   RowBox[{"\[Omega]m", "*", "\[Tau]sm"}]}], ";", "\n", "\t\t\t", 
                  
                  RowBox[{"rem", "=", 
                   RowBox[{"Sum", "[", 
                    RowBox[{
                     RowBox[{
                      RowBox[{"ToExpression", "[", 
                       RowBox[{"\"\<x\>\"", "<>", 
                        RowBox[{"ToString", "[", "n", "]"}]}], "]"}], " ", 
                      RowBox[{"Exp", "[", 
                       RowBox[{
                        RowBox[{"-", 
                        RowBox[{"(", 
                        RowBox[{"Global`t", "-", "ti"}], ")"}]}], 
                        RowBox[{"(", 
                        RowBox[{
                        RowBox[{"\[Omega]s", "[", 
                        RowBox[{"[", 
                        RowBox[{"n", "+", "1"}], "]"}], "]"}], 
                        RowBox[{
                        RowBox[{"(", 
                        RowBox[{"1", "+", 
                        RowBox[{"ToExpression", "[", 
                        RowBox[{"\"\<\[Alpha]\>\"", "<>", 
                        RowBox[{"ToString", "[", "n", "]"}]}], "]"}]}], ")"}], 
                        "/", 
                        RowBox[{"(", 
                        RowBox[{
                        RowBox[{"qfactm", "[", 
                        RowBox[{"[", 
                        RowBox[{"n", "+", "1"}], "]"}], "]"}], 
                        RowBox[{"(", 
                        RowBox[{"1", "+", 
                        RowBox[{"ToExpression", "[", 
                        RowBox[{"\"\<\[Beta]\>\"", "<>", 
                        RowBox[{"ToString", "[", "n", "]"}]}], "]"}]}], ")"}]}], 
                        ")"}]}]}], ")"}]}], "]"}], " ", 
                      RowBox[{"(", 
                       RowBox[{
                        RowBox[{"Cos", "[", 
                        RowBox[{
                        RowBox[{"\[Omega]m", "[", 
                        RowBox[{"[", 
                        RowBox[{"n", "+", "1"}], "]"}], "]"}], " ", 
                        RowBox[{"(", "Global`t", ")"}]}], "]"}], "+", 
                        RowBox[{"I", " ", 
                        RowBox[{"Sin", "[", " ", 
                        RowBox[{
                        RowBox[{"\[Omega]m", "[", 
                        RowBox[{"[", 
                        RowBox[{"n", "+", "1"}], "]"}], "]"}], " ", 
                        RowBox[{"(", "Global`t", ")"}]}], "]"}]}]}], " ", ")"}]}],
                      ",", 
                     RowBox[{"{", 
                      RowBox[{"n", ",", "0", ",", "overtones"}], "}"}]}], "]"}]}],
                   ";", "\n", "\t\t\t", 
                  RowBox[{"imm", "=", 
                   RowBox[{"Sum", "[", 
                    RowBox[{
                     RowBox[{
                      RowBox[{"ToExpression", "[", 
                       RowBox[{"\"\<x\>\"", "<>", 
                        RowBox[{"ToString", "[", "n", "]"}]}], "]"}], " ", 
                      RowBox[{"Exp", "[", 
                       RowBox[{
                        RowBox[{"-", 
                        RowBox[{"(", 
                        RowBox[{"Global`t", "-", "ti"}], ")"}]}], 
                        RowBox[{"(", 
                        RowBox[{
                        RowBox[{"\[Omega]s", "[", 
                        RowBox[{"[", 
                        RowBox[{"n", "+", "1"}], "]"}], "]"}], 
                        RowBox[{
                        RowBox[{"(", 
                        RowBox[{"1", "+", 
                        RowBox[{"ToExpression", "[", 
                        RowBox[{"\"\<\[Alpha]\>\"", "<>", 
                        RowBox[{"ToString", "[", "n", "]"}]}], "]"}]}], ")"}], 
                        "/", 
                        RowBox[{"(", 
                        RowBox[{
                        RowBox[{"qfactm", "[", 
                        RowBox[{"[", 
                        RowBox[{"n", "+", "1"}], "]"}], "]"}], 
                        RowBox[{"(", 
                        RowBox[{"1", "+", 
                        RowBox[{"ToExpression", "[", 
                        RowBox[{"\"\<\[Beta]\>\"", "<>", 
                        RowBox[{"ToString", "[", "n", "]"}]}], "]"}]}], ")"}]}], 
                        ")"}]}]}], ")"}]}], "]"}], " ", 
                      RowBox[{"(", 
                       RowBox[{
                        RowBox[{"Sin", "[", 
                        RowBox[{
                        RowBox[{"\[Omega]m", "[", 
                        RowBox[{"[", 
                        RowBox[{"n", "+", "1"}], "]"}], "]"}], " ", 
                        RowBox[{"(", "Global`t", ")"}]}], "]"}], "+", 
                        RowBox[{"I", " ", 
                        RowBox[{"Sin", "[", " ", 
                        RowBox[{
                        RowBox[{"\[Omega]m", "[", 
                        RowBox[{"[", 
                        RowBox[{"n", "+", "1"}], "]"}], "]"}], " ", 
                        RowBox[{"(", "Global`t", ")"}]}], "]"}]}]}], " ", ")"}]}],
                      ",", 
                     RowBox[{"{", 
                      RowBox[{"n", ",", "0", ",", "overtones"}], "}"}]}], "]"}]}],
                   ";"}], "\n", "\t\t\t", ",", "\n", "\t\t\t", 
                 RowBox[{
                  RowBox[{"rem", "=", "0"}], ";", "\n", "\t\t\t", 
                  RowBox[{"imm", "=", "0"}], ";"}]}], "\n", "\t\t\t", "]"}], 
               ";"}], "\n", "\t", ",", "\n", "\t", 
              RowBox[{
               RowBox[{"re", "=", 
                RowBox[{"Sum", "[", 
                 RowBox[{
                  RowBox[{
                   RowBox[{"ToExpression", "[", 
                    RowBox[{"\"\<x\>\"", "<>", 
                     RowBox[{"ToString", "[", "n", "]"}]}], "]"}], " ", 
                   RowBox[{"Exp", "[", 
                    RowBox[{
                     RowBox[{"-", 
                      RowBox[{"(", 
                       RowBox[{"Global`t", "-", "ti"}], ")"}]}], "/", 
                     RowBox[{"(", 
                      RowBox[{
                       RowBox[{"\[Tau]s", "[", 
                        RowBox[{"[", 
                        RowBox[{"n", "+", "1"}], "]"}], "]"}], 
                       RowBox[{"(", 
                        RowBox[{"1", "+", 
                        RowBox[{"ToExpression", "[", 
                        RowBox[{"\"\<\[Beta]\>\"", "<>", 
                        RowBox[{"ToString", "[", "n", "]"}]}], "]"}]}], ")"}]}], 
                      ")"}]}], "]"}], 
                   RowBox[{"Cos", "[", 
                    RowBox[{
                     RowBox[{
                      RowBox[{"\[Omega]s", "[", 
                       RowBox[{"[", 
                        RowBox[{"n", "+", "1"}], "]"}], "]"}], 
                      RowBox[{"(", 
                       RowBox[{"1", "+", 
                        RowBox[{"ToExpression", "[", 
                        RowBox[{"\"\<\[Alpha]\>\"", "<>", 
                        RowBox[{"ToString", "[", "n", "]"}]}], "]"}]}], ")"}], 
                      " ", 
                      RowBox[{"(", "Global`t", ")"}]}], "+", 
                     RowBox[{"ToExpression", "[", 
                      RowBox[{"\"\<\[Phi]\>\"", "<>", 
                       RowBox[{"ToString", "[", "n", "]"}]}], "]"}]}], "]"}]}], 
                  ",", 
                  RowBox[{"{", 
                   RowBox[{"n", ",", "0", ",", "overtones"}], "}"}]}], "]"}]}], 
               ";", "\n", "\t", 
               RowBox[{"im", "=", 
                RowBox[{"Sum", "[", 
                 RowBox[{
                  RowBox[{
                   RowBox[{"ToExpression", "[", 
                    RowBox[{"\"\<x\>\"", "<>", 
                     RowBox[{"ToString", "[", "n", "]"}]}], "]"}], " ", 
                   RowBox[{"Exp", "[", 
                    RowBox[{
                     RowBox[{"-", 
                      RowBox[{"(", 
                       RowBox[{"Global`t", "-", "ti"}], ")"}]}], "/", 
                     RowBox[{"(", 
                      RowBox[{
                       RowBox[{"\[Tau]s", "[", 
                        RowBox[{"[", 
                        RowBox[{"n", "+", "1"}], "]"}], "]"}], 
                       RowBox[{"(", 
                        RowBox[{"1", "+", 
                        RowBox[{"ToExpression", "[", 
                        RowBox[{"\"\<\[Beta]\>\"", "<>", 
                        RowBox[{"ToString", "[", "n", "]"}]}], "]"}]}], ")"}]}], 
                      ")"}]}], "]"}], 
                   RowBox[{"Sin", "[", 
                    RowBox[{
                     RowBox[{
                      RowBox[{"\[Omega]s", "[", 
                       RowBox[{"[", 
                        RowBox[{"n", "+", "1"}], "]"}], "]"}], 
                      RowBox[{"(", 
                       RowBox[{"1", "+", 
                        RowBox[{"ToExpression", "[", 
                        RowBox[{"\"\<\[Alpha]\>\"", "<>", 
                        RowBox[{"ToString", "[", "n", "]"}]}], "]"}]}], ")"}], 
                      " ", 
                      RowBox[{"(", "Global`t", ")"}]}], "+", 
                     RowBox[{"ToExpression", "[", 
                      RowBox[{"\"\<\[Phi]\>\"", "<>", 
                       RowBox[{"ToString", "[", "n", "]"}]}], "]"}]}], "]"}]}], 
                  ",", 
                  RowBox[{"{", 
                   RowBox[{"n", ",", "0", ",", "overtones"}], "}"}]}], "]"}]}], 
               ";", "\n", "\n", "\t\t", 
               RowBox[{"If", "[", 
                RowBox[{
                 RowBox[{"mixing", "[", 
                  RowBox[{"[", "1", "]"}], "]"}], ",", "\n", "\t\t\t", 
                 RowBox[{
                  RowBox[{"\[Omega]m\[Tau]sm", "=", 
                   RowBox[{"Table", "[", 
                    RowBox[{
                     RowBox[{"\[Omega]lmn", "[", 
                      RowBox[{
                      "lm", ",", "mm", ",", "n", ",", "\[Eta]", ",", "\[Chi]1", 
                       ",", "\[Chi]2", ",", 
                       RowBox[{"\"\<ModesFile\>\"", "->", "modesfile"}]}], "]"}], 
                     ",", 
                     RowBox[{"{", 
                      RowBox[{"n", ",", "0", ",", "overtones"}], "}"}]}], "]"}]}],
                   ";", "\n", "\t\t\t", 
                  RowBox[{"\[Omega]m", "=", 
                   RowBox[{"\[Omega]m\[Tau]sm", "[", 
                    RowBox[{"[", 
                     RowBox[{"All", ",", "1"}], "]"}], "]"}]}], ";", "\n", 
                  "\t\t\t", 
                  RowBox[{"\[Tau]sm", "=", 
                   RowBox[{"\[Omega]m\[Tau]sm", "[", 
                    RowBox[{"[", 
                     RowBox[{"All", ",", "2"}], "]"}], "]"}]}], ";", "\n", 
                  "\t\t\t", 
                  RowBox[{"rem", "=", 
                   RowBox[{"Sum", "[", 
                    RowBox[{
                     RowBox[{
                      RowBox[{"ToExpression", "[", 
                       RowBox[{"\"\<x\>\"", "<>", 
                        RowBox[{"ToString", "[", "n", "]"}]}], "]"}], " ", 
                      RowBox[{"Exp", "[", 
                       RowBox[{
                        RowBox[{"-", 
                        RowBox[{"(", 
                        RowBox[{"Global`t", "-", "ti"}], ")"}]}], "/", 
                        RowBox[{"(", 
                        RowBox[{"\[Tau]sm", "[", 
                        RowBox[{"[", 
                        RowBox[{"n", "+", "1"}], "]"}], "]"}], ")"}]}], "]"}], 
                      " ", 
                      RowBox[{"(", 
                       RowBox[{
                        RowBox[{"Cos", "[", 
                        RowBox[{
                        RowBox[{"\[Omega]m", "[", 
                        RowBox[{"[", 
                        RowBox[{"n", "+", "1"}], "]"}], "]"}], " ", 
                        RowBox[{"(", "Global`t", ")"}]}], "]"}], "+", 
                        RowBox[{"I", " ", 
                        RowBox[{"Sin", "[", " ", 
                        RowBox[{
                        RowBox[{"\[Omega]m", "[", 
                        RowBox[{"[", 
                        RowBox[{"n", "+", "1"}], "]"}], "]"}], " ", 
                        RowBox[{"(", "Global`t", ")"}]}], "]"}]}]}], " ", ")"}]}],
                      ",", 
                     RowBox[{"{", 
                      RowBox[{"n", ",", "0", ",", "overtones"}], "}"}]}], "]"}]}],
                   ";", "\n", "\t\t\t", 
                  RowBox[{"imm", "=", 
                   RowBox[{"Sum", "[", 
                    RowBox[{
                     RowBox[{
                      RowBox[{"ToExpression", "[", 
                       RowBox[{"\"\<x\>\"", "<>", 
                        RowBox[{"ToString", "[", "n", "]"}]}], "]"}], " ", 
                      RowBox[{"Exp", "[", 
                       RowBox[{
                        RowBox[{"-", 
                        RowBox[{"(", 
                        RowBox[{"Global`t", "-", "ti"}], ")"}]}], "/", 
                        RowBox[{"(", 
                        RowBox[{"\[Tau]sm", "[", 
                        RowBox[{"[", 
                        RowBox[{"n", "+", "1"}], "]"}], "]"}], ")"}]}], "]"}], 
                      " ", 
                      RowBox[{"(", 
                       RowBox[{
                        RowBox[{"Sin", "[", 
                        RowBox[{
                        RowBox[{"\[Omega]m", "[", 
                        RowBox[{"[", 
                        RowBox[{"n", "+", "1"}], "]"}], "]"}], " ", 
                        RowBox[{"(", "Global`t", ")"}]}], "]"}], "+", 
                        RowBox[{"I", " ", 
                        RowBox[{"Sin", "[", " ", 
                        RowBox[{
                        RowBox[{"\[Omega]m", "[", 
                        RowBox[{"[", 
                        RowBox[{"n", "+", "1"}], "]"}], "]"}], " ", 
                        RowBox[{"(", "Global`t", ")"}]}], "]"}]}]}], " ", ")"}]}],
                      ",", 
                     RowBox[{"{", 
                      RowBox[{"n", ",", "0", ",", "overtones"}], "}"}]}], "]"}]}],
                   ";"}], "\n", "\t\t\t", ",", "\n", "\t\t\t", 
                 RowBox[{
                  RowBox[{"rem", "=", "0"}], ";", "\n", "\t\t\t", 
                  RowBox[{"imm", "=", "0"}], ";"}]}], "\n", "\t\t\t", "]"}], 
               ";"}]}], "\n", "      ", "]"}], ";", "\n", 
            RowBox[{"ampansatz", "=", 
             RowBox[{"Sqrt", "[", 
              RowBox[{
               RowBox[{
                RowBox[{"(", 
                 RowBox[{"re", "+", "rem"}], ")"}], "^", "2"}], "+", 
               RowBox[{
                RowBox[{"(", 
                 RowBox[{"im", "+", "imm"}], ")"}], "^", "2"}]}], "]"}]}], ";", 
            "\n", 
            RowBox[{"phaseansatz", "=", 
             RowBox[{"ArcTan", "[", 
              RowBox[{"im", "/", "re"}], "]"}]}], ";", "\n", 
            RowBox[{"ansatz", "=", 
             RowBox[{"{", 
              RowBox[{"ampansatz", ",", "phaseansatz"}], "}"}]}], ";"}]}], "\n", 
          "]"}], ";", "\n", "\n", 
         RowBox[{"modto0", "=", 
          RowBox[{"Complement", "[", 
           RowBox[{
            RowBox[{"Table", "[", 
             RowBox[{"i", ",", 
              RowBox[{"{", 
               RowBox[{"i", ",", "0", ",", "overtones"}], "}"}]}], "]"}], ",", 
            "fit\[Alpha]"}], "]"}]}], ";", "\n", 
         RowBox[{"modto0", "=", 
          RowBox[{"Table", "[", 
           RowBox[{
            RowBox[{"ToExpression", "[", 
             RowBox[{"\"\<\[Alpha]\>\"", "<>", 
              RowBox[{"ToString", "[", 
               RowBox[{"modto0", "[", 
                RowBox[{"[", "i", "]"}], "]"}], "]"}]}], "]"}], ",", 
            RowBox[{"{", 
             RowBox[{"i", ",", 
              RowBox[{"Length", "@", "modto0"}]}], "}"}]}], "]"}]}], ";", "\n", 
         RowBox[{"ansatz", "=", 
          RowBox[{"ansatz", "/.", 
           RowBox[{"(", 
            RowBox[{"Table", "[", 
             RowBox[{
              RowBox[{
               RowBox[{"modto0", "[", 
                RowBox[{"[", "i", "]"}], "]"}], "->", "0"}], ",", 
              RowBox[{"{", 
               RowBox[{"i", ",", 
                RowBox[{"Length", "@", "modto0"}]}], "}"}]}], "]"}], ")"}]}]}], 
         ";", "\n", "\n", 
         RowBox[{"modto0", "=", 
          RowBox[{"Complement", "[", 
           RowBox[{
            RowBox[{"Table", "[", 
             RowBox[{"i", ",", 
              RowBox[{"{", 
               RowBox[{"i", ",", "0", ",", "overtones"}], "}"}]}], "]"}], ",", 
            "fit\[Tau]"}], "]"}]}], ";", "\n", 
         RowBox[{"modto0", "=", 
          RowBox[{"Table", "[", 
           RowBox[{
            RowBox[{"ToExpression", "[", 
             RowBox[{"\"\<\[Beta]\>\"", "<>", 
              RowBox[{"ToString", "[", 
               RowBox[{"modto0", "[", 
                RowBox[{"[", "i", "]"}], "]"}], "]"}]}], "]"}], ",", 
            RowBox[{"{", 
             RowBox[{"i", ",", 
              RowBox[{"Length", "@", "modto0"}]}], "}"}]}], "]"}]}], ";", "\n", 
         RowBox[{"ansatz", "=", 
          RowBox[{"ansatz", "/.", 
           RowBox[{"(", 
            RowBox[{"Table", "[", 
             RowBox[{
              RowBox[{
               RowBox[{"modto0", "[", 
                RowBox[{"[", "i", "]"}], "]"}], "->", "0"}], ",", 
              RowBox[{"{", 
               RowBox[{"i", ",", 
                RowBox[{"Length", "@", "modto0"}]}], "}"}]}], "]"}], ")"}]}]}], 
         ";", "\n", "\n", 
         RowBox[{"If", "[", 
          RowBox[{"ex\[Omega]val", ",", 
           RowBox[{"{", 
            RowBox[{"ansatz", ",", "var"}], "}"}], ",", "ansatz"}], "]"}]}]}], 
       "\[IndentingNewLine]", "]"}]}], "\n"}], "Code",
     CellChangeTimes->{{3.771677386705565*^9, 3.771677432575967*^9}, {
       3.771677478692521*^9, 3.7716776974786987`*^9}, {3.771677749156809*^9, 
       3.771677749245604*^9}, {3.771678368242831*^9, 3.77167855802042*^9}, {
       3.7719072251494093`*^9, 3.771907227456575*^9}, {3.7719072710256453`*^9, 
       3.771907398091879*^9}, {3.771907458458599*^9, 3.771907471104031*^9}, {
       3.771907535295508*^9, 3.771907567230341*^9}, {3.771907597432748*^9, 
       3.771907629986505*^9}, {3.77190871277954*^9, 3.771908761390111*^9}, {
       3.771908813523059*^9, 3.7719089729431467`*^9}, {3.771909004206633*^9, 
       3.77190900469588*^9}, {3.771909058496481*^9, 3.771909075189431*^9}, {
       3.771909162367087*^9, 3.7719093135594387`*^9}, {3.7719093472737703`*^9, 
       3.7719094536444597`*^9}, {3.771909485309827*^9, 3.7719096216321917`*^9}, {
       3.771911525736096*^9, 3.771911555269594*^9}, {3.771911592383946*^9, 
       3.771911650727923*^9}, {3.7719119344490023`*^9, 3.771911934634461*^9}, {
       3.772193444179907*^9, 3.7721934684908667`*^9}, 3.7721935063709593`*^9, {
       3.7721935368526163`*^9, 3.77219366166796*^9}, {3.77219642009752*^9, 
       3.772196501577361*^9}, {3.772196556744199*^9, 3.7721965582919827`*^9}, {
       3.772196623495311*^9, 3.772196703653275*^9}, {3.772196842685261*^9, 
       3.772196859406479*^9}, {3.772196988080412*^9, 3.7721970025950603`*^9}, {
       3.7722478303251*^9, 3.772247831532436*^9}, {3.77658033668747*^9, 
       3.776580348028509*^9}, {3.7765809639728327`*^9, 3.77658097177113*^9}, {
       3.776581457080768*^9, 3.776581475487019*^9}, {3.776581515046463*^9, 
       3.77658160150498*^9}, {3.7765817333625803`*^9, 3.7765817752553797`*^9}, {
       3.7765860616001368`*^9, 3.776586064674204*^9}, {3.776586100742178*^9, 
       3.776586185337967*^9}, {3.776586259954899*^9, 3.776586260329609*^9}, {
       3.776586308985792*^9, 3.776586326416067*^9}, {3.776586370893306*^9, 
       3.7765863790338497`*^9}, {3.7765864409394817`*^9, 3.776586462208321*^9}, {
       3.776586494448669*^9, 3.776586550379714*^9}, {3.776588773375059*^9, 
       3.776588777468933*^9}, {3.778555556406411*^9, 3.778555568824278*^9}, {
       3.778565526517099*^9, 3.778565530554241*^9}, {3.7785655639133472`*^9, 
       3.7785656183907623`*^9}, {3.778565653049898*^9, 3.7785657064928303`*^9}, {
       3.778565785975872*^9, 3.7785657961721077`*^9}, {3.778565857608344*^9, 
       3.778565859731264*^9}, 3.77856591349852*^9, {3.778566191886526*^9, 
       3.778566193930477*^9}, 3.778566246778599*^9, {3.778566363118126*^9, 
       3.77856640048003*^9}, {3.778566501309498*^9, 3.778566501907134*^9}, {
       3.778567075366261*^9, 3.7785670782516212`*^9}, {3.784027275521529*^9, 
       3.7840273848540783`*^9}, {3.784027466674209*^9, 3.7840276726788597`*^9}, {
       3.784027744249055*^9, 3.784027770048777*^9}, {3.784027807926426*^9, 
       3.7840278173359623`*^9}, {3.784027960944667*^9, 3.784028054211288*^9}, {
       3.7840280871565647`*^9, 3.7840281001470327`*^9}, {3.7840344337639017`*^9, 
       3.784034529470811*^9}, {3.784034583373845*^9, 3.784034630941607*^9}, {
       3.784037500320373*^9, 3.78403752221579*^9}, {3.784037556624576*^9, 
       3.784037655409525*^9}, {3.784037695864181*^9, 3.7840377491643267`*^9}, {
       3.784037826395269*^9, 3.784037838389056*^9}, {3.785135168481369*^9, 
       3.785135188672686*^9}, {3.785135370031146*^9, 3.785135632797415*^9}, {
       3.785135704427512*^9, 3.785135709699354*^9}, {3.7851358102358313`*^9, 
       3.785135865344125*^9}, {3.7851360843385277`*^9, 3.7851361456991663`*^9}, {
       3.785136185872944*^9, 3.785136191845982*^9}, {3.785140798343335*^9, 
       3.785140803112817*^9}, {3.785140833533779*^9, 3.785140839360903*^9}, {
       3.7851408796427526`*^9, 3.7851408919338703`*^9}, {3.7851409237996197`*^9, 
       3.785141030146646*^9}, {3.785141183125049*^9, 3.785141196189204*^9}, {
       3.785141236134383*^9, 3.7851412547365723`*^9}, {3.785742317087573*^9, 
       3.7857423818009644`*^9}, {3.788588900081777*^9, 3.788588922583219*^9}, {
       3.788588977524485*^9, 3.78858899232054*^9}, {3.788592700140904*^9, 
       3.788592829761201*^9}, {3.78859288245713*^9, 3.788592886045624*^9}, {
       3.788592986457713*^9, 3.788593032023745*^9}, {3.788593174304693*^9, 
       3.788593193410795*^9}, {3.788593249525272*^9, 3.788593249845934*^9}, {
       3.799117023811561*^9, 3.7991170620045013`*^9}, {3.799117327168158*^9, 
       3.799117328720833*^9}, {3.799117528607526*^9, 3.799117625219865*^9}, {
       3.799117723391061*^9, 3.799117729813736*^9}, {3.799117808069282*^9, 
       3.7991178319953527`*^9}, 3.799117913918251*^9, {3.7991179442970963`*^9, 
       3.799117946897843*^9}, {3.799117988695221*^9, 3.799118002060157*^9}, {
       3.799118164806386*^9, 3.799118171828588*^9}, {3.799121555953467*^9, 
       3.799121605765253*^9}, {3.799121810634165*^9, 3.799121812345255*^9}, {
       3.799121879641095*^9, 3.799121918333335*^9}, {3.799122036271903*^9, 
       3.799122041022492*^9}, {3.800075376244379*^9, 3.80007540453275*^9}, {
       3.800075443434237*^9, 3.800075445045846*^9}, {3.800076115854972*^9, 
       3.800076140880919*^9}, {3.80008068851781*^9, 3.800080746362953*^9}, {
       3.800080780024949*^9, 3.8000808514481983`*^9}, {3.800081341480514*^9, 
       3.8000814602083263`*^9}, {3.800081492076582*^9, 3.800081681089995*^9}, {
       3.800088960496607*^9, 3.80008897437778*^9}, {3.800089225155568*^9, 
       3.800089231743319*^9}, {3.800089309267664*^9, 3.8000893111631317`*^9}, {
       3.8000894233429127`*^9, 3.800089424068041*^9}, {3.800089457010537*^9, 
       3.8000894734082737`*^9}, {3.800089572498385*^9, 3.8000895831367807`*^9}, 
       3.802773665064678*^9, {3.803265134261528*^9, 3.803265243812134*^9}},
     CellLabel->"In[49]:=",ExpressionUUID->"497c5c2c-74eb-4562-8f69-941dcd0056c7"]
    }, Closed]],
    
    Cell[CellGroupData[{
    
    Cell["AIC,BIC, PValue", "Subsection",
     CellChangeTimes->{{3.785048243361456*^9, 
      3.7850482482750387`*^9}},ExpressionUUID->"3fb109b0-2e0f-4e1e-a4da-\
    311a2f2e096d"],
    
    Cell[BoxData[{
     RowBox[{
      RowBox[{
       RowBox[{"Options", "[", "AICcRes", "]"}], "=", 
       RowBox[{"Options", "[", "AICcRes", "]"}]}], ";"}], "\n", 
     RowBox[{
      RowBox[{"AICcRes", "[", 
       RowBox[{"res_", ",", "coeff_"}], "]"}], ":=", 
      RowBox[{"Module", "[", 
       RowBox[{
        RowBox[{"{", 
         RowBox[{
         "err", ",", "n", ",", "newfit", ",", "bracketedvars", ",", "ress", ",", 
          "weigths"}], "}"}], ",", "\[IndentingNewLine]", 
        RowBox[{
         RowBox[{"err", "=", "1"}], ";", "\[IndentingNewLine]", 
         RowBox[{"n", "=", 
          RowBox[{"Length", "@", "res"}]}], ";", "\n", 
         RowBox[{"ress", "=", 
          RowBox[{"Total", "[", 
           RowBox[{"err", 
            RowBox[{
             RowBox[{"(", 
              RowBox[{"Abs", "[", 
               StyleBox["res", "Code"], 
               StyleBox["]", "Code"]}], ")"}], "^", "2"}]}], "]"}]}], ";", "\n", 
         RowBox[{
          RowBox[{"n", " ", 
           RowBox[{"Log", "[", 
            RowBox[{"ress", "/", "n"}], "]"}]}], "+", 
          RowBox[{"2", 
           RowBox[{"(", 
            RowBox[{"coeff", "+", "1"}], ")"}]}], "+", 
          FractionBox[
           RowBox[{"2", "*", "coeff", 
            RowBox[{"(", 
             RowBox[{"coeff", "+", "1"}], ")"}], " "}], 
           RowBox[{"n", " ", "-", " ", "coeff", " ", "-", "1"}]]}]}]}], 
       "\[IndentingNewLine]", "\[IndentingNewLine]", "]"}]}]}], "Code",
     CellChangeTimes->{{3.684235123940609*^9, 3.684235178622861*^9}, {
       3.6842352304450693`*^9, 3.684235266801034*^9}, {3.6842357209981833`*^9, 
       3.684235721420925*^9}, {3.6842358004206553`*^9, 3.684235829618177*^9}, {
       3.684235871562796*^9, 3.684235953109355*^9}, {3.6842359930084677`*^9, 
       3.68423600045492*^9}, {3.684236046190096*^9, 3.684236136607703*^9}, {
       3.684236230675322*^9, 3.6842363351919537`*^9}, {3.6842363978154163`*^9, 
       3.684236597490655*^9}, {3.684237002736021*^9, 3.684237003142733*^9}, {
       3.684237052308125*^9, 3.6842370616346483`*^9}, {3.684237563942689*^9, 
       3.684237626100822*^9}, {3.684237832420291*^9, 3.684237874906782*^9}, {
       3.778390463654558*^9, 3.778390511054487*^9}, {3.778390544683858*^9, 
       3.778390549680479*^9}, {3.77839066811514*^9, 3.778390685263955*^9}, {
       3.778391716414667*^9, 3.7783917695790033`*^9}, {3.77891899937022*^9, 
       3.778919008973011*^9}, 3.778921364633644*^9, 3.778924393733334*^9, {
       3.7789244317694817`*^9, 3.778924436818432*^9}, {3.7991208774828587`*^9, 
       3.799120878619252*^9}},ExpressionUUID->"7d702440-ce11-4f2f-a3fd-\
    860210f78382"],
    
    Cell[BoxData[{
     RowBox[{
      RowBox[{
       RowBox[{"Options", "[", "BICRes", "]"}], "=", 
       RowBox[{"Options", "[", "AICcRes", "]"}]}], ";"}], "\n", 
     RowBox[{
      RowBox[{"BICRes", "[", 
       RowBox[{"res_", ",", "coeff_"}], "]"}], ":=", 
      RowBox[{"Module", "[", 
       RowBox[{
        RowBox[{"{", 
         RowBox[{
         "err", ",", "fact1", ",", "fact2", ",", "n", ",", "newfit", ",", 
          "bracketedvars", ",", "ress", ",", "weigths"}], "}"}], ",", 
        "\[IndentingNewLine]", 
        RowBox[{
         RowBox[{"err", "=", "1"}], ";", "\[IndentingNewLine]", 
         RowBox[{"n", "=", 
          RowBox[{"Length", "@", "res"}]}], ";", "\n", 
         RowBox[{"ress", "=", 
          RowBox[{"Total", "[", 
           RowBox[{"err", 
            RowBox[{
             RowBox[{"(", 
              RowBox[{"Abs", "[", 
               StyleBox["res", "Code"], 
               StyleBox["]", "Code"]}], ")"}], "^", "2"}]}], "]"}]}], ";", "\n", 
         RowBox[{"fact1", "=", 
          RowBox[{"n", " ", 
           RowBox[{"Log", "[", 
            RowBox[{"ress", "/", "n"}], "]"}]}]}], ";", "\n", 
         RowBox[{"fact2", "=", 
          RowBox[{
           RowBox[{"Log", "[", "n", "]"}], 
           RowBox[{"(", 
            RowBox[{"coeff", "+", "1."}], ")"}]}]}], ";", "\n", 
         RowBox[{"fact1", "+", "fact2"}]}]}], "\[IndentingNewLine]", 
       "]"}]}]}], "Code",
     CellChangeTimes->{{3.684235123940609*^9, 3.684235178622861*^9}, {
       3.6842352304450693`*^9, 3.684235266801034*^9}, {3.6842357209981833`*^9, 
       3.684235721420925*^9}, {3.6842358004206553`*^9, 3.684235829618177*^9}, {
       3.684235871562796*^9, 3.684235953109355*^9}, {3.6842359930084677`*^9, 
       3.68423600045492*^9}, {3.684236046190096*^9, 3.684236136607703*^9}, {
       3.684236230675322*^9, 3.6842363351919537`*^9}, {3.6842363978154163`*^9, 
       3.684236597490655*^9}, {3.684237002736021*^9, 3.684237003142733*^9}, {
       3.684237052308125*^9, 3.6842370616346483`*^9}, {3.684237563942689*^9, 
       3.684237626100822*^9}, {3.684237832420291*^9, 3.684237874906782*^9}, {
       3.778390463654558*^9, 3.778390511054487*^9}, {3.778390544683858*^9, 
       3.778390549680479*^9}, {3.77839066811514*^9, 3.778390685263955*^9}, {
       3.778391716414667*^9, 3.7783917695790033`*^9}, {3.77891899937022*^9, 
       3.778919008973011*^9}, {3.7789192361692877`*^9, 3.778919242750613*^9}, {
       3.778919293657011*^9, 3.7789192947423*^9}, {3.778919868815625*^9, 
       3.778919947193172*^9}, {3.778920001593031*^9, 3.7789200018414392`*^9}, {
       3.778921044343191*^9, 3.7789210576462603`*^9}, {3.778921143854371*^9, 
       3.778921144927823*^9}, {3.778921344987707*^9, 3.778921347063178*^9}, {
       3.778924392256567*^9, 3.778924429472744*^9}, {3.778924579590026*^9, 
       3.778924601567306*^9}, {3.778924645350624*^9, 3.7789246674167833`*^9}, 
       3.799120895846953*^9, {3.8000775279579363`*^9, 
       3.8000775281291723`*^9}},ExpressionUUID->"6a85250f-5ba5-40dd-bedb-\
    945dda498b2a"],
    
    Cell[BoxData[{
     RowBox[{
      RowBox[{
       RowBox[{"Options", "[", "PValueTest", "]"}], "=", 
       RowBox[{"{", 
        RowBox[{"\"\<IRoot\>\"", "\[Rule]", "10"}], "}"}]}], 
      ";"}], "\[IndentingNewLine]", 
     RowBox[{
      RowBox[{"PValueTest", "[", 
       RowBox[{"dfnum_", ",", "dfden_", ",", "signl_", ",", 
        RowBox[{"OptionsPattern", "[", "]"}]}], "]"}], ":=", 
      RowBox[{"Module", "[", 
       RowBox[{
        RowBox[{"{", 
         RowBox[{"xmax", ",", "iroot"}], "}"}], ",", "\[IndentingNewLine]", 
        RowBox[{
         RowBox[{"iroot", "=", 
          RowBox[{"OptionValue", "[", "\"\<IRoot\>\"", "]"}]}], ";", 
         "\[IndentingNewLine]", 
         RowBox[{"xmax", "/.", 
          RowBox[{"FindRoot", "[", 
           RowBox[{
            RowBox[{
             RowBox[{"NIntegrate", "[", 
              RowBox[{
               RowBox[{"PDF", "[", 
                RowBox[{
                 RowBox[{"FRatioDistribution", "[", 
                  RowBox[{"dfnum", ",", "dfden"}], "]"}], ",", "x"}], "]"}], ",", 
               
               RowBox[{"{", 
                RowBox[{"x", ",", "0", ",", "xmax"}], "}"}]}], "]"}], "\[Equal]", 
             
             RowBox[{"1", "-", "signl"}]}], ",", 
            RowBox[{"{", 
             RowBox[{"xmax", ",", "iroot"}], "}"}]}], "]"}]}]}]}], 
       "]"}]}]}], "Code",
     CellChangeTimes->{{3.778993361891452*^9, 3.778993440441951*^9}, {
      3.778993491640397*^9, 3.778993500693678*^9}, {3.778993679624543*^9, 
      3.77899367996894*^9}, {3.778993763369728*^9, 3.778993854199657*^9}, {
      3.778994067826223*^9, 3.7789941443716707`*^9}},
     CellLabel->
      "In[137]:=",ExpressionUUID->"dedb7461-041a-428c-ba62-81c1dfe604f2"]
    }, Closed]],
    
    Cell[CellGroupData[{
    
    Cell["Hessian", "Subsection",
     CellChangeTimes->{{3.802757124788665*^9, 
      3.802757126851701*^9}},ExpressionUUID->"356909a0-587d-4c43-bcac-\
    361575f578c4"],
    
    Cell[BoxData[
     RowBox[{
      RowBox[{"HessianH", "[", 
       RowBox[{"f_", ",", 
        RowBox[{"t_List", "?", "VectorQ"}]}], "]"}], ":=", 
      RowBox[{"D", "[", 
       RowBox[{"f", ",", 
        RowBox[{"{", 
         RowBox[{"t", ",", "2"}], "}"}]}], "]"}]}]], "Code",ExpressionUUID->\
    "80893771-7d64-4f7f-a960-3d86197a9d5b"]
    }, Closed]],
    
    Cell[CellGroupData[{
    
    Cell["CovarianceMatrix", "Subsection",
     CellChangeTimes->{{3.802757124788665*^9, 3.802757126851701*^9}, {
      3.80275721922922*^9, 
      3.802757223544718*^9}},ExpressionUUID->"486ce4fb-6f1b-4d61-b371-\
    e434cd33afb3"],
    
    Cell[BoxData[{
     RowBox[{
      RowBox[{
       RowBox[{"Options", "[", "CovarianceMatrix", "]"}], "=", 
       RowBox[{"{", 
        RowBox[{"\"\<Tolerance\>\"", "\[Rule]", 
         RowBox[{"10", "^", 
          RowBox[{"(", 
           RowBox[{"-", "32"}], ")"}]}]}], "}"}]}], ";"}], "\n", 
     RowBox[{
      RowBox[{"CovarianceMatrix", "[", 
       RowBox[{"Xx_", ",", "length_", ",", "pars_", ",", "truepars_", ",", 
        RowBox[{"OptionsPattern", "[", "]"}]}], "]"}], ":=", 
      RowBox[{"Module", "[", 
       RowBox[{
        RowBox[{"{", 
         RowBox[{"hessian", ",", "tol", ",", "resreim"}], "}"}], ",", "\n", "\n", 
        
        RowBox[{
         RowBox[{"tol", "=", 
          RowBox[{"OptionValue", "[", "\"\<Tolerance\>\"", "]"}]}], ";", "\n", 
         "\n", 
         RowBox[{"hessian", "=", 
          RowBox[{"Rationalize", "[", 
           RowBox[{
            RowBox[{
             RowBox[{"HessianH", "[", 
              RowBox[{
               RowBox[{"Log", "[", "Xx", "]"}], ",", "pars"}], "]"}], "/.", 
             "truepars"}], ",", "tol"}], "]"}]}], ";", "\n", "\n", 
         RowBox[{
          RowBox[{
           RowBox[{"(", 
            RowBox[{"2", 
             RowBox[{"Inverse", "[", "hessian", "]"}]}], ")"}], "/", 
           RowBox[{"(", 
            RowBox[{"length", "-", "2"}], ")"}]}], "*", "1."}]}]}], 
       "]"}]}]}], "Code",
     CellChangeTimes->{{3.802757290050189*^9, 3.802757353192521*^9}, {
       3.802757385445712*^9, 3.802757411931959*^9}, {3.8027656834313602`*^9, 
       3.8027658382638407`*^9}, {3.80276587030466*^9, 3.802765876862022*^9}, {
       3.8027673334193974`*^9, 3.8027673430162582`*^9}, {3.802767576380888*^9, 
       3.802767580007012*^9}, {3.802769058278777*^9, 3.80276906496807*^9}, {
       3.80276944040654*^9, 3.802769443595483*^9}, 3.802771922939023*^9, {
       3.8027739716448174`*^9, 3.802773972086204*^9}, {3.8037913010681353`*^9, 
       3.803791301260662*^9}},ExpressionUUID->"60106d1f-0ecd-4b9c-8e7a-\
    58325e7721f8"]
    }, Open  ]],
    
    Cell[CellGroupData[{
    
    Cell["CorrelationMatrix", "Subsection",
     CellChangeTimes->{{3.802757124788665*^9, 3.802757126851701*^9}, {
      3.80275721922922*^9, 3.802757223544718*^9}, {3.8027668558212442`*^9, 
      3.802766860241334*^9}},ExpressionUUID->"e5170d4d-131e-4832-b133-\
    ee5d4d215557"],
    
    Cell[BoxData[{
     RowBox[{
      RowBox[{
       RowBox[{"Options", "[", "CorrelationMatrix", "]"}], "=", 
       RowBox[{"Options", "[", "CovarianceMatrix", "]"}]}], ";"}], "\n", 
     RowBox[{
      RowBox[{"CorrelationMatrix", "[", 
       RowBox[{"Xx_", ",", "length_", ",", "pars_", ",", "truepars_", ",", 
        RowBox[{"OptionsPattern", "[", "]"}]}], "]"}], ":=", 
      RowBox[{"Module", "[", 
       RowBox[{
        RowBox[{"{", 
         RowBox[{"Ds", ",", "Dsi", ",", "covmat", ",", "hessian", ",", "tol"}], 
         "}"}], ",", "\n", "\n", 
        RowBox[{
         RowBox[{"tol", "=", 
          RowBox[{"OptionValue", "[", "\"\<Tolerance\>\"", "]"}]}], ";", "\n", 
         RowBox[{"covmat", "=", 
          RowBox[{"CovarianceMatrix", "[", 
           RowBox[{"Xx", ",", "length", ",", "pars", ",", "truepars"}], "]"}]}], 
         ";", "\n", 
         RowBox[{"Ds", "=", 
          RowBox[{"Rationalize", "[", 
           RowBox[{
            RowBox[{"DiagonalMatrix", "[", 
             RowBox[{"Diagonal", "[", 
              RowBox[{"Sqrt", "[", 
               RowBox[{"Re", "@", "covmat"}], "]"}], "]"}], "]"}], ",", "tol"}], 
           "]"}]}], ";", "\n", 
         RowBox[{"Dsi", "=", 
          RowBox[{"Inverse", "[", "Ds", "]"}]}], ";", "\n", "\n", 
         RowBox[{"Dsi", ".", "covmat", ".", "Dsi"}]}]}], "\n", "]"}]}]}], "Code",
     CellChangeTimes->{{3.802757290050189*^9, 3.802757353192521*^9}, {
      3.802757385445712*^9, 3.802757411931959*^9}, {3.8027656834313602`*^9, 
      3.8027658382638407`*^9}, {3.80276587030466*^9, 3.802765876862022*^9}, {
      3.8027659607872257`*^9, 3.8027661142159157`*^9}, {3.802769072592805*^9, 
      3.8027690765913773`*^9}, {3.802769206917276*^9, 
      3.802769207228895*^9}},ExpressionUUID->"7b6418b0-64f8-490b-bd06-\
    4ffdd1c3e1f2"]
    }, Closed]],
    
    Cell[CellGroupData[{
    
    Cell["Likelihood", "Subsection",
     CellChangeTimes->{{3.802757124788665*^9, 3.802757126851701*^9}, {
      3.80275721922922*^9, 3.802757223544718*^9}, {3.8027668558212442`*^9, 
      3.802766860241334*^9}, {3.8032657855617037`*^9, 
      3.8032657882922363`*^9}},ExpressionUUID->"b810eb33-06bd-49a9-9c2c-\
    95c819d4497b"],
    
    Cell[BoxData[
     RowBox[{
      RowBox[{"LogLikelihoodDist", "[", 
       RowBox[{"data_", ",", "ansatz_", ",", "vars_", ",", "x_"}], "]"}], ":=", 
      RowBox[{"Module", "[", 
       RowBox[{
        RowBox[{"{", "ansatzlist", "}"}], ",", "\[IndentingNewLine]", 
        RowBox[{
         RowBox[{"ansatzlist", "=", 
          RowBox[{
           RowBox[{"ansatz", "/.", "vars"}], "/.", 
           RowBox[{"x", "->", 
            RowBox[{"data", "[", 
             RowBox[{"[", 
              RowBox[{"All", ",", "1"}], "]"}], "]"}]}]}]}], ";", 
         "\[IndentingNewLine]", 
         RowBox[{"-", 
          RowBox[{"Total", "[", 
           RowBox[{"(", 
            RowBox[{
             RowBox[{
              RowBox[{"Re", "[", 
               RowBox[{"ansatzlist", "-", 
                RowBox[{"data", "[", 
                 RowBox[{"[", 
                  RowBox[{"All", ",", "2"}], "]"}], "]"}]}], "]"}], "^", "2"}], 
             "+", 
             RowBox[{
              RowBox[{"Im", "[", 
               RowBox[{"ansatzlist", "-", 
                RowBox[{"data", "[", 
                 RowBox[{"[", 
                  RowBox[{"All", ",", "2"}], "]"}], "]"}]}], "]"}], "^", "2"}]}], 
            ")"}], "]"}]}]}]}], "]"}]}]], "Code",
     CellChangeTimes->{{3.80326588158187*^9, 3.803265900398424*^9}, {
       3.80326594384317*^9, 3.803265976645152*^9}, {3.803266029498752*^9, 
       3.803266046171425*^9}, 3.8032663623440313`*^9, {3.8032664185243607`*^9, 
       3.8032664239708*^9}, 
       3.803266515100753*^9},ExpressionUUID->"126b7858-728f-4a7e-812b-\
    80dcecabe308"]
    }, Closed]],
    
    Cell[CellGroupData[{
    
    Cell["ComputeFitBands", "Subsection",
     CellChangeTimes->{{3.803794084771727*^9, 
      3.803794088912798*^9}},ExpressionUUID->"c960c6cd-c63d-4558-b661-\
    e050b480ca99"],
    
    Cell[BoxData[{
     RowBox[{
      RowBox[{
       RowBox[{"Options", "[", "ComputeFitBands", "]"}], "=", 
       RowBox[{"{", 
        RowBox[{"\"\<ConfidenceLevel\>\"", "\[Rule]", "0.9"}], "}"}]}], 
      ";"}], "\n", 
     RowBox[{
      RowBox[{"ComputeFitBands", "[", 
       RowBox[{"data_", ",", "ansatz_", ",", "vars_", ",", "pars_", ",", 
        RowBox[{
         RowBox[{"OptionsPattern", "[", "]"}], ";"}]}], "]"}], ":=", 
      RowBox[{"Module", "[", 
       RowBox[{
        RowBox[{"{", 
         RowBox[{
         "ansatzv", ",", "colevel", ",", "covmat", ",", "dvec", ",", "lower", ",",
           "res", ",", "resce", ",", "resre", ",", "resim", ",", "times", ",", 
          "tval", ",", "Xx", ",", "upper", ",", "a1"}], "}"}], ",", "\n", "\n", 
        RowBox[{
         RowBox[{"colevel", "=", 
          RowBox[{"OptionValue", "[", "\"\<ConfidenceLevel\>\"", "]"}]}], ";", 
         "\n", 
         RowBox[{"tval", "=", 
          RowBox[{
           RowBox[{"StudentTCI", "[", 
            RowBox[{"0", ",", "1", ",", 
             RowBox[{"Length", "@", "vars"}], ",", 
             RowBox[{"ConfidenceLevel", "\[Rule]", "colevel"}]}], "]"}], "[", 
           RowBox[{"[", "2", "]"}], "]"}]}], ";", "\n", 
         RowBox[{"res", "=", 
          RowBox[{
           RowBox[{"(", 
            RowBox[{"ansatz", "/.", 
             RowBox[{"t", "\[Rule]", 
              RowBox[{"data", "[", 
               RowBox[{"[", 
                RowBox[{"All", ",", "1"}], "]"}], "]"}]}]}], ")"}], "-", 
           RowBox[{"data", "[", 
            RowBox[{"[", 
             RowBox[{"All", ",", "2"}], "]"}], "]"}]}]}], ";", "\n", "\n", 
         RowBox[{"resce", "=", 
          RowBox[{"ComplexExpand", "@", 
           RowBox[{"Total", "[", "res", "]"}]}]}], ";", "\[IndentingNewLine]", 
         RowBox[{"(", 
          RowBox[{"resre", "=", 
           RowBox[{"Simplify", "[", 
            RowBox[{
             RowBox[{"Re", "[", 
              RowBox[{"ComplexExpand", "[", "resce", "]"}], "]"}], ",", 
             RowBox[{"Element", "[", 
              RowBox[{"vars", ",", "Reals"}], "]"}]}], "]"}]}], ")"}], ";", 
         "\[IndentingNewLine]", 
         RowBox[{"(", 
          RowBox[{"resim", "=", 
           RowBox[{"Simplify", "[", 
            RowBox[{
             RowBox[{"Im", "[", 
              RowBox[{"ComplexExpand", "[", "resce", "]"}], "]"}], ",", 
             RowBox[{"Element", "[", 
              RowBox[{"vars", ",", "Reals"}], "]"}]}], "]"}]}], ")"}], ";", 
         "\[IndentingNewLine]", 
         RowBox[{"Xx", "=", 
          RowBox[{
           RowBox[{"resre", "^", "2"}], "+", 
           RowBox[{"resim", "^", "2"}]}]}], ";", "\n", "\n", 
         RowBox[{"covmat", "=", 
          RowBox[{"CovarianceMatrix", "[", 
           RowBox[{"Xx", ",", 
            RowBox[{"Length", "@", "res"}], ",", "vars", ",", "pars"}], "]"}]}], 
         ";", "\n", 
         RowBox[{"times", "=", 
          RowBox[{"data", "[", 
           RowBox[{"[", 
            RowBox[{"All", ",", "1"}], "]"}], "]"}]}], ";", "\n", "\n", 
         RowBox[{"lower", "=", 
          RowBox[{"Table", "[", 
           RowBox[{
            RowBox[{"{", 
             RowBox[{
              RowBox[{"times", "[", 
               RowBox[{"[", "i", "]"}], "]"}], ",", 
              RowBox[{
               RowBox[{"ansatzv", "=", 
                RowBox[{"ansatz", "/.", 
                 RowBox[{"t", "\[Rule]", 
                  RowBox[{"times", "[", 
                   RowBox[{"[", "i", "]"}], "]"}]}]}]}], ";", 
               RowBox[{"dvec", "=", 
                RowBox[{
                 RowBox[{"Table", "[", 
                  RowBox[{
                   RowBox[{"D", "[", 
                    RowBox[{"ansatzv", ",", 
                     RowBox[{"vars", "[", 
                      RowBox[{"[", "j", "]"}], "]"}]}], "]"}], ",", 
                   RowBox[{"{", 
                    RowBox[{"j", ",", 
                     RowBox[{"Length", "@", "vars"}]}], "}"}]}], "]"}], "/.", 
                 "pars"}]}], ";", 
               RowBox[{
                RowBox[{"(", 
                 RowBox[{"ansatzv", "/.", "pars"}], ")"}], "-", 
                RowBox[{"tval", " ", 
                 RowBox[{"Sqrt", "[", 
                  RowBox[{"dvec", ".", "covmat", ".", "dvec"}], "]"}]}]}]}]}], 
             "}"}], ",", 
            RowBox[{"{", 
             RowBox[{"i", ",", 
              RowBox[{"Length", "@", "times"}]}], "}"}]}], "]"}]}], ";", 
         "\[IndentingNewLine]", 
         RowBox[{"upper", "=", 
          RowBox[{"Table", "[", 
           RowBox[{
            RowBox[{"{", 
             RowBox[{
              RowBox[{"times", "[", 
               RowBox[{"[", "i", "]"}], "]"}], ",", 
              RowBox[{
               RowBox[{"ansatzv", "=", 
                RowBox[{"ansatz", "/.", 
                 RowBox[{"t", "\[Rule]", 
                  RowBox[{"times", "[", 
                   RowBox[{"[", "i", "]"}], "]"}]}]}]}], ";", 
               RowBox[{"dvec", "=", 
                RowBox[{
                 RowBox[{"Table", "[", 
                  RowBox[{
                   RowBox[{"D", "[", 
                    RowBox[{"ansatzv", ",", 
                     RowBox[{"vars", "[", 
                      RowBox[{"[", "j", "]"}], "]"}]}], "]"}], ",", 
                   RowBox[{"{", 
                    RowBox[{"j", ",", 
                     RowBox[{"Length", "@", "vars"}]}], "}"}]}], "]"}], "/.", 
                 "pars"}]}], ";", 
               RowBox[{
                RowBox[{"(", 
                 RowBox[{"ansatzv", "/.", "pars"}], ")"}], "+", 
                RowBox[{"tval", " ", 
                 RowBox[{"Sqrt", "[", 
                  RowBox[{"dvec", ".", "covmat", ".", "dvec"}], "]"}]}]}]}]}], 
             "}"}], ",", 
            RowBox[{"{", 
             RowBox[{"i", ",", 
              RowBox[{"Length", "@", "times"}]}], "}"}]}], "]"}]}], ";", "\n", 
         RowBox[{"{", 
          RowBox[{"lower", ",", "upper"}], "}"}]}]}], "\n", "]"}]}]}], "Code",
     CellChangeTimes->{{3.8037958673712273`*^9, 3.803795897737733*^9}, {
       3.803797318419023*^9, 3.803797342571529*^9}, {3.8037982144198027`*^9, 
       3.8037982410650873`*^9}, {3.803798271238851*^9, 3.8037982810199957`*^9}, {
       3.8037989443273*^9, 3.803798946863171*^9}, {3.803798984831874*^9, 
       3.803798987396311*^9}, 3.803799415565712*^9},
     CellLabel->
      "In[124]:=",ExpressionUUID->"c3d05ccf-c015-4e03-adc9-22bf8795f8c0"]
    }, Open  ]]
    }, Open  ]],
    
    Cell[CellGroupData[{
    
    Cell["End Package", "Section",ExpressionUUID->"f1741b14-531a-4442-958b-fde3bfdb7b10"],
    
    Cell[BoxData[{
     RowBox[{
      RowBox[{"End", "[", "]"}], ";"}], "\[IndentingNewLine]", 
     RowBox[{
      RowBox[{"EndPackage", "[", "]"}], ";"}]}], "Code",
     InitializationCell->True,
     CellLabel->
      "In[143]:=",ExpressionUUID->"c8870d35-e01d-4f7c-b081-273dc39f3a98"]
    }, Open  ]]
    }, Open  ]]
    },
    AutoGeneratedPackage->Automatic,
    WindowSize->{Full, Full},
    WindowMargins->{{Automatic, 49}, {-286, Automatic}},
    FrontEndVersion->"12.0 for Mac OS X x86 (64-bit) (April 8, 2019)",
    StyleDefinitions->"Default.nb"
    ]
    (* End of Notebook Content *)
    
    (* Internal cache information *)
    (*CellTagsOutline
    CellTagsIndex->{}
    *)
    (*CellTagsIndex
    CellTagsIndex->{}
    *)
    (*NotebookFileOutline
    Notebook[{
    Cell[CellGroupData[{
    Cell[580, 22, 235, 4, 98, "Title",ExpressionUUID->"412e446d-949d-4a39-ab8f-2e74aab963be"],
    Cell[818, 28, 263, 4, 45, "Subtitle",ExpressionUUID->"03c7a68d-9296-477d-858e-f28f41a96ef7"],
    Cell[1084, 34, 368, 7, 31, "Subsubtitle",ExpressionUUID->"1dd49449-a8ac-466f-9155-195dee63ff9f"],
    Cell[CellGroupData[{
    Cell[1477, 45, 381, 6, 32, "Item",ExpressionUUID->"5790c103-deb7-4616-bb6c-3201fb52dcfe"],
    Cell[1861, 53, 336, 5, 32, "Item",ExpressionUUID->"44de3030-71f6-405b-999e-75aa76f5f611"]
    }, Open  ]],
    Cell[2212, 61, 178, 2, 35, "Text",ExpressionUUID->"9611da95-c63f-4174-ad5e-d05a8caf1d44"],
    Cell[2393, 65, 217, 4, 35, "Text",ExpressionUUID->"d61a9f74-a8b4-4661-9a96-0aec3ba57e56"],
    Cell[CellGroupData[{
    Cell[2635, 73, 158, 3, 67, "Section",ExpressionUUID->"d1f4fc7b-0fc3-4dfa-87e1-5cab3334f1ef"],
    Cell[2796, 78, 971, 19, 72, "Code",ExpressionUUID->"73646baf-e1d8-48be-b891-b1d31c1d0092"]
    }, Open  ]],
    Cell[CellGroupData[{
    Cell[3804, 102, 156, 3, 67, "Section",ExpressionUUID->"62bc7e4c-e5f8-44b8-8aaf-b650c91c7ebe"],
    Cell[3963, 107, 9758, 219, 794, "Code",ExpressionUUID->"efab591e-4b89-4ab2-bcfe-eef66d3d6303"],
    Cell[13724, 328, 201, 4, 52, "Code",ExpressionUUID->"ee552dc2-de40-46d1-94d7-658affe7b6fa"]
    }, Open  ]],
    Cell[CellGroupData[{
    Cell[13962, 337, 352, 6, 67, "Section",ExpressionUUID->"ce20086e-e551-498e-b1a1-dd3723b02cc4"],
    Cell[CellGroupData[{
    Cell[14339, 347, 215, 4, 54, "Subsection",ExpressionUUID->"964e5ea4-c776-451f-948b-bb9802afe3ef"],
    Cell[14557, 353, 2809, 79, 281, "Code",ExpressionUUID->"acd9a80b-e291-43b4-8ff4-1cf9230d8178"]
    }, Closed]],
    Cell[CellGroupData[{
    Cell[17403, 437, 220, 4, 38, "Subsection",ExpressionUUID->"356b8483-9e89-4e97-a126-f1f283137492"],
    Cell[17626, 443, 649, 17, 72, "Code",ExpressionUUID->"1d7c374f-07e5-4e30-96cb-5384d03c28d7"],
    Cell[18278, 462, 2048, 55, 357, "Code",ExpressionUUID->"44421514-cbe3-43d9-a22a-ae2f79f87679"],
    Cell[20329, 519, 3015, 87, 224, "Code",ExpressionUUID->"2c5ed9b6-4222-400a-b38f-6974d610d5ff"],
    Cell[23347, 608, 1318, 33, 300, "Code",ExpressionUUID->"4d6816fc-0043-4b06-b78b-bf0c073e819b"],
    Cell[24668, 643, 2461, 66, 262, "Code",ExpressionUUID->"eb6e4d3b-ad4a-48e6-bb7d-c0810255f29d"],
    Cell[27132, 711, 1025, 28, 167, "Code",ExpressionUUID->"f6f26bfb-56ea-4ac2-93fe-b97ba55f21e4"],
    Cell[28160, 741, 1552, 47, 110, "Code",ExpressionUUID->"e92bdec3-aab4-44bb-9eb8-e8593dedbc5d",
     InitializationCell->True],
    Cell[29715, 790, 420, 11, 52, "Code",ExpressionUUID->"468673e1-1d1a-410f-9fbc-3a840631d046"],
    Cell[30138, 803, 223, 5, 52, "Code",ExpressionUUID->"66e2ce9e-8bca-4f1a-be52-019a85583e21"],
    Cell[30364, 810, 283, 7, 52, "Code",ExpressionUUID->"eb24db11-1413-4288-bb86-fd01706cab41"],
    Cell[30650, 819, 3716, 97, 547, "Code",ExpressionUUID->"e0b2f90b-4851-4681-a707-93dfa51b950f"],
    Cell[34369, 918, 1114, 29, 243, "Code",ExpressionUUID->"bc53afdf-e943-48c2-86c7-f6061351661a"],
    Cell[35486, 949, 813, 21, 205, "Code",ExpressionUUID->"85473fd6-6758-42ab-b08c-9603b15a8b4c"],
    Cell[36302, 972, 1235, 36, 129, "Code",ExpressionUUID->"e7ae596b-deb7-4f84-9610-9a11170e29df"],
    Cell[37540, 1010, 254, 6, 52, "Code",ExpressionUUID->"ac162a9f-c8ea-4b77-b9dd-33728f284915"],
    Cell[37797, 1018, 460, 12, 52, "Code",ExpressionUUID->"a7650f1d-49ea-409d-b201-4e28f33d8f17"],
    Cell[38260, 1032, 982, 30, 91, "Code",ExpressionUUID->"3c2acbf4-48c7-465c-8286-93552b4d3531"],
    Cell[39245, 1064, 3613, 115, 224, "Code",ExpressionUUID->"1410a7ff-128b-4a76-b41a-a0f54f55ac65"]
    }, Closed]],
    Cell[CellGroupData[{
    Cell[42895, 1184, 181, 3, 38, "Subsection",ExpressionUUID->"c6bb24a7-12f8-4cda-bce0-4aa336c33174"],
    Cell[43079, 1189, 2421, 56, 186, "Code",ExpressionUUID->"5de50ab8-e5be-4535-9354-434de2836834"]
    }, Open  ]],
    Cell[CellGroupData[{
    Cell[45537, 1250, 229, 4, 54, "Subsection",ExpressionUUID->"306aaf72-c2ea-46d3-b394-84934dd4014f"],
    Cell[45769, 1256, 8563, 210, 775, "Code",ExpressionUUID->"c03ad841-0c13-4803-9638-d5c9b3a75ca4"],
    Cell[54335, 1468, 6690, 178, 965, "Code",ExpressionUUID->"924831b0-9d8f-411c-aba6-db1145813b58"],
    Cell[61028, 1648, 51635, 1269, 5639, "Code",ExpressionUUID->"53efc507-6a18-4eaf-b317-b615cf672bde"]
    }, Closed]],
    Cell[CellGroupData[{
    Cell[112700, 2922, 497, 7, 38, "Subsection",ExpressionUUID->"f2291a02-b823-4df6-a581-4fcde9b9eb4e"],
    Cell[113200, 2931, 6474, 154, 547, "Code",ExpressionUUID->"bc897087-f67b-459c-87a4-ec5ee7ca2ba2"]
    }, Open  ]],
    Cell[CellGroupData[{
    Cell[119711, 3090, 487, 7, 54, "Subsection",ExpressionUUID->"4969b6f9-be82-4f3e-abc6-45d648828266"],
    Cell[120201, 3099, 4454, 121, 186, "Code",ExpressionUUID->"eda9a3bd-b2dd-4fe8-9fcb-bd728e8a287d"],
    Cell[124658, 3222, 12341, 336, 224, "Code",ExpressionUUID->"7c11673b-6e54-49ee-822b-64e19a8a50a6"]
    }, Closed]],
    Cell[CellGroupData[{
    Cell[137036, 3563, 223, 4, 38, "Subsection",ExpressionUUID->"150df7a9-0598-4dbe-b33a-3a640381122d"],
    Cell[137262, 3569, 4147, 137, 186, "Code",ExpressionUUID->"5a45b164-5323-4cf0-886c-ea802182cb1d"],
    Cell[141412, 3708, 3151, 95, 167, "Code",ExpressionUUID->"8b8ec213-3236-4399-a9d4-0d7dbfdcc7e4"]
    }, Closed]],
    Cell[CellGroupData[{
    Cell[144600, 3808, 267, 4, 38, "Subsection",ExpressionUUID->"ef40d02e-f487-40e1-b6da-592e7b6c3f02"],
    Cell[144870, 3814, 3357, 82, 243, "Code",ExpressionUUID->"cb69a25b-ca49-41e1-ac39-61c32a4d9fb6"],
    Cell[148230, 3898, 16567, 384, 775, "Code",ExpressionUUID->"2820b72e-3d09-4482-8e84-0d295d489fa4"],
    Cell[164800, 4284, 54920, 1231, 1991, "Code",ExpressionUUID->"497c5c2c-74eb-4562-8f69-941dcd0056c7"]
    }, Closed]],
    Cell[CellGroupData[{
    Cell[219757, 5520, 165, 3, 38, "Subsection",ExpressionUUID->"3fb109b0-2e0f-4e1e-a4da-311a2f2e096d"],
    Cell[219925, 5525, 2443, 54, 218, "Code",ExpressionUUID->"7d702440-ce11-4f2f-a3fd-860210f78382"],
    Cell[222371, 5581, 2812, 59, 205, "Code",ExpressionUUID->"6a85250f-5ba5-40dd-bedb-945dda498b2a"],
    Cell[225186, 5642, 1570, 42, 110, "Code",ExpressionUUID->"dedb7461-041a-428c-ba62-81c1dfe604f2"]
    }, Closed]],
    Cell[CellGroupData[{
    Cell[226793, 5689, 155, 3, 38, "Subsection",ExpressionUUID->"356909a0-587d-4c43-bcac-361575f578c4"],
    Cell[226951, 5694, 305, 9, 52, "Code",ExpressionUUID->"80893771-7d64-4f7f-a960-3d86197a9d5b"]
    }, Closed]],
    Cell[CellGroupData[{
    Cell[227293, 5708, 212, 4, 38, "Subsection",ExpressionUUID->"486ce4fb-6f1b-4d61-b371-e434cd33afb3"],
    Cell[227508, 5714, 1838, 46, 186, "Code",ExpressionUUID->"60106d1f-0ecd-4b9c-8e7a-58325e7721f8"]
    }, Open  ]],
    Cell[CellGroupData[{
    Cell[229383, 5765, 261, 4, 54, "Subsection",ExpressionUUID->"e5170d4d-131e-4832-b133-ee5d4d215557"],
    Cell[229647, 5771, 1664, 38, 224, "Code",ExpressionUUID->"7b6418b0-64f8-490b-bd06-4ffdd1c3e1f2"]
    }, Closed]],
    Cell[CellGroupData[{
    Cell[231348, 5814, 307, 5, 38, "Subsection",ExpressionUUID->"b810eb33-06bd-49a9-9c2c-95c819d4497b"],
    Cell[231658, 5821, 1443, 39, 91, "Code",ExpressionUUID->"126b7858-728f-4a7e-812b-80dcecabe308"]
    }, Closed]],
    Cell[CellGroupData[{
    Cell[233138, 5865, 163, 3, 38, "Subsection",ExpressionUUID->"c960c6cd-c63d-4558-b661-e050b480ca99"],
    Cell[233304, 5870, 5880, 154, 395, "Code",ExpressionUUID->"c3d05ccf-c015-4e03-adc9-22bf8795f8c0"]
    }, Open  ]]
    }, Open  ]],
    Cell[CellGroupData[{
    Cell[239233, 6030, 85, 0, 67, "Section",ExpressionUUID->"f1741b14-531a-4442-958b-fde3bfdb7b10"],
    Cell[239321, 6032, 257, 7, 72, "Code",ExpressionUUID->"c8870d35-e01d-4f7c-b081-273dc39f3a98",
     InitializationCell->True]
    }, Open  ]]
    }, Open  ]]
    }
    ]
    *)