gcamdata icon indicating copy to clipboard operation
gcamdata copied to clipboard

Refactor base year scaling operation

Open rplzzz opened this issue 7 years ago • 4 comments

We do a lot of scaling stuff by base year ratios. Specifically, we compute the ratio of a time series to its base year value, and then we find the base year value of some other quantity and multiply the ratio series by that base year value. This seems like a good candidate for refactoring into a utility function, since we waste a lot of lines of code rediscovering this idiom everywhere it is used.

However, it may be that as we work forward in the data pipeline we don't do this so much anymore (i.e., we're working off of time series from previous stages where this was already done). The question is, is there enough value in whatever instances of this operation are still ahead to justify doing the refactoring?

rplzzz avatar May 03 '17 13:05 rplzzz

I definitely agree that this may be a good candidate. Tagging @pkyle for his thoughts on how much more for this is out there.

bpbond avatar May 04 '17 02:05 bpbond

Hmm...not sure how common it is, and the method here is pretty similar to others that might be captured under a similar function, or even the same one. Off the top of my head, it's used in socioeconomics for merging historical and future data, in the energy sector for computing industrial sector output and income elasticities (L232), in the ag sector for merging historical and projected yield, in land for estimating land cover prior to 1971. WRT the broader applications, there many of instances of scaling and/or expanding one year's portional allocations to other years. However I don't know that a function would be easier or more transparent than just implementing the individual steps?

pkyle avatar May 04 '17 18:05 pkyle

Abstracting an operation like that is always better than implementing the individual steps, both for productivity and reliability. The question here is, have we already done this as many times as we're going to do it, or are there still gains to be had?

rplzzz avatar May 05 '17 13:05 rplzzz

I don't know; if I had to guess I'd say 60% of the instances of this are already done, and 40% remain. Totally made up tho.

pkyle avatar May 05 '17 17:05 pkyle