Code Monkey home page Code Monkey logo

speclite's Introduction

speclite package

Powered by Astropy Badge Distribution Status BSD License GitHub Actions CI Status Test Coverage Status Documentation Status

Introduction

This package provides a set of lightweight utilities for working with spectroscopic data in astronomy.

  • Free software: 3-clause BSD style license.
  • Documentation: latest | stable
  • Based on the Astropy affiliated package template.

Citation

DOI: 10.5281/zenodo.8347108

Please cite as:

David Kirkby, Andy Park, John Moustakas, Stephen Bailey, Benjamin Alan Weaver, Sergey Koposov, Marcelo Alvarez, Hélion du Mas des Bourboux, & Javier Sanchez. (2023). desihub/speclite: 2MASS Filters (v0.17). Zenodo. https://doi.org/10.5281/zenodo.8347108

Requirements

Speclite has the following package requirements:

License

speclite is free software licensed under a 3-clause BSD-style license. For details see the licenses/LICENSE.rst file.

Releasing

Please follow these instructions when creating a new tag of speclite.

  1. Update docs/changes.rst: set the date corresponding to the next tag.
  2. Update setup.cfg: in the [metadata] section set the version entry to the next tag (but without v).
  3. Check in the changes; a git push is optional at this point.
  4. Create the tag: git tag -s -m 'Tagging speclite/vX.Y.Z' vX.Y.Z. -s is optional; it adds a cryptographic signature to the tag.
  5. Update docs/changes.rst: add a new entry for a future tag with (unreleased).
  6. Update setup.cfg: set the version entry to the future tag plus .dev.
  7. Check in the changes, then push: git push; git push --tags.
  8. In your git clone, check out the tag: git co vX.Y.Z.
  9. Run python setup.py sdist --format=gztar. This command will change in the future as we move away from using setup.py.
  10. In the dist/ directory, inspect the .tar.gz file. Make sure the version is set properly, that all expected files are present, etc.
  11. In the dist/ directory, run twine upload speclite-X.Y.Z.tar.gz.
  12. In your git clone, clean up and go back to main. You don't want to accidentally edit or commit on a tag.
  13. On GitHub, create a new Release corresponding to the tag. This is important: creating a release will also automatically create a new DOI on Zenodo.
  14. On the main branch, update the README.rst file (this file) with the new DOI.

speclite's People

Contributors

andyypark avatar astrofrog avatar bsipocz avatar cdeil avatar crawfordsm avatar dcunning11235 avatar dkirkby avatar dstndstn avatar embray avatar eteq avatar fjaviersanchez avatar grburgess avatar hamogu avatar kbarbary avatar keflavich avatar larrybradley avatar londumas avatar marcelo-alvarez avatar mdboom avatar moustakas avatar mwcraig avatar pllim avatar sbailey avatar segasai avatar weaverba137 avatar wkerzendorf avatar zblz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

speclite's Issues

speclite slow to import

On both my laptop and at NERSC, speclite takes ~10x longer to import than other packages, even heavyweight ones like numpy. e.g. on my laptop:

[master*] speclite $ time python -c "import numpy"

real    0m0.197s
user    0m0.145s
sys 0m0.046s
[master*] speclite $ time python -c "import speclite"

real    0m1.763s
user    0m1.534s
sys 0m0.220s

At NERSC, speclite can take 5-10 seconds for a single process to import it.

Within speclite/__init__.py, the primary culprit is import filters, though from ._astropy_init import * is also fairly slow. Within filters.py, these astropy imports take much of the time:

import astropy.table
import astropy.units
import astropy.utils.data

Can anything be done to make this faster, e.g. lazy loading or using pkg_resources instead of astropy.utils.data routines?

This might be at the core of why our batch pipeline startup times are much slower than NERSC benchmarks indicate they should be, since desispec.io imports speclite.filters, while NERSC benchmarks are focused on importing numpy and scipy.

Warning from future non-tuple

I get this warning message, running quickquasar.
It is only a warning for now, but it might be useful to fix it before it becomes an error.

quickquasars -i /project/projectdirs/desi/mocks/lya_forest/london/v6.0/v6.0.0/1/137/transmission-16-137.fits
--outdir /project/projectdirs/desi/mocks/lya_forest/london/v6.0/v6.0.0/eboss-0.0/test-0-0/spectra-16
--zbest --bbflux --eboss --seed 123
--shift_kms_los -100.0 --gamma_kms_zfit 400.0 --zmin 1.8 --metals LYB
--overwrite
<home>/Programs/dkirkby/speclite/speclite/filters.py:1466: FutureWarning: Using a non-tuple sequence for multidimensional indexing is deprecated; use `arr[tuple(seq)]` instead of `arr[seq]`. In the future this will be interpreted as an array index, `arr[np.array(seq)]`, which will result either in an error or a different result.
  values_no_units = values_no_units[values_slice]
<home>/Programs/dkirkby/speclite/speclite/filters.py:1520: FutureWarning: Using a non-tuple sequence for multidimensional indexing is deprecated; use `arr[tuple(seq)]` instead of `arr[seq]`. In the future this will be interpreted as an array index, `arr[np.array(seq)]`, which will result either in an error or a different result.
  integrand = integrand[values_slice]

Add MaskedArray output option to `accumulate`

Currently accumulate always returns ndarray. When a MaskedArray is used for input (for at least one of the data_in parameters?), would be nice to automatically return a MaskedArray. Additionally, it would be nice to have the option to force output to either a MaskedArray or (plain) ndarray.

All together, something like a output_type parameter that could be set to "auto", "masked", or "array".

SDSS filters missing atmospheric transmission factor?

Hi specliters-

In trying to move to speclite from some quick-and-dirty synthetic photometry code of my own, using SDSS filters, I found that I could get my calculations to agree w/ speclite only by dropping the atmospheric transmission factor from the SDSS filter responses in my calculations.

The speclite documentation indicates that its SDSS filter responses are "calculated as the reference response multiplied by the reference APO atmospheric transmission": https://speclite.readthedocs.io/en/stable/filters.html.

The filter data tables have comments indicating the same. E.g., for the u band, a comment reads, "Values are the product of the u and atmospheric transmission columns from Table 4 of Doi...": https://github.com/desihub/speclite/blob/v0.13/speclite/data/filters/sdss2010-u.ecsv

Here are the first few entries in the speclite SDSS u band filter data file:

wavelength response
2930.0 0.0
2940.0 0.0001
2960.0 0.0003
2980.0 0.0005
3000.0 0.0009
3020.0 0.0014
3040.0 0.0029

Here is the content at the start of the Doi+ Table 4 (ASCII version here: https://iopscience.iop.org/1538-3881/139/4/1628/suppdata/aj330387t4_ascii.txt?doi=10.1088/0004-6256/139/4/1628):

lambda	u	g	r	i	z	T_1.3 air mass	
2940	0.0001	 ... 	 ... 	 ... 	 ... 	0.0162	
2960	0.0003	 ... 	 ... 	 ... 	 ... 	0.0242	
2980	0.0005	 ... 	 ... 	 ... 	 ... 	0.0351	
3000	0.0009	 ... 	 ... 	 ... 	 ... 	0.0459	
3020	0.0014	 ... 	 ... 	 ... 	 ... 	0.0644	
3040	0.0029	 ... 	 ... 	 ... 	 ... 	0.0828	

I checked a couple other SDSS data files, with similar findings. It appears the speclite SDSS filter responses do not include the atmospheric transmission factor.

Have I misunderstood something here?

Add support for basic filter operations

This issue has two components:

  • code to calculate filter-weighted integrals and
  • data files with tabulated filter curves.

Existing python implementations of the code are in:

Filter curves are collected in several places:

This issue is to implement the code in the same style as other speclite methods, so that others can try it out and give feedback, and to collect a basic set of filter curves sufficient for doing work now (SDSS, DES, LSST, WISE, UVB ?)

@moustakas Anything to add to this?

module 'astropy.utils.data' has no attribute '_find_pkg_data_path'

conda create -n speclite-test python=3.8 astropy=4.3
conda activate speclite-test
pip install speclite
python -c "from speclite.filters import load_filters ; load_filters('decam2014-r')"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/ioannis/anaconda3/envs/speclite-test/lib/python3.8/site-packages/speclite/filters.py", line 1807, in load_filters
    filters_path = astropy.utils.data._find_pkg_data_path('data/filters/')
AttributeError: module 'astropy.utils.data' has no attribute '_find_pkg_data_path'

Recipe in conda-forge

Hi,
I just submitted a pull request to the conda-forge organization containing a recipe for speclite:

4598

I hope this is welcome (if not, of course, I can delete the pull request).

I'd also add @dkirkby among the maintainer of the recipe, so you can keep an eye on it and modify it if you think it is necessary. Is it ok?

Thank you for your nice work!

ReadTheDocs configuration

I received the following message when I logged in to ReadTheDocs recently:

Your project(s) "speclite" don't have a configuration file. Configuration files will soon be required by projects, and will no longer be optional. Read our blog post to create one and ensure your project continues building successfully.

Negative Redshifts

The redshift module raises a ValueError if given a negative Z value (lines 109-110, 113-114)
Negative redshift values should be allowed.

Add more filter responses

@moustakas has requested MzLS-z and Bok-g,r for DESI work. This issue is to gather the data and include it in this package. Are there any other filters we need soon?

ModuleNotFoundError: No module named 'imp'

Cannot install speclite on Python 3.12, because Python 3.12 has removed the imp package.

Traceback (most recent call last):
        File "/home/user/desihub/speclite/astropy_helpers/setup.py", line 22, in <module>
          from astropy_helpers.version_helpers import generate_version_py  # noqa
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/user/desihub/speclite/astropy_helpers/astropy_helpers/version_helpers.py", line 34, in <module>
          from .distutils_helpers import is_distutils_display_option
        File "/home/user/desihub/speclite/astropy_helpers/astropy_helpers/distutils_helpers.py", line 18, in <module>
          from .utils import silence
        File "/home/user/desihub/speclite/astropy_helpers/astropy_helpers/utils.py", line 4, in <module>
          import imp
      ModuleNotFoundError: No module named 'imp'

Padding method not propagated for filter group

Calling pad_spectrum on a FilterSequence does not propagate a non-default method arg when pad_spectrum is called on the individual filters. The solution is to add method below:

        for response in sorted_responses:
            padded_spectrum, padded_wavelength = response.pad_spectrum(
                padded_spectrum, padded_wavelength, method)

Thanks to Anand for reporting this.

Add redshift convenience wrapper functions

The currently implemented redshift function is very general but cumbersome for simple cases. This issue is to specify and implement some wrapper functions to handle the most common cases where rules do not need to be passed as a parameter. Instead, the rules could be specified by the choice of wrapper function, or inferred based on field names.

Latest speclite release incompatible with setuptools>=58.0.2

The most recent release of speclite is incompatible with the most recent release of setuptools:

>> pip install setuptools==58.0.2
>> pip install --upgrade --no-cache-dir speclite

Collecting speclite
  Downloading speclite-0.13.tar.gz (813 kB)
     |████████████████████████████████| 813 kB 4.4 MB/s 
    ERROR: Command errored out with exit status 1:
     command: python -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/nw/43x1r_9n2235_0prypvp329w0000gp/T/pip-install-veu0mnlm/speclite_2f9edd95dc2742aa965feed4c25bf466/setup.py'"'"'; __file__='"'"'/private/var/folders/nw/43x1r_9n2235_0prypvp329w0000gp/T/pip-install-veu0mnlm/speclite_2f9edd95dc2742aa965feed4c25bf466/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/var/folders/nw/43x1r_9n2235_0prypvp329w0000gp/T/pip-pip-egg-info-uk77udyx
         cwd: /private/var/folders/nw/43x1r_9n2235_0prypvp329w0000gp/T/pip-install-veu0mnlm/speclite_2f9edd95dc2742aa965feed4c25bf466/
    Complete output (11 lines):
    /private/var/folders/nw/43x1r_9n2235_0prypvp329w0000gp/T/pip-install-veu0mnlm/speclite_2f9edd95dc2742aa965feed4c25bf466/astropy_helpers/astropy_helpers/setup_helpers.py:161: AstropyDeprecationWarning: The package argument to generate_version_py has been deprecated and will be removed in future. Specify the package name in setup.cfg instead
      warnings.warn('The package argument to generate_version_py has '
    /private/var/folders/nw/43x1r_9n2235_0prypvp329w0000gp/T/pip-install-veu0mnlm/speclite_2f9edd95dc2742aa965feed4c25bf466/astropy_helpers/astropy_helpers/setup_helpers.py:166: AstropyDeprecationWarning: The version argument to generate_version_py has been deprecated and will be removed in future. Specify the version number in setup.cfg instead
      warnings.warn('The version argument to generate_version_py has '
    /private/var/folders/nw/43x1r_9n2235_0prypvp329w0000gp/T/pip-install-veu0mnlm/speclite_2f9edd95dc2742aa965feed4c25bf466/astropy_helpers/astropy_helpers/setup_helpers.py:171: AstropyDeprecationWarning: The release argument to generate_version_py has been deprecated and will be removed in future. We now use the presence of the "dev" string in the version to determine whether this is a release
      warnings.warn('The release argument to generate_version_py has '
    /private/var/folders/nw/43x1r_9n2235_0prypvp329w0000gp/T/pip-install-veu0mnlm/speclite_2f9edd95dc2742aa965feed4c25bf466/astropy_helpers/astropy_helpers/setup_helpers.py:186: AstropyDeprecationWarning: Specifying the package name using the "package_name" option in setup.cfg is deprecated - use the "name" option instead.
      warnings.warn('Specifying the package name using the "package_name" '
    /private/var/folders/nw/43x1r_9n2235_0prypvp329w0000gp/T/pip-install-veu0mnlm/speclite_2f9edd95dc2742aa965feed4c25bf466/astropy_helpers/astropy_helpers/version_helpers.py:264: AstropyDeprecationWarning: Specifying the package name using the "package_name" option in setup.cfg is deprecated - use the "name" option instead.
      warnings.warn('Specifying the package name using the "package_name" '
    error in speclite setup command: use_2to3 is invalid.
    ----------------------------------------
WARNING: Discarding https://files.pythonhosted.org/packages/83/ae/c940436d23883d4e45bfa79fca5e7cc084fd07b2722e407cfcbf6ddf47f2/speclite-0.13.tar.gz#sha256=cf32e5e7a060690fb9eecb071bbdce61854f04fe25e7fd312346a82446c56111 (from https://pypi.org/simple/speclite/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

It looks like #65 already implemented the necessary fix, removing use_2to3=True from the setup function arguments. As a result, building from the master branch with setuptools==58.0.2 is successful:

>> pip install setuptools==58.0.2
>> git clone https://github.com/desihub/speclite.git
>> cd speclite
>> pip install .

Collecting astropy
  Using cached astropy-4.3.1-cp39-cp39-macosx_10_9_x86_64.whl (6.6 MB)
Collecting scipy
  Using cached scipy-1.7.1-cp39-cp39-macosx_10_9_x86_64.whl (32.8 MB)
Collecting pyyaml
  Using cached PyYAML-5.4.1-cp39-cp39-macosx_10_9_x86_64.whl (259 kB)
Collecting numpy>=1.17
  Using cached numpy-1.21.2-cp39-cp39-macosx_10_9_x86_64.whl (17.0 MB)
Collecting pyerfa>=1.7.3
  Using cached pyerfa-2.0.0-cp39-cp39-macosx_10_9_x86_64.whl (340 kB)
Building wheels for collected packages: speclite
  Building wheel for speclite (setup.py) ... done
  Created wheel for speclite: filename=speclite-0.14.dev592-py3-none-any.whl size=362165 sha256=c23d35f3491207e31a7005713a0d47553bea01472b47bfc68be482b0bb9d4f71
  Stored in directory: /private/var/folders/nw/43x1r_9n2235_0prypvp329w0000gp/T/pip-ephem-wheel-cache-kdt3qvxj/wheels/e5/f1/8d/8435528e26defdd25d0821f33b32ab92260a0efe5056911ef4
Successfully built speclite
Installing collected packages: numpy, pyerfa, scipy, pyyaml, astropy, speclite
Successfully installed astropy-4.3.1 numpy-1.21.2 pyerfa-2.0.0 pyyaml-5.4.1 scipy-1.7.1 speclite-0.14.dev592

A new release off master should therefore be sufficient to resolve this issue.

astropy and numpy warnings

When running

python setup.py test 

in an updated conda environment (including Astropy v4.3 see pkg_list.txt for the full package list) the following warnings occur:

grep warnings speclite.stdout
=============================== warnings summary ===============================
../../../../../global/common/software/desi/users/malvarez/desiconda-test/conda/lib/python3.9/site
-packages/astropy/tests/plugins/display.py:16
  /global/common/software/desi/users/malvarez/desiconda-test/conda/lib/python3.9/site-packages/as
tropy/tests/plugins/display.py:16: AstropyDeprecationWarning: The astropy.tests.plugins.display p
lugin has been deprecated. See the pytest-astropy-header documentation for information on migrati
ng to using pytest-astropy-header to customize the pytest header.
    warnings.warn('The astropy.tests.plugins.display plugin has been deprecated. '

speclite/filters.py::speclite.filters.FilterResponse
speclite/filters.py::speclite.filters.FilterResponse
speclite/filters.py::speclite.filters.FilterResponse
speclite/tests/test_filters.py::test_response_call
speclite/tests/test_filters.py::test_response_call
speclite/tests/test_filters.py::test_response_call
  /tmp/speclite-test-_ix9yqj_/lib/python3.9/site-packages/speclite/filters.py:832: DeprecationWar
ning: np.asscalar(a) is deprecated since NumPy v1.16, use a.item() instead
    response = np.asscalar(response)

speclite/redshift.py: 2 warnings
speclite/tests/test_redshift.py: 31 warnings
  /tmp/speclite-test-_ix9yqj_/lib/python3.9/site-packages/speclite/redshift.py:111: DeprecationWa
rning: `np.float` is a deprecated alias for the builtin `float`. To silence this warning, use `fl
oat` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted t
he numpy scalar type, use `np.float64` here.
  Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20
.0-notes.html#deprecations
    z_in = np.float(z_in)

speclite/redshift.py: 2 warnings
speclite/tests/test_redshift.py: 28 warnings
  /tmp/speclite-test-_ix9yqj_/lib/python3.9/site-packages/speclite/redshift.py:115: DeprecationWa
rning: `np.float` is a deprecated alias for the builtin `float`. To silence this warning, use `fl
oat` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted t
he numpy scalar type, use `np.float64` here.
  Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20
.0-notes.html#deprecations
    z_out = np.float(z_out)

speclite/redshift.py: 4 warnings
speclite/tests/test_redshift.py: 29 warnings
  /tmp/speclite-test-_ix9yqj_/lib/python3.9/site-packages/speclite/redshift.py:139: DeprecationWa
rning: `np.float` is a deprecated alias for the builtin `float`. To silence this warning, use `fl
oat` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted t
he numpy scalar type, use `np.float64` here.
  Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20
.0-notes.html#deprecations
    exponent = np.float(rule.get('exponent'))

speclite/redshift.py: 4 warnings
speclite/tests/test_redshift.py: 12 warnings
  /tmp/speclite-test-_ix9yqj_/lib/python3.9/site-packages/speclite/redshift.py:200: DeprecationWa
rning: `np.float` is a deprecated alias for the builtin `float`. To silence this warning, use `fl
oat` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted t
he numpy scalar type, use `np.float64` here.
  Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20
.0-notes.html#deprecations
    exponent = np.float(rule.get('exponent'))

-- Docs: https://docs.pytest.org/en/stable/warnings.html
====================== 132 passed, 119 warnings in 3.33s =======================

When using astropy 4.0.1.post1, the unit tests for speclite have 6 warnings:

grep warnings speclite.stdout
=============================== warnings summary ===============================
speclite/filters.py::speclite.filters.FilterResponse
speclite/filters.py::speclite.filters.FilterResponse
speclite/filters.py::speclite.filters.FilterResponse
speclite/tests/test_filters.py::test_response_call
speclite/tests/test_filters.py::test_response_call
speclite/tests/test_filters.py::test_response_call
  /tmp/speclite-test-tobvrzl2/lib/python3.8/site-packages/speclite/filters.py:832: DeprecationWar
ning: np.asscalar(a) is deprecated since NumPy v1.16, use a.item() instead
    response = np.asscalar(response)

-- Docs: https://docs.pytest.org/en/latest/warnings.html
======================= 132 passed, 6 warnings in 4.01s ========================

MNT: Stop using ci-helpers in appveyor.yml

To whom it may concern,

If you are using https://github.com/astropy/ci-helpers in your appveyor.yml , please know that the Astropy project has dropped active development/support for Appveyor CI. If it still works, good for you, because we did not remove the relevant files (yet). But if it ever stops working, we have no plans to fix anything for Appveyor CI. Please consider using native Windows support other CI, e.g., Travis CI (see https://docs.travis-ci.com/user/reference/windows/). We apologize for any inconvenience caused.

If this issue is opened in error or irrelevant to you, feel free to close. Thank you.

xref astropy/ci-helpers#464

speclite installs extra scripts in bin/

I just installed speclite at NERSC with desiInstall, which is just a wrapper on python setup.py install. A number of command-line scripts appeared in the bin directory, in addition to the speclite_benchmark script. See /global/project/projectdirs/desi/software/cori/speclite/v0.4/bin.

speclite v0.9 pip install failure

The new speclite pypi v0.9 tag is failing pip installs with:

(desi) [travis*] surveysim $ pip install speclite==v0.9
Collecting speclite==v0.9
  Using cached speclite-0.9.tar.gz (627 kB)
    ERROR: Command errored out with exit status 1:
     command: /Users/sbailey/anaconda3/envs/desi/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/lt/w2k_kx011kd7s2g9rk27xgzc0000gr/T/pip-install-9b8rh66q/speclite/setup.py'"'"'; __file__='"'"'/private/var/folders/lt/w2k_kx011kd7s2g9rk27xgzc0000gr/T/pip-install-9b8rh66q/speclite/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/var/folders/lt/w2k_kx011kd7s2g9rk27xgzc0000gr/T/pip-pip-egg-info-agkb5u4k
         cwd: /private/var/folders/lt/w2k_kx011kd7s2g9rk27xgzc0000gr/T/pip-install-9b8rh66q/speclite/
    Complete output (5 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/lt/w2k_kx011kd7s2g9rk27xgzc0000gr/T/pip-install-9b8rh66q/speclite/setup.py", line 83, in <module>
        generate_version_py()
    TypeError: generate_version_py() missing 2 required positional arguments: 'packagename' and 'version'
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

@dkirkby please check and fix. Thanks.

@schlafly this is current blocking factor for desihub/surveysim#73 travis failures, though I may try downgrading to v0.8 which previously worked. Mentioning @dmargala as recently wanting this v0.9 tag on pypi.

Consider re-enabling travis tests for numpy 1.7, 1.6

I disabled these a while ago so this issue is to review that decision. Note .travis.yaml in astropy (and its affiliated package template) considers 1.9 the default and also tests against 1.8, 1.7, 1.6. I just filed astropy/package-template#152 in case that is about to change.

I recently disabled tests against 1.7 and 1.6 in specsim because speclite uses the new assume_sorted option to scipy.interpolate.interp1d, so this should probably be fixed.

loading all filters with a wild card crashes impolitely

This works fine

decam = filters.load_filters('decam2014-*')

but this causes doom and destruction:

decam = filters.load_filters('decam2014*')
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-76-017fef935f54> in <module>()
----> 1 decam = filters.load_filters('decam2014*')

/usr/local/lib/python2.7/site-packages/speclite-0.4.dev338-py2.7.egg/speclite/filters.pyc in load_filters(*names)
   1504     responses = []
   1505     for name in names_to_load:
-> 1506         responses.append(load_filter(name))
   1507     return FilterSequence(responses)
   1508 

/usr/local/lib/python2.7/site-packages/speclite-0.4.dev338-py2.7.egg/speclite/filters.pyc in load_filter(name, load_from_cache, verbose)
   1571             'data/filters/{0}.ecsv'.format(name))
   1572     if not os.path.isfile(file_name):
-> 1573         raise ValueError('No such filter file "{0}".'.format(file_name))
   1574     if verbose:
   1575         print('Loading filter response from "{0}".'.format(file_name))

ValueError: No such filter file "/usr/local/lib/python2.7/site-packages/speclite-0.4.dev338-py2.7.egg/speclite/data/filters/decam2014*.ecsv".

add band_shift option

Are you familiar with synthesizing photometry using a band_shifted filter curve? By band-shifting the filter curve to the median redshift of the sample you minimize the K-correction -- see Section 2.3 of http://arxiv.org/abs/astro-ph/0205243.

The option could either be added to load_filters by simply dividing the filter wavelength array by (1+band_shift), or it could be an optional input to get_ab_maggies so the band-shifting can happen on-the-fly. I need this capability in order to connect the BGS mock galaxy catalog to the BGS templates in desisim.

AB magnitudes not correctly predicted

Hi,

I am using speclite for one of my project. I wanted check whether speclite's get_ab_magnitude function correctly predicts the magnitudes, as given in SDSS object explorer. So I downloaded a fits spectra of an object at RA = 190.269777714638 Dec = 37.6625678269159. The wavelength axis was not covering the u - band and z - band range, so I padded the spectrum and tried to get the magnitudes using get_ab_magnitudes. Unfortunately, I didn't got the same values. Could you please help me?

Result : [(22.24537585, 21.73756632, 21.54939652, 21.23126276, 20.98593275)]

https://skyserver.sdss.org/dr14/en/tools/explore/summary.aspx?ra=190.269777714638%09&dec=37.6625678269159 object

speclite v0.9 installation problems

speclite v0.9 isn't on pypi yet so I'm trying to install with pip directly from GitHub. If I use either of these, it doesn't seem to include the filter responses:

pip install https://github.com/dkirkby/speclite/archive/v0.9.tar.gz
pip install git+https://github.com/dkirkby/[email protected]#egg=speclite

e.g.

(desitest) ~ $ python -c "import speclite.filters; r = speclite.filters.load_filter('decam2014-r')"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/sbailey/anaconda3/envs/desitest/lib/python3.8/site-packages/speclite/filters.py", line 1918, in load_filter
    raise ValueError("No such filter '{0}' in this group.".format(name))
ValueError: No such filter 'decam2014-r' in this group.

However, if I clone the repo and use python setup.py install it seems to work fine:

git clone https://github.com/dkirkby/speclite
cd speclite
python setup.py install
...
python -c "import speclite.filters; r = speclite.filters.load_filter('decam2014-r')"
[no error]

Ideal would be to deploy to pypi so that normal pip install speclite works. Otherwise it would be helpful to know a 1-liner for simple instructions about how to install speclite v0.9.

"Wavelength values must be strictly increasing." error for monotonically increasing array

I've double- and triple-checked that the wavelength array for the ELG basis spectra is monotonically increasing, and yet speclite.filters is still throwing an error:

from speclite import filters
from desisim.io import read_basis_templates
flux, wave, meta = read_basis_templates(objtype='ELG')
rfilt = filters.load_filters('decam2014-r')
rfilt.get_ab_maggies(flux[0,:], wave)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-9-a86f52a94e30> in <module>()
----> 1 rfilt.get_ab_maggies(flux[0,:], wave)

/usr/local/lib/python2.7/site-packages/speclite-0.4.dev342-py2.7.egg/speclite/filters.pyc in get_ab_maggies(self, spectrum, wavelength, axis, mask_invalid)
   1455         """
   1456         return self._get_table(spectrum, wavelength, axis, mask_invalid,
-> 1457                                method=FilterResponse.get_ab_maggies)
   1458 
   1459 

/usr/local/lib/python2.7/site-packages/speclite-0.4.dev342-py2.7.egg/speclite/filters.pyc in _get_table(self, spectrum, wavelength, axis, mask_invalid, method)
   1408             except ValueError as e:
   1409                 if not mask_invalid:
-> 1410                     raise e
   1411                 # Create a missing column the first time we need it.
   1412                 if missing_column is None:

ValueError: Wavelength values must be strictly increasing.

Imports in Python 3

speclite does not correctly import internal packages in Python 3.

For example in __init__.py:

if not _ASTROPY_SETUP_:
    from redshift import redshift
    from accumulate import accumulate
    from resample import resample
    from downsample import downsample
    import filters

For Python 3 support, this should be:

if not _ASTROPY_SETUP_:
    from .redshift import redshift
    from .accumulate import accumulate
    from .resample import resample
    from .downsample import downsample
    from . import filters

find_pkg_data_path deprecated in Astropy 5.0

sdss = speclite.filters.load_filters('sdss2010-*')

gives the following error in Astropy 5.0:


AttributeError Traceback (most recent call last)
in
----> 1 sdss = speclite.filters.load_filters('sdss2010-*')
2 speclite.filters.plot_filters(sdss, wavelength_limits=(3000, 11000))

~/miniconda3/envs/science/lib/python3.8/site-packages/speclite/filters.py in load_filters(*names)
1805 """
1806 # Replace any group wildcards with the corresponding canonical names.
-> 1807
1808
1809 filters_path = get_path_of_data_file('filters/')

AttributeError: module 'astropy.utils.data' has no attribute '_find_pkg_data_path'


According to the Astropy 5.0 changelog: https://docs.astropy.org/en/stable/changelog.html

astropy.utils.data.get_pkg_data_path is publicly scoped (previously the private function _find_pkg_data_path) for obtaining file paths without checking if the file/directory exists, as long as the package and module do. [#11006]

Support multi-dim. resample

The resample method currently requires that its input be 1D, i.e., a single spectrum. Can this be generalized to to support resampling of multiple spectra with a single operation? There are two use-cases that need to work:

  • Each spectrum has its own input wavelength grid, defined by a named input array field.
  • All spectra share the same input wavelength grid, specified by an external array.

speclite.filters.get_ab_maggies alters input wavelength array?

In imcgreer/simqso#20 @imcgreer identified an issue in which the speclite.filters.get_ab_maggies method appears to alter the input wavelength array. See, specifically, this comment and the subsequent one.

However, I can't reproduce this with a MWE (see below). Do you have any thoughts?

import numpy as np
from speclite import filters
ff = filters.load_filters('decam2014-r')
wave = np.linspace(3000., 11000., 100)
wave2 = wave.copy()
flux = np.ones_like(wave)
_ = ff.get_ab_maggies(flux, wave)
assert(np.all(wave == wave2))

pad_spectrum does not fully obey axis argument

The FilterResponse object's pad_spectrum method appears to not add elements along the correct axis. For example...

import numpy as np, astropy.units as u, speclite.filters as filters
# 1-dim wavelength array
lam0 = np.arange(3800., 5500., 1.) * u.AA
# compatible datacube shape
flam0 = np.tile(np.ones_like(lam0.value)[..., None, None], (1, 20, 20)) * \
    u.Unit('1e-17 erg/s/cm2/AA')
sdss = filters.load_filters('sdss2010-*')
flam, lam = sdss.pad_spectrum(spectrum=flam0, wavelength=lam0, method='zero', axis=0)
print(flam0.shape, lam0.shape, flam.shape, lam.shape)

which outputs (1700, 20, 237) (1917,) instead of (1917, 20, 20), (1917,)

my version is 0.5

The workaround seems to be to np.moveaxis from 0 ==> -1 prior to calling pad_spectrum, and then reversing that operation after.

ValueError: Wavelengths do not cover filter response 3330.0-10980.0 Angstrom.

One should be able to synthesize photometry in a filter that is covered by the wavelengths of the spectrum, even if some filters are not covered. However, even in the latter case it would be nice if the "Wavelengths do not cover..." error was non-catastrophic and something functional (like np.nan) is returned in the bands that are either too blue or too red.

from astropy.io import fits
from speclite import filters
from desisim.templates import ELG

elg = ELG()
flux, wave, meta = elg.make_templates(nmodel=10)
wave.min(), wave.max()
  (3600.0, 10000.0)
decam = filters.load_filters('decam2014-r')
decam.get_ab_maggies(flux,wave)
[snip]
/usr/local/lib/python2.7/site-packages/speclite-0.4.dev338-py2.7.egg/speclite/filters.pyc in __init__(self, response, wavelength, photon_weighted, interpolate, units)
   1069                 .format(self.response._wavelength[0],
   1070                         self.response._wavelength[-1],
-> 1071                         default_wavelength_unit))
   1072 
   1073         # Find the smallest slice that covers the non-zero range of the

ValueError: Wavelengths do not cover filter response 3330.0-10990.0 Angstrom.

Infrastructure updates notice from Astropy Project

Hello from Astropy Project!

The following updates to your package might be necessary to ensure compatibility with the latest stable version of Astropy:

  • MPLBACKEND is now set to Agg in ci-helpers, packages expecting interactive plotting should override it in .travis.yml
  • Astropy 3.1 is not compatible with Numpy <1.13 versions. If you want to keep testing these older Numpy versions, please use ASTROPY_VERSION=3.0 or ASTROPY_VERSION=LTS in your Travis CI matrix.
  • Add sphinx-astropy as a package dependency if you are using astropy-helpers 3.1 or later. Otherwise, your documentation build (e.g., on ReadTheDocs) might fail.
  • If you are using six that is bundled with Astropy, please consider using the standalone six package instead.

If these are no longer applicable to you, please close the issue.

This is an automated issue for packages that opted in for automated astropy-helpers update. If this is opened in error, please let @pllim know.

xref astropy/astropy-tools#108

FilterSequence get_abmag as array?

Do you think it would be easy to have an option to have FilterSequence.get_ab_magnitudes have an option to return an array instead of a table?

Currently, I need to do this type of operation:

 def ab_magnitudes(self):
        """
        return the effective stimulus of the model and filter for the given
        magnitude system
        :return: np.ndarray of ab magnitudes
        """

        assert self._model_set, 'no likelihood model has been set'


        return self._filters.get_ab_magnitudes(self._wrapped_model).to_pandas().loc[0]

because I may mask some of the filters if a user wants to do a fit without them. Like so:

 def _get_expectations(self):

        return self._filter_set.ab_magnitudes()[self._mask]

where self._mask is a numpy boolean array. I am not sure how to do this cleanly with a table and Table.as_array() returns a structured np array which does not understand the indexing. However, going to pandas is incredibly slow!

I was thinking to modify the _get_table() method to just build up a np 2D array optionally. Or do you think there is a better way?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.