I/O¶
Readers and writers for tabulated inputs and outputs. Unit conversions belong here, at the I/O boundary — never in the physics or numerics layers.
Readers¶
liulu.io.readers.read_columns ¶
Read columnar data from a text file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Path to file. |
required |
usecols
|
tuple of int
|
Column indices to read. |
None
|
skiprows
|
int
|
Number of header rows to skip. |
0
|
delimiter
|
str
|
Column delimiter. None = whitespace. |
None
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Data array, shape (n_rows, n_cols) or (n_rows,) if single column. |
Source code in liulu/io/readers.py
liulu.io.readers.read_xi_table ¶
Read a tabulated xi(r) file.
Returns:
| Name | Type | Description |
|---|---|---|
r |
ndarray
|
Separation, Mpc/h. |
xi |
ndarray
|
Correlation function. |
Source code in liulu/io/readers.py
liulu.io.readers.read_moments_table ¶
read_moments_table(filename, r_col=0, vr_col=1, sr_col=2, st_col=3, gr_col=None, kr_col=None, kt_col=None, **kwargs)
Read a tabulated pairwise velocity moments file.
Returns:
| Type | Description |
|---|---|
dict
|
Keys: 'r', 'v_r', 'sigma_r', 'sigma_t', and optionally 'gamma_r', 'kappa_r', 'kappa_t'. |
Source code in liulu/io/readers.py
liulu.io.readers.read_pk_table ¶
Read a tabulated P(k) file.
Returns:
| Name | Type | Description |
|---|---|---|
k |
ndarray
|
Wavenumbers, h/Mpc. |
pk |
ndarray
|
Power spectrum, (Mpc/h)^3. |
Source code in liulu/io/readers.py
Writers¶
liulu.io.writers.write_xi_2d ¶
Write 2D xi^s(s_perp, s_par) to file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Output path. |
required |
s_perp
|
ndarray
|
Unique s_perp values. |
required |
s_par
|
ndarray
|
Unique s_par values. |
required |
xi_s
|
(ndarray, shape(len(s_perp), len(s_par)))
|
2D correlation function. |
required |
header
|
str
|
Optional header string. |
''
|
Source code in liulu/io/writers.py
liulu.io.writers.write_multipoles ¶
Write multipoles to file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Output path. |
required |
s
|
ndarray
|
Separation values. |
required |
multipoles_dict
|
dict
|
{ell: xi_ell(s)} dictionary. |
required |
header
|
str
|
Optional header string. |
''
|