Code Monkey home page Code Monkey logo

Comments (4)

dkirkby avatar dkirkby commented on August 11, 2024

These lines will modify the input wave array under certain conditions:

  • validate_wavelength_array() does not need to make a copy, e.g., to strip units or convert from python to numpy array.
  • the filter response is zero for some of the wavelengths in the input array.

However, I am also unable to reproduce this with a MWE, so there's something I still don't understand. For moving forwards with simqso, I suggest that you use the copy() for now, until I can spend more time getting to the bottom of this.

from speclite.

segasai avatar segasai commented on August 11, 2024

Hi,

This code will consistently corrupt the wavelength array

import speclite.filters
import numpy as np
filters = speclite.filters.load_filters('gaiadr2-BP', 'gaiadr2-RP',
                                        'gaiadr2-G')
waves = np.arange(3000, 11000, 0.11)
waves0 = waves.copy()
flux = waves * 1.
filters[0].get_ab_magnitude(flux, waves)
print(np.nonzero(waves != waves0), waves[2249], waves0[2249])

Output:
(array([ 2249, 40932]),) 3247.4999999999995 3247.3900000002864

IMO validate_wavelength_array() must make a copy even at a performance cost, because
the current behaviour is dangerous as it leads to silent corruption (i've encountered this bug while working on stdstars DESI script)

S

from speclite.

dkirkby avatar dkirkby commented on August 11, 2024

Thanks for this @segasai. I will take care of this but presumably you can copy your wavelength array in the stdstars script so this is not blocking you?

from speclite.

segasai avatar segasai commented on August 11, 2024

Yes, that's what I did for the time being.
I just was suggesting that given the danger of the bug, it may be worth putting a stopgap copy() inside validate_wavelength_array() now before coming with a proper fix, but that's just IMO.

from speclite.

Related Issues (20)

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.