geanders / futureheatwaves

Functions to Identify and Characterize Heatwaves in Climate Projections
3 stars 0 forks source link

How to use ID heatwaves option for main #42

Closed geanders closed 8 years ago

geanders commented 8 years ago

I think that there are a couple problems with getting it to work right now:

  1. The logic call custom["IDheatwaves"] == TRUE in IDheatwaves won't work. If you didn't put a custom heatwave definition in here, it would be fine, because it would keep the default FALSE. However, if you did put a custom definition in, R would not evaluate this statement as now being TRUE. We'll need to fix this logic once figure out how to pass the custom function through. That leads to...
  2. We'll need to pass the custom function through a different way. Popping it into custom converts it to a list, so it can't evaluate as a function. There may be a way to then use as.function to pull it back into a function form. If not, we will probably want to go more the route of using do.call within this part of IDheatwaves and just passing the name of the function, rather than the full function, through in custom.
geanders commented 8 years ago

Got it! The IDHeatwaves now uses a do.call to direct to the desired function to ID heatwaves. I made a wrapper function for the C++ function (IDHeatwavesCPPwrapper), so now to call the C++ function, you would just specify IDheatwavesReplacement = "IDHeatwavesCPPwrapper" in the gen_hw_set function. That means we don't need the RorCPP specification anymore, so I took that out. The default for the IDheatwavesReplacement is currently the "IDHeatwavesR" function. Once we get the C++ function de-bugged, we could use that as the default. As a note, the function name needs to be in quotation marks for the IDheatwavesReplacement argument.