Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include gaps in coverage plots #314

Closed
philipshirk opened this issue Sep 11, 2019 · 6 comments · Fixed by #343
Closed

Include gaps in coverage plots #314

philipshirk opened this issue Sep 11, 2019 · 6 comments · Fixed by #343
Milestone

Comments

@philipshirk
Copy link
Contributor

philipshirk commented Sep 11, 2019

I'm not sure if this really belongs in the issues or the forum, since it's more a feature request than a bug, but here it goes. In some cases stations are missing a lot of data, making the autoplot() of a meteo_coverage object very misleading. For example:

library(rnoaa)
library(ggplot2)

# Site
Safe_Harbor <-  'USC00367732'

# get data
dat <- meteo_pull_monitors(monitors =  Safe_Harbor, 
                            keep_flags = T, 
                            var = c("PRCP", "TAVG", "TMAX", "TMIN"))

# autoplot plots from first to last date, ignoring gaps
obs_covr <- meteo_coverage(meteo_df = dat)
autoplot(obs_covr)

# Alternative plot, showing gaps
# unique dates
min_date <- min(dat$date)
max_date <- max(dat$date)
dates <- data.frame(date = as.Date(x = seq.Date(from = min_date,
to = max_date, 
by = 'day')))
# join the original data to all the unique dates
temp <- dplyr::full_join(x = dates,
y = dat,
by='date')
temp$location <- Safe_Harbor

# dummy column for plotting
temp$size <- NA
temp$size[which(!is.na(temp$prcp))] <- 1

# plot with gaps in coverage
ggplot(temp, aes(x = date, y = location, size = size))+
   theme_bw()+
   geom_line(show.legend = F)
@sckott
Copy link
Contributor

sckott commented Sep 11, 2019

Thanks for the issue @filups - Sorry for any confusion: this is a great place to open issues regarding bugs, features, use cases, etc. Not just bug reports.

@geanders do you have any thoughts on this? plotting stuff is not one of my skills, and you were the original author of this i think

it makes sense to me to make this change to account for gaps

@sckott
Copy link
Contributor

sckott commented Sep 20, 2019

@filups if you have time, could you send a pull request with your proposed changes?

@philipshirk
Copy link
Contributor Author

I'll see what I can do. Could you save me a bit of time by pointing me towards where I can find the code for the autoplot function and some info on the meteo_coverage output structure?

@sckott
Copy link
Contributor

sckott commented Sep 23, 2019

@philipshirk
Copy link
Contributor Author

philipshirk commented Mar 6, 2020

I (finally) started working on this, but I'm not sure if I can stay within the confines of the meteo_coverage class. What can you tell me about that class? Is it used for anything other than the autoplot.meteo_coverage function? My initial thought is to change the output of the meteo_coverage function from a data.frame to a list that contains the current data.frame output as well as a 2nd data.frame that I'll use for plotting in the autoplot.meteo_coverage.

@sckott
Copy link
Contributor

sckott commented Mar 6, 2020

@philipshirk Great, glad to hear it. Looks like meteo_coverage is only used for autoplot - so we are free to change it outputs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants