Closed karawoo closed 5 years ago
Thanks Kara -- Andy and I will review tomorrow and get back to you, but Andy will get to your specific questions today.
This is a great start! I can run the Rmd and produce the pdf (with the small tweak in functions.R
suggested above).
For including all years, for now can you try adding !is.na(longitude), !is.na(latitiude)
to the filter call here to exclude the stations without lat/longs, and then subset ozone_clean_data
to just those stations in stations_az
?
So the bottom of 02_clean.R
in the ozone repo would look something like this:
#assign airzones to stations
stations_az <- stations_clean %>%
filter(ems_id %in% unique(ozone_site_summary$ems_id),
!is.na(latitude), !is.na(longitude)) %>%
assign_airzone(airzones = azone,
coords = c("longitude", "latitude")) %>%
select(ems_id, station_name, city, lat, lon, airzone)
ozone_clean_data <- ozone_clean_data %>%
semi_join(stations_az, by = "ems_id")
I haven't tested it right the way through the pipeline yet, but running o3_caaqs(ozone_clean_data)
does work.
One other thought - since running the analysis scripts takes some time with the full data sets, I wonder if render_airzone_reports.R
should just load the .RData
/.rda
objects rather than sourcing all the scripts - it would make for much faster iteration and would avoid setting/resetting your working directory. E.g., something like:
load(file.path(ozone_dir, "tmp/ozone_clean.RData"))
load(file.path(ozone_dir, "tmp/analysed.RData"))
load(file.path(pm25_dir, "tmp/pm25_clean.rda"))
load(file.path(pm25_dir, "tmp/analysed.RData"))
Kara -- the plots look good. There are some minor editorial issues that I will provide for you in one go so you can deal with that at the end (like font size, missing label on chart and extra space). Nothing major.
Thanks for the suggestions @ateucher! And yes, sounds good to do the editorial things all at the end -- I'm sure there will be a bunch of minor tweaks to get all the figures for the different air zones looking good.
@karawoo I’ve pushed updates to the ozone and pm2.5 repos that should create objects containing the annual results for the full time range (2010-2017)
Hi @karawoo - I know you haven't asked for review yet but I was curious so I pulled and ran it, and all rendered nicely - looking great!
We have a function in rcaaqs
that generates the red/yellow/orange/red colours we use on our indicator web pages:
.
If @nmsuzuki likes them, the function is rcaaqs::get_colours()
that generates a named vector of hex colour codes:
rcaaqs::get_colours(type = "management")
#> Insufficient Data
#> "grey80"
#> Actions for Keeping Clean Areas Clean
#> "#A6D96A"
#> Actions for Preventing Air Quality Deterioration
#> "#FEE08B"
#> Actions for Preventing CAAQS Exceedance
#> "#F46D43"
#> Actions for Achieving Air Zone CAAQS
#> "#A50026"
You could use them here: https://github.com/bcgov/air-zone-reports/blob/e9962266444d19b791c0065069b97206618c648e/functions.R#L145-L153
Andy - the colours you have used for State of Air Reporting are fine -- they just have to be clearly distinguishable as green, yellow, orange and red. So Kara - feel free to use rcaaqs for this.
Merged pull request (#3) by @karawoo satisfies the requirements for this code with us opportunity.
This creates one report template for one air zone (Georgia Strait) with the four figures from the example report, helper functions to create these figures, and a script to run the ozone and PM2.5 analyses and then render the report. The tables are not included yet, but I wanted to open this PR so you can see how things are looking so far.
Both the text and the figure aspect ratios will probably need to vary by report (since not all air zones have the same number of stations, there won't be a single size for each bar chart that works well for all reports). Since both of these things will probably need customizing, I'm opting to create 6 Rmd templates for now, and minimize the repeated code as much as possible by wrapping it in functions in the
functions.R
script.I'm using the
ozone_caaqs_results
andpm_caaqs_combined_results
objects for the bar charts andozone_caaqs
andpm25_caaqs_annual
for the time series. As we discussed, the analysis as written only covers 3 years. @ateucher I think I might need your help in getting the full data needed for the time series figures. Removing this line from the ozone data processing causes errors when assigning stations to airzones here. Some of the stations in the full data lack coordinates. Do you have any thoughts on where I can find those?