Skip to content

Commit

Permalink
add atol to zero check for calibrated spectra and fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
Will-Cooper committed May 21, 2024
1 parent 2e29ce2 commit ab231da
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions simple_app/plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def normalise() -> np.ndarray:
else:
fluxmed = np.nanmedian(flux)

if not np.isclose(fluxmed, 0):
if not np.isclose(fluxmed, 0, atol=1e-30):
return flux / fluxmed
return flux # unable to normalise by first 0.01um

Expand Down Expand Up @@ -180,7 +180,7 @@ def normalise() -> np.ndarray:
wave: np.ndarray = spectrum.spectral_axis.to(u.micron).value
flux: np.ndarray = spectrum.flux.value
nan_check: np.ndarray = ~np.isnan(flux) & ~np.isnan(wave)
zero_check: np.ndarray = ~np.isclose(flux, 0)
zero_check: np.ndarray = ~np.isclose(flux, 0, atol=1e-30)
nanzero_check = nan_check & zero_check
wave = wave[nanzero_check]
flux = flux[nanzero_check]
Expand Down
3 changes: 2 additions & 1 deletion simple_app/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,10 @@ def test_results_concat(db, test_get_all_photometry, test_get_all_sources,
all_results, all_results_full = test_get_all_sources
all_parallaxes = test_get_all_parallaxes
all_spectral_types = test_get_all_spectral_types
wanted_mags = {'GAIA3.G', '2MASS.J', 'WISE.W1'}
all_results_concat = results_concat(all_results_full, all_photometry, all_parallaxes, all_spectral_types, all_bands)
assert all([col in all_results_concat.columns for col in ('ra_projected', 'dec_projected')])
assert all([f'M_{band}' in all_results_concat.columns for band in all_bands])
assert all([f'M_{band}' in all_results_concat.columns for band in all_bands if band in wanted_mags])
return


Expand Down

0 comments on commit ab231da

Please sign in to comment.