Skip to main content

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.

Project description

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

Project details


Download files

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

Source Distribution

galmoss-2.2.tar.gz (40.1 kB view details)

Uploaded Source

Built Distribution

galmoss-2.2-py3-none-any.whl (42.2 kB view details)

Uploaded Python 3

File details

Details for the file galmoss-2.2.tar.gz.

File metadata

  • Download URL: galmoss-2.2.tar.gz
  • Upload date:
  • Size: 40.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.5

File hashes

Hashes for galmoss-2.2.tar.gz
Algorithm Hash digest
SHA256 e7662d5c0db481013e12c4bdb06b14ffc77ad0c6ceff22cfb4e37a2b4411a0cb
MD5 0806cc7ff29cb20926a26927afd9418d
BLAKE2b-256 9dd8e9bb46f60988f0cf60fb6ae126287583f49934fbb704d6c56a13c6ebda56

See more details on using hashes here.

File details

Details for the file galmoss-2.2-py3-none-any.whl.

File metadata

  • Download URL: galmoss-2.2-py3-none-any.whl
  • Upload date:
  • Size: 42.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.5

File hashes

Hashes for galmoss-2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 190e334bcc218a9025bfd74e71a0137f08260794a1fb5ba659c375835c1bf4cc
MD5 e1b1dd384f6ab009337159b0f00e02ab
BLAKE2b-256 5ecc3e5fb6627c4ebb2d30fed8a86fe1b6bde0af654e44ab6184c460eef03b26

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page