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

Add consistent units #467

Merged
merged 11 commits into from May 16, 2022
Merged

Add consistent units #467

merged 11 commits into from May 16, 2022

Conversation

erwanp
Copy link
Member

@erwanp erwanp commented May 15, 2022

Main change, suggested by @AllanHOlesenBW : if using default Spectrum.get() and Spectrum.plot() return Iunits consistent with wunit (i.e. "mW/cm2/sr/nm" if wunit~"nm" and "mW/cm2/sr/cm-1" if wunit~"cm-1"

Implementation :

  • Spectrum exported by SpectrumFactory remains in wavenumber, but a "default_output_unit" condition is written ; and later read by Spectrum.get() and Spectrum.plot() --> .get() and .plot() give Iunits consistent with wunit (i.e. "mW/cm2/sr/nm" if wunit~"nm" and "mW/cm2/sr/cm-1" if wunit~"cm-1"
  • update all internal functions that used .get() to enforce Iunit

Minor changes :

  • make Radiance(s), Transmittance(s) deprecated in favor of s.take("radiance") etc
  • new fast version to check if an array is evenly distributed
  • apply_slit always check Spectrum is evenly distributed (fast version)
  • new method Spectrum.resample_even()
  • add Spectrum.get(return_units=True) option, which returns Astropy arrays (to make sure we always know which units are used)

Fixes #456

@erwanp erwanp added the interface not related to the physics of the code label May 15, 2022
@erwanp erwanp added this to the 0.13 milestone May 15, 2022
…m with consistent radiance & emission coefficient (mW/cm2/sr/nm, mW/cm3/sr/nm)

updated eq_spectrum, non_eq_spectrum, eq_bands, non_eq_bands
add tests
apply_slit always check Spectrum is evenly distributed (fast version)
new method Spectrum.resample_even()
… initially computed in wavenumber & exported in wavelength.

This maintains Radis<=0.12 output
…in wavenumber, but a "default_output_unit" condition is written ; and later read by Spectrum.get() and Spectrum.plot() --> .get() and .plot() give Iunits consistent with wunit (i.e. "mW/cm2/sr/nm" if wunit~"nm" and "mW/cm2/sr/cm-1" if wunit~"cm-1"

update all internal functions that used .get() to enforce Iunit
- add Spectrum.get(return_units=True) option, which returns Astropy arrays
- make Radiance(s), Transmittance(s) deprecated in favor of s.take("radiance") etc
…in wavenumber, but a "default_output_unit" condition is written ; and later read by Spectrum.get() and Spectrum.plot() --> .get() and .plot() give Iunits consistent with wunit (i.e. "mW/cm2/sr/nm" if wunit~"nm" and "mW/cm2/sr/cm-1" if wunit~"cm-1"

update all internal functions that used .get() to enforce Iunit
- add Spectrum.get(return_units=True) option, which returns Astropy arrays
- make Radiance(s), Transmittance(s) deprecated in favor of s.take("radiance") etc
…rent from initial arrays (due to Iunit not specified)

add exhaustive tests, testing every possible recalculation pathway (test_rescale.py)

also:
- show units in print(Spectrum)
@codecov-commenter
Copy link

Codecov Report

Merging #467 (8dbf86f) into develop (e462f0a) will decrease coverage by 3.95%.
The diff coverage is 91.41%.

@@             Coverage Diff             @@
##           develop     #467      +/-   ##
===========================================
- Coverage    77.04%   73.09%   -3.96%     
===========================================
  Files          164      137      -27     
  Lines        18927    18831      -96     
===========================================
- Hits         14583    13764     -819     
- Misses        4344     5067     +723     

@erwanp erwanp merged commit 17c33f6 into radis:develop May 16, 2022
@erwanp erwanp mentioned this pull request May 16, 2022
@erwanp erwanp deleted the add/consistent-units branch August 13, 2022 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interface not related to the physics of the code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Intensity units consistent with the wavespace unit
2 participants