Skip to content

Commit

Permalink
Fixed normalization shape mismatch and fixed resource call in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hover2pi committed Sep 20, 2024
1 parent 40170a0 commit ec55146
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions sedkit/spectrum.py
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,10 @@ def norm_to_spec(self, spec, add=False, plot=False, **kwargs):
spec0 = slf.data
spec1 = spec.data[:, idx]

# Fix shape mismatch
if len(spec0[0]) < len(spec1[0]):
spec1 = spec1[:, 1:]

# Find the normalization factor
norm = u.minimize_norm(spec1[1], spec0[1], **kwargs)

Expand Down
6 changes: 3 additions & 3 deletions sedkit/tests/test_sed.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import unittest
import copy
from pkg_resources import resource_filename
import importlib_resources

import numpy as np
import astropy.units as q
Expand Down Expand Up @@ -48,7 +48,7 @@ def test_add_photometry_table(self):
s = copy.copy(self.sed)

# Add the photometry
f = resource_filename('sedkit', 'data/L3_photometry.txt')
f = str(importlib_resources.files('sedkit')/ 'data/L3_photometry.txt')
s.add_photometry_table(f)
self.assertEqual(len(s.photometry), 8)

Expand Down Expand Up @@ -279,7 +279,7 @@ def test_fit_modelgrid(self):
# s.add_spectrum(self.spec1)
#
# # Add photometry
# f = resource_filename('sedkit', 'data/L3_photometry.txt')
# f = str(importlib_resources.files('sedkit')/ 'data/L3_photometry.txt')
# s.add_photometry_file(f)
#
# # Fit with SPL
Expand Down

0 comments on commit ec55146

Please sign in to comment.