Skip to main content

ProMage

ProMage is the inference wrapper for the magnitude emulator used by GalSBI. End users provide galaxy physical properties and requested bands; ProMage loads opaque TorchScript resources and returns emulated magnitudes.

The public API intentionally does not expose the neural-network architecture, activation function, training loop, or scalers.

Each emulator instance is bound to one ProSpect star-formation-history (SFH) model. The SFH model passed to ProMage must be the same SFH model used to create the galaxy properties. Current resources provide massfunc_snorm_trunc; future resources can also contain massfunc_snorm_burst_trunc.

Installation

Install the released package from PyPI with:

pip install promage

For development, install a local checkout in editable mode:

pip install -e .

If the Python environment has no network access but already contains the build dependencies, use:

pip install -e . --no-build-isolation

The magnitude-emulator resources are distributed separately through cosmo-torrent. In GalSBI-SPS, load them with data_path("ProMage_res").

Basic Usage

from promage import ProMage
from cosmo_torrent import data_path

emu = ProMage(
    data_path("ProMage_res"),
    sfh_model="massfunc_snorm_trunc",
)

mags = emu.predict(
    properties=properties,
    bands=["g_HSC", "r_HSC", "i_HSC"],
)

SFH-aware resources require sfh_model; omitting it or requesting an unavailable family raises an error rather than silently loading the wrong network. The selected family and all families in the resource can be inspected with emu.sfh_model and emu.available_sfh_models.

By default, predict uses frame="observed" and returns final observer-frame magnitudes. For artifacts trained as m_obs - DM(z), ProMage adds the fixed training distance modulus internally.

mags is a dictionary mapping each requested band to a NumPy array with the same shape as the input property arrays.

Absolute Magnitudes

Absolute/rest-frame magnitudes are requested with frame="absolute":

mags_abs = emu.predict(
    properties=properties,
    bands=["g_HSC", "r_HSC", "i_HSC"],
    frame="absolute",
)

Absolute-frame artifacts are trained directly on the ProSpect absolute_magnitudes dataset. No distance-modulus correction is applied to absolute-frame outputs.

Available frames and bands can be inspected with:

print(emu.available_frames)
print(emu.available_roles)
print(emu.available_bands)

Selection Magnitudes

Some resources include a threshold-selection role. This is separate from the default precision magnitude emulators and is intended for broad sample selection over the full redshift range. The current massfunc_snorm_trunc resource was trained around an HSC i_HSC = 32 threshold:

i_selection = emu.predict(
    properties=properties,
    bands=["i_HSC"],
    role="selection",
)["i_HSC"]

threshold = emu.selection_threshold("i_HSC")
selected = i_selection < threshold

The default role is role="magnitude", so existing calls to predict(...) are unchanged. The selection role should not be treated as the final precision magnitude estimate for all downstream photometry.

Inputs

The resource manifest defines the required properties. Current ProSpect Latin-hypercube resources use:

[
    "z",
    "logmSFR",
    "mpeak",
    "logmperiod",
    "mskew",
    "logZfinal",
    "logtaubirth",
    "logtauscreen",
    "alphabirth",
    "alphascreen",
    "logU",
]

All arrays must have the same shape. Redshifts must lie inside the resource domain, typically 0 < z <= 5.

Return Formats

The default return format is a dictionary:

{
    "g_HSC": np.ndarray,
    "r_HSC": np.ndarray,
    "i_HSC": np.ndarray,
}

An array can be requested with:

mag_array = emu.predict(
    properties=properties,
    bands=["g_HSC", "r_HSC", "i_HSC"],
    return_format="array",
)

The final axis follows the order of the requested bands.

Resource Directory

ProMage(...) expects a directory containing a manifest.json and TorchScript .pt artifacts.

An SFH-aware resource directory looks like:

manifest.json
models/
  massfunc_snorm_trunc/
    observed/
      magnitude/
        g_HSC/
          z0p0_0p5.pt
          z0p5_1p0.pt
          ...
        r_HSC/
          ...
      selection/
        i_HSC/
          z0p0_5p0.pt
    absolute/
      magnitude/
        g_HSC/
          z0p0_0p5.pt
          z0p5_1p0.pt
          ...
        r_HSC/
          ...
  massfunc_snorm_burst_trunc/
    ...

SFH families, observer-frame artifacts, and absolute-frame artifacts can coexist in the same ProMage_res directory because each has a distinct model path.

Legacy manifests without explicit SFH families remain supported through ProMage(resource_dir). They cannot be safely assigned to a named SFH at load time; regenerate those resources to obtain an SFH-aware manifest. Legacy manifests without explicit roles are treated as role="magnitude".

Cosmology

The training data use a fixed flat LambdaCDM cosmology:

H0 = 67.8
Omega_M = 0.308
Tcmb0 = 2.725

The package uses Astropy:

from astropy.cosmology import FlatLambdaCDM

FlatLambdaCDM(H0=67.8, Om0=0.308, Tcmb0=2.725)

The distance-modulus correction is applied only for observer-frame artifacts whose target convention is obs_minus_dm.

Out-of-Range Redshifts

By default, ProMage raises an error if a redshift is outside the manifest domain:

emu = ProMage(
    data_path("ProMage_res"),
    sfh_model="massfunc_snorm_trunc",
    on_out_of_range="raise",
)

To leave out-of-range predictions as NaN:

emu = ProMage(
    data_path("ProMage_res"),
    sfh_model="massfunc_snorm_trunc",
    on_out_of_range="nan",
)

License

ProMage is distributed under the MIT License. See LICENSE.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

promage-0.2.0.tar.gz (16.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

promage-0.2.0-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

Details for the file promage-0.2.0.tar.gz.

File metadata

  • Download URL: promage-0.2.0.tar.gz
  • Upload date:
  • Size: 16.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.11.11

File hashes

Hashes for promage-0.2.0.tar.gz
Algorithm Hash digest
SHA256 c9c7bb5715eddcb0732bfb07fc43ec119a5b7da1956101db3e456e35b5add8bb
MD5 f47460ea9e406a182886d161c4ffb0e0
BLAKE2b-256 c405657cccd87a8810616a2ccdf42f24a47008f31a0ded1ddb42c5868d9c4328

See more details on using hashes here.

File details

Details for the file promage-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: promage-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 11.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.11.11

File hashes

Hashes for promage-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a156bfa02530f9ad499ce4635b40bdc32ee986aa6b01d3b7b2e1bb06ee0be8fa
MD5 c14e349dbf9ed70f947e8f6d4849679e
BLAKE2b-256 29f39a5ef6abf37160d27dbfa9b23375e7938ed79dd6da66089472013e4cd61a

See more details on using hashes here.

Release history Release notifications | RSS feed

0.4.0

2 files

0.3.0

2 files

This release

0.2.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page