mirror of
https://github.com/Richard-Sti/csiborgtools.git
synced 2024-10-18 20:25:07 +02:00
66d9f46919
Richard Stiskalek
fc51f75e16
Add field interpolation along LOS (#112)
* Add attemtp * Add import * Update LOS code * Add better docstrings * Update nb
127 KiB
127 KiB
In [1]:
import numpy as np
import numpy
import matplotlib.pyplot as plt
import h5py
%matplotlib inline
import csiborgtools
%load_ext autoreload
%autoreload 2
In [2]:
field_reader = csiborgtools.read.CSiBORG1Field(7444)
density = field_reader.density_field("SPH", 1024)
In [54]:
sky_pos = np.array([[30, 20], [20, 30]]).reshape(2, -1)
boxsize = 677.7
rmax = 100
dr = 0.01
smooth_scales = [0., 2.0]
In [55]:
rdist, finterp = csiborgtools.field.evaluate_los(density, density, sky_pos=sky_pos, boxsize=boxsize,
rmax=rmax, dr=dr, verbose=True, smooth_scales=smooth_scales)
Smoothing and interpolating field 1/2: 50%|█████ | 1/2 [01:19<01:19, 79.48s/it]
Smoothing....
Smoothing and interpolating field 1/2: 100%|██████████| 2/2 [06:13<00:00, 186.93s/it] Smoothing and interpolating field 2/2: 50%|█████ | 1/2 [00:28<00:28, 28.69s/it]
Smoothing....
Smoothing and interpolating field 2/2: 100%|██████████| 2/2 [04:22<00:00, 131.10s/it]
In [58]:
finterp[0].shape
Out[58]:
(2, 10000, 2)
In [62]:
plt.figure()
plt.plot(rdist, finterp[0][0, :, 0])
plt.plot(rdist, finterp[0][0, :, 1])
# plt.plot(rdist, finterp[0][1, :, 1])
# plt.plot(rdist, finterp[0][1])
plt.yscale("log")
plt.xlabel(r"$r_{\rm LOS} ~ [\mathrm{Mpc} / h]$")
plt.ylabel(r"$\rho ~ [h^2 M_\odot / \mathrm{kpc}^3]$")
# plt.savefig("../plots/los_density.png")
plt.show()
In [66]:
with h5py.File("/mnt/extraspace/rstiskalek/catalogs/PV_Supranta/A2.h5", 'r') as f:
print(f.keys())
print(f["RA"][:])
<KeysViewHDF5 ['DEC', 'RA', 'e_rhMpc', 'r_hMpc', 'z_obs']> [257.913777 153.92777016 179.31705342 191.86833286 281.66408049 288.50201589 174.50610479 216.60269476 108.90996236 309.42214917 16.81750993 269.4221259 238.14579579 121.27993484 203.84909417 188.47592843 185.27476324 106.4123163 133.64692979 37.85860654 146.02174412 129.61819338 84.1608868 334.00415153 38.45407476 22.82045861 263.94764257 211.6610223 240.72609721 140.4400568 165.4075435 241.85718797 126.90418905 275.68210609 24.32272137 339.92326 15.87872813 103.26137093 3.62135198 348.62844138 11.99957619 326.85679608 268.67725928 179.16012979 192.18390097 191.36167164 101.85702889 111.72088801 355.05147665 6.32760332 212.48967159 154.29785936 191.7514308 144.21308917 199.48295574 207.74625324 94.07749024 27.10552055 9.08016256 145.25330055 71.2998542 147.69263532 41.4626546 341.35398351 200.37903246 187.7966961 252.43764592 187.78615058 188.51866596 161.78216462 202.77460985 344.50141817 208.19964002 357.99225248 150.84098733 22.44821136 190.69817669 197.55360519 152.26699777 20.53369464 348.78662296 55.80119084 74.92982832 115.56810544 46.36468273 2.62559378 311.50438523 201.0484087 54.06477017 200.82380934 188.54026322 157.34550311 186.27299493 299.96404118 54.28864501 299.71317893 258.87747769 190.74616502 323.68818129 50.65852321 188.6292888 50.65852321 204.92511588 181.04114568 224.87717796 49.29458383 180.48486297 358.53577477 333.66225313 275.79193882 127.87912282 169.86464498 125.69222982 239.147036 149.88078731 243.18209259 215.56607699 116.72919416 224.06941322 195.84316823 122.96725952 29.58300214 0.93116777 120.06679851 320.87870897 258.055495 11.7128841 75.23040696 55.44712201 75.47421592 338.0514929 49.42814975 10.67700364 347.46738146 9.74709771 31.08975506 206.38317338 201.14565869 184.79362167 196.25154221 163.51425895 195.15614351 218.4838896 239.17590965 280.00381267 174.63466403 183.0468047 159.29914255 167.41350695 190.43199067 191.40565404 92.15394679 51.44466864 49.94857163 132.33219645 53.81277962 21.66780081 36.93337167 230.34340444 308.83195891 170.22633436 171.39729356 156.77706557 91.18355283 42.55409849 1.48044748 10.4452016 265.9636781 218.65474602 179.08781069 109.52032216 146.67896832 260.59544048 99.2572855 20.2673852 34.52302921 125.05394773 133.48723463 311.85000548 50.48631212 29.47435015 352.11136336 198.25108016 244.14673219 211.6610223 236.73192995 216.20481873 196.98318008 154.21746761 347.67175318 144.51030743 74.29365823 21.3304381 24.51151613 358.39943833 270.36918589 248.51109397 167.61667914 160.0084801 137.380361 20.70373877 340.54264114 308.22338964 327.28042733 80.45893098 129.59442911 191.60356348 37.67929646 144.39106248 207.50161362 224.88355178 184.3229601 192.42303228 77.95062894 47.20574611 359.63485111 338.52965431 160.11729905 39.0166275 105.40725449 185.72695755 171.01074151 340.07395544 14.07408326 27.69070833 139.05195833 181.05108333 344.92754167 126.7765 193.14141667 202.5075 322.74691667 79.39320833 138.82345833 6.31941667 141.90004167 171.25958333 202.77420833 345.44954167 52.46175 54.00641667 354.70170833 152.33325 104.29804167 104.39358333 45.97375 144.630125 128.97245833 100.26045833 162.57033333 189.74058333 315.87341667 198.75729167 211.88566667 303.49983333 294.18683333 109.13583333 17.95475 45.61875 157.23320833 21.346 20.22841667 332.68679167 1.00795833 136.89191667 132.64645833 58.595125 74.84816667 170.16158333 220.599375 170.92616667 75.88908333 107.92004167 162.84195833 138.75008333 177.267125 32.32141667 227.86837 14.6925 241.36508 291.08729 356.85458 1.55754 274.74571 346.27442 15.4335 277.60646 200.43687 219.45867 257.76075 320.25721 249.37108 272.71 335.22483 299.05367 334.77183 314.12537 27.43167 1.70442 144.723 338.46533 308.24633 359.73771 199.21417 164.68825 204.36967 225.94479 30.27671 219.31271 270.59733 32.70733 128.37954 242.48517 355.44933 128.75825 107.94212 245.54412 194.22404 176.44104 3.74929 145.81354 186.158 332.71529 345.819 334.38854 202.30342 330.45446 109.44041667 16.83491667 24.88333 154.81917 65.45125 37.66542 177.86762 163.7425 212.86042 236.37625 155.62458 162.8025 197.99167 102.65292 162.03125 216.82862 167.35751 215.07542 162.20262 202.50333 203.68955 287.65542 203.06375 217.78875 203.14908 182.02833 236.13 221.7775 341.55171 318.0975 209.76858 273.1225 200.78025 336.38233 5.34333 36.84042 225.65229 26.02737 15.39792 339.24642 227.95617 272.02708 37.32283 44.39175 324.92216 317.28283 90.81942 338.34446 38.01092 32.87112 1.76313 23.5621 135.05499 108.05958 181.3575 207.45479 205.84688 166.89787 208.53675 208.1625 130.20479 128.23873 248.3325 152.69017 117.04587 173.29408 196.91421 14.38292 45.38504 174.64075 176.11058 171.97717 214.12917 156.67654 42.29325 211.67305 240.96735 165.33138 146.13396 203.17538 61.561 257.44179 148.45258 239.28395 230.67133 334.04921 198.88683 200.30375 213.595 233.09502 226.51104 259.33012 261.67433 35.80504 337.6749 24.65033 60.85967 346.66457 121.33125 33.99229 2.86509 168.54599 93.13916 5.17108 40.28692 25.98572 126.78388 38.89295 229.19654167 269.87408 191.18975 358.35642 355.46738 21.09388 78.69917 56.84763 234.77917 145.80508 28.42666667 43.194625 134.89545833 181.0215 240.71283333 310.97141667 358.15491667]
In [ ]:
In [ ]:
In [28]:
finterp[0], finterp[1]
Out[28]:
(array([ 10.583365 , 6.7742605, 7.1643467, 6.8513064, 5.5301476, 6.9267087, 22.147158 , 108.51967 , 112.481346 , 88.93071 , 145.0881 , 141.2615 , 134.5087 , 87.61397 , 139.79611 , 315.07483 , 234.62367 , 301.84012 , 484.01865 , 663.8185 , 293.2296 , 136.89264 , 147.65718 , 130.9273 , 116.33771 , 143.74536 , 80.08072 , 30.173855 , 12.165639 , 10.68441 , 9.221353 , 10.211646 , 11.992005 , 19.4537 , 11.251454 , 8.464169 , 13.099285 , 17.883732 , 19.20988 , 46.738792 , 55.239193 , 6.841834 , 9.18582 , 23.706173 , 74.723434 , 187.2956 , 369.05817 , 253.03062 , 55.191418 , 68.85495 , 289.00592 , 969.0986 , 180.4563 , 70.97476 , 24.608627 , 24.743225 , 47.642834 , 21.767788 , 8.428687 , 7.14018 , 7.660934 , 13.2114 , 62.22416 , 70.15863 , 33.04026 , 39.356396 , 73.14411 , 39.452133 , 36.98149 , 26.600525 , 17.725557 , 53.196896 , 52.465004 , 64.81822 , 173.60437 , 245.58018 , 187.42072 , 770.42847 , 102.52525 , 11.396799 , 24.54599 , 66.20458 , 95.76814 , 37.810677 , 34.16611 , 52.21646 , 103.09187 , 38.738525 , 14.756968 , 11.289859 , 37.27441 , 55.70077 , 19.752144 , 32.716606 , 57.033173 , 11.952204 , 7.6880813, 8.264174 , 9.047332 , 10.430565 , 10.583365 , 5.6465387, 4.6723876, 4.644058 , 4.635455 , 6.1151123, 11.864274 , 19.191708 , 9.1014805, 7.5032997, 9.466907 , 10.716101 , 9.155455 , 9.917248 , 136.0201 , 57.726727 , 47.618767 , 115.29523 , 110.45297 , 60.60472 , 37.797356 , 41.525276 , 65.375465 , 94.393906 , 19.892447 , 20.74041 , 15.574245 , 19.020699 , 16.831785 , 22.487307 , 20.252598 , 14.337538 , 17.36609 , 17.485952 , 18.453922 , 26.196033 , 29.500584 , 26.58963 , 37.125656 , 81.49562 , 83.77232 , 137.38773 , 1295.4517 , 398.84943 , 1082.2748 , 402.14554 , 277.34045 , 25.818726 , 15.6923275, 15.24346 , 20.254032 , 14.838277 , 11.22076 , 19.399096 , 10.351105 , 30.465406 , 46.79307 , 19.40228 , 12.464137 , 14.419122 , 12.179465 , 9.22182 , 21.167253 , 29.398338 , 21.396988 , 19.779228 , 22.205538 , 12.95934 , 8.252939 , 26.199804 , 30.8148 , 41.415253 , 57.572132 , 74.17276 , 101.8926 , 75.438385 , 71.87181 , 116.71039 , 99.06143 , 138.8481 , 84.13705 , 44.81233 , 8.080019 , 4.576476 , 4.3324184, 5.0273733, 7.6751394, 16.073715 , 12.193309 , 6.509601 , 5.840347 , 7.337933 , 9.146312 , 9.227291 , 9.852993 , 13.049668 , 13.314442 , 16.158342 , 17.48068 , 10.954332 ], dtype=float32), array([ 10.583365 , 6.7742605, 7.1643467, 6.8513064, 5.5301476, 6.9267087, 22.147158 , 108.51967 , 112.481346 , 88.93071 , 145.0881 , 141.2615 , 134.5087 , 87.61397 , 139.79611 , 315.07483 , 234.62367 , 301.84012 , 484.01865 , 663.8185 , 293.2296 , 136.89264 , 147.65718 , 130.9273 , 116.33771 , 143.74536 , 80.08072 , 30.173855 , 12.165639 , 10.68441 , 9.221353 , 10.211646 , 11.992005 , 19.4537 , 11.251454 , 8.464169 , 13.099285 , 17.883732 , 19.20988 , 46.738792 , 55.239193 , 6.841834 , 9.18582 , 23.706173 , 74.723434 , 187.2956 , 369.05817 , 253.03062 , 55.191418 , 68.85495 , 289.00592 , 969.0986 , 180.4563 , 70.97476 , 24.608627 , 24.743225 , 47.642834 , 21.767788 , 8.428687 , 7.14018 , 7.660934 , 13.2114 , 62.22416 , 70.15863 , 33.04026 , 39.356396 , 73.14411 , 39.452133 , 36.98149 , 26.600525 , 17.725557 , 53.196896 , 52.465004 , 64.81822 , 173.60437 , 245.58018 , 187.42072 , 770.42847 , 102.52525 , 11.396799 , 24.54599 , 66.20458 , 95.76814 , 37.810677 , 34.16611 , 52.21646 , 103.09187 , 38.738525 , 14.756968 , 11.289859 , 37.27441 , 55.70077 , 19.752144 , 32.716606 , 57.033173 , 11.952204 , 7.6880813, 8.264174 , 9.047332 , 10.430565 , 10.583365 , 5.6465387, 4.6723876, 4.644058 , 4.635455 , 6.1151123, 11.864274 , 19.191708 , 9.1014805, 7.5032997, 9.466907 , 10.716101 , 9.155455 , 9.917248 , 136.0201 , 57.726727 , 47.618767 , 115.29523 , 110.45297 , 60.60472 , 37.797356 , 41.525276 , 65.375465 , 94.393906 , 19.892447 , 20.74041 , 15.574245 , 19.020699 , 16.831785 , 22.487307 , 20.252598 , 14.337538 , 17.36609 , 17.485952 , 18.453922 , 26.196033 , 29.500584 , 26.58963 , 37.125656 , 81.49562 , 83.77232 , 137.38773 , 1295.4517 , 398.84943 , 1082.2748 , 402.14554 , 277.34045 , 25.818726 , 15.6923275, 15.24346 , 20.254032 , 14.838277 , 11.22076 , 19.399096 , 10.351105 , 30.465406 , 46.79307 , 19.40228 , 12.464137 , 14.419122 , 12.179465 , 9.22182 , 21.167253 , 29.398338 , 21.396988 , 19.779228 , 22.205538 , 12.95934 , 8.252939 , 26.199804 , 30.8148 , 41.415253 , 57.572132 , 74.17276 , 101.8926 , 75.438385 , 71.87181 , 116.71039 , 99.06143 , 138.8481 , 84.13705 , 44.81233 , 8.080019 , 4.576476 , 4.3324184, 5.0273733, 7.6751394, 16.073715 , 12.193309 , 6.509601 , 5.840347 , 7.337933 , 9.146312 , 9.227291 , 9.852993 , 13.049668 , 13.314442 , 16.158342 , 17.48068 , 10.954332 ], dtype=float32))
In [ ]:
In [24]:
plt.figure()
plt.plot(rdist, finterp[:100])
plt.yscale("log")
plt.show()
In [ ]: