pz-rail-dnf


Namepz-rail-dnf JSON
Version 1.1.6 PyPI version JSON
download
home_pageNone
SummaryNone
upload_time2025-07-11 21:24:41
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseMIT License Copyright (c) 2023 LSST Dark Energy Science Collaboration (DESC) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # rail_dnf

[![Template](https://img.shields.io/badge/Template-LINCC%20Frameworks%20Python%20Project%20Template-brightgreen)](https://lincc-ppt.readthedocs.io/en/latest/)
[![codecov](https://codecov.io/gh/LSSTDESC/rail_dnf/branch/main/graph/badge.svg)](https://codecov.io/gh/LSSTDESC/rail_dnf)
[![PyPI](https://img.shields.io/pypi/v/pz-rail-dnf?color=blue&logo=pypi&logoColor=white)](https://pypi.org/project/pz-rail-dnf/)

## DNF: Directional Neighbourhood Fitting

DNF is a nearest-neighbor approach for photometric redshift estimation developed at the CIEMAT (Centro de Investigaciones Energéticas, Medioambientales y Tecnológicas). DNF computes the photo-z hyperplane that best fits the directional neighbourhood of a photometric galaxy in the training sample. A detailed description of DNF is available [here](https://arxiv.org/abs/1511.07623).

If you have any questions or suggestions, please don't hesitate to contact us at laura.toribio@ciemat.es and/or juan.vicente@ciemat.es.

The current version of the code for `RAIL`consists of a training stage, `DNFInformer` and a estimation stage `DNFEstimator`. `DNFInformer` is a class that preprocesses the protometric data, handles missing or non-detected values, and trains a firts basic k-Nearest Neighbors regressor for redshift prediction. The `DNFEstimator` calculates photometric redshifts based on an enhancement of Nearest Neighbor techniques. The class supports three main metrics for redshift estimation: ENF, ANF or DNF.

- **ENF**: Euclidean neighbourhood. It's a common distance metric used in kNN (k-Nearest Neighbors) for photometric redshift prediction.
- **ANF**: uses normalized inner product for more accurate photo-z predictions. It is particularly **recommended** when working with datasets containing more than four filters. Use normalized inner product for more accurate photo-z predictions when signal/noise is good enough.
- **DNF**: combines Euclidean and angular metrics, improving accuracy, especially for larger neighborhoods, and maintaining proportionality in observable content.


### `DNFInformer`

The `DNFInformer` class processes a training dataset and produces a model file containing the computed magnitudes, colors, and their associated errors for the dataset. This model is then utilized in the `DNFEstimator` stage for photometric redshift estimation. Missing photometric detections (non-detections) are handled by replacing them with a configurable placeholder value, or optionally ignoring them during model training.

The configurable parameters for `DNFInformer` include:

- `bands`: List of band names expected in the input dataset.
- `err_bands`: List of magnitude error column names corresponding to the bands.
- `redshift_col`: String indicating the name of the redshift column in the input data.
- `mag_limits`: Dictionary with band names as keys and floats representing the acceptable magnitude range for each band.
- `nondetect_val`: Float or np.nan, the value indicating a non-detection, which will be replaced by the values in mag_limits.
- `replace_nondetect`: Boolean; if True, non-detections are replaced with the specified nondetect_val. If False, non-detections are ignored during the neighbor-finding process.


### `DNFEstimator`

The `DNFEstimator` class uses the model generated by DNFInformer to compute photometric redshifts for new datasets and the PDFs. It identifies the nearest neighbors from the training data using various distance metrics and estimates redshifts based on these neighbors.

The configurable parameters for `DNFEstimator` include:

- `bands`, `err_bands`, `redshift_col`, `nondetect_val`, `mag_limits`: As described for `DNFInformer`.
- `selection_mode`: Integer indicating the method for neighbor selection:
    * `0`: Euclidean Neighbourhood Fitting (ENF).
    * `1`: Angular Neighbourhood Fitting (ANF).
    * `2`: Directional Neighbourhood Fitting (DNF).
- `zmin`, `zmax`, `nzbins`: Float values defining the minimum and maximum redshift range and the number of bins for estimation of the PDFs.
- `pdf_estimation`: Boolean; if True, computes a probability density function (PDF) for the redshift of each object.

DNF calculates its own point estimate, `DNF_Z`, which is stored in the qp Ensemble `ancil` data. Also, DNF calculates other photo-zs called `DNF_ZN`.

- `DNF_Z` represents the photometric redshift for each galaxy computed as the weighted average or hyperplane fit (depending on the option selected) for a set of neighbors determined by a specific metric (ENF, ANF, DNF) where the outliers are removed

- `DNF_ZN` represents the photometric redshift using only the closest neighbor. It is mainly used for computing the redshift distributions.

## RAIL: Redshift Assessment Infrastructure Layers

This package is part of the larger ecosystem of Photometric Redshifts
in [RAIL](https://github.com/LSSTDESC/RAIL).

### Citing RAIL

This code, while public on GitHub, has not yet been released by DESC and is
still under active development. Our release of v1.0 will be accompanied by a
journal paper describing the development and validation of RAIL.

If you make use of the ideas or software in RAIL, please cite the repository 
<https://github.com/LSSTDESC/RAIL>. You are welcome to re-use the code, which
is open source and available under terms consistent with the MIT license.

External contributors and DESC members wishing to use RAIL for non-DESC projects
should consult with the Photometric Redshifts (PZ) Working Group conveners,
ideally before the work has started, but definitely before any publication or 
posting of the work to the arXiv.

### Citing this package
Users of rail_dnf can cite [De Vicente, Sanchez, & Sevilla-Noarbe](https://ui.adsabs.harvard.edu/abs/2016MNRAS.459.3078D/abstract)
If you use this package, you should also cite the appropriate papers for each
code used.  A list of such codes is included in the 
[Citing RAIL](https://lsstdescrail.readthedocs.io/en/stable/source/citing.html)
section of the main RAIL Read The Docs page.


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "pz-rail-dnf",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": null,
    "author": null,
    "author_email": "\"LSST Dark Energy Science Collaboration (DESC)\" <laura.toribio@ciemat.es>",
    "download_url": "https://files.pythonhosted.org/packages/6c/83/c4dbfc92680495eeb7abb1d0611ee7f101fc3faa484aba71d81884b912aa/pz_rail_dnf-1.1.6.tar.gz",
    "platform": null,
    "description": "# rail_dnf\n\n[![Template](https://img.shields.io/badge/Template-LINCC%20Frameworks%20Python%20Project%20Template-brightgreen)](https://lincc-ppt.readthedocs.io/en/latest/)\n[![codecov](https://codecov.io/gh/LSSTDESC/rail_dnf/branch/main/graph/badge.svg)](https://codecov.io/gh/LSSTDESC/rail_dnf)\n[![PyPI](https://img.shields.io/pypi/v/pz-rail-dnf?color=blue&logo=pypi&logoColor=white)](https://pypi.org/project/pz-rail-dnf/)\n\n## DNF: Directional Neighbourhood Fitting\n\nDNF is a nearest-neighbor approach for photometric redshift estimation developed at the CIEMAT (Centro de Investigaciones Energ\u00e9ticas, Medioambientales y Tecnol\u00f3gicas). DNF computes the photo-z hyperplane that best fits the directional neighbourhood of a photometric galaxy in the training sample. A detailed description of DNF is available [here](https://arxiv.org/abs/1511.07623).\n\nIf you have any questions or suggestions, please don't hesitate to contact us at laura.toribio@ciemat.es and/or juan.vicente@ciemat.es.\n\nThe current version of the code for `RAIL`consists of a training stage, `DNFInformer` and a estimation stage `DNFEstimator`. `DNFInformer` is a class that preprocesses the protometric data, handles missing or non-detected values, and trains a firts basic k-Nearest Neighbors regressor for redshift prediction. The `DNFEstimator` calculates photometric redshifts based on an enhancement of Nearest Neighbor techniques. The class supports three main metrics for redshift estimation: ENF, ANF or DNF.\n\n- **ENF**: Euclidean neighbourhood. It's a common distance metric used in kNN (k-Nearest Neighbors) for photometric redshift prediction.\n- **ANF**: uses normalized inner product for more accurate photo-z predictions. It is particularly **recommended** when working with datasets containing more than four filters. Use normalized inner product for more accurate photo-z predictions when signal/noise is good enough.\n- **DNF**: combines Euclidean and angular metrics, improving accuracy, especially for larger neighborhoods, and maintaining proportionality in observable content.\n\n\n### `DNFInformer`\n\nThe `DNFInformer` class processes a training dataset and produces a model file containing the computed magnitudes, colors, and their associated errors for the dataset. This model is then utilized in the `DNFEstimator` stage for photometric redshift estimation. Missing photometric detections (non-detections) are handled by replacing them with a configurable placeholder value, or optionally ignoring them during model training.\n\nThe configurable parameters for `DNFInformer` include:\n\n- `bands`: List of band names expected in the input dataset.\n- `err_bands`: List of magnitude error column names corresponding to the bands.\n- `redshift_col`: String indicating the name of the redshift column in the input data.\n- `mag_limits`: Dictionary with band names as keys and floats representing the acceptable magnitude range for each band.\n- `nondetect_val`: Float or np.nan, the value indicating a non-detection, which will be replaced by the values in mag_limits.\n- `replace_nondetect`: Boolean; if True, non-detections are replaced with the specified nondetect_val. If False, non-detections are ignored during the neighbor-finding process.\n\n\n### `DNFEstimator`\n\nThe `DNFEstimator` class uses the model generated by DNFInformer to compute photometric redshifts for new datasets and the PDFs. It identifies the nearest neighbors from the training data using various distance metrics and estimates redshifts based on these neighbors.\n\nThe configurable parameters for `DNFEstimator` include:\n\n- `bands`, `err_bands`, `redshift_col`, `nondetect_val`, `mag_limits`: As described for `DNFInformer`.\n- `selection_mode`: Integer indicating the method for neighbor selection:\n    * `0`: Euclidean Neighbourhood Fitting (ENF).\n    * `1`: Angular Neighbourhood Fitting (ANF).\n    * `2`: Directional Neighbourhood Fitting (DNF).\n- `zmin`, `zmax`, `nzbins`: Float values defining the minimum and maximum redshift range and the number of bins for estimation of the PDFs.\n- `pdf_estimation`: Boolean; if True, computes a probability density function (PDF) for the redshift of each object.\n\nDNF calculates its own point estimate, `DNF_Z`, which is stored in the qp Ensemble `ancil` data. Also, DNF calculates other photo-zs called `DNF_ZN`.\n\n- `DNF_Z` represents the photometric redshift for each galaxy computed as the weighted average or hyperplane fit (depending on the option selected) for a set of neighbors determined by a specific metric (ENF, ANF, DNF) where the outliers are removed\n\n- `DNF_ZN` represents the photometric redshift using only the closest neighbor. It is mainly used for computing the redshift distributions.\n\n## RAIL: Redshift Assessment Infrastructure Layers\n\nThis package is part of the larger ecosystem of Photometric Redshifts\nin [RAIL](https://github.com/LSSTDESC/RAIL).\n\n### Citing RAIL\n\nThis code, while public on GitHub, has not yet been released by DESC and is\nstill under active development. Our release of v1.0 will be accompanied by a\njournal paper describing the development and validation of RAIL.\n\nIf you make use of the ideas or software in RAIL, please cite the repository \n<https://github.com/LSSTDESC/RAIL>. You are welcome to re-use the code, which\nis open source and available under terms consistent with the MIT license.\n\nExternal contributors and DESC members wishing to use RAIL for non-DESC projects\nshould consult with the Photometric Redshifts (PZ) Working Group conveners,\nideally before the work has started, but definitely before any publication or \nposting of the work to the arXiv.\n\n### Citing this package\nUsers of rail_dnf can cite [De Vicente, Sanchez, & Sevilla-Noarbe](https://ui.adsabs.harvard.edu/abs/2016MNRAS.459.3078D/abstract)\nIf you use this package, you should also cite the appropriate papers for each\ncode used.  A list of such codes is included in the \n[Citing RAIL](https://lsstdescrail.readthedocs.io/en/stable/source/citing.html)\nsection of the main RAIL Read The Docs page.\n\n",
    "bugtrack_url": null,
    "license": "MIT License\n        \n        Copyright (c) 2023 LSST Dark Energy Science Collaboration (DESC)\n        \n        Permission is hereby granted, free of charge, to any person obtaining a copy\n        of this software and associated documentation files (the \"Software\"), to deal\n        in the Software without restriction, including without limitation the rights\n        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n        copies of the Software, and to permit persons to whom the Software is\n        furnished to do so, subject to the following conditions:\n        \n        The above copyright notice and this permission notice shall be included in all\n        copies or substantial portions of the Software.\n        \n        THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n        SOFTWARE.\n        ",
    "summary": null,
    "version": "1.1.6",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "4a24c32e6d32d4cee75948e6c9374a6523fed8542ad9c30c4194c3f750b3bef8",
                "md5": "b7bd07ac339128153ea3d45feecff471",
                "sha256": "6c270818682dd8c4d2bbdfcba8ce2e1d1a074104e0e198f7c9d593ba88746887"
            },
            "downloads": -1,
            "filename": "pz_rail_dnf-1.1.6-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b7bd07ac339128153ea3d45feecff471",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 12756,
            "upload_time": "2025-07-11T21:24:40",
            "upload_time_iso_8601": "2025-07-11T21:24:40.076635Z",
            "url": "https://files.pythonhosted.org/packages/4a/24/c32e6d32d4cee75948e6c9374a6523fed8542ad9c30c4194c3f750b3bef8/pz_rail_dnf-1.1.6-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "6c83c4dbfc92680495eeb7abb1d0611ee7f101fc3faa484aba71d81884b912aa",
                "md5": "b6929a0c140163df72ce24577b8bdd9e",
                "sha256": "d24db691dc6173e3b0a7d7afd749dd5b05f21c91ccaf168b674bc6b56f5ee38a"
            },
            "downloads": -1,
            "filename": "pz_rail_dnf-1.1.6.tar.gz",
            "has_sig": false,
            "md5_digest": "b6929a0c140163df72ce24577b8bdd9e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 15068,
            "upload_time": "2025-07-11T21:24:41",
            "upload_time_iso_8601": "2025-07-11T21:24:41.575504Z",
            "url": "https://files.pythonhosted.org/packages/6c/83/c4dbfc92680495eeb7abb1d0611ee7f101fc3faa484aba71d81884b912aa/pz_rail_dnf-1.1.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-11 21:24:41",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "pz-rail-dnf"
}
        
Elapsed time: 1.45868s