csiborgtools/notebooks/flow/flow_calibration.ipynb
Richard Stiskalek 84a1609d77
Add Lilow2024 velocity fields (#133)
* Add Lilow data

* Fix Lilow NaNs

* Update nb

* Update nb
2024-06-28 11:55:42 +01:00

6.1 MiB

Calibrating the velocity field against observations

In [1]:
# Copyright (C) 2024 Richard Stiskalek
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
import numpy as np
import matplotlib.pyplot as plt
import jax
from jax import numpy as jnp
from numpyro.infer import MCMC, NUTS, init_to_median
import corner
from getdist import plots
from scipy.stats import multivariate_normal

import csiborgtools

from flow_calibration import *

%load_ext autoreload
%autoreload 2
%matplotlib inline

paths = csiborgtools.read.Paths(**csiborgtools.paths_glamdring)

LOS density & radial velocity plots

In [2]:
fpath = "/mnt/extraspace/rstiskalek/catalogs/PV_compilation.hdf5"

loader_carrick = csiborgtools.flow.DataLoader("Carrick2015", [0], "LOSS", fpath, paths, ksmooth=0, )
# loaders_csiborg2X = [csiborgtools.flow.DataLoader("csiborg2X", i, "LOSS", fpath, paths, ksmooth=1, verbose=False) for i in range(20)]
# loaders_csiborg2 = [csiborgtools.flow.DataLoader("csiborg2_main", i, "LOSS", fpath, paths, ksmooth=1, verbose=False) for i in range(20)]

loader_CF4 = csiborgtools.flow.DataLoader("CF4gp", [0], "LOSS", fpath, paths, ksmooth=0, )
loader_lilow = csiborgtools.flow.DataLoader("Lilow2024", [0], "LOSS", fpath, paths, ksmooth=0, )
2024-06-28 10:18:55.688429:   reading the catalogue,
2024-06-28 10:18:55.695821:   reading the interpolated field,
2024-06-28 10:18:55.702331:   calculating the radial velocity.
2024-06-28 10:18:55.711839:   reading the catalogue,
2024-06-28 10:18:55.716579:   reading the interpolated field,
2024-06-28 10:18:55.722066:   calculating the radial velocity.
2024-06-28 10:18:55.731522:   reading the catalogue,
2024-06-28 10:18:55.736014:   reading the interpolated field,
2024-06-28 10:18:55.741692:   calculating the radial velocity.
/mnt/users/rstiskalek/csiborgtools/csiborgtools/flow/flow_model.py:91: UserWarning: The number of radial steps is even. Skipping the first step at 0.0 because Simpson's rule requires an odd number of steps.
  warn(f"The number of radial steps is even. Skipping the first "
In [16]:
loader_lilow.los_density[0, 0]
Out[16]:
array([0.69685763, 0.73466307, 0.7650783 , 0.7883136 , 0.80457044,
       0.8140608 , 0.8169893 , 0.83643687, 0.88755405, 0.92116797,
       0.9380432 , 0.96328056, 0.9896469 , 1.0081652 , 1.0195258 ,
       1.0560786 , 1.0974658 , 1.1280113 , 1.1490052 , 1.1617223 ,
       1.1674689 , 1.1675296 , 1.1856278 , 1.2255898 , 1.2665467 ,
       1.3084732 , 1.3513306 , 1.3950762 , 1.4396795 , 1.4850777 ,
       1.504627  , 1.471647  , 1.439527  , 1.4058427 , 1.3500667 ,
       1.2967322 , 1.2527199 , 1.2113079 , 1.1499443 , 1.0797446 ,
       1.0111988 , 0.9442538 , 0.8788524 , 0.8149391 , 0.7524569 ,
       0.6899462 , 0.64999485, 0.6120415 , 0.5759739 , 0.5417122 ,
       0.5091703 , 0.4782685 , 0.44892496, 0.42582405, 0.412762  ,
       0.39961132, 0.38850206, 0.380072  , 0.37210658, 0.36461502,
       0.3576082 , 0.35768077, 0.36142343, 0.3655083 , 0.36996365,
       0.37481946, 0.3801028 , 0.38672125, 0.3984471 , 0.4218305 ,
       0.445755  , 0.47025493, 0.4972704 , 0.52729154, 0.5595632 ,
       0.59434897, 0.6307517 , 0.6652177 , 0.69879574, 0.72388625,
       0.7457483 , 0.7653369 , 0.78251755, 0.7971557 , 0.8008448 ,
       0.7959661 , 0.7861842 , 0.7712729 , 0.75100523, 0.72515726,
       0.69321537, 0.6571734 , 0.6334162 , 0.6085876 , 0.58270174,
       0.5558152 , 0.5279944 , 0.4992937 , 0.46977374, 0.44858807,
       0.4463067 , 0.4488525 , 0.46350282, 0.4797486 , 0.49764305,
       0.5172368 , 0.53858614, 0.58701706, 0.6498171 , 0.71230537,
       0.77607214, 0.84107745, 0.9072731 , 0.96840215, 1.0283827 ,
       1.0995328 , 1.1694888 , 1.2381961 , 1.3056527 , 1.3718531 ,
       1.436802  , 1.5004954 , 1.5406916 , 1.5355375 , 1.5107039 ,
       1.4774832 , 1.4474292 , 1.4205686 , 1.3969333 , 1.3765533 ,
       1.3238554 , 1.2600352 , 1.2039832 , 1.1556861 , 1.115128  ,
       1.076347  , 1.0336369 , 0.99825376, 0.96500903, 0.93834096,
       0.91825336, 0.90472573, 0.89774036, 0.8972771 , 0.9024857 ,
       0.9097061 , 0.9177975 , 0.9144166 , 0.9149999 , 0.9194593 ,
       0.92770576, 0.93965113, 0.9552086 , 0.96433014, 0.9703311 ,
       0.97791064, 0.9869726 , 0.99741906, 0.9942949 , 0.98811895,
       0.98444855, 0.9805053 , 0.97829217, 0.9777103 , 0.9786558 ,
       0.9810231 , 0.984704  , 0.98959744, 1.0008274 , 1.0163866 ,
       1.023952  , 1.0305351 , 1.0363642 , 1.0416691 , 1.0466659 ,
       1.0515833 , 1.0505463 , 1.0439698 , 1.0347023 , 1.0230141 ,
       1.0108571 , 1.0221531 , 1.032491  , 1.0418603 , 1.0330213 ,
       1.0213324 , 1.006998  , 0.9901165 , 0.97079396, 0.9491259 ,
       0.92521906, 0.9023784 , 0.91259044, 0.9242483 , 0.9310528 ,
       0.93329376, 0.93126357, 0.925246  , 0.915538  , 0.9198018 ,
       0.9303906 , 0.9386621 , 0.9448134 , 0.9590964 , 0.976257  ,
       0.9856769 , 0.98796886, 1.0051105 , 1.0169095 , 1.0234919 ,
       1.0251429 , 1.0221395 , 1.0147623 , 1.0032927 , 0.9913863 ,
       0.9826922 , 0.9706438 , 0.95584977, 0.93774074, 0.916242  ,
       0.89143634, 0.8634156 , 0.83711463, 0.81098473, 0.7826282 ,
       0.7519914 , 0.7345157 , 0.7179058 , 0.7005569 , 0.6824472 ,
       0.6648912 , 0.64755756, 0.63039535, 0.61335933, 0.59640706,
       0.5794922 , 0.5625714 , 0.55372167, 0.55476856, 0.55651623,
       0.5590139 , 0.5623096 , 0.5664523 , 0.5714904 , 0.5774725 ,
       0.59912086, 0.6291951 , 0.66007686, 0.691631  , 0.7231415 ,
       0.7547109 , 0.78633296, 0.81799614, 0.88560414, 0.9516833 ,
       1.0147967 , 1.0749854 , 1.1322846 , 1.1867422 , 1.23839   ,
       1.287739  , 1.3389908 , 1.3828435 , 1.4194251 , 1.4488693 ,
       1.4713004 , 1.4868565 , 1.4956634 , 1.4776303 , 1.442771  ,
       1.4018629 , 1.3678957 , 1.3365828 , 1.3026344 , 1.2662126 ,
       1.2274774 , 1.1681819 , 1.1095585 , 1.0518968 , 0.99529195,
       0.9398451 , 0.88565576, 0.8376482 , 0.80287534, 0.77728087,
       0.7529412 , 0.72986865, 0.70807254, 0.6875645 , 0.6694155 ,
       0.65380484, 0.65046287, 0.65239877, 0.6537758 , 0.6596502 ,
       0.66487515, 0.6694619 , 0.6734169 , 0.6767498 , 0.69166327,
       0.70493   , 0.71642244, 0.72614235, 0.73408985, 0.7402644 ,
       0.7527538 , 0.76778936, 0.78356695, 0.79879445, 0.81343585,
       0.82745576, 0.840819  , 0.853489  , 0.86543196, 0.87035084,
       0.8713247 , 0.87983537, 0.8974779 , 0.91490054, 0.93207127,
       0.948962  , 0.96554136, 0.9673332 , 0.9676845 , 0.9667275 ,
       0.9643778 , 0.96048355, 0.95864886, 0.97222626, 0.98109716,
       0.98201334, 0.97941613, 0.97341514, 0.9641059 , 0.9515975 ,
       0.93599015, 0.91739005, 0.90093464, 0.8849075 , 0.87218845,
       0.85761374, 0.8403927 , 0.8207049 , 0.7987295 , 0.7746469 ,
       0.76474696, 0.75388706, 0.74197716, 0.7291062 , 0.7153663 ,
       0.70117784, 0.687008  , 0.67630523, 0.6728028 , 0.6690459 ,
       0.6650747 , 0.66093194, 0.65665966, 0.65229917, 0.6478932 ,
       0.6454716 , 0.64413816, 0.64389473, 0.64346874, 0.64287055,
       0.6421097 , 0.64119613, 0.6401398 , 0.6398357 , 0.6392334 ,
       0.63832307, 0.63710797, 0.635591  , 0.63416237, 0.6325924 ,
       0.6316564 , 0.63214314, 0.63232785, 0.6322132 , 0.63180107,
       0.631094  , 0.63009423, 0.628804  , 0.62947303, 0.6308802 ,
       0.6320521 , 0.6331332 , 0.6341251 , 0.6350298 , 0.63584924,
       0.6365851 ,        nan,        nan,        nan,        nan,
              nan,        nan,        nan,        nan], dtype=float32)
In [11]:
loader_lilow.rdist
Out[11]:
array([  0.5,   1. ,   1.5,   2. ,   2.5,   3. ,   3.5,   4. ,   4.5,
         5. ,   5.5,   6. ,   6.5,   7. ,   7.5,   8. ,   8.5,   9. ,
         9.5,  10. ,  10.5,  11. ,  11.5,  12. ,  12.5,  13. ,  13.5,
        14. ,  14.5,  15. ,  15.5,  16. ,  16.5,  17. ,  17.5,  18. ,
        18.5,  19. ,  19.5,  20. ,  20.5,  21. ,  21.5,  22. ,  22.5,
        23. ,  23.5,  24. ,  24.5,  25. ,  25.5,  26. ,  26.5,  27. ,
        27.5,  28. ,  28.5,  29. ,  29.5,  30. ,  30.5,  31. ,  31.5,
        32. ,  32.5,  33. ,  33.5,  34. ,  34.5,  35. ,  35.5,  36. ,
        36.5,  37. ,  37.5,  38. ,  38.5,  39. ,  39.5,  40. ,  40.5,
        41. ,  41.5,  42. ,  42.5,  43. ,  43.5,  44. ,  44.5,  45. ,
        45.5,  46. ,  46.5,  47. ,  47.5,  48. ,  48.5,  49. ,  49.5,
        50. ,  50.5,  51. ,  51.5,  52. ,  52.5,  53. ,  53.5,  54. ,
        54.5,  55. ,  55.5,  56. ,  56.5,  57. ,  57.5,  58. ,  58.5,
        59. ,  59.5,  60. ,  60.5,  61. ,  61.5,  62. ,  62.5,  63. ,
        63.5,  64. ,  64.5,  65. ,  65.5,  66. ,  66.5,  67. ,  67.5,
        68. ,  68.5,  69. ,  69.5,  70. ,  70.5,  71. ,  71.5,  72. ,
        72.5,  73. ,  73.5,  74. ,  74.5,  75. ,  75.5,  76. ,  76.5,
        77. ,  77.5,  78. ,  78.5,  79. ,  79.5,  80. ,  80.5,  81. ,
        81.5,  82. ,  82.5,  83. ,  83.5,  84. ,  84.5,  85. ,  85.5,
        86. ,  86.5,  87. ,  87.5,  88. ,  88.5,  89. ,  89.5,  90. ,
        90.5,  91. ,  91.5,  92. ,  92.5,  93. ,  93.5,  94. ,  94.5,
        95. ,  95.5,  96. ,  96.5,  97. ,  97.5,  98. ,  98.5,  99. ,
        99.5, 100. , 100.5, 101. , 101.5, 102. , 102.5, 103. , 103.5,
       104. , 104.5, 105. , 105.5, 106. , 106.5, 107. , 107.5, 108. ,
       108.5, 109. , 109.5, 110. , 110.5, 111. , 111.5, 112. , 112.5,
       113. , 113.5, 114. , 114.5, 115. , 115.5, 116. , 116.5, 117. ,
       117.5, 118. , 118.5, 119. , 119.5, 120. , 120.5, 121. , 121.5,
       122. , 122.5, 123. , 123.5, 124. , 124.5, 125. , 125.5, 126. ,
       126.5, 127. , 127.5, 128. , 128.5, 129. , 129.5, 130. , 130.5,
       131. , 131.5, 132. , 132.5, 133. , 133.5, 134. , 134.5, 135. ,
       135.5, 136. , 136.5, 137. , 137.5, 138. , 138.5, 139. , 139.5,
       140. , 140.5, 141. , 141.5, 142. , 142.5, 143. , 143.5, 144. ,
       144.5, 145. , 145.5, 146. , 146.5, 147. , 147.5, 148. , 148.5,
       149. , 149.5, 150. , 150.5, 151. , 151.5, 152. , 152.5, 153. ,
       153.5, 154. , 154.5, 155. , 155.5, 156. , 156.5, 157. , 157.5,
       158. , 158.5, 159. , 159.5, 160. , 160.5, 161. , 161.5, 162. ,
       162.5, 163. , 163.5, 164. , 164.5, 165. , 165.5, 166. , 166.5,
       167. , 167.5, 168. , 168.5, 169. , 169.5, 170. , 170.5, 171. ,
       171.5, 172. , 172.5, 173. , 173.5, 174. , 174.5, 175. , 175.5,
       176. , 176.5, 177. , 177.5, 178. , 178.5, 179. , 179.5, 180. ,
       180.5, 181. , 181.5, 182. , 182.5, 183. , 183.5, 184. , 184.5,
       185. , 185.5, 186. , 186.5, 187. , 187.5, 188. , 188.5, 189. ,
       189.5, 190. , 190.5, 191. , 191.5, 192. , 192.5, 193. , 193.5,
       194. , 194.5, 195. , 195.5, 196. , 196.5, 197. , 197.5, 198. ,
       198.5, 199. , 199.5], dtype=float32)
In [10]:
loader_lilow.los_radial_velocity
Out[10]:
array([[[  35.210815,   35.04605 ,   34.74849 , ...,         nan,
                 nan,         nan],
        [-441.1905  , -422.74704 , -404.55774 , ...,  -31.251247,
          -26.673668,  -22.087921],
        [-136.28223 , -143.65129 , -151.05142 , ...,         nan,
                 nan,         nan],
        ...,
        [-648.0296  , -644.74    , -641.37463 , ...,         nan,
                 nan,         nan],
        [ 326.15454 ,  337.55508 ,  349.01004 , ...,         nan,
                 nan,         nan],
        [-682.3207  , -676.8416  , -671.1299  , ...,         nan,
                 nan,         nan]]], dtype=float32)
In [7]:
ks = [i for i in range(50)]
# ks = [0, 1, 2, 3, 4, 5, 6, ]

for k in ks:
    fig, axs = plt.subplots(2, 1, figsize=(7, 7), sharex=True)
    fig.subplots_adjust(wspace=0)
    cols = plt.rcParams['axes.prop_cycle'].by_key()['color']

    # # CSiBORG2
    # x = loaders_csiborg2X[0].rdist
    # y = np.asarray([loaders_csiborg2[i].los_density[k, :] for i in range(len(loaders_csiborg2X))])
    # ylow, ymed, yhigh = np.percentile(y, [16, 50, 84], axis=0)
    # axs[0].fill_between(x, ylow, yhigh, color=cols[0], alpha=0.25)
    # axs[0].plot(x, ymed, color=cols[0], label="CSiBORG2")

    # y = np.asarray([loaders_csiborg2[i].los_radial_velocity[k, :] for i in range(len(loaders_csiborg2X))])
    # ylow, ymed, yhigh = np.percentile(y, [16, 50, 84], axis=0)
    # axs[1].fill_between(x, ylow, yhigh, color=cols[0], alpha=0.25)
    # axs[1].plot(x, ymed, color=cols[0], label="CSiBORG2")

    # # CSiBORG2X
    # x = loaders_csiborg2X[0].rdist
    # y = np.asarray([loaders_csiborg2X[i].los_density[k, :] for i in range(len(loaders_csiborg2X))])
    # ylow, ymed, yhigh = np.percentile(y, [16, 50, 84], axis=0)
    # axs[0].fill_between(x, ylow, yhigh, color=cols[1], alpha=0.25)
    # axs[0].plot(x, ymed, color=cols[1], label="CSiBORG2X")

    # y = np.asarray([loaders_csiborg2X[i].los_radial_velocity[k, :] for i in range(len(loaders_csiborg2X))])
    # ylow, ymed, yhigh = np.percentile(y, [16, 50, 84], axis=0)
    # axs[1].fill_between(x, ylow, yhigh, color=cols[1], alpha=0.25)
    # axs[1].plot(x, ymed, color=cols[1], label="CSiBORG2X")

    # Plot Carrick+2015
    axs[0].plot(loader_carrick.rdist, loader_carrick.los_density[0, k, :], color="red", label="Carrick+2015")
    axs[1].plot(loader_carrick.rdist, loader_carrick.los_radial_velocity[0, k, :] * 0.43, color="red")

    # Plot CF4
    c = cols[4]
    axs[0].plot(loader_CF4.rdist, loader_CF4.los_density[0, k, :], color=c, label="CF4")
    axs[1].plot(loader_CF4.rdist, loader_CF4.los_radial_velocity[0, k, :], color=c)

    # Plot Lilow2024
    c = cols[5]
    axs[0].plot(loader_lilow.rdist, loader_lilow.los_density[0, k, :], color=c, label="Lilow+2024")
    axs[1].plot(loader_lilow.rdist, loader_lilow.los_radial_velocity[0, k, :], color=c)


    axs[1].set_xlabel(r"$r ~ [\mathrm{Mpc} / h]$")
    axs[0].set_ylabel(r"$\rho_{\rm LOS} / \langle \rho_{\rm matter} \rangle$")
    axs[1].set_ylabel(r"$v_{\rm LOS} ~ [\mathrm{km/s}]$")
    axs[0].set_yscale("log")

    axs[0].legend(loc="upper right")
    axs[0].set_xlim(0, 200)

    fig.tight_layout(w_pad=0, h_pad=0)
    fig.savefig(f"../../plots/LOSS_los_{k}.png", dpi=500, bbox_inches="tight")

    fig.show()
/tmp/ipykernel_411260/1158227546.py:5: RuntimeWarning: More than 20 figures have been opened. Figures created through the pyplot interface (`matplotlib.pyplot.figure`) are retained until explicitly closed and may consume too much memory. (To control this warning, see the rcParam `figure.max_open_warning`). Consider using `matplotlib.pyplot.close()`.
  fig, axs = plt.subplots(2, 1, figsize=(7, 7), sharex=True)
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image

Test running a model

In [19]:
fpath_data = "/mnt/extraspace/rstiskalek/catalogs/PV_compilation.hdf5"
# fpath_data = "/mnt/extraspace/rstiskalek/catalogs/A2.h5"
# fpath_data = "/mnt/extraspace/rstiskalek/catalogs/PV_mock_CB2_17417_large.hdf5"

simname = "CF4"
catalogue = "LOSS"
loader = csiborgtools.flow.DataLoader(simname, [0], catalogue, fpath_data, paths, ksmooth=0, )

SN_hyperparams = {"e_mu_mean": 0.1, "e_mu_std": 0.05, 
                  "mag_cal_mean": -18.25, "mag_cal_std": 0.5,
                  "alpha_cal_mean": 0.148, "alpha_cal_std": 0.05,
                  "beta_cal_mean": 3.112, "beta_cal_std": 1.0,
                  }
calibration_hyperparams = {"Vext_std": 250,
                           "alpha_mean": 1.0, "alpha_std": 0.5,
                           "beta_mean": 1.0, "beta_std": 0.5,
                           "sigma_v_mean": 150., "sigma_v_std": 100.,
                           "sample_alpha": True, "sample_beta": True,
                           }
get_model_kwargs = {"zcmb_max": 0.05}
2024-06-27 13:05:36.632317:   reading the catalogue,
2024-06-27 13:05:36.639136:   reading the interpolated field,
2024-06-27 13:05:36.646839:   calculating the radial velocity.

Running HMC

In [20]:
model = csiborgtools.flow.get_model(loader, **get_model_kwargs)
model_kwargs = {"distmod_hyperparams": SN_hyperparams, "calibration_hyperparams": calibration_hyperparams,}
Selected 50/50 galaxies.
In [21]:
kernel = NUTS(model, init_strategy=init_to_median(num_samples=100))
mcmc = MCMC(kernel, num_warmup=500, num_samples=500)

rng_key = jax.random.PRNGKey(5)
mcmc.run(rng_key, extra_fields=("potential_energy",), **model_kwargs)
mcmc.print_summary()
samples = mcmc.get_samples()
warmup:   2%|▏         | 24/1000 [00:15<10:42,  1.52it/s, 1023 steps of size 1.33e-02. acc. prob=0.70]
---------------------------------------------------------------------------
KeyboardInterrupt                         Traceback (most recent call last)
Cell In[21], line 5
      2 mcmc = MCMC(kernel, num_warmup=500, num_samples=500)
      4 rng_key = jax.random.PRNGKey(5)
----> 5 mcmc.run(rng_key, extra_fields=("potential_energy",), **model_kwargs)
      6 mcmc.print_summary()
      7 samples = mcmc.get_samples()

File ~/csiborgtools/venv_csiborg/lib/python3.11/site-packages/numpyro/infer/mcmc.py:644, in MCMC.run(self, rng_key, extra_fields, init_params, *args, **kwargs)
    642 map_args = (rng_key, init_state, init_params)
    643 if self.num_chains == 1:
--> 644     states_flat, last_state = partial_map_fn(map_args)
    645     states = tree_map(lambda x: x[jnp.newaxis, ...], states_flat)
    646 else:

File ~/csiborgtools/venv_csiborg/lib/python3.11/site-packages/numpyro/infer/mcmc.py:450, in MCMC._single_chain_mcmc(self, init, args, kwargs, collect_fields)
    444 collection_size = self._collection_params["collection_size"]
    445 collection_size = (
    446     collection_size
    447     if collection_size is None
    448     else collection_size // self.thinning
    449 )
--> 450 collect_vals = fori_collect(
    451     lower_idx,
    452     upper_idx,
    453     sample_fn,
    454     init_val,
    455     transform=_collect_fn(collect_fields),
    456     progbar=self.progress_bar,
    457     return_last_val=True,
    458     thinning=self.thinning,
    459     collection_size=collection_size,
    460     progbar_desc=partial(_get_progbar_desc_str, lower_idx, phase),
    461     diagnostics_fn=diagnostics,
    462     num_chains=self.num_chains if self.chain_method == "parallel" else 1,
    463 )
    464 states, last_val = collect_vals
    465 # Get first argument of type `HMCState`

File ~/csiborgtools/venv_csiborg/lib/python3.11/site-packages/numpyro/util.py:367, in fori_collect(lower, upper, body_fun, init_val, transform, progbar, return_last_val, collection_size, thinning, **progbar_opts)
    365 with tqdm.trange(upper) as t:
    366     for i in t:
--> 367         vals = jit(_body_fn)(i, vals)
    368         t.set_description(progbar_desc(i), refresh=False)
    369         if diagnostics_fn:

File <string>:1, in <lambda>(_cls, step_size, inverse_mass_matrix, mass_matrix_sqrt, mass_matrix_sqrt_inv, ss_state, mm_state, window_idx, rng_key)

KeyboardInterrupt: 
In [25]:
from numpyro.infer import log_likelihood
In [26]:
ll_single = log_likelihood(model, samples, **model_kwargs)["ll"]
ll_mult = log_likelihood(model_mult, samples, **model_kwargs, )["ll"]
In [27]:
ll_single - ll_mult
Out[27]:
Array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
       0., 0., 0., 0., 0., 0., 0.], dtype=float32)
In [20]:

Out[20]:
Array([-374.78827, -376.5492 , -371.77686, -372.9841 , -378.55914,
       -378.39984, -378.2459 , -375.273  , -377.44177, -377.93024,
       -379.78754, -376.69867, -376.69543, -373.6802 , -378.27258,
       -375.40875, -375.0953 , -372.4082 , -378.23706, -373.86218,
       -378.33875, -376.94678, -373.83652, -378.32117, -378.96307,
       -376.3273 , -378.99994, -375.4494 , -377.64166, -375.86154,
       -378.59518, -380.15732, -377.50745, -380.40387, -376.8189 ,
       -376.1007 , -373.51187, -377.10147, -374.32153, -374.2683 ,
       -375.59872, -376.4356 , -377.2743 , -377.35114, -374.19208,
       -376.06555, -380.0948 , -374.54852, -377.23047, -382.89264,
       -380.85538, -378.4214 , -375.15735, -373.39212, -375.85846,
       -375.65417, -376.16678, -375.97055, -378.42426, -376.42603,
       -377.9259 , -372.40448, -373.42722, -374.55554, -378.3473 ,
       -373.24213, -374.04   , -374.16534, -374.32443, -379.45923,
       -375.31113, -378.57886, -375.84442, -377.4536 , -376.42334,
       -377.72723, -376.27448, -377.9539 , -373.5795 , -374.67526,
       -372.17963, -372.82324, -374.28815, -373.96506, -376.82507,
       -376.93213, -375.63318, -375.7738 , -375.90573, -378.0384 ,
       -378.0224 , -379.54617, -378.00513, -377.14618, -378.09073,
       -375.86597, -378.58353, -375.02972, -378.62332, -375.34515,
       -377.38895, -376.81897, -377.08514, -378.20892, -374.73334,
       -374.945  , -374.85724, -374.56958, -375.57413, -375.072  ,
       -377.19028, -377.54443, -374.5007 , -376.54013, -374.14465,
       -374.65546, -375.77112, -373.91183, -374.46637, -374.3336 ,
       -378.4422 , -375.58517, -376.24066, -374.48282, -376.95374,
       -372.74634, -372.97794, -374.2119 , -376.01407, -378.1242 ,
       -378.89832, -375.39142, -375.29816, -376.1898 , -374.10272,
       -375.10376, -376.2453 , -377.4701 , -378.1543 , -373.8468 ,
       -376.58026, -374.8551 , -375.1272 , -376.64966, -377.48123,
       -380.61816, -378.7544 , -374.92545, -374.71252, -372.59912,
       -373.55402, -373.39218, -374.92795, -373.6598 , -376.6132 ,
       -377.88617, -373.76184, -378.83252, -378.48187, -378.70923,
       -380.9616 , -381.7417 , -376.7549 , -379.59344, -380.48926,
       -374.94775, -376.39612, -374.6676 , -379.39023, -381.8791 ,
       -377.42413, -375.87958, -374.0121 , -375.43823, -372.45062,
       -372.70752, -373.5069 , -375.3844 , -375.36328, -373.78485,
       -376.49564, -374.79987, -375.86487, -374.06674, -377.0426 ,
       -377.5667 , -379.7243 , -379.37122, -376.22632, -375.70654,
       -377.56372, -377.34256, -373.73972, -377.02332, -375.53345,
       -378.89685, -377.6688 , -378.84888, -383.19537, -382.12585,
       -382.6466 , -376.49536, -375.93127, -377.6048 , -373.5756 ,
       -375.25043, -374.0218 , -374.23123, -377.78134, -375.96564,
       -378.48746, -376.1507 , -374.9716 , -373.93018, -374.73456,
       -376.74103, -376.92188, -375.25317, -374.2467 , -374.29163,
       -376.87674, -376.17133, -376.6051 , -376.20227, -378.027  ,
       -374.63226, -373.1444 , -378.2168 , -374.78253, -377.88095,
       -376.7299 , -374.00055, -374.18256, -374.50098, -377.90918,
       -377.5914 , -376.723  , -375.05054, -374.03278, -372.99585,
       -377.1592 , -378.5726 , -382.3648 , -381.95084, -379.8012 ,
       -377.27887, -374.89774, -374.56357, -375.84525, -377.89868,
       -382.2562 , -375.49042, -379.07535, -374.9853 , -376.29773,
       -374.1893 , -375.35574, -380.31897, -376.27448, -376.47168,
       -374.6464 , -378.147  , -375.70886, -376.68924, -375.76617,
       -376.2506 , -378.01782, -382.2915 , -374.9214 , -376.70178,
       -376.90546, -377.411  , -375.27643, -373.80533, -372.5861 ,
       -373.1949 , -376.22168, -377.56824, -378.8287 , -375.53308,
       -374.56818, -382.15012, -374.25894, -381.0781 , -374.3027 ,
       -380.56134, -376.60718, -376.42545, -375.17792, -376.3213 ,
       -374.37567, -373.76025, -374.4405 , -375.02045, -375.70337,
       -374.74585, -375.88458, -374.74628, -374.50763, -375.70026,
       -377.86438, -378.53693, -378.09235, -381.33105, -376.464  ,
       -378.4175 , -378.98584, -375.14954, -378.98206, -376.01047,
       -376.45996, -377.2332 , -374.2134 , -375.89975, -375.65414,
       -374.02612, -372.55133, -375.69962, -374.4325 , -376.36453,
       -373.98578, -375.55103, -377.81378, -377.8647 , -377.20526,
       -376.3604 , -381.58832, -376.55713, -376.03836, -376.24966,
       -373.95   , -379.94614, -377.0968 , -377.84164, -376.44522,
       -377.85254, -378.3142 , -375.67706, -380.1999 , -376.95044,
       -373.88947, -374.81598, -376.07452, -377.36395, -379.3869 ,
       -375.50687, -377.68784, -376.3739 , -375.44025, -375.18735,
       -376.06638, -376.60834, -376.28995, -377.0169 , -380.38916,
       -379.51105, -382.0304 , -380.0194 , -378.8652 , -375.53314,
       -375.5034 , -374.6402 , -376.51093, -377.72595, -380.00995,
       -379.5835 , -377.2257 , -379.3488 , -379.24078, -377.37265,
       -381.14996, -376.83673, -376.86017, -376.98822, -376.59003,
       -377.82474, -378.2244 , -376.83997, -375.96432, -374.3552 ,
       -372.27533, -380.0143 , -374.36603, -373.62616, -373.85562,
       -373.1689 , -374.1674 , -373.0071 , -373.59494, -376.51263,
       -373.30582, -374.53265, -374.3034 , -379.04468, -374.61243,
       -376.40887, -376.2823 , -381.99615, -379.41455, -377.62433,
       -376.36798, -378.97614, -375.00592, -377.91043, -377.10544,
       -375.4801 , -376.89624, -374.7605 , -375.33405, -374.52933,
       -375.02234, -375.1839 , -376.97693, -376.73566, -376.3647 ,
       -377.85864, -376.54773, -377.09457, -379.05438, -378.02417,
       -375.28592, -375.15805, -374.34442, -380.4338 , -376.1878 ,
       -373.36633, -376.19815, -376.89926, -376.19022, -377.86075,
       -377.2689 , -377.83676, -375.71466, -377.34888, -375.27258,
       -376.75476, -377.30792, -377.51782, -379.70868, -376.17413,
       -375.9779 , -377.96228, -374.87674, -373.77216, -375.6394 ,
       -375.8968 , -373.49118, -373.32666, -374.5882 , -375.28967,
       -375.78192, -377.6034 , -377.48282, -377.46722, -376.3749 ,
       -376.20535, -376.85107, -376.78308, -376.67972, -376.1621 ,
       -378.71033, -374.8225 , -377.3939 , -373.82043, -375.69586,
       -377.2488 , -374.63022, -374.32742, -374.76212, -379.32126,
       -379.09344, -375.42993, -378.1632 , -375.69092, -375.98285,
       -377.10352, -376.98743, -374.9332 , -375.23105, -374.81265,
       -374.3098 , -372.58917, -373.61246, -376.50525, -376.5714 ,
       -374.68048, -375.     , -375.02234, -377.66193, -379.3037 ,
       -378.351  , -375.5417 , -378.686  , -376.46448, -377.3991 ,
       -376.28412, -379.40198, -374.2234 , -372.92682, -376.41956],      dtype=float32)
In [ ]:

In [ ]:

In [10]:
mcmc.get_extra_fields()["potential_energy"]
Out[10]:
Array([391.9341 , 392.08212, 391.02206, 389.15616, 398.34534, 398.74045,
       394.00363, 394.9679 , 392.753  , 392.53403, 390.58237, 389.0428 ,
       390.0239 , 393.4534 , 392.26123, 390.88834, 389.4346 , 388.27728,
       388.42407, 390.7624 , 393.82834, 396.3672 , 393.64532, 392.78622,
       394.62543, 392.79187, 394.0692 , 394.19113, 393.68393, 393.9558 ,
       394.51782, 394.80338, 394.38104, 392.66638, 392.84058, 393.24478,
       394.0837 , 394.68433, 390.162  , 392.5648 , 390.56827, 394.7597 ,
       394.33154, 393.9468 , 391.83417, 394.58472, 394.23224, 391.1751 ,
       391.31418, 399.5129 , 394.8937 , 393.32156, 389.23395, 389.13815,
       389.2338 , 390.08365, 392.15442, 391.80756, 396.48865, 392.57013,
       392.00992, 392.81107, 391.49927, 391.80618, 395.6378 , 393.09927,
       392.07812, 389.32758, 391.35922, 393.24258, 393.46533, 391.42642,
       390.91577, 390.9773 , 389.37076, 392.87485, 393.59995, 393.8794 ,
       394.30118, 392.2907 , 390.15256, 390.99207, 391.33752, 390.59207,
       394.78662, 393.71133, 395.89343, 397.57526, 394.3614 , 395.2866 ,
       400.6802 , 393.19537, 392.35477, 395.25443, 391.1807 , 392.4784 ,
       394.2002 , 390.61996, 393.63477, 394.57047, 396.10788, 393.12854,
       394.32095, 396.66772, 394.04712, 391.67096, 391.37128, 389.3575 ,
       389.4813 , 392.70554, 391.0798 , 391.58707, 391.3387 , 392.6452 ,
       391.1168 , 391.28464, 389.49527, 391.098  , 390.07748, 391.25574,
       392.2501 , 392.58688, 393.03354, 391.07687, 392.5799 , 390.90054,
       389.83463, 389.98987, 392.46228, 390.82193, 393.27582, 393.54163,
       392.20618, 388.82373, 390.24686, 391.1798 , 390.0974 , 391.47324,
       396.02036, 393.31866, 394.73904, 393.04593, 396.20193, 392.5486 ,
       392.00214, 396.90887, 394.09827, 391.98636, 391.64633, 392.54788,
       390.28278, 391.5285 , 391.0113 , 390.20108, 391.2806 , 391.9383 ,
       394.31247, 392.9718 , 395.74432, 395.6111 , 396.32532, 396.84842,
       394.43015, 396.00247, 402.50272, 392.72025, 391.83334, 392.79337,
       396.3226 , 401.59814, 397.6963 , 395.19052, 394.43784, 392.80142,
       390.1531 , 389.4234 , 389.03558, 389.0597 , 392.2272 , 390.56104,
       394.64798, 391.2173 , 392.151  , 388.85483, 393.61578, 395.56732,
       396.60648, 393.86707, 392.8924 , 392.639  , 393.36166, 394.42212,
       392.52884, 393.4237 , 394.6955 , 392.98947, 392.58792, 394.54013,
       395.2757 , 394.46317, 396.52585, 393.2268 , 391.0806 , 390.68488,
       390.83286, 393.68234, 391.00925, 389.52612, 392.32867, 391.63733,
       392.44458, 397.25595, 392.09634, 394.46027, 392.6832 , 393.11966,
       392.70135, 392.94568, 390.5427 , 391.2181 , 390.14978, 393.05313,
       392.1329 , 395.2773 , 390.55872, 389.75958, 392.8294 , 390.34613,
       390.57422, 393.61807, 393.4588 , 392.6946 , 393.0386 , 390.5007 ,
       391.86188, 392.18567, 393.70074, 391.2875 , 389.60342, 390.3574 ,
       392.36462, 396.8469 , 395.1043 , 393.78467, 392.90707, 394.79532,
       392.64337, 392.04562, 391.07858, 393.60815, 399.3589 , 395.53397,
       392.84903, 392.6835 , 391.1862 , 391.29715, 393.18088, 396.14114,
       396.67612, 394.8662 , 395.70645, 393.47675, 396.14685, 395.2865 ,
       391.64557, 392.49634, 393.31058, 395.3479 , 390.1821 , 392.41928,
       391.62433, 394.0529 , 392.24847, 391.0419 , 391.29785, 392.43967,
       391.05963, 392.9988 , 390.8053 , 391.57315, 392.09854, 396.18353,
       393.75366, 393.8414 , 391.85266, 396.80035, 394.54794, 399.54883,
       393.41476, 390.52176, 392.8705 , 390.99615, 391.3205 , 392.70792,
       392.3243 , 389.38223, 392.36218, 392.93887, 393.47202, 391.486  ,
       390.32257, 390.8464 , 389.24442, 393.06158, 390.1328 , 394.20773,
       392.92813, 391.93857, 393.84244, 393.34424, 392.4594 , 392.7215 ,
       389.22064, 390.21176, 390.24298, 390.88086, 388.82172, 390.49158,
       390.16858, 392.40662, 393.3886 , 394.6822 , 393.8078 , 396.0063 ,
       393.62537, 392.98868, 395.08075, 394.6271 , 389.055  , 390.7642 ,
       390.36136, 394.7984 , 389.74716, 392.25842, 392.42697, 393.6167 ,
       390.31824, 391.90237, 399.44983, 393.19128, 393.52548, 392.53802,
       390.68805, 391.63797, 396.24985, 394.57785, 392.13458, 390.36664,
       390.1804 , 390.89145, 395.8922 , 396.92868, 390.8619 , 391.1419 ,
       392.4267 , 393.0737 , 397.35675, 398.8355 , 396.29037, 391.05008,
       389.4605 , 391.93326, 391.39075, 390.61874, 394.65973, 394.07922,
       394.02365, 397.24677, 397.92264, 392.71225, 393.26868, 392.57773,
       389.75055, 391.72717, 392.82794, 390.9369 , 392.5645 , 391.68805,
       393.5547 , 392.33005, 389.79407, 396.49945, 393.72034, 393.51117,
       392.1612 , 390.8545 , 390.19092, 389.54028, 390.081  , 393.38885,
       389.43814, 391.40814, 392.77875, 390.07477, 389.34094, 390.62073,
       391.42688, 396.5186 , 397.25574, 388.39703, 391.31366, 398.72787,
       391.05505, 392.2018 , 391.27768, 393.10678, 395.05096, 393.76315,
       392.66342, 392.51956, 390.97275, 390.50626, 393.93262, 391.706  ,
       390.8292 , 394.87894, 393.27704, 390.10495, 389.4763 , 388.9353 ,
       388.51953, 388.58496, 389.6656 , 394.77295, 391.35245, 391.1977 ,
       391.07584, 391.1299 , 390.0027 , 392.0007 , 392.77393, 392.88647,
       388.6409 , 392.9662 , 390.44272, 391.4916 , 389.46524, 392.48782,
       391.1928 , 391.6972 , 392.49786, 397.5695 , 391.7954 , 391.18668,
       394.03104, 391.3363 , 393.5302 , 391.74683, 389.46597, 389.0724 ,
       395.04776, 395.0067 , 394.68988, 392.55582, 391.55222, 391.8968 ,
       392.51648, 389.999  , 390.82315, 391.85864, 397.0075 , 393.12473,
       394.1504 , 388.86996, 390.43127, 393.28723, 394.8042 , 394.32358,
       394.70056, 394.62448, 393.04788, 391.87747, 392.00067, 390.53983,
       390.52933, 390.52118, 391.3734 , 389.67596, 391.80765, 391.9735 ,
       388.86786, 389.31982, 389.36093, 390.76718, 393.16095, 392.73416,
       392.00232, 391.61856, 394.8812 , 398.4053 , 398.8124 , 393.909  ,
       399.0349 , 393.04034, 390.39853, 390.08875, 389.0157 , 388.95517,
       392.23053, 390.5207 ], dtype=float32)
In [ ]:

In [11]:
samples = mcmc.get_samples()
csiborgtools.numpyro_gof(model, mcmc)
Out[11]:
(774.734619140625, 755.6143798828125)
In [117]:
data, names, __ = read_samples("LOSS", "Carrick2015", 0, return_MCsamples=False)
Reading LOSS fitted to Carrick2015 with ksmooth = 0.
BIC  = 773.225037 +- 0.000000
AIC  = 754.104797 +- 0.000000
logZ = -356.240234 +- 0.000000
chi2 = 1.207006 +- 0.228673
In [118]:
key = "beta"

plt.figure()
plt.hist(data[:, names.index(key)], bins="auto", density=1, histtype="step")
plt.hist(samples[key], bins="auto", density=1, histtype="step")

plt.show()
No description has been provided for this image
In [ ]:

In [119]:
samples = mcmc.get_samples()
In [120]:
samples["ll_values"]
Out[120]:
Array([-369.51086, -369.97043, -370.17526, ..., -372.54755, -376.03503,
       -374.88458], dtype=float32)
In [ ]:

In [121]:
nparam = 0
for val in samples.values():
    if val.ndim == 1:
        nparam += 1
    elif val.ndim == 2:
        nparam += val.shape[-1]
    else:
        raise ValueError("Invalid dimensionality of samples to count the number of parameters.")
    

nparam
Out[121]:
11
In [ ]:

In [122]:
Vmag = np.sqrt(samples["Vext"][:, 0]**2 + samples["Vext"][:, 1]**2 + samples["Vext"][:, 2]**2)

V = np.vstack([samples["Vext"][:, 0], samples["Vext"][:, 1], samples["Vext"][:, 2]]).T
V = csiborgtools.cartesian_to_radec(V)

l, b = csiborgtools.radec_to_galactic(V[:, 1], V[:, 2])

print(f"|V|  = {np.mean(Vmag)} +- {np.std(Vmag)}")
print(f"l    = {np.mean(l)} +- {np.std(l)}")
print(f"b    = {np.mean(b)} +- {np.std(b)}")
if "beta" in samples:
    print(f"beta = {np.mean(samples['beta'])} +- {np.std(samples['beta'])}")
|V|  = 197.8179931640625 +- 99.38513946533203
l    = 213.2463176948003 +- 116.2995226818662
b    = -5.31730133782022 +- 27.004291397137365
beta = 0.4450029134750366 +- 0.10768470168113708
In [123]:
data = [l, b, Vmag]
labels = [r"$l$", r"$b$", r"$|\bf{V}_{\rm ext}|$"]
if "alpha" in samples:
    data.append(samples["alpha"])
    labels.append(r"$\alpha$")

if "beta" in samples:
    data.append(samples["beta"])
    labels.append(r"$\beta$")

if "h" in samples:
    data.append(samples["h"])
    labels.append(r"$h$")

if "sigma_v" in samples:
    data.append(samples["sigma_v"])
    labels.append(r"$\sigma_v$")

data = np.vstack(data).T
fig = corner.corner(data, labels=labels, show_titles=True, title_fmt=".3f", title_kwargs={"fontsize": 12}, smooth=1)
fig.savefig(f"../../plots/mock_{simname}_{catalogue}.png", dpi=500, bbox_inches="tight")
No description has been provided for this image
In [125]:
read_samples("Pantheon+", "csiborg2_main", 0, return_MCsamples=True)
Reading Pantheon+ fitted to csiborg2_main with ksmooth = 0.
BIC  = 10055.604150 +- 27.237237
AIC  = 10010.412744 +- 27.237237
logZ = -5000.136133 +- 23.062465
chi2 = 0.985968 +- 0.117400
Removed no burn in
Out[125]:
<getdist.mcsamples.MCSamples at 0x7f34904c5b90>

Vizualize the results

In [ ]:
data, names, gof = read_samples("Pantheon+_groups", "Carrick2015", 0)

fig = corner.corner(data, labels=names_to_latex(names, True), show_titles=True,
                    title_fmt=".3f", title_kwargs={"fontsize": 12}, smooth=1)

$\texttt{LOSS}$ comparison

In [126]:
LOSS_Carrick_0 = read_samples("LOSS", "Carrick2015", 0, return_MCsamples=True)
# LOSS_Carrick_1 = read_samples("LOSS", "Carrick2015", 1, return_MCsamples=True)

# LOSS_CB1_0 = read_samples("LOSS", "csiborg1", 0, return_MCsamples=True)
# LOSS_CB1_1 = read_samples("LOSS", "csiborg1", 1, return_MCsamples=True)

# LOSS_CB2_0 = read_samples("LOSS", "csiborg2_main", 0, return_MCsamples=True)
# LOSS_CB2_1 = read_samples("LOSS", "csiborg2_main", 1, return_MCsamples=True)
Reading LOSS fitted to Carrick2015 with ksmooth = 0.
BIC  = 773.225037 +- 0.000000
AIC  = 754.104797 +- 0.000000
logZ = -356.240234 +- 0.000000
chi2 = 1.207006 +- 0.228673
Removed no burn in
In [ ]:
X = [
     LOSS_Carrick_0,
     # LOSS_Carrick_1,
     # LOSS_CB1_0,
     LOSS_CB1_1,
     LOSS_CB2_0,
     LOSS_CB2_1,
     ]

# params = ["l", "b", "Vmag", "beta"]
params = None

g = plots.get_subplot_plotter()
g.settings.figure_legend_frame = False
g.settings.alpha_filled_add = 0.75
# g.settings.title_limit_fontsize = 14
g.triangle_plot(X, params=params, filled=True, legend_loc='upper right', )
g.export(f"../plots/LOSS_comparison.png", dpi=500,)

$\texttt{Foundation}$ comparison

In [ ]:
FOUNDATION_Carrick_0 = read_samples("Foundation", "Carrick2015", 0, return_MCsamples=True)
FOUNDATION_Carrick_1 = read_samples("Foundation", "Carrick2015", 1, return_MCsamples=True)

FOUNDATION_CB1_0 = read_samples("Foundation", "csiborg1", 0, return_MCsamples=True)
FOUNDATION_CB1_1 = read_samples("Foundation", "csiborg1", 1, return_MCsamples=True)

FOUNDATION_CB2_0 = read_samples("Foundation", "csiborg2_main", 0, return_MCsamples=True)
FOUNDATION_CB2_1 = read_samples("Foundation", "csiborg2_main", 1, return_MCsamples=True)
In [ ]:
X = [
    FOUNDATION_Carrick_0,
    # FOUNDATION_Carrick_1,
    # FOUNDATION_CB1_0,
    FOUNDATION_CB1_1,
    FOUNDATION_CB2_0,
    FOUNDATION_CB2_1,
    ]

g = plots.get_subplot_plotter()
g.settings.figure_legend_frame = False
g.settings.alpha_filled_add = 0.75
# g.settings.title_limit_fontsize = 14
g.triangle_plot(X, filled=True, legend_loc='upper right')
g.export(f"../plots/FOUNDATION_comparison.png", dpi=500,)

$\texttt{Pantheon+}$ comparison

In [ ]:
PANTHEONP_Carrick_0 = read_samples("Pantheon+", "Carrick2015", 0, return_MCsamples=True)
PANTHEONP_Carrick_1 = read_samples("Pantheon+", "Carrick2015", 1, return_MCsamples=True)

# PANTHEONP_CB1_0 = read_samples("Pantheon+", "csiborg1", 0, return_MCsamples=True)
# PANTHEONP_CB1_1 = read_samples("Pantheon+", "csiborg1", 1, return_MCsamples=True)

PANTHEONP_CB2_0 = read_samples("Pantheon+", "csiborg2_main", 0, return_MCsamples=True)
PANTHEONP_CB2_1 = read_samples("Pantheon+", "csiborg2_main", 1, return_MCsamples=True)
In [ ]:
X = [
    PANTHEONP_Carrick_0,
    # PANTHEONP_Carrick_1,
    # PANTHEONP_CB1_0,
    # PANTHEONP_CB1_1,
    PANTHEONP_CB2_0,
    PANTHEONP_CB2_1,
    ]

g = plots.get_subplot_plotter()
g.settings.figure_legend_frame = False
g.settings.alpha_filled_add = 0.75
# g.settings.title_limit_fontsize = 14
g.triangle_plot(X, filled=True, legend_loc='upper right')
# g.export(f"../plots/PANTHEONP_comparison.png", dpi=500,)

$\texttt{Pantheon+}$ groups

In [ ]:
LG = -1

PANTHEONP_Carrick = read_samples("Pantheon+", "Carrick2015", 0, return_MCsamples=True, subtract_LG_velocity=LG, )
PANTHEONP_Carrick_Groups = read_samples("Pantheon+_groups", "Carrick2015", 0, return_MCsamples=True, subtract_LG_velocity=LG)
PANTHEONP_Carrick_Groups_zSN = read_samples("Pantheon+_groups_zSN", "Carrick2015", 0, return_MCsamples=True, subtract_LG_velocity=LG)
PANTHEONP_Carrick_zSN = read_samples("Pantheon+_zSN", "Carrick2015", 0, return_MCsamples=True, subtract_LG_velocity=LG)

# ksmooth = 1
# PANTHEONP_CB2 = read_samples("Pantheon+", "csiborg2_main", ksmooth, return_MCsamples=True, subtract_LG_velocity=LG)
# PANTHEONP_CB2_Groups = read_samples("Pantheon+_groups", "csiborg2_main", ksmooth, return_MCsamples=True, subtract_LG_velocity=LG)
# PANTHEONP_CB2_Groups_zSN = read_samples("Pantheon+_groups_zSN", "csiborg2_main", ksmooth, return_MCsamples=True, subtract_LG_velocity=LG)
In [ ]:
params = ["Vmag", "l", "b"]
CMB = MCSamples(samples=multivariate_normal([627, 276, 30], [22, 3, 3]).rvs(size=20000),
                names=params, labels=names_to_latex(params, True), label="CMB")


X = [
    PANTHEONP_Carrick,
    # PANTHEONP_Carrick_Groups,
    # PANTHEONP_Carrick_Groups_zSN,
    PANTHEONP_Carrick_zSN,
    # PANTHEONP_CB2,
    # PANTHEONP_CB2_Groups,
    # PANTHEONP_CB2_Groups_zSN,
    # CMB,
    ]

g = plots.get_subplot_plotter()
g.settings.figure_legend_frame = False
g.settings.alpha_filled_add = 0.75
# g.settings.title_limit_fontsize = 14
g.triangle_plot(X, filled=True, legend_loc='upper right')
g.export(f"../../plots/PANTHEON_GROUPS_Carrick_comparison_LG.png", dpi=500,)

$\texttt{2MTF}$ comparison

In [24]:
TWOMTF_Carrick_0 = read_samples("2MTF", "Carrick2015", 0, return_MCsamples=True)
TWOMTF_Carrick_1 = read_samples("2MTF", "Carrick2015", 1, return_MCsamples=True)

TWOMTF_CB1_0 = read_samples("2MTF", "csiborg1", 0, return_MCsamples=True)
TWOMTF_CB1_1 = read_samples("2MTF", "csiborg1", 1, return_MCsamples=True)

TWOMTF_CB2_0 = read_samples("2MTF", "csiborg2_main", 0, return_MCsamples=True)
TWOMTF_CB2_1 = read_samples("2MTF", "csiborg2_main", 1, return_MCsamples=True)
Reading 2MTF fitted to Carrick2015 with ksmooth = 0.
BIC  = 19517.031250 +- 0.000000
AIC  = 19470.867188 +- 0.000000
logZ = -9731.227539 +- 0.000000
chi2 = 0.000000 +- 0.000000
Removed no burn in

Reading 2MTF fitted to Carrick2015 with ksmooth = 1.
BIC  = 19632.685547 +- 0.000000
AIC  = 19586.521484 +- 0.000000
logZ = -9788.892578 +- 0.000000
chi2 = 0.000000 +- 0.000000
Removed no burn in

Reading 2MTF fitted to csiborg1 with ksmooth = 0.
BIC  = 19922.607596 +- 33.988735
AIC  = 19876.443533 +- 33.988735
logZ = -9934.180538 +- 17.010780
chi2 = 0.000000 +- 0.000000
Removed no burn in

Reading 2MTF fitted to csiborg1 with ksmooth = 1.
BIC  = 19840.144473 +- 31.749545
AIC  = 19793.980411 +- 31.749545
logZ = -9891.951984 +- 16.078607
chi2 = 0.000000 +- 0.000000
Removed no burn in

Reading 2MTF fitted to csiborg2_main with ksmooth = 0.
BIC  = 19248.799609 +- 38.583873
AIC  = 19202.635547 +- 38.583873
logZ = -9598.394336 +- 19.251815
chi2 = 0.000000 +- 0.000000
Removed no burn in

Reading 2MTF fitted to csiborg2_main with ksmooth = 1.
BIC  = 19167.596582 +- 20.190445
AIC  = 19121.432520 +- 20.190445
logZ = -9555.558252 +- 9.820362
chi2 = 0.000000 +- 0.000000
Removed no burn in
In [ ]:
X = [
    TWOMTF_Carrick_0,
    # TWOMTF_Carrick_1,
    # TWOMTF_CB1_0,
    TWOMTF_CB1_1,
    TWOMTF_CB2_0,
    TWOMTF_CB2_1,
    ]

g = plots.get_subplot_plotter()
g.settings.figure_legend_frame = False
g.settings.alpha_filled_add = 0.75
# g.settings.title_limit_fontsize = 14
g.triangle_plot(X, filled=True, legend_loc='upper right')
g.export(f"../plots/2MTF_comparison.png", dpi=500,)

$\texttt{SFI++ galaxies}$ comparison

In [ ]:
SFIGAL_Carrick_0 = read_samples("SFI_gals", "Carrick2015", 0, return_MCsamples=True)
SFIGAL_Carrick_1 = read_samples("SFI_gals", "Carrick2015", 1, return_MCsamples=True)

# SFIGAL_CB1_0 = read_samples("SFI_gals", "csiborg1", 0, return_MCsamples=True)
# SFIGAL_CB1_1 = read_samples("SFI_gals", "csiborg1", 1, return_MCsamples=True)

SFIGAL_CB2_0 = read_samples("SFI_gals", "csiborg2_main", 0, return_MCsamples=True)
SFIGAL_CB2_1 = read_samples("SFI_gals", "csiborg2_main", 1, return_MCsamples=True)
In [ ]:
X = [
    SFIGAL_Carrick_0,
    # SFIGAL_Carrick_1,
    # SFIGAL_CB1_0,
    # SFIGAL_CB1_1,
    # SFIGAL_CB2_0,
    SFIGAL_CB2_1,
    ]

g = plots.get_subplot_plotter()
g.settings.figure_legend_frame = False
g.settings.alpha_filled_add = 0.75
# g.settings.title_limit_fontsize = 14
g.triangle_plot(X, filled=True, legend_loc='upper right')
g.export(f"../plots/SFI_gals_comparison.png", dpi=500,)

$\texttt{SFI++ groups}$ comparison

In [ ]:
SFIGROUP_Carrick_0 = read_samples("SFI_groups", "Carrick2015", 0, return_MCsamples=True)
SFIGROUP_Carrick_1 = read_samples("SFI_groups", "Carrick2015", 1, return_MCsamples=True)

SFIGROUP_CB2_0 = read_samples("SFI_groups", "csiborg2_main", 0, return_MCsamples=True)
SFIGROUP_CB2_1 = read_samples("SFI_groups", "csiborg2_main", 1, return_MCsamples=True)
In [ ]:
X = [
    SFIGROUP_Carrick_0,
    SFIGAL_Carrick_0,
    # SFIGROUP_Carrick_1,
    # SFIGROUP_CB2_0,
    # SFIGROUP_CB2_1,
    ]

g = plots.get_subplot_plotter()
g.settings.figure_legend_frame = False
g.settings.alpha_filled_add = 0.75
# g.settings.title_limit_fontsize = 14
g.triangle_plot(X, filled=True, legend_loc='upper right')
g.export(f"../plots/SFI_gals_vs_groups_comparison.png", dpi=500,)

SN to TF comparison

In [ ]:
LG = 0

# PANTHEONP_Carrick = read_samples("Pantheon+", "Carrick2015", 0, return_MCsamples=True, subtract_LG_velocity=LG, )
# PANTHEONP_Groups_Carrick = read_samples("Pantheon+_groups", "Carrick2015", 0, return_MCsamples=True, subtract_LG_velocity=LG, )
# TWOMTF_Carrick = read_samples("2MTF", "Carrick2015", 0, return_MCsamples=True, subtract_LG_velocity=LG)
# SFIGAL_Carrick = read_samples("SFI_gals", "Carrick2015", 0, return_MCsamples=True, subtract_LG_velocity=LG)

k = 1
PANTHEONP_CB2 = read_samples("Pantheon+", "csiborg2_main", k, return_MCsamples=True, subtract_LG_velocity=LG, )
PANTHEONP_Groups_CB2 = read_samples("Pantheon+_groups", "csiborg2_main", k, return_MCsamples=True, subtract_LG_velocity=LG, )
TWOMTF_CB2 = read_samples("2MTF", "csiborg2_main", k, return_MCsamples=True, subtract_LG_velocity=LG)
SFIGAL_CB2 = read_samples("SFI_gals", "csiborg2_main", k, return_MCsamples=True, subtract_LG_velocity=LG)
In [ ]:
params = ["Vmag", "l", "b"]
CMB = MCSamples(samples=multivariate_normal([627, 276, 30], [22, 3, 3]).rvs(size=20000),
                names=params, labels=names_to_latex(params, True), label="CMB")


X = [
    # PANTHEONP_Carrick,
    # PANTHEONP_Groups_Carrick,
    # TWOMTF_Carrick,
    # SFIGAL_Carrick,
    PANTHEONP_CB2,
    PANTHEONP_Groups_CB2,
    TWOMTF_CB2,
    SFIGAL_CB2,
    CMB,
    ]

g = plots.get_subplot_plotter()
g.settings.figure_legend_frame = False
g.settings.alpha_filled_add = 0.75
# g.settings.title_limit_fontsize = 14
g.triangle_plot(X, filled=True, legend_loc='upper right')
# g.export(f"../../plots/SN_TF_CB2_consistency.png", dpi=500,)

Mock $\texttt{CB2}$ comparison

In [ ]:
SMALLMOCK_CB2_0 = read_samples("CB2_small", "csiborg2_main", 0, return_MCsamples=True)
SMALLMOCK_CB2_1 = read_samples("CB2_small", "csiborg2_main", 1, return_MCsamples=True)

LARGEMOCK_CB2_0 = read_samples("CB2_large", "csiborg2_main", 0, return_MCsamples=True)
LARGEMOCK_CB2_1 = read_samples("CB2_large", "csiborg2_main", 1, return_MCsamples=True)
In [ ]:
X = [
    # SMALLMOCK_CB2_0,
    # SMALLMOCK_CB2_1,
    LARGEMOCK_CB2_0,
    LARGEMOCK_CB2_1,
    ]

g = plots.get_subplot_plotter()
g.settings.figure_legend_frame = False
g.settings.alpha_filled_add = 0.75
# g.settings.title_limit_fontsize = 14
g.triangle_plot(X, filled=True, legend_loc='upper right')
g.export(f"../plots/CB2_mocks_large.png", dpi=500,)

External flow consistency

Carrick2015

In [ ]:
X = [
    # LOSS_Carrick_0,
    # FOUNDATION_Carrick_0,
    PANTHEONP_Carrick_0,
    TWOMTF_Carrick_0,
    SFIGAL_Carrick_0,
    ]

params = ["Vmag", "l", "b", "beta"]
g = plots.get_subplot_plotter()
g.settings.figure_legend_frame = False
g.settings.alpha_filled_add = 0.75
# g.settings.title_limit_fontsize = 14
g.triangle_plot(X, params=params, filled=True, legend_loc='upper right',)
g.export(f"../plots/Carrick2015_external_flow.png", dpi=500,)

CSiBORG1

In [ ]:
X = [
    # LOSS_CB1_1,
    # FOUNDATION_CB1_1,
    PANTHEONP_CB1_1,
    TWOMTF_CB1_1,
    # SFIGAL_CB1_1,
    ]

params = ["Vmag", "l", "b", "beta"]
g = plots.get_subplot_plotter()
g.settings.figure_legend_frame = False
g.settings.alpha_filled_add = 0.75
# g.settings.title_limit_fontsize = 14
g.triangle_plot(X, params=params, filled=True, legend_loc='upper right',)
g.export(f"../plots/CB1_external_flow.png", dpi=500,)

CSiBORG2

In [ ]:
X = [
    # LOSS_CB2_1,
    # FOUNDATION_CB2_1,
    PANTHEONP_CB2_1,
    TWOMTF_CB2_1,
    SFIGAL_CB2_1,
    ]

params = ["Vmag", "l", "b", "beta"]
g = plots.get_subplot_plotter()
g.settings.figure_legend_frame = False
g.settings.alpha_filled_add = 0.75
# g.settings.title_limit_fontsize = 14
g.triangle_plot(X, params=params, filled=True, legend_loc='upper right',)
g.export(f"../plots/CB2_external_flow.png", dpi=500,)
In [ ]:
k = 1
LG = 0

# Carrick
# LOSS_Carrick_LG = read_samples("LOSS", "Carrick2015", k, return_MCsamples=True, subtract_LG_velocity=LG)
# FOUNDATION_Carrick_LG = read_samples("Foundation", "Carrick2015", k, return_MCsamples=True, subtract_LG_velocity=LG)
# PANTHEON_Carrick_LG = read_samples("Pantheon+", "Carrick2015", k, return_MCsamples=True, subtract_LG_velocity=LG)
# TWOMTF_Carrick_LG = read_samples("2MTF", "Carrick2015", k, return_MCsamples=True, subtract_LG_velocity=LG)
SFIGAL_Carrick_LG = read_samples("SFI_gals", "Carrick2015", k, return_MCsamples=True, subtract_LG_velocity=LG)
SFIGROUPS_Carrick_LG = read_samples("SFI_groups", "Carrick2015", k, return_MCsamples=True, subtract_LG_velocity=LG)


# # CSiBORG2
# LOSS_CB2_LG = read_samples("LOSS", "csiborg2_main", k, return_MCsamples=True,subtract_LG_velocity=LG)
# FOUNDATION_CB2_LG = read_samples("Foundation", "csiborg2_main", k, return_MCsamples=True, subtract_LG_velocity=LG)
# PANTHEON_CB2_LG = read_samples("Pantheon+", "csiborg2_main", k, return_MCsamples=True, subtract_LG_velocity=LG)
# TWOMTF_CB2_LG = read_samples("2MTF", "csiborg2_main", k, return_MCsamples=True, subtract_LG_velocity=LG)
SFIGAL_CB2_LG = read_samples("SFI_gals", "csiborg2_main", k, return_MCsamples=True, subtract_LG_velocity=LG)
SFIGROUP_CB2_LG = read_samples("SFI_groups", "csiborg2_main", k, return_MCsamples=True, subtract_LG_velocity=LG)

# # CSiBORG1
# LOSS_CB1_LG = read_samples("LOSS", "csiborg1", k, return_MCsamples=True, subtract_LG_velocity=LG)
# FOUNDATION_CB1_LG = read_samples("Foundation", "csiborg1", k, return_MCsamples=True, subtract_LG_velocity=LG)
# PANTHEON_CB1_LG = read_samples("Pantheon+", "csiborg1", k, return_MCsamples=True, subtract_LG_velocity=LG)
# TWOMTF_CB1_LG = read_samples("2MTF", "csiborg1", k, return_MCsamples=True, subtract_LG_velocity=LG)
# SFIGAL_CB1_LG = read_samples("SFI_gals", "csiborg1", k, return_MCsamples=True, subtract_LG_velocity=LG)
In [ ]:
params = ["Vmag", "l", "b"]
CMB = MCSamples(samples=multivariate_normal([627, 276, 30], [22, 3, 3]).rvs(size=20000),
                names=params, labels=names_to_latex(params, True), label="CMB")

X = [
    # LOSS_Carrick_LG,
    # FOUNDATION_Carrick_LG,
    # PANTHEON_Carrick_LG,
    # TWOMTF_Carrick_LG,
    # SFIGAL_Carrick_LG,
    # SFIGROUPS_Carrick_LG,
    # LOSS_CB1_LG,
    # FOUNDATION_CB1_LG,
    # PANTHEON_CB1_LG,
    # TWOMTF_CB1_LG,
    # SFIGAL_CB1_LG,
    # LOSS_CB2_LG,
    # FOUNDATION_CB2_LG,
    # PANTHEON_CB2_LG,
    # TWOMTF_CB2_LG,
    SFIGAL_CB2_LG,
    SFIGROUP_CB2_LG,
    CMB,
    ]

g = plots.get_subplot_plotter()
g.settings.figure_legend_frame = False
g.settings.alpha_filled_add = 0.75
# g.settings.title_limit_fontsize = 14
g.triangle_plot(X, params=params, filled=True, legend_loc='upper right', )
# g.export(f"../plots/ALL_dipole.png", dpi=500,)
In [ ]: