rich-iannone / splitr

Use the HYSPLIT model from inside R and do more with it
Other
141 stars 60 forks source link

Allow setup parameters from SETUP_CFG to be configurable #37

Closed rich-iannone closed 5 years ago

rich-iannone commented 5 years ago

First of all, thank you for making this package, it's made process files in batch much easier. However, I'm wondering for the function "hysplit_trajectory", is there any way I can alter parameters for the "SETUP_CFG" file it uses? Because in Hysplit, there is this default parameter kmix0=250, which results in a flooring effect for a lot of data. I could manually change advanced setting in HYSPLIT GUI and make this parameter 0, but then I lose the ability to process files in batch. I tried to make adjustment to your code by add a line of code: setup_cfg <- gsub("kmix0 = 0", "kmix0 = 250", setup_cfg)#Change 'kmix0=250' into 'kmix0=0' in your "hysplit_config_init(dir = exec_dir)" under hysplit_trajectory and then copy the entire function and redefined it in global environment. Just as expected, an error pop up saying the function "get_os" not defined. And when I looked in to your SplitR package. There isn't a "get_os" function defined anywhere either. Any chance you could let me know what I could do to change the default parameter in "SETUP.CFG" and use "hysplit_trajectory"? Because every time I run it, it creates a "SETUP.CFG" file that has the 'kmix0' parameter equal to 250. I know this isn't really closely related to the topic you guys are cracking. But any suggestion is much appreciated. Thank you! kmix comparison

Originally posted by @JunyanL in https://github.com/rich-iannone/splitr/issues/26#issuecomment-523199132

JunyanL commented 5 years ago

Thank you for making this a task! I have only practiced R language for 3 month and am completely new in package development. So i'm not sure if i'm crossing some sort of line for asking this(if I am, apologies in advance): is there any way I can add the extra line in the package myself? Because that would solve the problem i'm having and I really need it solved as soon as possible. I attempted to copy the source code for 'hysplit_trajectory' function then added alterations, then defined the new function in global environment. However, it does not run and has the error:"get_os not defined". The weird thing is, this function is not defined in 'SplitR' package either. I'm wondering what's going on with that. If it's not too much to ask, could you let me know what I can do? Thanks!

rich-iannone commented 5 years ago

@JunyanL the option for setting anything in the config is now available. We can now used the set_config() function in the config argument of hysplit_trajectory(). Here is an example:

trajectory <- 
  hysplit_trajectory(
    lat = c(42.83752, 42.93752),
    lon = c(-80.30364, -80.20364),
    height = c(50, 100, 500),
    duration = 24,
    days = "2012-03-12",
    daily_hours = c(0, 6, 12, 18),
    direction = "backward",
    met_type = "gdas1",
    extended_met = TRUE,
    config = set_config(kmix0 = 0),
    met_dir = here::here("met"),
    exec_dir = here::here("out"),
    clean_up = FALSE
  )
josh4ever commented 4 years ago

Hi Rich,

Can you add config function for dispersion models?