davidcarslaw / openair

Tools for air quality data analysis
https://davidcarslaw.github.io/openair/
GNU General Public License v2.0
303 stars 113 forks source link

Using 'ProcTraj' or 'run_hysplit' for non-Reanalysis data #174

Closed adoede closed 1 year ago

adoede commented 5 years ago

Hello,

I am attempting to run trajectories using NAM12 data rather than Reanalysis. I modified the getMet function for this purpose and was able to download the files, but it seems that the openair/opentraj package functions are looking only for Reanalysis-type files (RPyyyymm.gbl) only. Is there a modification that can be made to accommodate these different data?

Thank you very much for any help you can give.

jobonaf commented 5 years ago

Hi @adoede , getMet is not a function of the openair package. You probably found it here, in the repository run_hysplit. Package openair does not include functions to run HYSPLIT or to read its meteorological input. Function importTraj imports pre-calculated backtrajectories. You could try to submit this issue in the opentraj repository. Or run HYSPLIT with the SplitR package.

manleiva commented 5 years ago

one year

getMet <- function (year = 2018, month = 1, path_met = "~/TrajData/") { for (i in seq_along(year)) { for (j in seq_along(month)) { download.file(url = paste0("ftp://arlftp.arlhq.noaa.gov/pub/archives/reanalysis/RP", year[i], sprintf("%02d", month[j]), ".gbl"), destfile = paste0(path_met, "RP", year[i], sprintf("%02d", month[j]), ".gbl"), mode = "wb") } } }

many years

getMet <- function (year = 2010:2012, month = 1:12, path_met = "~/TrajData/") { for (i in seq_along(year)) { for (j in seq_along(month)) { download.file(url = paste0("ftp://arlftp.arlhq.noaa.gov/pub/archives/reanalysis/RP", year[i], sprintf("%02d", month[j]), ".gbl"), destfile = paste0(path_met, "RP", year[i], sprintf("%02d", month[j]), ".gbl"), mode = "wb") } } }

nogpaul commented 3 years ago

@manleiva @jobonaf @davidcarslaw @GjjvdBurg Please is there a way I can edit the getMet function to include variables like Temprature, windspeed, humidity and rain fall in My data extraction? Currently when I run run_hysplit() I only get lat, lon, date, time, pressure, and elevation but I also need Temprature, windspeed humidity and Rain fall in my extracted data. So please how I can solve this issue

schonhose commented 3 years ago

@nogpaul. This has nothing to do with the function to get the meteo. You need to add those extra variables to the cfg file for Hysplit.

Here is a list of possible options.

nogpaul commented 3 years ago

@schonhose Thanks a lot for the reply. Please I have one more question. is it possible to plot backward trajectory on openair without hour.inc variable? if yes how can I go about this.

Thanks @davidcarslaw @jobonaf @GjjvdBurg @cvitolo @Agriculturist

schonhose commented 3 years ago

@nogpaul I do not understand the question, can you elaborate?

nogpaul commented 3 years ago

@schonhose Hi I am currently trying to plot some trajectories using trajPlot() from openair. I extracted my data from hysplit using run_hysplit() from openair(I am not using importTraj(). this is what the data looks like

 receptor year month day hour hour.inc    lat
1        1 2017     2   1    0        0 52.524
2        1 2017     1  31   23       -1 52.551
3        1 2017     1  31   22       -2 52.573
4        1 2017     1  31   21       -3 52.592
5        1 2017     1  31   20       -4 52.606
6        1 2017     1  31   19       -5 52.615
     lon height pressure               date2
1 13.411   10.0   1011.2 2017-02-01 00:00:00
2 13.502   12.0   1010.4 2017-01-31 23:00:00
3 13.606   14.2   1009.5 2017-01-31 22:00:00
4 13.721   16.3   1008.7 2017-01-31 21:00:00
5 13.848   18.3   1008.0 2017-01-31 20:00:00
6 13.986   19.7   1007.3 2017-01-31 19:00:00
        date start_height      site
1 2017-02-01           10 Solenzara
2 2017-02-01           10 Solenzara
3 2017-02-01           10 Solenzara
4 2017-02-01           10 Solenzara
5 2017-02-01           10 Solenzara
6 2017-02-01           10 Solenzara

each time I run trajPlot() I get this error message

**Can't find the variable(s) lat lon hour.inc height 
 Error in checkPrep(mydata, vars, type, remove.calm = FALSE) : 
3.
stop(cat("Can't find the variable(s)", varNames[!matching], "\n")) 
2.
checkPrep(mydata, vars, type, remove.calm = FALSE) 
1.
trajPlot(ber, lon = "lon", lat = "lat", 
    pollutant = "height", type = "default", map = TRUE, group = NA, 
    map.fill = TRUE, map.res = "default", map.cols = "grey40", 
    map.alpha = 0.4, projection = "lambert", parameters = c(51,  ...** 

Please what I am doing wrong

Update I am also tried using importTraj() function to import met data, plotting trajectories using trajPlot() I am getting the same error message

schonhose commented 3 years ago

The function checkPrep() checks if the input is corresponding to what the function needs. It says it cannot find the variables needed, so I am wondering what is in the ber variable.

EduardoYubero commented 2 years ago

Hi, I am having problems using the function GetMet:

I am introducing this code:

getMet <- function (year = 2018, month = 1, path_met = "~/TrajData/") { for (i in seq_along(year)) { for (j in seq_along(month)) { download.file(url = paste0("ftp://arlftp.arlhq.noaa.gov/pub/archives/reanalysis/RP", year[i], sprintf("%02d", month[j]), ".gbl"), destfile = paste0(path_met, "RP", year[i], sprintf("%02d", month[j]), ".gbl"), mode = "wb") } } }

and when I introduce:

getMet(year = 2018, month = 1:12)

I am getting this error:

Error in download.file(url = paste0("ftp://arlftp.arlhq.noaa.gov/pub/archives/reanalysis/RP", : cannot open destfile '~/TrajData/RP201801.gbl', reason 'No such file or directory' In addition: Warning message: In download.file(url = paste0("ftp://arlftp.arlhq.noaa.gov/pub/archives/reanalysis/RP", : the 'wininet' method is deprecated for ftp:// URLs

I have created a folder with the name TrajData but I am getting the same result. Can you help me with this? I am using Windows 10.

Thanks!

davidcarslaw commented 2 years ago

Hi

I think this is because the destination directory where the files are saved does not exist. So, path_met needs to point to a directory on your computers that exists i.e. not "~/TrajData/"...

David

On Wed, 17 Nov 2021 at 10:17, EduardoYubero @.***> wrote:

Hi, I am having problems using the function GetMet:

I am introducing this code:

getMet <- function (year = 2018, month = 1, path_met = "~/TrajData/") { for (i in seq_along(year)) { for (j in seq_along(month)) { download.file(url = paste0(" ftp://arlftp.arlhq.noaa.gov/pub/archives/reanalysis/RP", year[i], sprintf("%02d", month[j]), ".gbl"), destfile = paste0(path_met, "RP", year[i], sprintf("%02d", month[j]), ".gbl"), mode = "wb") } } }

and when I introduce:

getMet(year = 2018, month = 1:12)

I am getting this error:

Error in download.file(url = paste0(" ftp://arlftp.arlhq.noaa.gov/pub/archives/reanalysis/RP", : cannot open destfile '~/TrajData/RP201801.gbl', reason 'No such file or directory' In addition: Warning message: In download.file(url = paste0(" ftp://arlftp.arlhq.noaa.gov/pub/archives/reanalysis/RP", : the 'wininet' method is deprecated for ftp:// URLs

I have created a folder with the name TrajData but I am getting the same result. Can you help me with this? I am using Windows 10.

Thanks!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/davidcarslaw/openair/issues/174#issuecomment-971433756, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJN4CY376ZJJ53EP4F5CWTUMN6NBANCNFSM4F7RZA7A .

EduardoYubero commented 2 years ago

Now it is working, thanks!