1
0
Fork 0
mirror of https://github.com/cosmo-sims/cosmICweb-music.git synced 2024-09-19 16:53:43 +02:00

fix tests

This commit is contained in:
Lukas Winkler 2024-04-23 13:10:13 +02:00
parent 1cf4ca5b5a
commit 67f8ff1149
Signed by: lukas
GPG key ID: 54DE4D798D244853
3 changed files with 88 additions and 45 deletions

View file

@ -22,7 +22,7 @@ class Configuration(TypedDict):
outputOptions: List[Tuple[str, str]]
startRedshift: int
outputFilename: str
separateFolders: bool
seperateFolders: bool
tracebackRadius: int | float | str

View file

@ -7,7 +7,7 @@ from cosmicweb_music.cosmICweb import (
DEFAULT_URL,
compose_template,
)
from cosmicweb_music.data_types import DownloadConfig, Args, Ellipsoid
from cosmicweb_music.data_types import DownloadConfig, Args, Ellipsoid, Configuration
some_config = """
[setup]
@ -40,7 +40,31 @@ baryons = no # switch on for baryon runs
use_2LPT = no
use_LLA = no # AMR codes might want to enable this
""".strip()
settings:Configuration={
"outputType": "grafic2",
"resolution": {
"low": 7,
"high": 11
},
"outputOptions": [
(
"ramses_nml",
"yes"
),
(
"ramses_old_nml",
"no"
),
(
"ramses_pvar_idx",
"43"
)
],
"startRedshift": 100,
"outputFilename": "ics.dat",
"seperateFolders": True,
"tracebackRadius": 4
}
config = DownloadConfig(
simulation_name="test",
project_name="project",
@ -50,7 +74,7 @@ config = DownloadConfig(
traceback_radius=10,
api_token="...",
MUSIC={"cosmology": "", "poisson": "", "random": "", "setup": ""},
settings=None,
settings=settings,
accessed_at=datetime.now(),
)
@ -93,6 +117,14 @@ region_ellipsoid_center = 0.42174551551333334, 0.42890526632, 0.2797593877600
[poisson]
[output]
format = grafic2
filename = ics.dat
ramses_nml = yes
ramses_old_nml = no
ramses_pvar_idx = 43
""".lstrip()

View file

@ -1,65 +1,73 @@
import re
from datetime import datetime
from cosmicweb_music.cosmICweb import (
apply_config_parameter,
music_config_to_template,
process_config,
DEFAULT_URL,
compose_template,
downloadstore_mode,
publication_mode,
)
from cosmicweb_music.data_types import DownloadConfig, Args, Ellipsoid
from cosmicweb_music.data_types import Args
reference_output = """
# Zoom Initial Conditions for halo 208416759 (halo_208416759) in simulation 150MPC (CosmOCA project)
# Details on this halo can be found on https://cosmicweb.eu/simulation/150MPC/halo/208416759
# This file has been generated by CosmICweb @2024-04-20T22:26:13.916577
# 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 = 150
zstart = 99
levelmin = 8
levelmin_TF = 8
levelmax = 12
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
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 10.0 Rvir of the halo center
# particles within 4.0 Rvir of the halo center
region = ellipsoid
region_ellipsoid_matrix[0] = 872.2886068575001, -31.76815629375, 92.22811563824999
region_ellipsoid_matrix[1] = -31.76815629375, 520.6134379275, 28.34206946775
region_ellipsoid_matrix[2] = 92.22811563824999, 28.34206946775, 165.70762251300002
region_ellipsoid_center = 0.42174551551333334, 0.42890526632, 0.27975938776000003
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.309
Omega_L = 0.691
Omega_b = 0.049
H0 = 67.74
sigma_8 = 0.816
nspec = 0.9667
transfer = eisenstein
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[9] = 74927
seed[10] = 21450
cubesize = 256
seed[8] = 95064
seed[9] = 31415
seed[10] = 27183
# do not add higher seeds!
[poisson]
fft_fine = true
accuracy = 1e-5
grad_order = 4
laplace_order = 4
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="""
@ -115,18 +123,21 @@ 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 = "f5399734-ad67-432b-ba4d-61bc2088136a"
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-150MPC/ics_halo_208416759.cfg"
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