Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backwards dispersion models don't work #81

Open
AlFontal opened this issue Aug 16, 2023 · 1 comment
Open

Backwards dispersion models don't work #81

AlFontal opened this issue Aug 16, 2023 · 1 comment

Comments

@AlFontal
Copy link

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?

@AlFontal AlFontal changed the title Proper calling of backwards dispersion models Backwards dispersion models don't work Aug 16, 2023
@AlFontal
Copy link
Author

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:

splitr/R/run_model.R

Lines 68 to 89 in 4485112

disp_df <-
hysplit_dispersion(
lat = lat,
lon = lon,
height = height,
start_day = start_day,
start_hour = start_hour,
duration = duration,
direction = "forward",
met_type = model$met_type,
vert_motion = model$vert_motion,
model_height = model$model_height,
particle_num = 2500,
particle_max = 10000,
species = species_list,
exec_dir = model$exec_dir,
met_dir = model$met_dir,
binary_path = model$binary_path,
binary_name = model$binary_name,
softrun = model$softrun,
clean_up = model$clean_up
)

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

No branches or pull requests

1 participant