def get_outreaches(self):
        self.reach_data.sort(order=['iseg', 'ireach'])
        reach_data = self.reach_data
        segment_data = self.segment_data[0]
        # this vectorized approach is more than an order of magnitude faster than a list comprehension
        first_reaches = reach_data[reach_data.ireach == 1]
        last_reaches = np.append((np.diff(reach_data.iseg) == 1), True)
        reach_data.outreach = np.append(reach_data.reachID[1:], 0)
        # for now, treat lakes (negative outseg number) the same as outlets
        reach_data.outreach[last_reaches] = [first_reaches.reachID[s] if s > 0 else 0
                                             for s in segment_data.outseg - 1]
        self.reach_data['outreach'] = reach_data.outreach
Get the first related model record matching the attributes or create it.
dataset/ETHPy150Open modflowpy/flopy/flopy/modflow/mfsfr2.py/ModflowSfr2.get_outreaches--crossover with--dataset/ETHPy150Open sdispater/orator/orator/orm/relations/belongs_to_many.py/BelongsToMany.first_or_create