Skip to content

Conversation

@sebastianrowan
Copy link
Contributor

This PR adds basic reconstruction time to 'Compute' for structures.

  • adds column "reconstruction_days" to result
  • adds reconstruction "damage" functions to occtypes.json
    • Xvals for function are percent damage to structure (sdampercent)
    • Yvals are number of days to return to 0% damage from given level of damage (Triangular distribution)
  • includes a default null reconstruction function to ensure compute does not return early if reconstruction not found for occtype (sets reconstruction time to -901 days)
  • reconstruction functions saved in excel spreadsheet
  • python script to insert functions into occtypes.json

Questions

  1. Do we want reconstruction to be an optional return value?
    • i.e. Do we want to separate this functionality into a separate computeConsequencesWithReconstruction function?
    • If so, we might need to add a flag to the Compute method for receptors.

Copy link
Contributor

@HenryGeorgist HenryGeorgist left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think i misled you when i said make a unit test. what i meant was make a unit test where we create a simple slice of hazards, a structure, and an occupancy type with a reconstruction component and write the logic for what we want the code to do in the unit test to review the behavior before we modify all of the code. we will learn from the unit test implementation before we force ourselves down a path.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets not checkin this draw io yet. lets make sure we know what we are doing first.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets not checkin this draw io yet lets make sure we know what we are doing

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should not be working at this high level yet. please revert this change.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets not start with the high level workflow - this forces us down a path by making alot more changes required before we even start. lets save those for when we know what we want to do works.

})
//compute consequences.
StreamAbstract(dfr, nsp, w)
StreamAbstractReconstruction(dfr, nsp, w)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets not start with this, lets do that later. we will start with a single structure unit test not a full inventory unit test.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets not check in a binary file into the code. worst case lets use a csv

"math/rand"
"strings"

"github.com/HydrologicEngineeringCenter/go-statistics/paireddata"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think we dont have to use a direct reference to the paired data object, we didnt with damage functions, so lets look into why this seems necessary before we include it. maybe we have another interface we need to create or one we need to modify.

rDamFun, rderr := s.OccType.GetComponentDamageFunctionForHazard("reconstruction", e)
if rderr != nil {
// this default reconstruction function will return -901 days for all input values of sdampercent
rDamFun = DamageFunction{Source: "DefaultNull", DamageDriver: hazards.Depth, DamageFunction: paireddata.PairedData{Xvals: []float64{0.0, 1.0}, Yvals: []float64{-901.0, -901.0}}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah. this is where the paired data comes from! cool. we may consider a different approach here somehow.

sdampercent = sDamFun.DamageFunction.SampleValue(depthAboveFFE) / 100 //assumes what type the damage array is in
cdampercent = cDamFun.DamageFunction.SampleValue(depthAboveFFE) / 100
duration := math.Max(0.0, e.Duration()) // if no duration, value is -901
reconstruction_days = rDamFun.DamageFunction.SampleValue(sdampercent) + duration
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

im not sure its a great idea that we add reconstruction days to the standard compute, it shouldnt really matter that much, but it is another dependency. we can avoid this with some changes in how we implement the higher level stuff, for now though lets remove this and focus on a simpler implementation that focuses on a separate path from the main path until we know our stuff works well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets not add python dependencies into our dev environment. i like what you have done generally, but lets do that in a go file (there should be an example in occtype_test.go

@HenryGeorgist
Copy link
Contributor

it might be worthwhile to set up a time to actually write out a unit test together so we can co-code the idea you have in its simplest way before we change the entire code base. I suspect the changes you made are close to right, but lets start smaller and verify each component part first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants