Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build_documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: '3.10'
python-version: '3.11'
- name: Install dependencies
run: |
sudo apt-get update
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/smoke-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.9', '3.10', '3.11']
python-version: ['3.11', '3.12']

steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/testing-and-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.9', '3.10', '3.11']
python-version: ['3.11', '3.12']

steps:
- uses: actions/checkout@v3
Expand Down
23 changes: 11 additions & 12 deletions src/rail/creation/engines/fsps_photometry_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import numpy as np
from astropy.cosmology import Planck15, w0waCDM
from ceci.config import StageParameter as Param
from rail.core.common_params import SHARED_PARAMS
from rail.core.data import Hdf5Handle
from rail.core.stage import RailStage
from rail.creation.engine import Creator
Expand All @@ -29,12 +30,7 @@ class FSPSPhotometryCreator(Creator):
)
config_options = RailStage.config_options.copy()
config_options.update(
redshift_key=Param(
str,
"redshifts",
msg="Redshift keyword name of the hdf5 dataset "
"containing rest-frame SEDs",
),
redshift_key=SHARED_PARAMS,
restframe_sed_key=Param(
str,
"restframe_seds",
Expand All @@ -60,7 +56,7 @@ class FSPSPhotometryCreator(Creator):
instrument_name=Param(
str, "lsst", msg="Instrument name as prefix to filter transmission" " files"
),
wavebands=Param(str, "u,g,r,i,z,y", msg="Comma-separated list of wavebands"),
wavebands=Param(list, ['u','g','r','i','z','y'], msg="Comma-separated list of wavebands"),
filter_wave_key=Param(str, "wave", msg=""),
filter_transm_key=Param(str, "transmission", msg=""),
Om0=Param(float, 0.3, msg="Omega matter at current time"),
Expand All @@ -79,8 +75,11 @@ class FSPSPhotometryCreator(Creator):
False,
msg="True to overwrite the cosmological parameters to their Planck2015 values",
),
physical_units=Param(bool, False),
msg="False (True) for rest-frame spectra in units of" "Lsun/Hz (erg/s/Hz)",
physical_units=Param(
bool,
False,
msg="False (True) for rest-frame spectra in units of" "Lsun/Hz (erg/s/Hz)",
),
)

inputs = [("model", Hdf5Handle)]
Expand All @@ -100,7 +99,7 @@ def __init__(self, args, **kwargs):

if not os.path.isdir(self.config.filter_folder):
raise OSError("File {self.config.filter_folder} not found")
self.wavebands = self.config.wavebands.split(",")
self.wavebands = self.config.wavebands.copy()
filter_wavelengths, filter_transmissions = [], []
for waveband in self.wavebands:
with h5py.File(
Expand Down Expand Up @@ -201,13 +200,13 @@ def _compute_apparent_magnitudes(
fill_value=0,
)
filt_interp = interp_function(observedframe_wavelength_in_Hz)
numerator = np.trapz(
numerator = np.trapezoid(
observedframe_sed_erg_s_cm2_Hz
* filt_interp
/ observedframe_wavelength,
x=observedframe_wavelength,
)
denominator = np.trapz(
denominator = np.trapezoid(
filt_interp / observedframe_wavelength, x=observedframe_wavelength
)
mag_ab = -2.5 * np.log10(numerator / denominator) - 48.6
Expand Down
20 changes: 12 additions & 8 deletions src/rail/creation/engines/fsps_sed_modeler.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from ceci.config import StageParameter as Param
from rail.core.common_params import SHARED_PARAMS
from rail.core.data import Hdf5Handle
from rail.core.stage import RailStage
from rail.creation.engine import Modeler
Expand Down Expand Up @@ -44,8 +45,8 @@ class FSPSSedModeler(Modeler):
config_options = RailStage.config_options.copy()

config_options.update(
chunk_size=10000,
hdf5_groupname=str,
chunk_size=SHARED_PARAMS,
hdf5_groupname=SHARED_PARAMS,
compute_vega_mags=Param(
bool, False, msg="True uses Vega magnitudes versus AB magnitudes"
),
Expand Down Expand Up @@ -126,7 +127,7 @@ class FSPSSedModeler(Modeler):
redshifts_key=Param(
str, "redshifts", msg="galaxy redshift, dataset keyword name"
),
zmet_key=Param(
Z_met_key=Param(
str,
"zmet",
msg=" The metallicity is specified as an integer ranging "
Expand Down Expand Up @@ -188,8 +189,8 @@ class FSPSSedModeler(Modeler):
"stellar_velocity_dispersion",
msg="stellar velocity dispersions (km/s), " "dataset keyword name",
),
min_wavelength=Param(float, 3000, msg="minimum rest-frame wavelength"),
max_wavelength=Param(float, 10000, msg="maximum rest-frame wavelength"),
min_wavelength=SHARED_PARAMS,
max_wavelength=SHARED_PARAMS,
gas_ionizations_key=Param(
str, "gas_ionization", msg="gas ionization values dataset keyword name"
),
Expand Down Expand Up @@ -383,8 +384,11 @@ class FSPSSedModeler(Modeler):
tabulated_lsf_key=Param(
str, "tabulated_lsf", msg="tabulated LSF dataset keyword name"
),
physical_units=Param(bool, False),
msg="False (True) for rest-frame spectra in units of" "Lsun/Hz (erg/s/Hz)",
physical_units=Param(
bool,
False,
msg="False (True) for rest-frame spectra in units of" "Lsun/Hz (erg/s/Hz)",
),
restframe_wave_key=Param(
str,
"restframe_wavelengths",
Expand Down Expand Up @@ -773,7 +777,7 @@ def _process_chunk(self, start, end, data, first):
velocity_dispersions = data[self.config.velocity_dispersions_key][()]
gas_ionizations = data[self.config.gas_ionizations_key][()]
gas_metallicities = data[self.config.gas_metallicities_key][()]
zmet = data[self.config.zmet_key][()]
zmet = data[self.config.Z_met_key][()]
pmetals = data[self.config.pmetals_key][()]
tau = data[self.config.tau_key][()]
const = data[self.config.const_key][()]
Expand Down
11 changes: 5 additions & 6 deletions tests/creation/test_fsps_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ def test_FSPSSedModeler_bad_min_wavelength(settings, error):
@pytest.mark.parametrize(
"settings,error",
[
({"min_wavelength": 3000}, ValueError),
({"max_wavelength": 1000}, ValueError),
({"min_wavelength": 3000, "max_wavelength": 1000}, ValueError),
],
)
def test_FSPSSedModeler_bad_max_wavelength(settings, error):
Expand Down Expand Up @@ -185,7 +184,7 @@ def test_FSPSPhotometryCreator():
apparent_mags_key="apparent_mags",
filter_folder=os.path.join(default_rail_fsps_files_folder, "filters"),
instrument_name="lsst",
wavebands="u,g,r,i,z,y",
wavebands=['u','g','r','i','z','y'],
filter_wave_key="wave",
filter_transm_key="transmission",
Om0=0.3,
Expand Down Expand Up @@ -215,7 +214,7 @@ def test_FSPSPhotometryCreator_noPlanck():
apparent_mags_key="apparent_mags",
filter_folder=os.path.join(default_rail_fsps_files_folder, "filters"),
instrument_name="lsst",
wavebands="u,g,r,i,z,y",
wavebands=['u','g','r','i','z','y'],
filter_wave_key="wave",
filter_transm_key="transmission",
Om0=0.3,
Expand Down Expand Up @@ -268,7 +267,7 @@ def test_FSPSSedModeler():
fbhb=0.0,
pagb=1.0,
redshifts_key="redshifts",
zmet_key="zmet",
Z_met_key="zmet",
stellar_metallicities_key="stellar_metallicity",
pmetals_key="pmetals",
imf_type=1,
Expand Down Expand Up @@ -364,7 +363,7 @@ def test_FSPSSedModeler_smooth_lsf():
fbhb=0.0,
pagb=1.0,
redshifts_key="redshifts",
zmet_key="zmet",
Z_met_key="zmet",
stellar_metallicities_key="stellar_metallicity",
pmetals_key="pmetals",
imf_type=1,
Expand Down
Loading