galmoss


Namegalmoss JSON
Version 2.2 PyPI version JSON
download
home_pagehttps://github.com/Chenmi0619/GALMoss
SummaryA 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.
upload_time2024-11-10 16:16:30
maintainerNone
docs_urlNone
authorChen Mi
requires_python>=3.9
licenseNone
keywords astronomy data analysis astronomy toolbox galaxy profile fitting
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
.. image:: repo/logo.jpg
   :alt: 

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
---------------

.. code-block:: python

    pip install galmoss


Install via git
---------------

.. code-block:: python

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

You can access it by clicking on   `GitHub-GALMoss <https://github.com/Chenmi0619/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 <https://github.com/Chenmi0619/GALMoss/tree/main/repo/dataset>`_ using the GALMoss package.

First, we need to load the necessary packages.

.. code-block:: python

    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.

.. code-block:: python

    # 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.

.. code-block:: python

    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.

.. code-block:: python

    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.


.. code-block:: python
    
    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.

.. code-block:: python

    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.

.. code-block:: python

    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.                        

.. code-block:: python

    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

   

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Chenmi0619/GALMoss",
    "name": "galmoss",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "Astronomy data analysis, Astronomy toolbox, Galaxy profile fitting",
    "author": "Chen Mi",
    "author_email": "chenmiastro@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/9d/d8/e9bb46f60988f0cf60fb6ae126287583f49934fbb704d6c56a13c6ebda56/galmoss-2.2.tar.gz",
    "platform": null,
    "description": "\n.. image:: repo/logo.jpg\n   :alt: \n\nWhy use GalMOSS?  \n===================================\n\n**Fit 8,000 galaxies in just 10 minutes!**\n\n**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\u00e9rsic, Exponential disk, Ferrer, King, Gaussian, and Moffat profiles, and allows for the easy integration of more complex models. \n\nHow to install \n===============\nWe provide two kinds of methods to download and install **GalMOSS**, pip and git.\n\nInstall via pip\n---------------\n\n.. code-block:: python\n\n    pip install galmoss\n\n\nInstall via git\n---------------\n\n.. code-block:: python\n\n    git clone https://github.com/Chenmi0619/GALMoss\n    cd galmoss\n    python setup.py install\n\nYou can access it by clicking on   `GitHub-GALMoss <https://github.com/Chenmi0619/GALMoss>`_.\n\n\nHow to use\n===========\n\nFit sersic profile on single galaxy\n------------------------------------\n\nHere, we demonstrate how to fit a single S\u00e9rsic profile to `SDSS image data <https://github.com/Chenmi0619/GALMoss/tree/main/repo/dataset>`_ using the GALMoss package.\n\nFirst, we need to load the necessary packages.\n\n.. code-block:: python\n\n    import Galmoss as gm\n\n\nNext, 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.\n\n.. code-block:: python\n\n    # define parameter objects and profile\n\n    sersic = gm.lp.Sersic(\n        cen_x=gm.p(65.43),\n        cen_y=gm.p(64.95),\n        pa=gm.p(-81.06, angle=True), \n        axis_r=gm.p(0.64),\n        eff_r=gm.p(7.58, pix_scale=0.396),\n        ser_n=gm.p(1.53, log=True),\n        mag=gm.p(17.68, M0=22.5)\n    )\n\n\n\n\nThe comprehensive dataset object can be formulated utilising the image sets (galaxy image, mask image, PSF image, sigma image) together with the chosen profiles.\n\n.. code-block:: python\n\n    dataset = gm.Dataset(\n        galaxy_index=\"J162123.19+322056.4\",\n        image_path=\"./J162123.19+322056.4_image.fits\",\n        sigma_path=\"./J162123.19+322056.4_sigma.fits\",\n        psf_path=\"./J162123.19+322056.4_psf.fits\",\n        mask_path=\"./J162123.19+322056.4_mask.fits\"\n        mask_index=2,\n        img_block_path=\"./test_repo\",\n        result_path=\"./test_repo\"    \n    )\n\n    dataset.define_profiles(sersic=sersic)\n\n\n\nAfter initializing the hyperparameter during the fitting process, training could start. Subsequently, we run the uncertainty estimation process.\n\n.. code-block:: python\n\n    fitting = gm.Fitting(dataset=dataset, \n                        batch_size=1, \n                        iteration=1000)\n    fitting.fit()\n    fitting.uncertainty(method=\"covar_mat\")\n\n\n\nWhen the fitting process is completed, the fitted results and the img\\_blocks are saved in corresponding path.\n\nFit bulge\\+disk profile on multiple galaxies\n---------------------------------------------\n\nHere, we demonstrate how to use a combination of two S\u00e9rsic profiles to make disk and bulge decomposition on SDSS image data using the **GalMOSS** package.\n\n\n.. code-block:: python\n    \n    import Galmoss as gm\n\nUpon 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.\n\n.. code-block:: python\n\n    xcen = gm.p([65.97, 65.73])\n    ycen = gm.p([65.30, 64.81])\n\nFor a quick start, we let the disk and bulge profile share the initial value from the SExtractor, with an initial S\u00e9rsic index of 1 for the bulge component and 4 for the disk component.\n\n.. code-block:: python\n\n    bulge = gm.lp.Sersic(cen_x=xcen, \n                        cen_y=ycen, \n                        pa=gm.p([58.7, -8.44], angle=True), \n                        axis_r=gm.p([0.75, 0.61709153]), \n                        eff_r=gm.p([4.09, 18], pix_scale=0.396), \n                        ser_n=gm.p([4, 4], log=True), \n                        mag=gm.p([17.97, 15.6911], M0=22.5))\n\n    disk = gm.lp.Sersic(cen_x=xcen, \n                        cen_y=ycen, \n                        pa=gm.p([58.7, -8.44], angle=True), \n                        axis_r=gm.p([0.75, 0.61709153]),  \n                        eff_r=gm.p([4.09, 18], pix_scale=0.396), \n                        ser_n=gm.p([1, 1], log=True), \n                        mag=gm.p([17.97, 15.6911], M0=22.5))\n\nCompared 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.                        \n\n.. code-block:: python\n\n    dataset = gm.DataSet([\"J100247.00+042559.8\", \"J092800.99+014011.9\"],\n                    image_path=[\"./J100247.00+042559.8_image.fits\",\n                                \"./J092800.99+014011.9_image.fits\"],\n                    sigma_path=[\"./J100247.00+042559.8_sigma.fits\",\n                                \"./J092800.99+014011.9_sigma.fits\"],\n                    psf_path=[\"./J100247.00+042559.8_psf.fits\",\n                            \"./J092800.99+014011.9_psf.fits\"],\n                    mask_path=[\"./J100247.00+042559.8_mask.fits\", \n                            \"./J092800.99+014011.9_mask.fits\"],\n                    img_block_path=\"./test_repo/\",\n                    result_path=\"./test_repo/\"\n    )\n    dataset.define_profiles(bulge=bulge, disk=disk)\n    fitting = gm.Fitting(dataset=dataset, \n                        batch_size=1, \n                        iteration=1000)\n    fitting.fit()\n    fitting.uncertainty(method=\"bstrap\")\n\n\nRequirements\n=============\nnumpy>=1.21.0\n\npandas>=1.4.4\n\ntorch>=2.0.1\n\nastropy>=5.1\n\nh5py>=3.7.0\n\ntorch-optimizer>=0.3.0\n\ntqdm>=4.64.1\n\n   \n",
    "bugtrack_url": null,
    "license": null,
    "summary": "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.",
    "version": "2.2",
    "project_urls": {
        "Homepage": "https://github.com/Chenmi0619/GALMoss"
    },
    "split_keywords": [
        "astronomy data analysis",
        " astronomy toolbox",
        " galaxy profile fitting"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5ecc3e5fb6627c4ebb2d30fed8a86fe1b6bde0af654e44ab6184c460eef03b26",
                "md5": "e1b1dd384f6ab009337159b0f00e02ab",
                "sha256": "190e334bcc218a9025bfd74e71a0137f08260794a1fb5ba659c375835c1bf4cc"
            },
            "downloads": -1,
            "filename": "galmoss-2.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e1b1dd384f6ab009337159b0f00e02ab",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 42168,
            "upload_time": "2024-11-10T16:16:29",
            "upload_time_iso_8601": "2024-11-10T16:16:29.153748Z",
            "url": "https://files.pythonhosted.org/packages/5e/cc/3e5fb6627c4ebb2d30fed8a86fe1b6bde0af654e44ab6184c460eef03b26/galmoss-2.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9dd8e9bb46f60988f0cf60fb6ae126287583f49934fbb704d6c56a13c6ebda56",
                "md5": "0806cc7ff29cb20926a26927afd9418d",
                "sha256": "e7662d5c0db481013e12c4bdb06b14ffc77ad0c6ceff22cfb4e37a2b4411a0cb"
            },
            "downloads": -1,
            "filename": "galmoss-2.2.tar.gz",
            "has_sig": false,
            "md5_digest": "0806cc7ff29cb20926a26927afd9418d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 40095,
            "upload_time": "2024-11-10T16:16:30",
            "upload_time_iso_8601": "2024-11-10T16:16:30.406348Z",
            "url": "https://files.pythonhosted.org/packages/9d/d8/e9bb46f60988f0cf60fb6ae126287583f49934fbb704d6c56a13c6ebda56/galmoss-2.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-10 16:16:30",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Chenmi0619",
    "github_project": "GALMoss",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "galmoss"
}
        
Elapsed time: 0.49111s