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

working with empty Spectrum object #359

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions prospect/likelihood/noise_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ def update(self, **params):

def lnlike(self, pred, obs, vectors={}):

if obs.flux is None:
return 0

# populatate vectors used as metrics and weight functions.
vectors = self.populate_vectors(obs)
# Construct Sigma (and factorize if 2d)
Expand Down
26 changes: 22 additions & 4 deletions prospect/observation/observation.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,24 @@ def rectify(self):
uncertainties.
"""
n = self.__repr__
if self.flux is None:
print(f"{n} has no data")
return

_flux_array = False
try:
len(self.flux)
_flux_array = True
except:
_flux_array = False

if _flux_array:
if self.flux is None:
print(f"{n} has no data")
return
else:
if self.flux == None:
print(f"{n} has no data")
self.flux = None
self.wavelength = None
return

assert self.flux.ndim == 1, f"{n}: flux is not a 1d array"
assert self.uncertainty.ndim == 1, f"{n}: uncertainty is not a 1d array"
Expand Down Expand Up @@ -331,7 +346,10 @@ def __init__(self,
self.resolution = resolution
self.response = response
self.instrument_smoothing_parameters = dict(smoothtype="vel", fftsmooth=True)
self.wavelength = np.atleast_1d(wavelength)
if wavelength is not None:
self.wavelength = np.atleast_1d(wavelength)
else:
self.wavelength = None

@property
def wavelength(self):
Expand Down