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

Properly flag custom wavelength band with empty range #213

Merged
merged 2 commits into from
Apr 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion SKIRT/core/TabulatedBand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ void TabulatedBand::setupSelfBefore()
getWavelengthsAndTransmissions(_lambdav, _transv);

// verify the number of values
if (_transv.size() < 2) throw FATALERROR("Number of loaded transmission values is less than 2");
if (_lambdav.size() != _transv.size()) throw FATALERROR("Number of wavelength and transmission values differ");
if (_lambdav.size() < 2) throw FATALERROR("Number of wavelength/transmission values is less than 2");

// reverse the arrays if needed to get the wavelengths in increasing order
if (_lambdav[0] > _lambdav[_lambdav.size() - 1])
Expand All @@ -25,6 +26,13 @@ void TabulatedBand::setupSelfBefore()
std::reverse(begin(_transv), end(_transv));
}

// verify that the wavelengths now are in increasing order
if (!std::is_sorted(begin(_lambdav), end(_lambdav), std::less<>()))
throw FATALERROR("Wavelengths are not sorted in increasing or decreasing order");

// verify that the wavelength range is nonzero
if (_lambdav[0] >= _lambdav[_lambdav.size() - 1]) throw FATALERROR("Wavelength range is empty");

// calculate the normalization factor for the transmission values
size_t size = _transv.size();
double norm = 0.;
Expand Down
Loading