Git Product home page Git Product logo

bcsnowstats's Introduction

img License

bcsnowstats

This package calculates relevant statistics for snow sites in British Columbia. It uses the package ‘bcsnowdata()’ to first retrieve SWE data from automated snow weather (ASWE) and manual snow sites, and calculate statistics (such as mean daily SWE, SWE normals for a defined times period, and percentiles for SWE values).

Features

Installation

Usage

bcsnowstats() contains two functions for analyzing and retrieving statistics for snow water equivalent (SWE) within provincial snow monitoring sites in British Columbia, Canada.

get_snow_stats() calculates statistics for a particular station (either manual or automated) for snow water equivalent (SWE). Statistics can either be calculated for the entire data record, or a particular day, survey period, or year. Statistics include the calculation of normals for a particular span of time specified by the user. Snow normals can also be calculated via the second function contained within the package

  • SWE_normals(). This function will calculate snow normals for a particular station for a particular time span specified by the user. Please see the Snow Normal vignette for a detailed explanation of how snow normals are calculated, including data filling for stations without sufficient data (<20 years of data) over a defined normal time span.

Examples

Statistics

This package contains two functions for retrieving statistics for automated and manual snow sites: 1) get_snow_stats() and 2) SWE_normals().

  1. get_snow_stats()

The get_snow_stats() function returns statistics for a particular station for a specific day or across the entire period of record. The station can be either a manual or automated snow monitoring station.

#> Loading required package: ggplot2
#> 
#> Attaching package: 'plotly'
#> The following object is masked from 'package:ggplot2':
#> 
#>     last_plot
#> The following object is masked from 'package:stats':
#> 
#>     filter
#> The following object is masked from 'package:graphics':
#> 
#>     layout
#> [1] "Calculating statistics for 2C09Q"
#> Reading the data using the read_csv function from the readr package.
#> Warning: One or more parsing issues, see `problems()` for details
#> Rows: 17365 Columns: 108
#> -- Column specification --------------------------------------------------------
#> Delimiter: ","
#> dbl  (105): 1A01P Yellowhead Lake, 1A02P McBride Upper, 1A03P Barkerville, 1...
#> lgl    (2): 2D10P Gray Creek Upper, 4A12P Tsaydaychi Lake
#> dttm   (1): DATE(UTC)
#> 
#> i Use `spec()` to retrieve the full column specification for this data.
#> i Specify the column types or set `show_col_types = FALSE` to quiet this message.
#> Reading the data using the read_csv function from the readr package.
#> 
#> Rows: 3190 Columns: 92
#> -- Column specification --------------------------------------------------------
#> Delimiter: ","
#> dbl  (91): 1A01P Yellowhead Lake, 1A02P McBride Upper, 1A03P Barkerville, 1A...
#> dttm  (1): DATE(UTC)
#> 
#> i Use `spec()` to retrieve the full column specification for this data.
#> i Specify the column types or set `show_col_types = FALSE` to quiet this message.
#> Joining, by = c("date_utc", "id", "value", "parameter")
#> Saving to bcsnowstats data directory at C:\Users\AJOLLYMO\AppData\Local/R/cache/R/bcsnowstats
#> 
#> Joining, by = c("id", "m_d")
#> # A tibble: 1 x 51
#>   date_utc            id    value parameter    wr m_d   date_dmy   mean_day
#>   <dttm>              <chr> <dbl> <chr>     <dbl> <chr> <date>        <dbl>
#> 1 2021-03-01 16:00:00 2C09Q   358 swe        2021 03-01 2021-03-01      358
#> # ... with 43 more variables: min <dbl>, swe_mean <dbl>, Q5 <dbl>, Q10 <dbl>,
#> #   Q25 <dbl>, Q50 <dbl>, Q75 <dbl>, Q90 <dbl>, max <dbl>, maxdate <dbl>,
#> #   mindate <dbl>, data_range <chr>, numberofyears <int>, date_min_utc <dttm>,
#> #   date_max_utc <dttm>, normal_minimum <dbl>, normal_swe_mean <dbl>,
#> #   normal_Q5 <dbl>, normal_Q10 <dbl>, normal_Q25 <dbl>, normal_Q50 <dbl>,
#> #   normal_Q75 <dbl>, normal_Q90 <dbl>, normal_maximum <dbl>,
#> #   data_range_normal <chr>, normal_datarange_estimated <int>, ...
  1. SWE_normals()

The SWE_normals function calculates normals for a defined time span. See vignette for a detailed explanation of how normals are calculated (including data coverage thresholds and data filling procedures).

#> Reading the data using the read_csv function from the readr package.
#> Warning: One or more parsing issues, see `problems()` for details
#> Rows: 17365 Columns: 108
#> -- Column specification --------------------------------------------------------
#> Delimiter: ","
#> dbl  (105): 1A01P Yellowhead Lake, 1A02P McBride Upper, 1A03P Barkerville, 1...
#> lgl    (2): 2D10P Gray Creek Upper, 4A12P Tsaydaychi Lake
#> dttm   (1): DATE(UTC)
#> 
#> i Use `spec()` to retrieve the full column specification for this data.
#> i Specify the column types or set `show_col_types = FALSE` to quiet this message.
#> Reading the data using the read_csv function from the readr package.
#> 
#> Rows: 3190 Columns: 92
#> -- Column specification --------------------------------------------------------
#> Delimiter: ","
#> dbl  (91): 1A01P Yellowhead Lake, 1A02P McBride Upper, 1A03P Barkerville, 1A...
#> dttm  (1): DATE(UTC)
#> 
#> i Use `spec()` to retrieve the full column specification for this data.
#> i Specify the column types or set `show_col_types = FALSE` to quiet this message.
#> Joining, by = c("date_utc", "id", "value", "parameter")
#> Saving to bcsnowstats data directory at C:\Users\AJOLLYMO\AppData\Local/R/cache/R/bcsnowstats
#> 
#> Reading the data using the read_csv function from the readr package.
#> 
#> Rows: 58014 Columns: 13
#> -- Column specification --------------------------------------------------------
#> Delimiter: ","
#> chr  (5): Snow Course Name, Number, Survey Code, Snow Line Code, Survey Period
#> dbl  (7): Elev. metres, Snow Depth cm, Water Equiv. mm, Snow Line Elev. m, %...
#> date (1): Date of Survey
#> 
#> i Use `spec()` to retrieve the full column specification for this data.
#> i Specify the column types or set `show_col_types = FALSE` to quiet this message.
#> Reading the data using the read_csv function from the readr package.
#> 
#> Rows: 180 Columns: 13
#> -- Column specification --------------------------------------------------------
#> Delimiter: ","
#> chr  (5): Snow Course Name, Number, Survey Code, Snow Line Code, Survey Period
#> dbl  (7): Elev. metres, Snow Depth cm, Water Equiv. mm, Snow Line Elev. m, %...
#> date (1): Date of Survey
#> 
#> i Use `spec()` to retrieve the full column specification for this data.
#> i Specify the column types or set `show_col_types = FALSE` to quiet this message.
#> Joining, by = c("Snow Course Name", "Number", "Elev. metres", "Date of Survey", "Snow Depth cm", "Water Equiv. mm", "Survey Code", "Snow Line Elev. m", "Snow Line Code", "% of Normal", "Density %", "Survey Period", "Normal mm")
#> Joining, by = "id"
#> Joining, by = "id"
Visualizations

This package also contains several functions for visualizing data and statistics from manual and automated snow monitoring. The RFC also produces a map that includes these interactive snow plots. All interactive plots were made using the plotly R package.

Automated Snow Station Visulizations
  1. plot_interactive_aswe This function plots SWE for the current water year for a particular ASWE station. The statistics for the station, including data for the past years, is also plotted.
plot_test <- plot_interactive_aswe(id = "1A01P",
                      save = FALSE)
plot_test$SWEplot
  1. plot_climate_aswe This function plots climate data from ASWE sites for the current water year, including daily precipitation, daily max and min air temperatures, and daily change in SWE.
climate <- plot_climate_aswe(id ="1A01P",
                                 save = FALSE)
climate
  1. plot_monthly_deltaswe This function plots the monthly change in SWE for automated snow survey stations. The monthly change is calculated for past months of data, and shows the change in SWE from the first to the last day of the month for the current year; the boxplot shows how the current year compares to previous years of data.
monthly_delta <- plot_monthly_deltaswe(id ="1A01P", 
                      save = FALSE)
monthly_delta
Manual Snow Station Visualizations
  1. plot_interactive_manual This function plots data from manual surveys. The interactive plot also shows statistics for the most recent manual snow survey, as well as the previous years data.
plot_manual <- plot_interactive_manual(id = "1B06",
                                       save = FALSE)
plot_manual
Snow Basin Visualizations
  1. plot_interactive_basin This function returns an interactive plot of SWE values averaged for all ASWE stations within a particular basin. Data for past years is also presented within the same plot.

Exceptions are any sites that the user wishes to skip within the calculation of basin-wide SWE (such as those with issues). The user also has the option to save the plot in the location of their specification.

plot_basin <- plot_interactive_basin(basin = "UpperFraserEast",
                       exceptions = NA,
                       save = FALSE)
plot_basin

Project Status

In development; may change or evolve.

Getting Help or Reporting an Issue

To report bugs/issues/feature requests, please file an issue.

How to Contribute

If you would like to contribute to the package, please see our CONTRIBUTING guidelines.

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

License

Copyright 2021 Province of British Columbia

Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an &quot;AS IS&quot; BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.

This project was created using the bcgovr package.

bcsnowstats's People

Contributors

ashjolly avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

pefrens

bcsnowstats's Issues

Lets use common phrasing

TL;DR 🏎️

Teams are encouraged to favour modern inclusive phrasing both in their communication as well as in any source checked into their repositories. You'll find a table at the end of this text with preferred phrasing to socialize with your team.

Words Matter

We're aligning our development community to favour inclusive phrasing for common technical expressions. There is a table below that outlines the phrases that are being retired along with the preferred alternatives.

During your team scrum, technical meetings, documentation, the code you write, etc. use the inclusive phrasing from the table below. That's it - it really is that easy.

For the curious mind, the Public Service Agency (PSA) has published a guide describing how Words Matter in our daily communication. Its an insightful read and a good reminder to be curious and open minded.

What about the master branch?

The word "master" is not inherently bad or non-inclusive. For example people get a masters degree; become a master of their craft; or master a skill. It's generally when the word "master" is used along side the word "slave" that it becomes non-inclusive.

Some teams choose to use the word main for the default branch of a repo as opposed to the more commonly used master branch. While it's not required or recommended, your team is empowered to do what works for them. If you do rename the master branch consider using main so that we have consistency among the repos within our organization.

Preferred Phrasing

Non-Inclusive Inclusive
Whitelist => Allowlist
Blacklist => Denylist
Master / Slave => Leader / Follower; Primary / Standby; etc
Grandfathered => Legacy status
Sanity check => Quick check; Confidence check; etc
Dummy value => Placeholder value; Sample value; etc

Pro Tip 🤓

This list is not comprehensive. If you're aware of other outdated nomenclature please create an issue (PR preferred) with your suggestion.

Add project lifecycle badge

No Project Lifecycle Badge found in your readme!

Hello! I scanned your readme and could not find a project lifecycle badge. A project lifecycle badge will provide contributors to your project as well as other stakeholders (platform services, executive) insight into the lifecycle of your repository.

What is a Project Lifecycle Badge?

It is a simple image that neatly describes your project's stage in its lifecycle. More information can be found in the project lifecycle badges documentation.

What do I need to do?

I suggest you make a PR into your README.md and add a project lifecycle badge near the top where it is easy for your users to pick it up :). Once it is merged feel free to close this issue. I will not open up a new one :)

Add missing topics

TL;DR

Topics greatly improve the discoverability of repos; please add the short code from the table below to the topics of your repo so that ministries can use GitHub's search to find out what repos belong to them and other visitors can find useful content (and reuse it!).

Why Topic

In short order we'll add our 800th repo. This large number clearly demonstrates the success of using GitHub and our Open Source initiative. This huge success means it's critical that we work to make our content as discoverable as possible. Through discoverability, we promote code reuse across a large decentralized organization like the Government of British Columbia as well as allow ministries to find the repos they own.

What to do

Below is a table of abbreviation a.k.a short codes for each ministry; they're the ones used in all @gov.bc.ca email addresses. Please add the short codes of the ministry or organization that "owns" this repo as a topic.

add a topic

That's it, you're done!!!

How to use

Once topics are added, you can use them in GitHub's search. For example, enter something like org:bcgov topic:citz to find all the repos that belong to Citizens' Services. You can refine this search by adding key words specific to a subject you're interested in. To learn more about searching through repos check out GitHub's doc on searching.

Pro Tip 🤓

  • If your org is not in the list below, or the table contains errors, please create an issue here.

  • While you're doing this, add additional topics that would help someone searching for "something". These can be the language used javascript or R; something like opendata or data for data only repos; or any other key words that are useful.

  • Add a meaningful description to your repo. This is hugely valuable to people looking through our repositories.

  • If your application is live, add the production URL.

Ministry Short Codes

Short Code Organization Name
AEST Advanced Education, Skills & Training
AGRI Agriculture
ALC Agriculture Land Commission
AG Attorney General
MCF Children & Family Development
CITZ Citizens' Services
DBC Destination BC
EMBC Emergency Management BC
EAO Environmental Assessment Office
EDUC Education
EMPR Energy, Mines & Petroleum Resources
ENV Environment & Climate Change Strategy
FIN Finance
FLNR Forests, Lands, Natural Resource Operations & Rural Development
HLTH Health
IRR Indigenous Relations & Reconciliation
JEDC Jobs, Economic Development & Competitiveness
LBR Labour Policy & Legislation
LDB BC Liquor Distribution Branch
MMHA Mental Health & Addictions
MAH Municipal Affairs & Housing
BCPC Pension Corporation
PSA Public Service Agency
PSSG Public Safety and Solicitor General
SDPR Social Development & Poverty Reduction
TCA Tourism, Arts & Culture
TRAN Transportation & Infrastructure

NOTE See an error or omission? Please create an issue here to get it remedied.

It's Been a While Since This Repository has Been Updated

This issue is a kind reminder that your repository has been inactive for 181 days. Some repositories are maintained in accordance with business requirements that infrequently change thus appearing inactive, and some repositories are inactive because they are unmaintained.

To help differentiate products that are unmaintained from products that do not require frequent maintenance, repomountie will open an issue whenever a repository has not been updated in 180 days.

  • If this product is being actively maintained, please close this issue.
  • If this repository isn't being actively maintained anymore, please archive this repository. Also, for bonus points, please add a dormant or retired life cycle badge.

Thank you for your help ensuring effective governance of our open-source ecosystem!

It's Been a While Since This Repository has Been Updated

This issue is a kind reminder that your repository has been inactive for 182 days. Some repositories are maintained in accordance with business requirements that infrequently change thus appearing inactive, and some repositories are inactive because they are unmaintained.

To help differentiate products that are unmaintained from products that do not require frequent maintenance, repomountie will open an issue whenever a repository has not been updated in 180 days.

  • If this product is being actively maintained, please close this issue.
  • If this repository isn't being actively maintained anymore, please archive this repository. Also, for bonus points, please add a dormant or retired life cycle badge.

Thank you for your help ensuring effective governance of our open-source ecosystem!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.