Skip to content

How to deal with large gaps #13

@SpheMakh

Description

@SpheMakh

The obvious way is to have a maximum gap parameter and then don't do the fit if the spectrum includes a gap larger than this.

Here is an algorithm to find gaps from this stack overflow query

import numpy as np
from itertools import groupby

x = np.array([10., 20., np.nan, 40., 50., np.nan, np.nan, np.nan, 10.,0.,-10.])
y = np.zeros_like(x, dtype=int)
y[np.where(np.isnan(x))] = 1 # Locate where the array is nan


z = []
for a, b in groupby(y, lambda x: x == 0):
     if a: # Where the value is 0, simply append to the list
         z.extend(list(b))
     else: # Where the value is one, replace 1 with the number of sequential 1's
         l = len(list(b))
         z.extend([l]*l)

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions