Hysplit on R studio:How to change northern hemisphere seasons to southern hemisphere seasons

General questions and postings pertaining to the use of HYSPLIT regardless of the platform. For platform specific questions, use the HYSPLIT Platform forums.
Post Reply
sihlenhlapo_
Posts: 6
Joined: June 15th, 2022, 8:01 am
Registered HYSPLIT User: No
Location: South Africa

Hysplit on R studio:How to change northern hemisphere seasons to southern hemisphere seasons

Post by sihlenhlapo_ »

Hi,

I am doing back trajectories on R studio using openair manual. The study site in focus is in South Africa. When I do the traj plot by seasons in R studio using the code from the openair manual, it plots the seasons assuming the northern hemisphere seasons for example DJF being winter in the North and DJF being summer in my side. I have tried to change season format and it did not work. It plotted DJF as winter, MAM as spring, JJA as summer and SON as autumn which is wrong for my study site. DJF should be summer, MAM should be autumn, JJA should be winter and SON should be spring. Here is my code, please help:

library(openair)
library(tidyverse)
library(lubridate)
library(devtools)
source_gist("https://gist.github.com/davidcarslaw/c6 ... 7796e4bdf5",
filename = "run_hysplit.R")

###this is a default do not change anything###
getMet <- function(year = 2013, month = 1,
path_met = "~/TrajData/") {
for (i in seq_along(year)) {
for (j in seq_along(month)) {
download.file(
url = paste0(
"https://www.ready.noaa.gov/data/archives/reanalysis/RP",
year, sprintf("%02d", month[j]), ".gbl"
),
destfile = paste0(
path_met, "RP", year,
sprintf("%02d", month[j]), ".gbl"
),
mode = "wb"
)
}
}
}
### change here if you want to download a specific year or set to a different path file###
getMet(year = 2022, month = 1:12, path_met = "C:\\PostDoc_UP\\Projects\\Students\\Sihle\\")

data_out <- run_hysplit(
latitude = -28.704083, ### spioenkop lat in decimal degrees
longitude = 29.525928, ### spioenkop lon in dec degrees
runtime = -24, ### short compared to -96
start_height = 3100, ### the desired starting height
model_height = 10000,
start = 2022, ###the desired year
end = "2022-12-31",
hysplit_exec = "C:\\hysplit\\exec",
hysplit_input = "C:\\PostDoc_UP\\Projects\\Students\\Sihle\\",
hysplit_output = "C:\\PostDoc_UP\\Projects\\Students\\Sihle",
site = "spioenkop") ###the name of my study site

saveRDS(data_out, file = "C:\\PostDoc_UP\\Projects\\Students\\Sihle\\myTrajData.rds")
skp_2022 <- readRDS("C:\\PostDoc_UP\\Projects\\Students\\Sihle\\myTrajData.rds") ###named it sk_2022 instead of traj

##change seasons to southern hemisphere seasons
skp_2022$date2 <- as.POSIXct(skp_2022$date2, format = "%Y-%m-%d %H:%M:%S")

New_Season <- function(date) { new_date <- as.Date(format(date, "%Y-12-%d"))
#Modify the month component by subtracting the current month from 12 (December)
new_date <- as.Date(format(new_date, "%Y-%m-%d"))
return(new_date)
}

# Modify dates for the Southern Hemisphere
skp_2022$date_southern <- New_Season(skp_2022$date2)

## plot trajectories
trajPlot(selectByDate(skp_2022, start = "1/1/2022", end = "31/12/2022"),
group = "season", col = "jet", lwd = 2, key.pos = "top",
key.col = 4)
Post Reply

Return to “Users”