rich-iannone / splitr

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

trajectory_read.R for variable header lengths #32

Closed hawkinsEPA closed 5 years ago

hawkinsEPA commented 5 years ago

The following logic is needed for trajectory_read.R to correctly read in trajectory files with differing variable header lengths using the expanded met fields. Without this the code will error here:
traj_df <- cbind(traj_df, traj_extra_df)

Fix is below... add in code starting at line 206... 206,220c206 < traj_temp <- try( < read.fwf(paste0(path.expand(output_folder), < "/", trajectory_file_list[i]), < widths = column_widths) < ) < < if(class(traj_temp)!="try-error") { < for (j in 1:nrow(traj_temp)) { < if (length(grep("PRESS", < traj_temp[j,2])) != 0) { < skip_up_to_line <- j < } < } < } <

rich-iannone commented 5 years ago

Hello. Sorry for the use of cbind(). Was not a good idea. I’ve recently changed this so that the code uses a dplyr::right_join().