Skip to content

Create ICT: automatically calculate dataIntervalCode?

For the user's convenience, I think the dataIntervalCode can be calculated automatically when IVAR is set. For example like

# let xarr be IVAR as np.array, dtype=float;

# calculate dx as unique diffs in X,
# unique with floats might fail, so add a round to n decimals (e.g. 4):
dx = np.unique(np.diff(xarr).round(4))
# dx is 0 if there's more than one unique diff
dx = dx[0] if dx.size == 1 else 0

OPTIONAL; see issue #14 (closed):

# use an integer if dx is close to its integer value, else float:
dx = int(dx) if np.isclose(dx, int(dx)) else dx
  • To make this a reliable feature, a reasonable number of decimals to round to must be determined
  • Add test

The other way around, this feature could be used to verify the dataIntervalCode in an imported ICARTT file.

Edited by Florian Obersteiner
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information