Skip to content

Commit

Permalink
Merge pull request #115 from SWIFTSIM/FIREbox-data
Browse files Browse the repository at this point in the history
FIREbox data
  • Loading branch information
bwvdnbro authored Jun 20, 2022
2 parents 6fda1ba + 934bd3e commit 808bc0c
Show file tree
Hide file tree
Showing 35 changed files with 1,521 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
from velociraptor.observations.objects import ObservationalData
import unyt
import numpy as np
import os
import sys


# Exec the master cosmology file passed as first argument
with open(sys.argv[1], "r") as handle:
exec(handle.read())

# Meta-data
name = f"Column Density Distribution Function (FIREbox)"
comment = "Curves for all redshift bins [0,6] have been fitted by eye."
citation = "Feldmann et al. (2022, FIREbox)"
bibcode = "2022arXiv220515325F"
plot_as = "line"
output_filename = "FIREbox.hdf5"
output_directory = "../"

# Create observational data instance
processed = ObservationalData()
processed.associate_citation(citation, bibcode)
processed.associate_name(name)
processed.associate_comment(comment)
processed.associate_cosmology(cosmology)

if not os.path.exists(output_directory):
os.mkdir(output_directory)

# Load raw data
data = np.loadtxt(f"../raw/FIREbox.txt")

logNHI = data[:, 0]
f_NHI = 10.0 ** data[:, 1]

# create NHI bins from the given values
# for each interval in log space, we assign half to the lower bin and
# half to the upper bin. We further assume that the lowest and highest
# bin are symmetric (in log space) around the central value
logNHI_plus = np.zeros(logNHI.shape)
logNHI_minus = np.zeros(logNHI.shape)
logNHI_plus[:-1] = 0.5 * (logNHI[1:] + logNHI[:-1])
logNHI_minus[1:] = 0.5 * (logNHI[1:] + logNHI[:-1])
logNHI_plus[-1] = 2.0 * logNHI[-1] - logNHI_minus[-1]
logNHI_minus[0] = 2.0 * logNHI[0] - logNHI_plus[0]

dlogNHI = logNHI_plus - logNHI_minus
dNHI = 10.0 ** logNHI_plus - 10.0 ** logNHI_minus

# convert from d/dN to d/dlogN
f_NHI *= dNHI / dlogNHI


NHI_bin = unyt.unyt_array(10.0 ** logNHI, units="cm**(-2)")
f_NHI_bin = unyt.unyt_array(f_NHI, units="dimensionless")

processed.associate_x(
NHI_bin, scatter=None, comoving=False, description="Column density"
)
processed.associate_y(
f_NHI_bin,
scatter=None,
comoving=False,
description="Column density distribution function",
)

z_minus = 0.0
z_plus = 6.0
processed.associate_redshift(0.5 * (z_minus + z_plus), z_minus, z_plus)
processed.associate_plot_as(plot_as)

output_path = f"{output_directory}/{output_filename}"

if os.path.exists(output_path):
os.remove(output_path)

processed.write(filename=output_path)
85 changes: 85 additions & 0 deletions data/ColumnDensityDistributionFunction/raw/FIREbox.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# FIREbox (Feldmann et al., 2022)
# Fig. 14, by eye average over all redshift bins
# Extracted using WebPlotDigitizer
# log10(NHI/cm^-2) log10(f/cm^2)
15.48293365561987 -15.19836843173678
15.775157432733286 -15.723868768214277
16.14835888302271 -16.32004293564103
16.514518796514217 -16.92533814598118
16.627183385280834 -17.010153480254257
16.704640290057885 -17.11071297837443
16.782097194834932 -17.218455297788903
16.859554099611984 -17.33076850348157
16.941235926467783 -17.43132800160174
17.010947140767126 -17.539070321016215
17.05269339464047 -17.625264176547795
17.12009096113479 -17.7192938371277
17.197547865911837 -17.830954059066336
17.275004770688888 -17.943267264759
17.352461675465936 -18.054927486697636
17.429918580242987 -18.167240692390298
17.507375485020034 -18.284124784361154
17.584832389797086 -18.397743957561868
17.662289294574137 -18.510057163254533
17.739746199351185 -18.626941255225386
17.817203104128236 -18.739907444672077
17.894660008905284 -18.857444520396957
17.972116913682335 -18.975634579875862
18.049573818459386 -19.090559720584636
18.127030723236434 -19.20221994252327
18.204487628013485 -19.315186131969963
18.281944532790533 -19.423581435138463
18.359401437567584 -19.535894640831124
18.436858342344635 -19.6436369602456
18.514315247121683 -19.752685247168127
18.591772151898734 -19.857815631566492
18.669229056675782 -19.963598999718883
18.746685961452833 -20.066117449101142
18.824142866229884 -20.16732993097534
18.901599771006932 -20.26919539660357
18.964973602188156 -20.347553447086828
19.14805355893391 -20.575009454739604
19.26775968449844 -20.716750461613756
19.375143120666625 -20.835985295099107
19.453186820176832 -20.886265044159195
19.542379619617073 -20.989518100264732
19.605753450798296 -21.073018397810948
19.877243814006743 -21.339580876954905
20.05782011322435 -21.561450245823227
20.27469944660009 -21.717876131787946
21.099967559315566 -22.666168160886297
21.274597671903823 -22.973201122029845
21.353462884040454 -23.122995595203665
21.415428407862095 -23.25006623373734
21.492885312639146 -23.404823383441766
21.566821449017237 -23.55109174434384
21.63019528019846 -23.674097559008697
21.711172953374465 -23.889990312683913
21.781588321353603 -24.04032168361104
21.844962152534826 -24.19355520455607
21.904815215317093 -24.347487055349156
21.964668278099357 -24.50401270272074
22.02804210928058 -24.65405385864608
22.1363734446331 -25.033515554544007
22.183738311812228 -25.195159729483215
22.235767444819032 -25.362359847389378
22.274495897207558 -25.50625570065182
22.313224349596084 -25.66643261551467
22.351952801984606 -25.842411737224978
22.387160485974174 -26.009053191252697
22.422368169963743 -26.18431403083357
22.45405508555435 -26.3416178171787
22.485742001144963 -26.52118834953616
22.51390814833662 -26.689984649952166
22.54559506392723 -26.894695056839666
22.57024044271993 -27.04194289337278
22.696988105082376 -28.50723843740962
22.718112715476117 -28.689203243531843
22.735716557470898 -28.89151937665458
22.753320399465682 -29.081864140953478
22.770924241460467 -29.28298313719383
22.78852808345525 -29.47931358590465
22.804958335983713 -29.721135236146022
22.825747635101365 -29.869922248670772
22.84358009842076 -30.076358398336772
22.858943451434385 -30.159287335098217
52 changes: 52 additions & 0 deletions data/CosmicH2Abundance/conversion/convertFIREbox.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
from velociraptor.observations.objects import ObservationalData

import unyt
import numpy as np
import os
import sys

# Exec the master cosmology file passed as first argument
with open(sys.argv[1], "r") as handle:
exec(handle.read())

input_filename = "../raw/FIREbox.txt"

processed = ObservationalData()
raw = np.loadtxt(input_filename)

comment = "Includes all gas in the simulation."
citation = "Feldmann et al. (2022, FIREbox)"
bibcode = "2022arXiv220515325F"
name = "H2 Mass Cosmic History (FIREbox)"
plot_as = "line"

a = raw[:, 0]
z = 1.0 / a - 1.0
rhoH2 = 10.0 ** raw[:, 1]
a = unyt.unyt_array(a, units=unyt.dimensionless)
rhoH2 = unyt.unyt_array(rhoH2, units=unyt.Msun / unyt.Mpc ** 3)

processed.associate_x(
a, scatter=None, comoving=False, description="Cosmic scale factor"
)
processed.associate_y(
rhoH2,
scatter=None,
comoving=False,
description="Cosmic Average H2 Mass Density",
)
processed.associate_citation(citation, bibcode)
processed.associate_name(name)
processed.associate_comment(comment)
zmin = z.min()
zmax = z.max()
processed.associate_redshift(0.5 * (zmin + zmax), zmin, zmax)
processed.associate_plot_as(plot_as)
processed.associate_cosmology(cosmology)

output_path = f"../FIREbox.hdf5"

if os.path.exists(output_path):
os.remove(output_path)

processed.write(filename=output_path)
95 changes: 95 additions & 0 deletions data/CosmicH2Abundance/raw/FIREbox.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# FIREbox (Feldmann et al., 2022)
# Fig. 12 right, all H2 in box
# Extracted using WebPlotDigitizer
# scale factor log10(rho_H2/Msun Mpc^-3)
0.9941427097449762 7.59066265060241
0.9665061415737314 7.603757454058659
0.9396378533413696 7.607576771733399
0.9135164873286243 7.616852257514909
0.8881212795479527 7.61848910794694
0.8634320432381513 7.6206715751896486
0.8394291528178114 7.625309318080403
0.8160935282848599 7.624490892864387
0.7934066200497818 7.64058658877936
0.7713503941904708 7.63867692994199
0.7499073181169864 7.651498924992902
0.7290603466348217 7.641677822400714
0.7087929083956042 7.653408583830271
0.6890888927244588 7.648225224128839
0.66748420149785 7.660969273921081
0.6513089132717083 7.648170662447772
0.63320291801999 7.641132205590038
0.6156002585239708 7.633493570240558
0.5984869423529978 7.623126850837695
0.5818493660575569 7.620125958378971
0.5656743043558318 7.604575879274675
0.5499488996208699 7.599665327978581
0.5346606516599991 7.561363027869053
0.5212983475681933 7.543773705934851
0.5027635600173299 7.501181493651374
0.48878703605931484 7.489177923816479
0.47580841146567515 7.471527219991076
0.4619888038224244 7.469262910226766
0.4491457935120984 7.447165429394346
0.436659811148048 7.448365786377835
0.42452093156854426 7.428068841020648
0.4129311206352547 7.431315261044178
0.40124615201360037 7.408972252646953
0.39059197587461825 7.4057326528335565
0.37827666470283394 7.377326477627683
0.36838972173788365 7.37393152858347
0.3575372727741317 7.345953511013752
0.34789504468814286 7.333252764142992
0.3370699167411868 7.30394101659162
0.32816651824323706 7.289906539739205
0.31826327334327986 7.2560631414547085
0.3099713694769077 7.239558232931728
0.3003519364885091 7.204547820913284
0.2939546845628854 7.189743418116913
0.2824333684893823 7.154714818871446
0.27741139535475634 7.144529971738807
0.26694867998118044 7.110247048801266
0.2618662434152847 7.100766956715752
0.251667102110134 7.067143320757779
0.24538863795887164 7.052645502645503
0.23786920455723293 7.003442558111233
0.2315955253347153 6.980409734174795
0.22482779037178063 6.93564966938461
0.21857771330085993 6.904898705934851
0.21250138460565318 6.865537909212608
0.2064175487250433 6.835438048490257
0.20085078621574004 6.797335807877977
0.19294563119624894 6.748412167187268
0.18844522694605076 6.720403837572513
0.1823152693690982 6.678724775645794
0.17812168326471978 6.647096321795118
0.17178069609512264 6.58754614417265
0.16676766754237296 6.541684020030741
0.162362649690117 6.494518477952213
0.15784906588304376 6.443776114559247
0.15346095698551623 6.399035536083729
0.1491948348706715 6.359478317309643
0.14504730837947127 6.326741308669019
0.14101508062505447 6.280727624301921
0.1370949463720279 6.242989128230093
0.13328378948861058 6.18788183035171
0.1295785804696069 6.151398252944437
0.12597637402823994 6.101674374264736
0.12294606740316213 6.057331641380337
0.11998865347969465 6.000462455884143
0.11695240766302294 5.9411530425051176
0.11399299234983559 5.885804980383294
0.1108240558649233 5.820954525171393
0.10774321390440594 5.768302502941057
0.10474801749359891 5.717014522737415
0.101836085737838 5.664635308912418
0.09925918050271043 5.6080730328722295
0.09699576525822826 5.538719073826169
0.09490550686193018 5.472782797858099
0.09286029352663719 5.406012940651495
0.09051051569699539 5.334537138452801
0.08799437791038307 5.276974564926372
0.08565788796077822 5.222358322177599
0.08338343817117277 5.14793618920125
0.08148203878284294 5.107209791547141
0.08054766057875663 5.0624107541276215
52 changes: 52 additions & 0 deletions data/CosmicHIAbundance/conversion/convertFIREbox.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
from velociraptor.observations.objects import ObservationalData

import unyt
import numpy as np
import os
import sys

# Exec the master cosmology file passed as first argument
with open(sys.argv[1], "r") as handle:
exec(handle.read())

input_filename = "../raw/FIREbox.txt"

processed = ObservationalData()
raw = np.loadtxt(input_filename)

comment = "Includes all gas in the simulation."
citation = "Feldmann et al. (2022, FIREbox)"
bibcode = "2022arXiv220515325F"
name = "HI Mass Cosmic History (FIREbox)"
plot_as = "line"

a = raw[:, 0]
z = 1.0 / a - 1.0
rhoHI = 10.0 ** raw[:, 1]
a = unyt.unyt_array(a, units=unyt.dimensionless)
rhoHI = unyt.unyt_array(rhoHI, units=unyt.Msun / unyt.Mpc ** 3)

processed.associate_x(
a, scatter=None, comoving=False, description="Cosmic scale factor"
)
processed.associate_y(
rhoHI,
scatter=None,
comoving=False,
description="Cosmic HI Mass Density",
)
processed.associate_citation(citation, bibcode)
processed.associate_name(name)
processed.associate_comment(comment)
zmin = z.min()
zmax = z.max()
processed.associate_redshift(0.5 * (zmin + zmax), zmin, zmax)
processed.associate_plot_as(plot_as)
processed.associate_cosmology(cosmology)

output_path = f"../FIREbox.hdf5"

if os.path.exists(output_path):
os.remove(output_path)

processed.write(filename=output_path)
Loading

0 comments on commit 808bc0c

Please sign in to comment.