1
0
Fork 0
mirror of https://github.com/cosmo-sims/cosmICweb-music.git synced 2024-09-19 16:53:43 +02:00
cosmICweb-music/tests/test_e2e.py
2024-04-23 13:10:13 +02:00

157 lines
4.3 KiB
Python

import re
from cosmicweb_music.cosmICweb import (
DEFAULT_URL,
downloadstore_mode,
publication_mode,
)
from cosmicweb_music.data_types import Args
reference_output = """
# Zoom Initial Conditions for halo 25401888 (halo_25401888) in simulation AGORA (AGORA Project project)
# Details on this halo can be found on https://cosmicweb.eu/simulation/AGORA/halo/25401888
# This file has been generated by CosmICweb @2024-04-23T12:56:20.876162
[setup]
boxlength = 60
zstart = 100
levelmin = 7
levelmin_TF = 7
levelmax = 11
padding = 16 # try reduce it at your own risk
overlap = 4
align_top = no
baryons = no # switch on for baryon runs
use_2LPT = no
use_LLA = no # AMR codes might want to enable this
# Ellipsoidal refinement region defined on unity cube
# This minimum bounding ellipsoid has been obtained from
# particles within 4.0 Rvir of the halo center
region = ellipsoid
region_ellipsoid_matrix[0] = 73.2097934892, 0.7223112927, 6.51459018132
region_ellipsoid_matrix[1] = 0.7223112927, 41.7248191188, -11.54268986796
region_ellipsoid_matrix[2] = 6.51459018132, -11.54268986796, 82.69775988479999
region_ellipsoid_center = 0.03202272286, 0.7263335608333333, 0.5582005855333333
[cosmology]
Omega_m = 0.272
Omega_L = 0.728
Omega_b = 0.0455
H0 = 70.2
sigma_8 = 0.807
nspec = 0.961
transfer = eisenstein
#below are MUSIC defaults to initialize gas temperature for some codes
#YHe = 0.248 # primordial He abundance
#gamma = 1.6667 # adiabatic exponent (=5/3)
[random]
cubesize = 256
seed[8] = 95064
seed[9] = 31415
seed[10] = 27183
# do not add higher seeds!
[poisson]
fft_fine = yes
accuracy = 1e-6
grad_order = 6
laplace_order = 6
[output]
format = grafic2
filename = ics.dat
ramses_nml = yes
ramses_old_nml = no
ramses_pvar_idx = 43
""".lstrip()
reference_output_publication="""
# Zoom Initial Conditions for halo 25505622 (1e11v) in simulation AGORA (AGORA Project project)
# Details on this halo can be found on https://cosmicweb.eu/simulation/AGORA/halo/25505622
# This file has been generated by CosmICweb @2024-04-21T00:03:24.827918
[setup]
boxlength = 60
zstart = 100
levelmin = 9
levelmin_TF = 9
levelmax = 9
padding = 16 # try reduce it at your own risk
overlap = 4
align_top = no
baryons = no # switch on for baryon runs
use_2LPT = no
use_LLA = no # AMR codes might want to enable this
# Ellipsoidal refinement region defined on unity cube
# This minimum bounding ellipsoid has been obtained from
# particles within 2.0 Rvir of the halo center
region = ellipsoid
region_ellipsoid_matrix[0] = 1202.685817644, -224.73030332520003, 78.4954201104
region_ellipsoid_matrix[1] = -224.73030332520003, 1126.675415484, -514.163771388
region_ellipsoid_matrix[2] = 78.4954201104, -514.163771388, 859.827522564
region_ellipsoid_center = 0.6253459789833333, 0.47749109738333334, 0.6903304682000001
[cosmology]
Omega_m = 0.272
Omega_L = 0.728
Omega_b = 0.0455
H0 = 70.2
sigma_8 = 0.807
nspec = 0.961
transfer = eisenstein
#below are MUSIC defaults to initialize gas temperature for some codes
#YHe = 0.248 # primordial He abundance
#gamma = 1.6667 # adiabatic exponent (=5/3)
[random]
cubesize = 256
seed[8] = 95064
seed[9] = 31415
seed[10] = 27183
# do not add higher seeds!
[poisson]
fft_fine = yes
accuracy = 1e-6
grad_order = 6
laplace_order = 6
[output]
# TODO: add output options
""".lstrip()
time_fix_regex = re.compile(r"@[\d\-T:.]+")
def test_single_saved():
id = "50e20c16-45b8-4d0f-b6cd-44e050b76afb"
args = Args(output_path="./", url=DEFAULT_URL, common_directory=True, attempts=1)
output = downloadstore_mode(args, id, store=False)
assert len(output) == 1
output = output[0]
assert output[0] == "./cosmICweb-zooms-AGORA/ics_halo_25401888.cfg"
assert time_fix_regex.sub("TIME", output[1]) == time_fix_regex.sub(
"TIME", reference_output
)
def test_publication():
id = "agora-halos"
args = Args(output_path="./", url=DEFAULT_URL, common_directory=True, attempts=1)
output = publication_mode(args, id, store=False, traceback_radius=2.0)
assert len(output) == 6
output = output[0]
assert output[0] == "./agora-halos/1e11v/ics.cfg"
assert time_fix_regex.sub("TIME", output[1]) == time_fix_regex.sub(
"TIME", reference_output_publication
)