Skip to main content

Why use GalMOSS?

Fit 8,000 galaxies in just 10 minutes!

GalMOSS a Python-based, Torch-powered tool for two-dimensional fitting of galaxy profiles. By seamlessly enabling GPU parallelization, GalMOSS meets the high computational demands of large-scale galaxy surveys, placing galaxy profile fitting in the CSST/LSST-era. It incorporates widely used profiles such as the Sérsic, Exponential disk, Ferrer, King, Gaussian, and Moffat profiles, and allows for the easy integration of more complex models.

How to install

We provide two kinds of methods to download and install GalMOSS, pip and git.

Install via pip

pip install galmoss

Install via git

git clone https://github.com/Chenmi0619/GALMoss
cd galmoss
python setup.py install

You can access it by clicking on GitHub-GALMoss.

How to use

Fit sersic profile on single galaxy

Here, we demonstrate how to fit a single Sérsic profile to SDSS image data using the GALMoss package.

First, we need to load the necessary packages.

import Galmoss as gm

Next, we need to define the parameter objects and associate them with profile instances. The initial estimates of the galaxy parameters are provided by texttt{sextractor}. Notably, we do not include the boxiness parameter in this simple example, despite its availability within the GalMOSS framework.

# define parameter objects and profile

sersic = gm.lp.Sersic(
    cen_x=gm.p(65.43),
    cen_y=gm.p(64.95),
    pa=gm.p(-81.06, angle=True),
    axis_r=gm.p(0.64),
    eff_r=gm.p(7.58, pix_scale=0.396),
    ser_n=gm.p(1.53, log=True),
    mag=gm.p(17.68, M0=22.5)
)

The comprehensive dataset object can be formulated utilising the image sets (galaxy image, mask image, PSF image, sigma image) together with the chosen profiles.

dataset = gm.Dataset(
    galaxy_index="J162123.19+322056.4",
    image_path="./J162123.19+322056.4_image.fits",
    sigma_path="./J162123.19+322056.4_sigma.fits",
    psf_path="./J162123.19+322056.4_psf.fits",
    mask_path="./J162123.19+322056.4_mask.fits"
    mask_index=2,
    img_block_path="./test_repo",
    result_path="./test_repo"
)

dataset.define_profiles(sersic=sersic)

After initializing the hyperparameter during the fitting process, training could start. Subsequently, we run the uncertainty estimation process.

fitting = gm.Fitting(dataset=dataset,
                    batch_size=1,
                    iteration=1000)
fitting.fit()
fitting.uncertainty(method="covar_mat")

When the fitting process is completed, the fitted results and the img_blocks are saved in corresponding path.

Fit bulge+disk profile on multiple galaxies

Here, we demonstrate how to use a combination of two Sérsic profiles to make disk and bulge decomposition on SDSS image data using the GalMOSS package.

import Galmoss as gm

Upon importing the package, the subsequent step entails defining parameter objects. To ensure that the center parameter within both profiles remains the same, it suffices to specify the center parameter once and subsequently incorporate it into various profiles.

xcen = gm.p([65.97, 65.73])
ycen = gm.p([65.30, 64.81])

For a quick start, we let the disk and bulge profile share the initial value from the SExtractor, with an initial Sérsic index of 1 for the bulge component and 4 for the disk component.

bulge = gm.lp.Sersic(cen_x=xcen,
                    cen_y=ycen,
                    pa=gm.p([58.7, -8.44], angle=True),
                    axis_r=gm.p([0.75, 0.61709153]),
                    eff_r=gm.p([4.09, 18], pix_scale=0.396),
                    ser_n=gm.p([4, 4], log=True),
                    mag=gm.p([17.97, 15.6911], M0=22.5))

disk = gm.lp.Sersic(cen_x=xcen,
                    cen_y=ycen,
                    pa=gm.p([58.7, -8.44], angle=True),
                    axis_r=gm.p([0.75, 0.61709153]),
                    eff_r=gm.p([4.09, 18], pix_scale=0.396),
                    ser_n=gm.p([1, 1], log=True),
                    mag=gm.p([17.97, 15.6911], M0=22.5))

Compared to the single profile case, we only need to change the code of profile definition. We choose to use bootstrap to calculate the uncertainty here.

dataset = gm.DataSet(["J100247.00+042559.8", "J092800.99+014011.9"],
                image_path=["./J100247.00+042559.8_image.fits",
                            "./J092800.99+014011.9_image.fits"],
                sigma_path=["./J100247.00+042559.8_sigma.fits",
                            "./J092800.99+014011.9_sigma.fits"],
                psf_path=["./J100247.00+042559.8_psf.fits",
                        "./J092800.99+014011.9_psf.fits"],
                mask_path=["./J100247.00+042559.8_mask.fits",
                        "./J092800.99+014011.9_mask.fits"],
                img_block_path="./test_repo/",
                result_path="./test_repo/"
)
dataset.define_profiles(bulge=bulge, disk=disk)
fitting = gm.Fitting(dataset=dataset,
                    batch_size=1,
                    iteration=1000)
fitting.fit()
fitting.uncertainty(method="bstrap")

Requirements

numpy>=1.21.0

pandas>=1.4.4

torch>=2.0.1

astropy>=5.1

h5py>=3.7.0

torch-optimizer>=0.3.0

tqdm>=4.64.1

Metadata

Release files for galmoss 2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for galmoss 2.2
File Size Uploaded Provenance Actions
galmoss-2.2.tar.gz 40.1 kB Without provenance Details for galmoss-2.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for galmoss 2.2
File Interpreter ABI Platform Actions
galmoss-2.2-py3-none-any.whl Python 3 none any Details for galmoss-2.2-py3-none-any.whl

Total release size: 82.3 kB

Release files / galmoss-2.2.tar.gz

Download URL galmoss-2.2.tar.gz
Size 40.1 kB
Tags Source
SHA-256 checksum
How to use checksums
e7662d5c0db481013e12c4bdb06b14ffc77ad0c6ceff22cfb4e37a2b4411a0cb
BLAKE2b-256 checksum
How to use checksums
9dd8e9bb46f60988f0cf60fb6ae126287583f49934fbb704d6c56a13c6ebda56
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.7.5

Release files / galmoss-2.2-py3-none-any.whl

Download URL galmoss-2.2-py3-none-any.whl
Size 42.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
190e334bcc218a9025bfd74e71a0137f08260794a1fb5ba659c375835c1bf4cc
BLAKE2b-256 checksum
How to use checksums
5ecc3e5fb6627c4ebb2d30fed8a86fe1b6bde0af654e44ab6184c460eef03b26
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.7.5

Security for galmoss 2.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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