verde.base.n_1d_arrays

verde.base.n_1d_arrays(arrays, n)[source]

Get the first n elements from a tuple/list, make sure they are arrays, and ravel.

Use this function to make sure that coordinate and data arrays are ready for building Jacobian matrices and least-squares fitting.

Parameters:
arrays : tuple of arrays

The arrays. Can be lists or anything that can be converted to a numpy array (including numpy arrays).

n : int

How many arrays to return.

Returns:
1darrays : tuple of arrays

The converted 1D numpy arrays.

Examples

>>> import numpy as np
>>> arrays = [np.arange(4).reshape(2, 2)]*3
>>> n_1d_arrays(arrays, n=2)
(array([0, 1, 2, 3]), array([0, 1, 2, 3]))