Skip to content

Commit e185130

Browse files
authored
Merge branch 'master' into soap_docs
2 parents 8d953e5 + 4b28395 commit e185130

14 files changed

Lines changed: 641 additions & 71 deletions

source/_static/viewer.js

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -344,35 +344,41 @@ async function display_directory(path, object) {
344344
// Get directory size as a string
345345
const dir_size = format_file_size(object.size);
346346

347-
if(sanitize_path(path) != "") {
347+
if((sanitize_path(path) != "") && (object.size < 1125899906842624)) {
348348
// Add a link to download the directory
349349
const card = add_element(div, "div");
350350
card.className = "downloadoptions";
351351
const details = add_element(card, "details");
352352
const summary = add_element(details, "summary");
353353
add_text(summary, "Download options");
354-
// Make a list of access options
355-
const ul = add_element(details, "ul");
356-
// Full download
357-
const li1 = add_element(ul, "li");
358-
const dl_link = add_element(li1, "a");
359-
dl_link.href = download_url(path);
360-
add_text(dl_link, "Full directory download as .tar file");
361354
if(object.size >= 107374182400) {
362355
if(Object.keys(object.directories).length > 0) {
363-
add_text(li1, " ( ⚠️"+dir_size+", see subdirectories for smaller downloads)");
356+
add_text(summary, " ( ⚠️"+dir_size+", see subdirectories for smaller downloads)");
364357
} else {
365-
add_text(li1, " ( ⚠️"+dir_size+")");
358+
add_text(summary, " ( ⚠️"+dir_size+")");
366359
}
367360
} else {
368-
add_text(li1, " ("+dir_size+")");
361+
add_text(summary, " ("+dir_size+")");
369362
}
363+
// Make a list of access options
364+
const ul = add_element(details, "ul");
370365
// Access via api
371-
const li2 = add_element(ul, "li");
372-
set_inner_html(li2, "Access individual datasets using the <a href='/flamingo/service_docs/python_module.html'>hdfstream python module</a>");
366+
const li_api = add_element(ul, "li");
367+
set_inner_html(li_api, "Access individual datasets using the <a href='/flamingo/service_docs/python_module.html'>hdfstream python module</a>");
368+
// Full download
369+
const li_dl = add_element(ul, "li");
370+
const dl_link = add_element(li_dl, "a");
371+
dl_link.href = download_url(path);
372+
add_text(dl_link, "Full directory download as .tar file");
373+
// Command line download
374+
const li_cmd = add_element(ul, "li");
375+
add_text(li_cmd, "Download and unpack on the command line:");
376+
add_element(li_cmd, "br");
377+
const dl_code = add_element(add_element(li_cmd, "pre"), "code");
378+
dl_code.textContent = 'curl -u my_username -L "'+download_url(path)+'" | tar xvf -';
373379
// Access via globus
374-
const li3 = add_element(ul, "li");
375-
set_inner_html(li3, "Users with a <a href='https://cosma.readthedocs.io/en/latest'>Cosma</a> account can use <a href='https://cosma.readthedocs.io/en/latest/data.html#globus-online'>Globus Online or bbcp</a>");
380+
const li_globus = add_element(ul, "li");
381+
set_inner_html(li_globus, "Users with a <a href='https://cosma.readthedocs.io/en/latest'>Cosma</a> account can use <a href='https://cosma.readthedocs.io/en/latest/data.html#globus-online'>Globus Online or bbcp</a>");
376382
}
377383

378384
// Make a div to contain any description for this diretcory

source/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Welcome to the FLAMINGO data release documentation
77
introduction
88
service_docs/index
99
simulations/index
10+
power_spectra
1011
snapshots/index
1112
Halo catalogues <soap/index>
1213
lightcones/index
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
Reading the maps with lightcone_io
2+
==================================
3+
4+
The `lightcone_io <https://lightconeio.readthedocs.io/en/stable/>`__
5+
python module can be used to read FLAMINGO HEALPix maps, either by
6+
reading downloaded HDF5 files directly or by accessing maps stored on
7+
`Cosma <https://cosma.readthedocs.io/en/latest/>`__ using the
8+
`hdfstream <https://hdfstream-python.readthedocs.io/en/latest>`__
9+
service. The latter method might be better if you're only interested
10+
in certain quantities or regions on the sky.
11+
12+
Installation
13+
------------
14+
15+
The ``lightcone_io`` module can be installed as follows::
16+
17+
pip install lightcone_io
18+
19+
For remote access to snapshots we also need the hdfstream module::
20+
21+
pip install hdfstream
22+
23+
Opening a set of HEALPix maps
24+
-----------------------------
25+
26+
The examples below show how to access the down-sampled maps for
27+
observer 0 in the fiducial ``L1_m9`` simulation.
28+
29+
.. tab-set::
30+
31+
.. tab-item:: Opening remote files
32+
33+
.. code-block:: python
34+
35+
# Connect to the hdfstream service and open the root directory
36+
import hdfstream
37+
root = hdfstream.open("cosma", "/", user="my_username") # TODO: update when we remove access restrictions
38+
39+
# Location of the lightcone output relative to the directory we opened
40+
basedir="FLAMINGO/L1_m9/L1_m9/healpix_maps/nside_4096"
41+
42+
# Specify which observer's lightcone to read
43+
basename="lightcone0"
44+
45+
# Open the set of HEALPix maps on the server
46+
import lightcone_io as lc
47+
shell = lc.ShellArray(basedir, basename, remote_dir=root)
48+
49+
.. tab-item:: Opening local files
50+
51+
.. code-block:: python
52+
53+
# Location of the lightcone output we downloaded
54+
basedir="./FLAMINGO/L1_m9/L1_m9/healpix_maps/nside_4096/"
55+
56+
# Specify which observer's lightcone to read
57+
basename="lightcone0"
58+
59+
# Open the set of HEALPix maps
60+
import lightcone_io as lc
61+
shell = lc.ShellArray(basedir, basename)
62+
63+
Reading map data
64+
----------------
65+
66+
For each observer we have a number of :doc:`concentric shells
67+
<healpix_shell_redshifts>`, and for each shell we have maps of various
68+
:doc:`physical quantities <healpix_map_descriptions>`. The pixel data
69+
for a particular map can be accessed by specifying a shell index and
70+
the name of the map::
71+
72+
# Index of the shell we're interested in
73+
shell_nr = 0
74+
75+
# Name of the quantity we want to read
76+
map_name = "TotalMass"
77+
78+
# Read the data
79+
map_data = shell[shell_nr][map_name][...]
80+
81+
Here, indexing an individual map with the ellipsis (``[...]``)
82+
triggers the full map to be read in or downloaded. The result is a
83+
`unyt <https://unyt.readthedocs.io/en/stable/>`__ array containing the
84+
pixel values with unit information. See the `lightcone_io
85+
documentation
86+
<https://lightconeio.readthedocs.io/en/stable/healpix_maps.html>`__
87+
for more details.

source/lightcones/healpix_lightcones.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ information see the documentation links below and appendix A of
5050
File format <healpix_format>
5151
Shell redshifts <healpix_shell_redshifts>
5252
Map descriptions <healpix_map_descriptions>
53+
Reading the maps <healpix_lightcone_io>
5354
integrated_lightcones
5455

5556

@@ -65,4 +66,3 @@ information see the documentation links below and appendix A of
6566

6667

6768

68-

source/lightcones/integrated_lightcones.rst

Lines changed: 78 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,35 @@ the gravitational potential. The files correspond to integrated weak
6565
lensing convergence maps (:math:`\kappa`) that assume an
6666
non-tomographic Euclid-like source redshift distribution and are saved
6767
as ring-ordered Healpix maps at :math:`N_\mathrm{side} = 8192`. No
68-
smoothing or noise has been applied to these files. The files can be
69-
read as
68+
smoothing or noise has been applied to these files.
7069

70+
Each simulation has a subdirectory ``value_add/broxterman24`` which
71+
contains the convergence maps. For example, the maps for ``L1_m9`` are
72+
in `this directory
73+
</flamingo/viewer.html?path=FLAMINGO/L1_m9/L1_m9/value_add/broxterman24>`__. The
74+
files can be accessed using the :doc:`hdfstream
75+
</service_docs/python_module>` module or downloaded and read directly,
76+
as shown below.
7177

72-
.. code-block:: python
78+
.. tab-set::
7379

74-
import h5py
75-
file_path = '/cosma8/data/dp004/dc-brox1/FLAMINGO_datarelease/WL_convergence_Euclid_like_nz_Broxterman24_L1_m9_lc0.hdf5'
76-
data_file = h5py.File(f"/{file_path}",'r')
77-
kappa_map = data_file["Convergence"][:]
78-
data_file.close()
80+
.. tab-item:: Remote access
81+
82+
.. code-block:: python
83+
84+
import hdfstream
85+
file_path = 'FLAMINGO/L1_m9/L1_m9/value_add/broxterman24/WL_convergence_Euclid_like_nz_Broxterman24_L1_m9_lc0.hdf5'
86+
with hdfstream.open("cosma", file_path) as data_file:
87+
kappa_map = data_file["Convergence"][:]
88+
89+
.. tab-item:: Reading downloaded files
90+
91+
.. code-block:: python
92+
93+
import h5py
94+
file_path = './FLAMINGO/L1_m9/L1_m9/value_add/broxterman24/WL_convergence_Euclid_like_nz_Broxterman24_L1_m9_lc0.hdf5'
95+
with h5py.File(f"/{file_path}",'r') as data_file:
96+
kappa_map = data_file["Convergence"][:]
7997
8098
where the part ``L1_m9_lc0`` changes between the variations and lightcones (lc), for example,
8199
``L2p8_m9_DMO_lc4`` for observer four in the 2800 cGpc dark-matter-only box.
@@ -98,30 +116,63 @@ lightcone (of the 0th observer of each ``L1_m9`` simulation
98116
given). When integrating along the line of sight the on-sky
99117
coordinates of the gas particles in each shell are rotated as
100118
described in `Broxterman et al (2024)
101-
<https://ui.adsabs.harvard.edu/abs/2024MNRAS.529.2309B%2F/abstract>`__. The
102-
maps containing the X-ray emission from hot gas can be read as
119+
<https://ui.adsabs.harvard.edu/abs/2024MNRAS.529.2309B%2F/abstract>`__.
103120

104-
.. code-block:: python
121+
Each simulation has a subdirectory ``value_add/mcdonald26`` which
122+
contains the convergence maps. For example, the maps for ``L1_m9`` are
123+
in `this directory
124+
</flamingo/viewer.html?path=FLAMINGO/L1_m9/L1_m9/value_add/mcdonald26>`__. The
125+
files can be accessed using the :doc:`hdfstream
126+
</service_docs/python_module>` module or downloaded and read
127+
directly. Below, we show how to read the maps:
105128

106-
import h5py
107-
filename="/cosma8/data/dp004/dc-mcdo1/DataRelease/ROSAT_Xray_Maps/Gas_Convolved/{BoxsizeResolution}/{SimulationName}.h5"
108-
xray_source="Gas"
109-
map_name="XrayROSATIntrinsicPhotonsConvolved"
129+
.. tab-set::
130+
131+
.. tab-item:: Remote access
132+
133+
.. code-block:: python
110134
111-
with h5py.File(filename.format(BoxsizeResolution="L1000N1800", SimulationName="HYDRO_FIDUCIAL"), "r") as integrated_map:
135+
import hdfstream
112136
113-
# read ROSAT convolved photon flux X-ray map
114-
ROSAT_Xray_map=integrated_map[xray_source+'/'+map_name][:]
137+
xray_source="Gas"
138+
map_name="XrayROSATIntrinsicPhotonsConvolved"
139+
with hdfstream.open("cosma", "./FLAMINGO/L1_m9/L1_m9/value_add/mcdonald26/ROSAT_convolved_Xray_AllSky_L1_m9.hdf5", "r") as integrated_map:
115140
116-
# print simulations identifier (name) in FLAMINGO papers:
117-
print("\tFLAMINGO identifier: {label}".format(label=integrated_map[xray_source].attrs['paper_name'][:]))
141+
# read ROSAT convolved photon flux X-ray map
142+
ROSAT_Xray_map=integrated_map[xray_source+'/'+map_name][:]
118143
119-
# print integrated redshift range:
120-
lc_zmin=integrated_map[xray_source].attrs['redshift_min'] lc_zmax=integrated_map[xray_source].attrs['redshift_max']
121-
print("\tredshift range: {zmin:.3f}, {zmax:.3f}".format(zmin=lc_zmin, zmax=lc_zmax))
144+
# print simulations identifier (name) in FLAMINGO papers:
145+
print("\tFLAMINGO identifier: {label}".format(label=integrated_map[xray_source].attrs['paper_name'][:]))
122146
123-
# print expression for map units:
124-
print("\tunit expression: {map_units}".format(map_units=integrated_map[xray_source].attrs['unit_expression']))
147+
# print integrated redshift range:
148+
lc_zmin=integrated_map[xray_source].attrs['redshift_min'] lc_zmax=integrated_map[xray_source].attrs['redshift_max']
149+
print("\tredshift range: {zmin:.3f}, {zmax:.3f}".format(zmin=lc_zmin, zmax=lc_zmax))
150+
151+
# print expression for map units:
152+
print("\tunit expression: {map_units}".format(map_units=integrated_map[xray_source].attrs['unit_expression']))
153+
154+
.. tab-item:: Reading local files
155+
156+
.. code-block:: python
157+
158+
import h5py
159+
160+
xray_source="Gas"
161+
map_name="XrayROSATIntrinsicPhotonsConvolved"
162+
with h5py.File("./FLAMINGO/L1_m9/L1_m9/value_add/mcdonald26/ROSAT_convolved_Xray_AllSky_L1_m9.hdf5", "r") as integrated_map:
163+
164+
# read ROSAT convolved photon flux X-ray map
165+
ROSAT_Xray_map=integrated_map[xray_source+'/'+map_name][:]
166+
167+
# print simulations identifier (name) in FLAMINGO papers:
168+
print("\tFLAMINGO identifier: {label}".format(label=integrated_map[xray_source].attrs['paper_name'][:]))
169+
170+
# print integrated redshift range:
171+
lc_zmin=integrated_map[xray_source].attrs['redshift_min'] lc_zmax=integrated_map[xray_source].attrs['redshift_max']
172+
print("\tredshift range: {zmin:.3f}, {zmax:.3f}".format(zmin=lc_zmin, zmax=lc_zmax))
173+
174+
# print expression for map units:
175+
print("\tunit expression: {map_units}".format(map_units=integrated_map[xray_source].attrs['unit_expression']))
125176
126177
127178
@@ -136,15 +187,13 @@ to per steradian (or square degree.)
136187
import h5py
137188
import healpy as hp
138189
import unyt
139-
filename="/cosma8/data/dp004/dc-mcdo1/DataRelease/ROSAT_Xray_Maps/Gas_Convolved/{BoxsizeResolution}/{simulation}.h5"
140190
xray_source="Gas"
141191
map_name="XrayROSATIntrinsicPhotonsConvolved"
142-
with h5py.File(filename.format(BoxsizeResolution="L1000N1800", simulation="HYDRO_FIDUCIAL"), "r") as integrated_map:
192+
193+
with h5py.File("./FLAMINGO/L1_m9/L1_m9/value_add/mcdonald26/ROSAT_convolved_Xray_AllSky_L1_m9.hdf5", "r") as integrated_map:
143194
# read map
144195
ROSAT_Xray_map_per_sr=integrated_map[xray_source+'/'+map_name][:]
145-
146196
nside = integrated_map[xray_source].attrs['shell_nside'] # can take nside from map attributes, otherwise confirm from the number of pixels in the map
147197
# apply unit transformation and define map units
148198
ROSAT_Xray_map_per_sr /= hp.nside2pixarea(nside, degrees=False) * unyt.photon / unyt.s / unyt.radian**2
149199
150-

source/lightcones/particle_lightcones.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ beyond which particles are not output.
1414
File format <particle_lightcone_format>
1515
Redshift ranges <particle_lightcone_redshifts>
1616
Particle properties <particle_lightcone_properties>
17+
Reading the particles <reading_particles>

0 commit comments

Comments
 (0)