From 0dcf99c9a4c79f6a80d4ff894bbf4dbdba7cad2c Mon Sep 17 00:00:00 2001 From: Joe Zuntz Date: Wed, 23 Oct 2024 15:08:51 +0100 Subject: [PATCH] add spk v1 --- structure/spk/BAHAMAS_fb_M200.csv | 566 ++++++++++++++++++++++++++++++ structure/spk/spk_interface.py | 330 +++++++++++++++++ 2 files changed, 896 insertions(+) create mode 100644 structure/spk/BAHAMAS_fb_M200.csv create mode 100644 structure/spk/spk_interface.py diff --git a/structure/spk/BAHAMAS_fb_M200.csv b/structure/spk/BAHAMAS_fb_M200.csv new file mode 100644 index 00000000..99121696 --- /dev/null +++ b/structure/spk/BAHAMAS_fb_M200.csv @@ -0,0 +1,566 @@ +z,M500,f_b +0.0,99999999999.99918,0.675459583378501 +0.0,125892541179.4156,0.6592030003484469 +0.0,158489319246.1098,0.6850401883090748 +0.0,199526231496.88583,0.7222167331556161 +0.0,251188643150.9551,0.7512196267873744 +0.0,316227766016.83405,0.7807856066164997 +0.0,398107170553.49207,0.8127077729037058 +0.0,501187233627.2653,0.8301126956231796 +0.0,630957344480.184,0.7764402731329328 +0.0,794328234724.2692,0.6858034660801223 +0.0,999999999999.9836,0.6335773400539592 +0.0,1258925411794.1455,0.5966502244868653 +0.0,1584893192461.085,0.5580380956291531 +0.0,1995262314968.842,0.5160144758416306 +0.0,2511886431509.531,0.4636508168116371 +0.0,3162277660168.3145,0.4130424753261995 +0.0,3981071705534.888,0.378063288751971 +0.0,5011872336272.612,0.3448822490042357 +0.0,6309573444801.788,0.3231384837576538 +0.0,7943282347242.627,0.3110545471430873 +0.0,9999999999999.754,0.3084289653955134 +0.0,12589254117941.354,0.3110357480469572 +0.0,15848931924610.72,0.3247456834072713 +0.0,19952623149688.258,0.3432912952904562 +0.0,25118864315095.1,0.3698527942175155 +0.0,31622776601682.887,0.4014379070788078 +0.0,39810717055348.555,0.4334491372072315 +0.0,50118723362725.71,0.4719564336844215 +0.0,63095734448017.37,0.5180878810070573 +0.0,79432823472425.61,0.5608091173740078 +0.0,99999999999996.72,0.605033320005765 +0.0,125892541179412.5,0.655956387206232 +0.0,158489319246105.9,0.6839928875987412 +0.0,199526231496880.97,0.7368840387353841 +0.0,251188643150948.97,0.762951062519631 +0.0,316227766016826.3,0.7969370210518935 +0.0,398107170553482.25,0.8117762102945236 +0.0,501187233627253.0,0.8390460620838079 +0.0,630957344480168.5,0.8412726467463552 +0.0,794328234724249.6,0.85738503514469 +0.0,999999999999959.2,0.885049965450176 +0.0,1258925411794114.8,0.9077231622661588 +0.0,1584893192461046.0,0.9299174228540268 +0.0,1995262314968792.8,0.9045429894378432 +0.12,99999999999.99918,0.687367825029278 +0.12,125892541179.4156,0.6956324875375194 +0.12,158489319246.1098,0.7030688226645987 +0.12,199526231496.88583,0.7419335334030321 +0.12,251188643150.9551,0.7681637586967215 +0.12,316227766016.83405,0.7952723845212964 +0.12,398107170553.49207,0.8248114507012723 +0.12,501187233627.2653,0.8422356965787664 +0.12,630957344480.184,0.7791487983675588 +0.12,794328234724.2692,0.6753899494716504 +0.12,999999999999.9836,0.6266167376345898 +0.12,1258925411794.1455,0.5949602601785317 +0.12,1584893192461.085,0.5583913492893106 +0.12,1995262314968.842,0.5130914493648825 +0.12,2511886431509.531,0.4686586084776902 +0.12,3162277660168.3145,0.4235050657802718 +0.12,3981071705534.888,0.3874924391347124 +0.12,5011872336272.612,0.3547074355829159 +0.12,6309573444801.788,0.3372858374259029 +0.12,7943282347242.627,0.3286489640672004 +0.12,9999999999999.754,0.3246100210372891 +0.12,12589254117941.354,0.3274563271819645 +0.12,15848931924610.72,0.3463563210080796 +0.12,19952623149688.258,0.3644700447374634 +0.12,25118864315095.1,0.3897905931720562 +0.12,31622776601682.887,0.4234884999900585 +0.12,39810717055348.555,0.4556954198093071 +0.12,50118723362725.71,0.4963490730869793 +0.12,63095734448017.37,0.5390029949794454 +0.12,79432823472425.61,0.5852921168750159 +0.12,99999999999996.72,0.6230115902314451 +0.12,125892541179412.5,0.6703687731701405 +0.12,158489319246105.9,0.7041694000026406 +0.12,199526231496880.97,0.7422821172542191 +0.12,251188643150948.97,0.7764900943059958 +0.12,316227766016826.3,0.7974679476787274 +0.12,398107170553482.25,0.8288452156795537 +0.12,501187233627253.0,0.8289703707081761 +0.12,630957344480168.5,0.8678048313129878 +0.12,794328234724249.6,0.8566385724748179 +0.12,999999999999959.2,0.8868507108454903 +0.12,1258925411794114.8,0.9176981845959156 +0.12,1584893192461046.0,0.9333537234956026 +0.12,1995262314968792.8,0.9484002208825618 +0.25,99999999999.99918,0.6986981894664874 +0.25,125892541179.4156,0.7137561689008773 +0.25,158489319246.1098,0.7203073275433548 +0.25,199526231496.88583,0.7597630400033708 +0.25,251188643150.9551,0.7849241836235793 +0.25,316227766016.83405,0.8101134678017342 +0.25,398107170553.49207,0.8374116267316344 +0.25,501187233627.2653,0.8536760749410343 +0.25,630957344480.184,0.7856012485459412 +0.25,794328234724.2692,0.6688052615079231 +0.25,999999999999.9836,0.6236863548598677 +0.25,1258925411794.1455,0.5938642573440789 +0.25,1584893192461.085,0.5631509878559229 +0.25,1995262314968.842,0.517764793421452 +0.25,2511886431509.531,0.4733981035980185 +0.25,3162277660168.3145,0.4303907935881494 +0.25,3981071705534.888,0.3976959092048934 +0.25,5011872336272.612,0.3688620648783017 +0.25,6309573444801.788,0.3506419101674475 +0.25,7943282347242.627,0.3426785193307598 +0.25,9999999999999.754,0.3428006518389016 +0.25,12589254117941.354,0.3490323973118241 +0.25,15848931924610.72,0.3648862354950385 +0.25,19952623149688.258,0.3857006605022137 +0.25,25118864315095.1,0.4104627276894882 +0.25,31622776601682.887,0.4442245909420327 +0.25,39810717055348.555,0.4744378365069456 +0.25,50118723362725.71,0.5170123825450331 +0.25,63095734448017.37,0.5572854553919316 +0.25,79432823472425.61,0.596891101274522 +0.25,99999999999996.72,0.6368475331916058 +0.25,125892541179412.5,0.6790205295107343 +0.25,158489319246105.9,0.7199479275647832 +0.25,199526231496880.97,0.7495826447057261 +0.25,251188643150948.97,0.7772766509874287 +0.25,316227766016826.3,0.8158023882144315 +0.25,398107170553482.25,0.8249229338492776 +0.25,501187233627253.0,0.8471885263103867 +0.25,630957344480168.5,0.8552828635451661 +0.25,794328234724249.6,0.8552895048226411 +0.25,999999999999959.2,0.8777516424137162 +0.25,1258925411794114.8,0.914933587583436 +0.25,1584893192461046.0,0.8866342776349665 +0.25,1995262314968792.8,0.9367700366054276 +0.37,99999999999.99918,0.7396720900620991 +0.37,125892541179.4156,0.7347176307781964 +0.37,158489319246.1098,0.7379828183930964 +0.37,199526231496.88583,0.7756874901214417 +0.37,251188643150.9551,0.8011227040913899 +0.37,316227766016.83405,0.824190661456608 +0.37,398107170553.49207,0.8493041263770948 +0.37,501187233627.2653,0.864431700780706 +0.37,630957344480.184,0.7932902947683618 +0.37,794328234724.2692,0.6651496378275943 +0.37,999999999999.9836,0.6206115101942828 +0.37,1258925411794.1455,0.5997273686614931 +0.37,1584893192461.085,0.5635039818857952 +0.37,1995262314968.842,0.5236487624722274 +0.37,2511886431509.531,0.4784099974042063 +0.37,3162277660168.3145,0.4378273800301475 +0.37,3981071705534.888,0.407964242589143 +0.37,5011872336272.612,0.3789801277296267 +0.37,6309573444801.788,0.3663435014928453 +0.37,7943282347242.627,0.3574166399385229 +0.37,9999999999999.754,0.3590583950210336 +0.37,12589254117941.354,0.3661041809676744 +0.37,15848931924610.72,0.3821078931060221 +0.37,19952623149688.258,0.404280357945298 +0.37,25118864315095.1,0.4314967248217691 +0.37,31622776601682.887,0.4608480178791831 +0.37,39810717055348.555,0.4954198069182177 +0.37,50118723362725.71,0.5351002692401788 +0.37,63095734448017.37,0.5774122258416579 +0.37,79432823472425.61,0.6144670646779217 +0.37,99999999999996.72,0.6509041307673815 +0.37,125892541179412.5,0.6951265502647497 +0.37,158489319246105.9,0.7362334442799798 +0.37,199526231496880.97,0.7601682353822817 +0.37,251188643150948.97,0.7832580535121373 +0.37,316227766016826.3,0.8162550773432634 +0.37,398107170553482.25,0.8324484007653218 +0.37,501187233627253.0,0.8412400939878955 +0.37,630957344480168.5,0.8538987987208422 +0.37,794328234724249.6,0.8858738013907587 +0.37,999999999999959.2,0.8985552081020454 +0.37,1584893192461046.0,0.9167187126599587 +0.5,99999999999.99918,0.7420626020831786 +0.5,125892541179.4156,0.7575499570558306 +0.5,158489319246.1098,0.7542762237179643 +0.5,199526231496.88583,0.7919086306482704 +0.5,251188643150.9551,0.8148385215235279 +0.5,316227766016.83405,0.8378360772613774 +0.5,398107170553.49207,0.8606191672618824 +0.5,501187233627.2653,0.8755790992671044 +0.5,630957344480.184,0.8052792099627059 +0.5,794328234724.2692,0.6646850397044614 +0.5,999999999999.9836,0.6245644283815908 +0.5,1258925411794.1455,0.5996471584078213 +0.5,1584893192461.085,0.5682120357375514 +0.5,1995262314968.842,0.5278835535427066 +0.5,2511886431509.531,0.4853676236834072 +0.5,3162277660168.3145,0.4476795905816058 +0.5,3981071705534.888,0.4165886113404544 +0.5,5011872336272.612,0.3893707899687514 +0.5,6309573444801.788,0.3809671490170061 +0.5,7943282347242.627,0.3720298641229428 +0.5,9999999999999.754,0.376028305898115 +0.5,12589254117941.354,0.3842010109187674 +0.5,15848931924610.72,0.4006340303989847 +0.5,19952623149688.258,0.4211409267514874 +0.5,25118864315095.1,0.4501730707184465 +0.5,31622776601682.887,0.477981469783126 +0.5,39810717055348.555,0.5148769582371181 +0.5,50118723362725.71,0.5501710630878894 +0.5,63095734448017.37,0.588583627842858 +0.5,79432823472425.61,0.6249250526249165 +0.5,99999999999996.72,0.6713882484379512 +0.5,125892541179412.5,0.7107921910253115 +0.5,158489319246105.9,0.7312904392489052 +0.5,199526231496880.97,0.7652164152334386 +0.5,251188643150948.97,0.8012124939432297 +0.5,316227766016826.3,0.826462736873431 +0.5,398107170553482.25,0.8433570092055183 +0.5,501187233627253.0,0.8625245792085603 +0.5,630957344480168.5,0.8885377685608123 +0.5,794328234724249.6,0.9133611930135784 +0.5,999999999999959.2,0.897884509044247 +0.5,1258925411794114.8,0.8958598922248108 +0.5,1995262314968792.8,0.9123254726101552 +0.75,99999999999.99918,0.7901438589653403 +0.75,125892541179.4156,0.7932123477248747 +0.75,158489319246.1098,0.7848772965452554 +0.75,199526231496.88583,0.8195058850415883 +0.75,251188643150.9551,0.8427013618980803 +0.75,316227766016.83405,0.8611423534415604 +0.75,398107170553.49207,0.8828532714228439 +0.75,501187233627.2653,0.8963111094927081 +0.75,630957344480.184,0.8304068132047401 +0.75,794328234724.2692,0.6758213750912566 +0.75,999999999999.9836,0.6316250457252606 +0.75,1258925411794.1455,0.6074912422592844 +0.75,1584893192461.085,0.576725703763563 +0.75,1995262314968.842,0.5411251494198126 +0.75,2511886431509.531,0.5021703310056941 +0.75,3162277660168.3145,0.4641601183534243 +0.75,3981071705534.888,0.4363496595290788 +0.75,5011872336272.612,0.4165735812632004 +0.75,6309573444801.788,0.4062208386265755 +0.75,7943282347242.627,0.4044627066553288 +0.75,9999999999999.754,0.4068260555601312 +0.75,12589254117941.354,0.4190098740643379 +0.75,15848931924610.72,0.432667795500154 +0.75,19952623149688.258,0.4554212042618503 +0.75,25118864315095.1,0.4857502150139071 +0.75,31622776601682.887,0.511773127668209 +0.75,39810717055348.555,0.5445945345203898 +0.75,50118723362725.71,0.5806108873262259 +0.75,63095734448017.37,0.6136973934480405 +0.75,79432823472425.61,0.6594099235184901 +0.75,99999999999996.72,0.6828468467175189 +0.75,125892541179412.5,0.7167513533943038 +0.75,158489319246105.9,0.7490032170812669 +0.75,199526231496880.97,0.7852435131585709 +0.75,251188643150948.97,0.8162909349050147 +0.75,316227766016826.3,0.8260970558178738 +0.75,398107170553482.25,0.8415565740399062 +0.75,501187233627253.0,0.869456877363789 +0.75,630957344480168.5,0.8656239380845414 +0.75,794328234724249.6,0.8814833661136895 +0.75,1258925411794114.8,0.903608712395624 +0.75,1584893192461046.0,0.8958328725217106 +1.0,99999999999.99918,0.8471769272440682 +1.0,125892541179.4156,0.829602251959821 +1.0,158489319246.1098,0.8261226112211512 +1.0,199526231496.88583,0.8464862972822806 +1.0,251188643150.9551,0.8674157240940912 +1.0,316227766016.83405,0.8828320945444573 +1.0,398107170553.49207,0.9031105905589436 +1.0,501187233627.2653,0.9159685228333287 +1.0,630957344480.184,0.8575493997364229 +1.0,794328234724.2692,0.6878629786864172 +1.0,999999999999.9836,0.646293356184072 +1.0,1258925411794.1455,0.6203634493039996 +1.0,1584893192461.085,0.5934022156698294 +1.0,1995262314968.842,0.5561704594676361 +1.0,2511886431509.531,0.5169248947594346 +1.0,3162277660168.3145,0.4846551898815474 +1.0,3981071705534.888,0.4603885879358811 +1.0,5011872336272.612,0.4410423242065426 +1.0,6309573444801.788,0.4365158366803676 +1.0,7943282347242.627,0.4331118134645959 +1.0,9999999999999.754,0.440034050472431 +1.0,12589254117941.354,0.4504839231233208 +1.0,15848931924610.72,0.4649731270778058 +1.0,19952623149688.258,0.4877590288326273 +1.0,25118864315095.1,0.5176684962738672 +1.0,31622776601682.887,0.5409801061205448 +1.0,39810717055348.555,0.5760042713579215 +1.0,50118723362725.71,0.6056184380215001 +1.0,63095734448017.37,0.6429810321149209 +1.0,79432823472425.61,0.6843165787587074 +1.0,99999999999996.72,0.6967431981470481 +1.0,125892541179412.5,0.7434940320226964 +1.0,158489319246105.9,0.783733387435818 +1.0,199526231496880.97,0.7922624311829425 +1.0,251188643150948.97,0.8351114721322929 +1.0,316227766016826.3,0.8268730561623342 +1.0,398107170553482.25,0.8340927629832945 +1.0,501187233627253.0,0.862082928402618 +1.0,630957344480168.5,0.9106597285726298 +1.0,999999999999959.2,0.9125701228422372 +1.25,99999999999.99918,0.8987346886988202 +1.25,125892541179.4156,0.8656525237255591 +1.25,158489319246.1098,0.862886675659804 +1.25,199526231496.88583,0.8742538230729037 +1.25,251188643150.9551,0.8914879191057036 +1.25,316227766016.83405,0.904821082980134 +1.25,398107170553.49207,0.922617023862474 +1.25,501187233627.2653,0.9337193936956704 +1.25,630957344480.184,0.8843353910254917 +1.25,794328234724.2692,0.7126162906672623 +1.25,999999999999.9836,0.6683716398932238 +1.25,1258925411794.1455,0.6434215070102763 +1.25,1584893192461.085,0.6109730565741159 +1.25,1995262314968.842,0.5753276365515992 +1.25,2511886431509.531,0.5393734595897945 +1.25,3162277660168.3145,0.5079604792706228 +1.25,3981071705534.888,0.4859489932451687 +1.25,5011872336272.612,0.4681446240441008 +1.25,6309573444801.788,0.4628338485227776 +1.25,7943282347242.627,0.4638358042549025 +1.25,9999999999999.754,0.4675752552822919 +1.25,12589254117941.354,0.4786979039602693 +1.25,15848931924610.72,0.4952858775285864 +1.25,19952623149688.258,0.5192576941131157 +1.25,25118864315095.1,0.5431735952617744 +1.25,31622776601682.887,0.567200456646328 +1.25,39810717055348.555,0.5944769878776357 +1.25,50118723362725.71,0.6255497096158019 +1.25,63095734448017.37,0.6683453542568325 +1.25,79432823472425.61,0.6867006797522027 +1.25,99999999999996.72,0.7339121767210908 +1.25,125892541179412.5,0.7693866879316151 +1.25,158489319246105.9,0.8139850600128232 +1.25,199526231496880.97,0.8264202211693159 +1.25,251188643150948.97,0.8863560030660596 +1.25,316227766016826.3,0.8722301084308326 +1.25,398107170553482.25,0.8976850063581009 +1.25,501187233627253.0,0.9135134522488914 +1.5,99999999999.99918,0.9459498835806304 +1.5,125892541179.4156,0.9059336911701472 +1.5,158489319246.1098,0.8956678818607273 +1.5,199526231496.88583,0.8992576625688766 +1.5,251188643150.9551,0.9131216186630966 +1.5,316227766016.83405,0.9261975773417988 +1.5,398107170553.49207,0.9403314364872092 +1.5,501187233627.2653,0.9502326481648654 +1.5,630957344480.184,0.911815016291272 +1.5,794328234724.2692,0.747970656175556 +1.5,999999999999.9836,0.69409415048472 +1.5,1258925411794.1455,0.6675554800531152 +1.5,1584893192461.085,0.6358217879269558 +1.5,1995262314968.842,0.6011476394026691 +1.5,2511886431509.531,0.5621002909058725 +1.5,3162277660168.3145,0.5337897527724998 +1.5,3981071705534.888,0.512955609745981 +1.5,5011872336272.612,0.4978303447706957 +1.5,6309573444801.788,0.4935664660262145 +1.5,7943282347242.627,0.4917319485498725 +1.5,9999999999999.754,0.4985363582831649 +1.5,12589254117941.354,0.5078729016437005 +1.5,15848931924610.72,0.5262459030267065 +1.5,19952623149688.258,0.5512875192801644 +1.5,25118864315095.1,0.570076035534398 +1.5,31622776601682.887,0.5895697754123276 +1.5,39810717055348.555,0.6216189530298105 +1.5,50118723362725.71,0.6537620441140538 +1.5,63095734448017.37,0.6681711380966755 +1.5,79432823472425.61,0.7171368475766077 +1.5,99999999999996.72,0.7420974484394525 +1.5,125892541179412.5,0.7987290193087327 +1.5,158489319246105.9,0.8252061620748442 +1.5,199526231496880.97,0.810484915260535 +1.5,251188643150948.97,0.8600479427311291 +1.5,316227766016826.3,0.8784130857381119 +1.75,99999999999.99918,0.9504444968318148 +1.75,125892541179.4156,0.9192751755829852 +1.75,158489319246.1098,0.924479794437526 +1.75,199526231496.88583,0.9218309023229746 +1.75,251188643150.9551,0.933257400670412 +1.75,316227766016.83405,0.9447906258947046 +1.75,398107170553.49207,0.9557668513271564 +1.75,501187233627.2653,0.9645022205910658 +1.75,630957344480.184,0.936954535479134 +1.75,794328234724.2692,0.7873206101451221 +1.75,999999999999.9836,0.7240971393982114 +1.75,1258925411794.1455,0.6945992319581421 +1.75,1584893192461.085,0.664425937629438 +1.75,1995262314968.842,0.6266802821022164 +1.75,2511886431509.531,0.5902800206126786 +1.75,3162277660168.3145,0.5700471980343242 +1.75,3981071705534.888,0.5396539322353107 +1.75,5011872336272.612,0.5263742984095062 +1.75,6309573444801.788,0.5228425086800984 +1.75,7943282347242.627,0.5205213039164499 +1.75,9999999999999.754,0.5241143179019345 +1.75,12589254117941.354,0.5388261353408236 +1.75,15848931924610.72,0.5507224097982074 +1.75,19952623149688.258,0.5702652842362094 +1.75,25118864315095.1,0.5944408984731191 +1.75,31622776601682.887,0.6254453678544676 +1.75,39810717055348.555,0.6365970204949681 +1.75,50118723362725.71,0.6711242749931253 +1.75,63095734448017.37,0.7149296474100306 +1.75,79432823472425.61,0.7320362624459564 +1.75,99999999999996.72,0.7792704131056762 +1.75,125892541179412.5,0.780625292969651 +1.75,158489319246105.9,0.8070101659322542 +1.75,199526231496880.97,0.8432586259151611 +1.75,251188643150948.97,0.8629622005481928 +2.0,99999999999.99918,0.9489186573463656 +2.0,125892541179.4156,0.9579399066380074 +2.0,158489319246.1098,0.9349996865428084 +2.0,199526231496.88583,0.9455720039778904 +2.0,251188643150.9551,0.9532231908883044 +2.0,316227766016.83405,0.9619608618821224 +2.0,398107170553.49207,0.9701658671485344 +2.0,501187233627.2653,0.9766772383745912 +2.0,630957344480.184,0.956223594714417 +2.0,794328234724.2692,0.8303206220301576 +2.0,999999999999.9836,0.750311253052496 +2.0,1258925411794.1455,0.7235309023464304 +2.0,1584893192461.085,0.6858858769596415 +2.0,1995262314968.842,0.6548623306071886 +2.0,2511886431509.531,0.6226140063414811 +2.0,3162277660168.3145,0.5946626007006431 +2.0,3981071705534.888,0.5699507103412347 +2.0,5011872336272.612,0.5615893036899616 +2.0,6309573444801.788,0.5508036464973118 +2.0,7943282347242.627,0.5504736047863333 +2.0,9999999999999.754,0.557874481703073 +2.0,12589254117941.354,0.5661533000969454 +2.0,15848931924610.72,0.5833771229631539 +2.0,19952623149688.258,0.5966149539093226 +2.0,25118864315095.1,0.6212548469431106 +2.0,31622776601682.887,0.6413327651207169 +2.0,39810717055348.555,0.6600292412551144 +2.0,50118723362725.71,0.6956886040358711 +2.0,63095734448017.37,0.733401750036612 +2.0,79432823472425.61,0.7725801212997381 +2.0,99999999999996.72,0.7941847707710945 +2.0,125892541179412.5,0.829625027268496 +2.0,158489319246105.9,0.8335933515340357 +2.0,199526231496880.97,0.8517887324377467 +2.25,99999999999.99918,0.944468297413244 +2.25,125892541179.4156,0.9917795116101192 +2.25,158489319246.1098,0.9634658760816546 +2.25,199526231496.88583,0.963757361268458 +2.25,251188643150.9551,0.9608971520775716 +2.25,316227766016.83405,0.9689117543260192 +2.25,398107170553.49207,0.9824561402908112 +2.25,501187233627.2653,0.987142080074672 +2.25,630957344480.184,0.971060625746014 +2.25,794328234724.2692,0.875424618749135 +2.25,999999999999.9836,0.7828849044994303 +2.25,1258925411794.1455,0.7463658494516853 +2.25,1584893192461.085,0.7163111976859599 +2.25,1995262314968.842,0.6812700731046442 +2.25,2511886431509.531,0.6550476720260496 +2.25,3162277660168.3145,0.6223308301911383 +2.25,3981071705534.888,0.6007872109914683 +2.25,5011872336272.612,0.5881813618716978 +2.25,6309573444801.788,0.5779194243414945 +2.25,7943282347242.627,0.5795509770528253 +2.25,9999999999999.754,0.587587495411771 +2.25,12589254117941.354,0.5970120585519111 +2.25,15848931924610.72,0.600734515892776 +2.25,19952623149688.258,0.6345038530164437 +2.25,25118864315095.1,0.6524401507321387 +2.25,31622776601682.887,0.6693436597593636 +2.25,39810717055348.555,0.702015367163864 +2.25,50118723362725.71,0.7118838933814292 +2.25,63095734448017.37,0.7628727108347002 +2.25,79432823472425.61,0.77703799370317 +2.25,99999999999996.72,0.8069049708012219 +2.25,125892541179412.5,0.9223206056025992 +2.25,158489319246105.9,0.8228496194536806 +2.5,99999999999.99918,1.1012939871331566 +2.5,125892541179.4156,0.9992104930158564 +2.5,158489319246.1098,0.9664081411737038 +2.5,199526231496.88583,0.9726857206082784 +2.5,251188643150.9551,0.9770354631695564 +2.5,316227766016.83405,0.9813216415263268 +2.5,398107170553.49207,0.9854483594642208 +2.5,501187233627.2653,0.9889738418840792 +2.5,630957344480.184,0.9807489930358184 +2.5,794328234724.2692,0.9113344103400196 +2.5,999999999999.9836,0.8099368440582843 +2.5,1258925411794.1455,0.764863576150384 +2.5,1584893192461.085,0.7386893241480654 +2.5,1995262314968.842,0.7057853314468585 +2.5,2511886431509.531,0.6797567209396929 +2.5,3162277660168.3145,0.6494637855160389 +2.5,3981071705534.888,0.6304503425485514 +2.5,5011872336272.612,0.6154248503244529 +2.5,6309573444801.788,0.6137109369167556 +2.5,7943282347242.627,0.6096047248634888 +2.5,9999999999999.754,0.611859280467422 +2.5,12589254117941.354,0.6268427657187768 +2.5,15848931924610.72,0.6327901780534158 +2.5,19952623149688.258,0.6561587264869693 +2.5,25118864315095.1,0.6620244283198111 +2.5,31622776601682.887,0.6796752553252456 +2.5,39810717055348.555,0.7202205328448117 +2.5,50118723362725.71,0.6894777849968478 +2.5,63095734448017.37,0.8542675526018052 +2.5,79432823472425.61,0.7731108873842173 +2.5,99999999999996.72,0.8659241658364596 +2.75,99999999999.99918,0.9504444982763716 +2.75,125892541179.4156,0.9999999462914424 +2.75,158489319246.1098,0.96803823135008 +2.75,199526231496.88583,0.9737945807642744 +2.75,251188643150.9551,0.9785181563617597 +2.75,316227766016.83405,0.9825600188519434 +2.75,398107170553.49207,0.986720611437211 +2.75,501187233627.2653,0.9907472352919876 +2.75,630957344480.184,0.9879372150247114 +2.75,794328234724.2692,0.9353456662035172 +2.75,999999999999.9836,0.8351486010793885 +2.75,1258925411794.1455,0.7939263891835849 +2.75,1584893192461.085,0.7610816133953896 +2.75,1995262314968.842,0.7327447044182241 +2.75,2511886431509.531,0.7064463391895391 +2.75,3162277660168.3145,0.6791067038619765 +2.75,3981071705534.888,0.6613303933290625 +2.75,5011872336272.612,0.6521508188756757 +2.75,6309573444801.788,0.634558413355843 +2.75,7943282347242.627,0.6320611160581434 +2.75,9999999999999.754,0.6377830739408697 +2.75,12589254117941.354,0.6434549605211316 +2.75,15848931924610.72,0.6687643526694234 +2.75,19952623149688.258,0.6718138522686822 +2.75,25118864315095.1,0.6987500443240268 +2.75,31622776601682.887,0.6920084279317629 +2.75,39810717055348.555,0.7172492755225471 +2.75,50118723362725.71,0.7550131564972615 +2.75,63095734448017.37,0.8257297944158789 +2.75,79432823472425.61,0.9066063170139022 +3.0,99999999999.99918,1.049580313142511 +3.0,125892541179.4156,0.9999999634009004 +3.0,158489319246.1098,0.9689117606696332 +3.0,199526231496.88583,0.975193356341358 +3.0,251188643150.9551,0.9800586776515668 +3.0,316227766016.83405,0.9839058032415549 +3.0,398107170553.49207,0.9943162301078858 +3.0,501187233627.2653,0.9980067398342652 +3.0,630957344480.184,0.990280914167346 +3.0,794328234724.2692,0.9562083427922192 +3.0,999999999999.9836,0.8647570393299824 +3.0,1258925411794.1455,0.8132353030298785 +3.0,1584893192461.085,0.7826094353604386 +3.0,1995262314968.842,0.7563234659938257 +3.0,2511886431509.531,0.7320300706780624 +3.0,3162277660168.3145,0.704815865353475 +3.0,3981071705534.888,0.6893706650558034 +3.0,5011872336272.612,0.6731562377374695 +3.0,6309573444801.788,0.6624473421792948 +3.0,7943282347242.627,0.657041708607156 +3.0,9999999999999.754,0.6485751056039002 +3.0,12589254117941.354,0.6696924375373732 +3.0,15848931924610.72,0.697301637598067 +3.0,19952623149688.258,0.7264461548209162 +3.0,25118864315095.1,0.7535675917640918 +3.0,31622776601682.887,0.7934681456397924 +3.0,39810717055348.555,0.7538345417563423 +3.0,50118723362725.71,0.8435623399848996 +3.0,99999999999996.72,0.86998972437802 diff --git a/structure/spk/spk_interface.py b/structure/spk/spk_interface.py new file mode 100644 index 00000000..109b34f6 --- /dev/null +++ b/structure/spk/spk_interface.py @@ -0,0 +1,330 @@ +""" +An interface to the baryonic code. + +""" + +from cosmosis.datablock import option_section, names as section_names +import numpy as np +import astropy.cosmology +import warnings +from scipy.interpolate import LinearNDInterpolator + + +# pyspk tells the whole of python to always print every warning over and over again. +# Undo it like this. +warnings_filters = warnings.filters[:] +import pyspk.model as spk +warnings.filters = warnings_filters + + +def my_ceil(a, precision=0): + return np.true_divide(np.ceil(a * 10**precision), 10**precision) + + +def my_floor(a, precision=0): + return np.true_divide(np.floor(a * 10**precision), 10**precision) + + +round_up = np.vectorize(my_ceil) +round_down = np.vectorize(my_floor) + + +def set_params(block, model_class): + # These pairs are the astropy parameter name and the cosmosis param name + params_needed_by_class = { + astropy.cosmology.FlatLambdaCDM: [ + ("H0", "hubble"), + ("Om0", "omega_m"), + ("Ob0", "omega_b"), + ], + astropy.cosmology.FlatwCDM: [ + ("H0", "hubble"), + ("Om0", "omega_m"), + ("Ob0", "omega_b"), + ("w0", "w"), + ], + astropy.cosmology.Flatw0waCDM: [ + ("H0", "hubble"), + ("Om0", "omega_m"), + ("Ob0", "omega_b"), + ("w0", "w"), + ("wa", "wa"), + ], + astropy.cosmology.LambdaCDM: [ + ("H0", "hubble"), + ("Om0", "omega_m"), + ("Ob0", "omega_b"), + ("Ode0", "omega_lambda"), + ], + astropy.cosmology.wCDM: [ + ("H0", "hubble"), + ("Om0", "omega_m"), + ("Ob0", "omega_b"), + ("Ode0", "omega_lambda"), + ("w0", "w"), + ], + astropy.cosmology.w0waCDM: [ + ("H0", "hubble"), + ("Om0", "omega_m"), + ("Ob0", "omega_b"), + ("Ode0", "omega_lambda"), + ("w0", "w"), + ("wa", "wa"), + ], + astropy.cosmology.w0wzCDM: [ + ("H0", "hubble"), + ("Om0", "omega_m"), + ("Ob0", "omega_b"), + ("Ode0", "omega_lambda"), + ("w0", "w"), + ("wz", "wz"), + ], + astropy.cosmology.w0wzCDM: [ + ("H0", "hubble"), + ("Om0", "omega_m"), + ("Ob0", "omega_b"), + ("Ode0", "omega_lambda"), + ("w0", "w"), + ("wz", "wz"), + ], + astropy.cosmology.wpwaCDM: [ + ("H0", "hubble"), + ("Om0", "omega_m"), + ("Ob0", "omega_b"), + ("Ode0", "omega_lambda"), + ("wp", "wp"), + ("wa", "wa"), + ("zp", "zp"), + ], + } + + params_needed = params_needed_by_class[model_class] + + # Pull the parameters we need out from cosmosis + params = {} + for astropy_name, cosmosis_name in params_needed: + params[astropy_name] = block[ + section_names.cosmological_parameters, cosmosis_name + ] + + # Create the astropy object that does the calculations + cosmo = model_class(**params) + + return cosmo + + +def setup(options): + + verbose = options.get_bool(option_section, "verbose", default=False) + SO = options.get_int(option_section, "SO", default=500) + model = options.get_string(option_section, "astropy_model", default="None") + fb_table = options.get_string(option_section, "fb_table", default="") + + if fb_table: + tab = np.loadtxt(fb_table, skiprows=1, delimiter=",") + inter = LinearNDInterpolator(tab[:, [0, 1]], tab[:, 2], rescale=True) + else: + inter = None + fb_table = None + + extrapolate = options.get_bool(option_section, "extrapolate", default=False) + + # These are parameters for spk + config = {} + config["verbose"] = verbose + config["SO"] = SO + config["fb_table"] = fb_table + config["extrapolate"] = extrapolate + config["interpolator"] = inter + + # Models available in astropy.cosmology + astropy_models = { + "flatlambdacdm": astropy.cosmology.FlatLambdaCDM, + "flatw0wacdm": astropy.cosmology.Flatw0waCDM, + "flatwcdm": astropy.cosmology.FlatwCDM, + "lambdacdm": astropy.cosmology.LambdaCDM, + "w0wacdm": astropy.cosmology.w0waCDM, + "w0wzcdm": astropy.cosmology.w0wzCDM, + "wcdm": astropy.cosmology.wCDM, + "wpwacdm": astropy.cosmology.wpwaCDM, + } + + # Find the model the user has specified + model_class = None + + if "None" not in model: + model_class = astropy_models.get(model.lower()) + if model_class is None: + raise ValueError(f"[SPK]: Unknown astropy model: {model}") + + config["model_class"] = model_class + + return config + + +def check_parameter_choice(cosmo, fb_table, spk_params): + """ + Look at the parameters provided for SPK and check that + they are consistent with exactly one mode. + + This could be simplified. + """ + if spk_params["epsilon"] or spk_params["m_pivot"]: + modes = [ + ( + "Power law", + ["fb_a", "fb_pow", "fb_pivot"], + spk_params["fb_a"], + spk_params["fb_pow"], + spk_params["fb_pivot"], + ), + + ("Non-parametric fb table", ["fb_table"], fb_table), + ( + "Redshift dependent double power law", + ["epsilon", "alpha", "beta", "gamma", "m_pivot", "astropy_model"], + spk_params["epsilon"], + spk_params["alpha"], + spk_params["beta"], + spk_params["gamma"], + spk_params["m_pivot"], + cosmo, + ), + ] + else: + modes = [ + ( + "Power law", + ["fb_a", "fb_pow", "fb_pivot"], + spk_params["fb_a"], + spk_params["fb_pow"], + spk_params["fb_pivot"], + ), + ("Non-parametric fb table", ["fb_table"], fb_table), + ( + "Redshift dependent power law", + ["alpha", "beta", "gamma", "astropy_model"], + spk_params["alpha"], + spk_params["beta"], + spk_params["gamma"], + cosmo, + ), + ] + + provided_modes = sum(any(param is not None for param in mode[2:]) for mode in modes) + + # Complain of more than one mode is consistent with the parameters specfified. + # This will happen if parameters that should be left unset are supplied. + if provided_modes != 1: + provided_params = [ + param + for mode in modes + for param in mode[1] + if mode[2:].count(None) != len(mode[2:]) + ] + raise ValueError( + f"[SPK]: Only one mode to specify the baryon fraction should be provided. You provided: {provided_params}" + ) + + # Now complain if not all parameters are set for a chosen mode. + for mode in modes: + if any(param is not None for param in mode[2:]): + missing_params = [ + param_name + for param_name, param_value in zip(mode[1], mode[2:]) + if param_value is None + ] + if len(missing_params) != 0: + raise ValueError( + f"[SPK]: The following parameter(s) is(are) missing in mode '{mode[0]}': {', '.join(missing_params)}." + ) + +def execute(block, config): + verbose = config["verbose"] + SO = config["SO"] + fb_table = config["fb_table"] + extrapolate = config["extrapolate"] + inter = config["interpolator"] + + # Create our cosmological model + model_class = config["model_class"] + + M_halo = None + fb = None + cosmo = None + if model_class: + cosmo = set_params(block, model_class) + + # Load the current non-linear matter power spectrum + section = section_names.matter_power_nl + k, z_array, P = block.get_grid(section, "k_h", "z", "P_k") + + params = [ + "fb_a", + "fb_pow", + "fb_pivot", + "epsilon", + "alpha", + "beta", + "gamma", + "m_pivot", + ] + + # Get any of the named parameters from above that are in the block + spk_params = {} + for param_i in params: + if block.has_value("spk", param_i): + spk_params[param_i] = block.get("spk", param_i) + else: + spk_params[param_i] = None + + # Check that the specified parameters match exactly one + # sensible mode. + check_parameter_choice(cosmo, fb_table, spk_params) + + sup_array = np.empty_like(P) + + for i in range(len(z_array)): + z = z_array[i] + + if inter is not None: + min_mass = round_down(np.log10(spk.optimal_mass(SO, z, np.max(k))), 1) + max_mass = round_up(np.log10(spk.optimal_mass(SO, z, np.min(k))), 1) + M_halo = np.logspace(min_mass, max_mass, 100) + fb = inter(z, M_halo) + if np.isnan(np.sum(fb)): + raise ValueError( + f"[SPK]: Requested values (z and/or M_halo) outside of the convex hull of the input points in fb_table. Hint: Check your fb_table and the requested redshifts." + ) + + # Get the suppression factor for this redshift + k, sup = spk.sup_model( + SO=SO, + z=z, + fb_a=spk_params["fb_a"], + fb_pow=spk_params["fb_pow"], + fb_pivot=spk_params["fb_pivot"], + M_halo=M_halo, + fb=fb, + extrapolate=extrapolate, + epsilon=spk_params["epsilon"], + alpha=spk_params["alpha"], + beta=spk_params["beta"], + gamma=spk_params["gamma"], + m_pivot=spk_params["m_pivot"], + cosmo=cosmo, + k_array=k, + verbose=verbose, + ) + sup_array[:, i] = sup + + # Scale the matter power spectrum by the suppression + P_mod = P * sup_array + + # JZ I've also replaced this to avoid assuming the ordering + # of the P grid in memory. + section = section_names.matter_power_nl + block.replace_grid(section, "k_h", k, "z", z_array, "P_k", P_mod) + + # All is good - return + return 0