traveler.skims.omx.OMX.lookup_to_index#
- OMX.lookup_to_index(lookupname, arr)[source]#
Convert an array of lookup-able values into indexes.
If you have an array of lookup-able values (e.g., TAZ identifiers) and you want to convert them to 0-based indexes for use in accessing matrix data, this is the function for you.
- Parameters:
lookupname (str) – The name of the lookup in the open matrix file. This lookup must already exist and have a set of unique lookup values.
arr (array-like) – An array of values that appear in the lookup. This method uses numpy.digitize to process values, so any target value that appears in arr but does not appear in the lookup will be assigned the index of the smallest lookup value that is greater than the target, or the maximum lookup value if no lookup value is greater than the target.
- Returns:
An array of index (int) values, with the same shape as arr.
- Return type:
array
- Raises:
OMXNonUniqueLookup – When the lookup does not contain a set of unique values, this tool is not appropriate.