Backwards dispersion models don't work
Hi!
Thanks for wrapping HYSPLIT with such a nice R package!
I was able to get the last version running and did some test runs on dispersion models. Everything seems to work correctly for the 'forward' models, but I am unable to properly run 'backward' models. Just building on the example dispersion model:
f_dispersion_model <-
create_dispersion_model() %>%
add_source(
name = "particle",
lat = 49.0, lon = -123.0, height = 50,
rate = 5, pdiam = 15, density = 1.5, shape_factor = 0.8,
release_start = lubridate::ymd_hm("2015-07-01 00:00"),
release_end = lubridate::ymd_hm("2015-07-01 00:00") + lubridate::hours(2)
) %>%
add_dispersion_params(
start_time = lubridate::ymd_hm("2015-07-01 00:00"),
end_time = lubridate::ymd_hm("2015-07-01 00:00") + lubridate::hours(6),
direction = "forward",
met_type = "reanalysis",
met_dir = here::here("hysplit/met"),
exec_dir = here::here("hysplit/out")
) %>%
run_model()
However, if I now change to a 'backwards' model, and edit the time such that:
...
add_dispersion_params(
start_time = lubridate::ymd_hm("2015-07-01 00:00") - lubridate::hours(6),
end_time = lubridate::ymd_hm("2015-07-01 00:00"),
direction = "backward",
...
This basically generates an empty output table.
Then I thought, okay, maybe start and end time definitions are switched in the backwards case, so I test with the following:
...
add_dispersion_params(
start_time = lubridate::ymd_hm("2015-07-01 00:00"),
end_time = lubridate::ymd_hm("2015-07-01 00:00") - lubridate::hours(6),
direction = "backward",
...
However, again we obtain an empty output table.
Simply as a last resort, if I test simply changing the direction parameter with the original example (of course, start and end times in the future of the release start-end don't make sense in a backwards scenario, but just for testing purposes):
...
add_dispersion_params(
start_time = lubridate::ymd_hm("2015-07-01 00:00"),
end_time = lubridate::ymd_hm("2015-07-01 00:00") + lubridate::hours(6),
direction = "backward",
...
This does give a result, which happens to be exactly the same as when we test with the forward direction.
So, given this, has anyone been able to successfully run a backwards dispersion model with splitr?
I think I might have noticed an issue in the run_model.R file, where the direction of the models when passed to run_model() is hardcoded to be 'forward' instead of using model$direction:
https://github.com/rich-iannone/splitr/blob/44851122514e1296291f0e9b082326717549715f/R/run_model.R#L68-L89