Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

leff and lphot do not convert wavelength units #45

Open
christophra opened this issue Jul 21, 2022 · 1 comment
Open

leff and lphot do not convert wavelength units #45

christophra opened this issue Jul 21, 2022 · 1 comment
Assignees
Labels

Comments

@christophra
Copy link

christophra commented Jul 21, 2022

Steps to reproduce

  1. Get a transmission curve in nanometers
  2. Pass it to the constructor of Filter
  3. Get that new filter's leff and lphot

Expected behaviour:
Like the other derived quantities, lphot and leff are also in nanometers and fall within the filter's band.

Observed behaviour:
The leff and lphot are a factor 10 too large; in other words, the value is in Ångström but the Quantity has units nanometer.

Minimal example

(using filters from the library as an example, although of course the point is that this can happen when creating new filters)

import pyphot

# would work with any filters, these are available for the example
lib = pyphot.get_library()

for filter_name in ['ZTF_g', # in nanometers
                    'SDSS_g', # in Angstrom
                   ]:
    print(filter_name)
    
    # In the HDF5 file, lphot and leff are correct
    original = lib[filter_name]
    
    # Now construct a new filter based on this
    reloaded = pyphot.phot.Filter(
        # all arguments the constructor accepts:
        original.wavelength,
        original.transmit,
        name = 'test_Filter_constructor',
        dtype='photon',
        unit=original.wavelength_unit,
    )
    print(f'lphot {original.lpivot:.2f} turns to {reloaded.lphot:.2f}')
    print(f'leff {original.leff:.2f} turns to {reloaded.leff:.2f}')
@christophra
Copy link
Author

I now found out about pyphot.sandbox and its parallel Unit classes. The bug appears also in pyphot.sandbox.UnitFilter.

@mfouesneau mfouesneau self-assigned this Aug 18, 2022
@mfouesneau mfouesneau added the bug label Aug 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants