-
Notifications
You must be signed in to change notification settings - Fork 3
Description
The way the FFC API calculates spring magnitude finds a date by behavior and then moves the date by four days (I don't recall why). Some of the team members want the ability to disable the date move, but not impact existing calculations from the API. A good option for this is to have the FFC API Client handle the adjustment since it can be turned on and off and doesn't involve deploying an update to a wider audience on the server side.
This involves a few pieces of work:
- A new flag needs to be added to the FFCProcessor class. It could be something like
perform_spring_magnitude_adjustment = FALSE,- I'd recommend this go somewhere near line 357 (https://github.com/ceff-tech/ffc_api_client/blob/release/ffcAPIClient/R/ffc_api_client.R#L357) - Need to add a function that conditionally does the filtering. I'd recommend a few things here:
- Around this line, add a new variable named something like
ffc_results_pre_spring_fix = NA, - Then, somewhere like this, add a new code block like the following:
- Around this line, add a new variable named something like
if(self$perform_spring_magnitude_adjustment){
self$prefix_ffc_results <- self$ffc_results # back up the original results
self$ffc_results <- self$adjust_spring_magnitude(days=4)
}- while adding another function to the class (somewhere around line 507 is fine) that looks something like the following:
adjust_spring_magnitude=function(days){
# a function that accepts a number of days to adjust the spring magnitude metric
current_results <- self$ffc_results
#
# ... code that fixes spring magnitude timing based on the number of days specified to adjust in the parameters here ...
# the thing to note is that this class has access to all the data that went into and came out of the FFC. We can access
# the input timeseries, the returned metrics, etc.
new_results <- output_of_the_above_section # this is pseudocode - we just need a new object named new_results that has everything in self$ffc_results, but with the fixed spring timing info
return(new_results)
}@kristaniguchi it'd be worth knowing a verbal description of what's required to adjust the magnitude value. Is it that once we know the day of year, we go look at input timeseries (of which there can be many years), or do we look at the DOH data and pull the magnitude values for the new day of the year we want to use? Can you describe what data has the values we want to pull data from?