Giter VIP home page Giter VIP logo

nr-rfc-ensweather's Introduction

BC FORECASTING

Lifecycle:Stable

This project was designed by Weatherlogics for the use of the B.C. government for the purposes of bias correcting and forecasting for individual stations run by the B.C. government using the GEPS (Global Ensemble Prediction System).

Install

Installation of this program involves two main parts: installing the python dependencies and installing wgrib2. We recommend installing the python dependences by creating a conda environment as described below. Wgrib2 is a program used to process GRIB2 files containing meteorological data. It must be downloaded and then compiled. We have included some basic instructions about this process below, but more information about wgrib2 is available from the software developer.

Project installation

Within the project directory, the anaconda environment used by this project can be installed as follows:

conda env create --file environment.yaml

If anaconda or miniconda is not already installed on the machine in which this program runs, it is recommended to install miniconda so as to reduce overhead. Miniconda installation instructions can be found on the anaconda website.

WGRIB2 Installation

An additional package must be installed for the project to function correctly (wgrib2). This is an ncep package used for the purposes of modifying and reading grib files used to store government forecast models.

In a suitable directory (downloads for example):

wget ftp://ftp.cpc.ncep.noaa.gov/wd51we/wgrib2/wgrib2.tgz
tar -xzvf wgrib2.tar

cd grib2
sed 's/\\#/#/' <makefile >makefile.cygwin

export CC=gcc
export FC=gfortran
make

cp wgrib2/wgrib2.exe C:\Program Files\wgrib2

Modifications may need to be made to the above script in order to deal with different operating systems. However, installation instructions for this package are also provided by ncep at the same site from which wgrib2 is downloaded.

More details and tips for compiling wgrib2 are available at: https://www.cpc.ncep.noaa.gov/products/wesley/wgrib2/

Configuration

Settings Configuration

Before first usage, in src/config/general_settings:

  • DIR will need to point to the root directory of the project.
  • WGRIB2 must be set to the location of the WGRIB2 install. In the WGRIB2 script found above, this location is 'C:\Program Files\wgrib2'

Beyond that, the user may choose to adjust BIAS_DAYS to include more or fewer days in the bias correction, and may also adjust MAX_HOURS if they wish to reduce the number of days in which to forecast. MAX_HOURS could also be increased if the GEPS model increased in it's runtime.

Additionally, FORECAST_COLUMN denotes the column used to calculate biases for old forecasts, and can be any of RAW_COLUMNS (excepting percentiles), although median or mean is recommended. RAW_COLUMNS denotes all aggregate columns included in the daily raw files. Simply remove whichever columns are not needed.

EXCEL_VARIABLE_ORDER will display forecasts in the order of the list given.

Within each variable in variable settings, new percentiles can be added at will following the same format as 25 and 75 exist in the default installation. For example a new key (10) could be added, with the associated value being 'very_low'. Any number of percentiles can be added, but suffixes should be unique to the key.

New Stations

Within the resources folder, the stations csv contains all stations for which a forecast is created. To add a new station, simply fill in the required fields in this csv. The entered station must also be found in the observational data sheet in order to be used.

Output

Two excel files are created as output of the bias correction program. One is placed in output/daily_raw, the other in output/forecasts. Both are named by their creation date (yyyy-mm-dd.xlsx). The daily raw file contains a sheet for each station, with each variable present as a mean value, lower percentile and upper percentile forecast. The forecast file contains all stations on a single sheet, with only the mean value present.

Usage

The ensemble processing script is executed from the command line. To start a run, the user activates their conda environment and then executes the python script. In its simplest form, the script is executed without any arguments to process the latest GEPS forecast. However, there are some arguments available to control the program:

usage: python src/ens_processing.py [-h] [-v] [-V] [-r RUN] [-d] [-p]

Main program for ensemble model processing.

optional arguments:
  -h, --help         show this help message and exit
  -v, --version      show program's version number and exit
  -V, --verbose      Do not silence terminal output.
  -r RUN, --run RUN  Specify run to forecast. Format is YYYYMMDD_HH
  -d, --download     Only download, do not process.
  -p, --process      Only process, do not download.

Examples

The program can be run on a schedule (e.g. using cron), or executed manually. Here is an example of running all aspects of the program for the most recent cycle of the GEPS.

Using a terminal, change directories to the root of the bc_forecasting directory, and type in the following commands.

conda activate bc_forecasting
python src/ens_processing.py

Arguments can be used to change the behaviour of the run. For example, here we specify a previous cycle of the GEPS to process.

conda activate bc_forecasting
python src/ens_processing.py -r 20210220_00

Arguments can also be used to only download or process the GEPS. For example, if the GEPS for the current cycle has already been downloaded and we only want to process it:

conda activate bc_forecasting
python src/ens_processing.py -p

Or if the GEPS for a previous cycle has already been downloaded and we only want to process it:

conda activate bc_forecasting
python src/ens_processing.py -p -r 20210220_00

Bias Correction

How it works

Using station observational data and archived historical forecasts, we can calculate the errors made by the forecasted data over a period of time. Analyzing those errors may show a systemic bias in the forecast (temperature consistently too low for instance), and using the calculated errors, we then adjust the forecast by the average calculated error. If observations or forecasts are missing for some portion of the bias correction daily range, the bias correction is reduced in magnitude. For example, if only one day of data is present, and the bias range is fifteen days. If that single day had an error of +15 temperature, the bias it generated would be reduced to 1/15 of the original error. (+15 degrees) * (one available day / expected available days). For ratio type bias correction such as precip, a time range of values is summed for both observations and forecasts. The ratio of these values (forecasts/observations) is then used as a multiplier for the new forecast. For example, if forecasts predicted 40mm of precipitation over a time period, and only 20mm occurred, the multiplier would be 0.5 for the new forecast.

nr-rfc-ensweather's People

Contributors

frantarkenton avatar kysiemens avatar paul-pries-weatherlogics avatar scottkehler avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

nr-rfc-ensweather's Issues

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 215 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!

Posting Code

Hey @scottkehler hoping you can post your code to this repo so we can see it and start to figure out the best way to deploy it in our architecture. Let me know if there are any blockers I can help with, with respect to getting what you have posted. It doesn't have to work or be pretty, just want to get a better understanding of what is going to be required to deploy.

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 :)

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.

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

This issue is a kind reminder that your repository has been inactive for 180 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.