rich-iannone / splitr

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

How to run SplitR for NARR #4

Closed kurkutesa closed 8 years ago

kurkutesa commented 8 years ago

Hi Richard, I am curious if can I run SplitR using NARR data ?
If yes could you please let me know what kind of changes do I need to do ?

Thank You, Shanky

rich-iannone commented 8 years ago

Hey! This seemed to me like a request so I built in the ability to do NARR runs (with trajectories) last night. Here's an example:

devtools::install_github("rich-iannone/SplitR")
library(SplitR)
setwd("~/Documents/wd_splitR")

wind_trajectories_narr <-
  hysplit_trajectory(
    traj_name = "narr_test",
    return_traj_df = TRUE,
    start_lat_deg = 49.263405,
    start_long_deg = -123.250054,
    start_height_m_AGL = 50,
    simulation_duration_h = 24,
    backtrajectory = TRUE,
    met_type = "narr",
    vertical_motion_option = 0,
    top_of_model_domain_m = 20000,
    run_type = "day",
    run_day = "2013-07-2015",
    daily_hours_to_start = c(0, 12),
    return_met_along_traj = TRUE)

trajectory_plot(wind_trajectories_narr)

I'm in the middle of testing this (the NARR files are pretty large so download times are somewhat lengthy) but it seems to work well. You need to have NARR201306, NARR201307, and NARR201308 in the R working directory (in the example above this was "~/Documents/wd_splitR"). SplitR will try to download these met files but you can also do it yourself with a better FTP program. Files are available at ftp://arlftp.arlhq.noaa.gov/narr. Let me know if you have any questions performing these model runs.

kurkutesa commented 8 years ago

Hi Richard, Thank you very much for your reply. The changes you'd made about including NARR data source are working excellent. I do have few queries about trajectory and dispersion runs ... A. Trajectory Runs :

  1. I wanted to run back-trajectories for multiple locations in a single run. I am not sure how to insert multiple locations at "_start_latdeg = ", ... Ex. in HYSPLIT we can give multiple locations in CONTROL file.
  2. As well as, How I can run the Matrix and Cluster Analysis like HYSPLIT ?

B. Dispersion Runs: When I had tried to run Dispersion using following SplitR function test111<-hysplit_dispersion( disp_name = Example, return_disp_df = TRUE, write_disp_CSV = TRUE, start_lat_deg = 49.263405, start_long_deg = -113.250054, start_height_m_AGL = 1500, simulation_duration_h = 96, backward_running = TRUE, met_type = "reanalysis", vertical_motion_option = 0, top_of_model_domain_m = 20000, number_of_particles = 2500, max_particles = 10000, run_type = "day", run_day = "2005-06-18", daily_hours_to_start = c(00,03,06,09,12,15,18,21), emissions = 0, species = 0, grids = 1)

I had got the following Error: Error in file(file, "rt") : cannot open the connection In addition: Warning message: In file(file, "rt") : cannot open file '/Users/sopan/Downloads/Assign#3-2/emissions': No such file or directory I do not need emission and species files because I am running Dispersion model using airmass (without any particle emissions).

I hope I am not asking you too much. Once again thank you very much for your reply and for your time.

Thank You, Cheers, Shanky

kurkutesa commented 8 years ago

Hi Richard, I had figured it out about trajectories with multiple locations. I only have queries about Matrix runs, Clustering and Dispersion using SplitR as mentioned in earlier comment.

Thanking Yours, Cheers, Sopan

rich-iannone commented 8 years ago

@shanky1985 for dispersion, you need to have information about emissions and species. Just create zero-quantity versions of them and then run (see below),

dispersion_preset_add(
  type = 'emissions',
  interactive = FALSE,
  emissions_name = "none",
  emissions_rate = 0,
  emissions_duration = 1,
  emissions_start_time = "2005 06 18 00 00")

dispersion_preset_add(
  type = "species",
  interactive = FALSE,
  species_name = "none",
  particle_pdiam = 0,
  particle_density = 0,
  particle_shape_factor = 0,
  ddep_velocity = 0,
  ddep_MW = 0,
  ddep_A_ratio = 0,
  ddep_D_ratio = 0,
  ddep_Henrys_Law_coeff = 0,
  wdep_Henrys_Law_coeff = 0,
  wdep_in_cloud_dep = 0,
  wdep_below_cloud_dep = 0,
  rad_decay = 0,
  pollutant_resuspension_factor = 0)

test111<-hysplit_dispersion(
  disp_name = Example,
  return_disp_df = TRUE,
  write_disp_CSV = TRUE,
  start_lat_deg = 49.263405,
  start_long_deg = -113.250054,
  start_height_m_AGL = 1500,
  simulation_duration_h = 96,
  backward_running = TRUE,
  met_type = "reanalysis",
  vertical_motion_option = 0,
  top_of_model_domain_m = 20000,
  number_of_particles = 2500,
  max_particles = 10000,
  run_type = "day",
  run_day = "2005-06-18",
  daily_hours_to_start = c(0, 3, 6, 9, 12, 15, 18, 21),
  emissions = 1,
  species = 1,
  grids = 1)

For a matrix run, there doesn't exist functionality to do this yet with just two lat/lon pairs defining the corners. However, you can for the time being create two vectors for lat and lon using a for loop and the seq function. Then pass those vectors to start_lat_deg and start_long_deg.

Clustering is not yet available in Splitr but the the data frames returned from the hysplit_trajectory() function can be used with the trajCluster() function in the OpenAir package. Details can be found here: https://github.com/davidcarslaw/openair.