Skip to content

Commit

Permalink
Merge pull request #68 from ToFuProject/Issue064_save
Browse files Browse the repository at this point in the history
save / load
  • Loading branch information
dvezinet authored Sep 5, 2024
2 parents aff39ee + dfd1f9f commit 3ed5960
Show file tree
Hide file tree
Showing 5 changed files with 172 additions and 103 deletions.
28 changes: 14 additions & 14 deletions spectrally/_class01_valid.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@


_DINDOK = {
0: 'ok',
-1: 'mask',
-2: 'out of domain',
-3: 'neg, inf or NaN',
-4: 'S/N valid, excl. (fract.)',
-5: 'S/N non-valid, incl. (fract.)',
-6: 'S/N non-valid, excl. (fract.)',
-7: 'S/N valid, excl. (bs)',
-8: 'S/N non-valid, incl. (bs)',
'0': 'ok',
'-1': 'mask',
'-2': 'out of domain',
'-3': 'neg, inf or NaN',
'-4': 'S/N valid, excl. (fract.)',
'-5': 'S/N non-valid, incl. (fract.)',
'-6': 'S/N non-valid, excl. (fract.)',
'-7': 'S/N valid, excl. (bs)',
'-8': 'S/N non-valid, incl. (bs)',
}


Expand Down Expand Up @@ -155,12 +155,12 @@ def mask_domain(
# -----------------

if key_bs_vect is None:
lindok = sorted([
k0 for k0, v0 in _DINDOK.items()
if '(bs)' not in v0
])[::-1]
lkm = [k0 for k0, v0 in _DINDOK.items() if '(bs)' not in v0]
else:
lindok = sorted(_DINDOK.keys())[::-1]
lkm = list(_DINDOK.keys())

inds = np.argsort([int(ss) for ss in lkm])[::-1]
lindok = [lkm[ii] for ii in inds]

dvalid.update({
'domain': domain,
Expand Down
58 changes: 58 additions & 0 deletions spectrally/_class02_SpectralFit.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,29 +178,87 @@ def compute_spectral_fit(
def plot_spectral_fit_input_validity(
self,
key=None,
keyY=None,
dref_vectorY=None,
# options
dprop=None,
vmin=None,
vmax=None,
cmap=None,
plot_text=None,
# figure
dax=None,
fs=None,
dmargin=None,
tit=None,
# interactivity
connect=True,
dinc=None,
show_commands=None,
):
""" Plot the validity map if input data
Parameters
----------
key : str, optional
DESCRIPTION. The default is None.
keyY : str, optional
DESCRIPTION. The default is None.
dref_vectorY : dict, optional
DESCRIPTION. The default is None.
dprop : TYPE, optional
DESCRIPTION. The default is None.
vmin : float, optional
DESCRIPTION. The default is None.
vmax : float, optional
DESCRIPTION. The default is None.
cmap : str, optional
DESCRIPTION. The default is None.
plot_text : bool, optional
DESCRIPTION. The default is None.
dax : dict, optional
DESCRIPTION. The default is None.
fs : tuple, optional
DESCRIPTION. The default is None.
dmargin : dict, optional
DESCRIPTION. The default is None.
tit : str, optional
DESCRIPTION. The default is None.
connect : bool, optional
DESCRIPTION. The default is True.
dinc : dict, optional
DESCRIPTION. The default is None.
show_commands : bool, optional
DESCRIPTION. The default is None.
Returns
-------
dax: Collection
collection of axes
"""

return _plot_valid.plot(
coll=self,
key=key,
keyY=keyY,
dref_vectorY=dref_vectorY,
# options
dprop=dprop,
vmin=vmin,
vmax=vmax,
cmap=cmap,
plot_text=plot_text,
# figure
dax=dax,
fs=fs,
dmargin=dmargin,
tit=tit,
# interactivity
connect=connect,
dinc=dinc,
show_commands=show_commands,
)

# ----------------------------
Expand Down
4 changes: 2 additions & 2 deletions spectrally/_class02_compute_fit_1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,9 @@ def get_iok_all(
]

# iok_all
iok_all = (iok == lind_valid[0])
iok_all = (iok == int(lind_valid[0]))
for k0 in lind_valid[1:]:
iok_all = np.logical_or(iok_all, (iok == k0))
iok_all = np.logical_or(iok_all, (iok == int(k0)))

iok_reduced = np.any(iok_all, axis=axis)

Expand Down
Loading

0 comments on commit 3ed5960

Please sign in to comment.