Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This addresses rich-iannone#81, and also could be considered to address rich-iannone#66.
Basically, there were 2 really small errors that made the logic of running backwards dispersion models not work.
For starters, the
run_model
function has a hardcoded 'forward' parameter, so no matter the direction specified inadd_dispersion_params
, thehysplit_dispersion
function always received 'forward' as the parameter. This is fixedin commit caead2f.
Second, the
add_dispersion_params
function has noduration
parameter. The value ofduration
that is passed ontohysplit_dispersion
is computed by the difference in hours between start_time and end_time:https://github.com/rich-iannone/splitr/blob/44851122514e1296291f0e9b082326717549715f/R/run_model.R#L51
In a backwards model, the
end_time
is before thestart_time
, so this variable takes negative values.When writing the CONTROL file, however, there is an ifelse clause that prepends a '-' to the duration value. In the case of an already negative value, this writes a line with --duration, leading to a faulty CONTROL file that HYSPLIT doesn't accept and it just doesn't run. Removing the ifelse clause seems to work and is what I did in d4ca419.