swaschke / pypnf

GNU General Public License v2.0
18 stars 15 forks source link

VAP #15

Open vbkrish73 opened 6 months ago

vbkrish73 commented 6 months ago

Great project!

Pl do consider adding VAP

fivethreeo commented 6 months ago

I will look into it but it needs volume aggregation

fivethreeo commented 6 months ago

A start, at line #1042


        ic = np.logical_or(iBc, iTc)  # index of steps with changes

        if 'volume' in self.ts:
            # create a new zero array with the size of ts
            volume_bins = np.zeros(np.size(self.ts['volume']))
            volume_bins[ic] = 1
            volume_bins = np.cumsum(volume_bins)
            volume = np.zeros(np.size(self.ts['volume']))
            volume[ic] = np.bincount(volume_bins, weights=self.ts['volume'])
            volume[~ic] = np.nan

        ts[~ic, :] = np.nan  # set elements without action to NaN

        # index values cant be integer because of the nans in the arrays.
        pftseries = {'date': pfdate,
                     'box value': ts[:, 0],
                     'box index': ts[:, 1],
                     'column index': ts[:, 2],
                     'trend': ts[:, 3],
                     'filled boxes': ts[:, 4],
                    }

        if volume is not None:
            pftseries['box volume'] = volume