Skip to content

JuliaExtremes/CanadianClimateData.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CanadianClimateData 🇨🇦

Active – The project has reached a stable, usable state and is being actively developed. Build Status codecov

CanadianClimateData.jl provides methods to retrieve historical meteorological data from Environment and Climate Change Canada (ECCC) via automatic download and extraction from archives hosted on ECCC's server. The package enables users to extract data from meteorological stations as well as from the Intensity-Duration-Frequency (IDF) engineering dataset.

Installation

To install the package, run the following command in the Julia REPL:

julia> import Pkg
julia> Pkg.add("CanadianClimateData.jl")

Station data

Retrieve the station inventory

The following command downloads the station inventory into the working directory and reads the CSV file into a DataFrame:

julia> using CanadianClimateData
julia> CanadianClimateData.load_station_inventory()

This inventory is useful for identifying station names, station IDs, and climate IDs.

Retrieve Daily Records

The following command downloads the daily data for the station with ClimateID = "702S006" and returns it as a DataFrame:

julia> CanadianClimateData.fetch_daily_records(ClimateID="702S006")

Retrieve Hourly Records

The following command downloads the hourly data for the station with ClimateID = "702S006" and returns it as a DataFrame:

julia> CanadianClimateData.fetch_hourly_records(ClimateID="702S006")

!!! note "Hourly records" Although ECCC allows downloading hourly records, they are often empty because the data is not actually provided.

IDF data

Download the ZIP IDF files of a province

The following command downloads the IDF ZIP file for the province "QC" into the working directory and returns the local path of the archive:

julia> zip_path = CanadianClimateData.download_idf_zip("QC")

Unzip the ZIP IDF files on Unix-based systems (Linux/macOS)

The following command unzips the .txt files contained in the archive and returns the path of the unzipped folder:

julia> unzipped_folder_path = CanadianClimateData.unzip_idf_txt(zip_path)

For Windows user, the archive should be unzipped externally.

Read the IDF text file

The following commands read the text file for the station MONTREAL_PIERRE_ELLIOTT_TRUDEAU_INTL and return a DataFrame:

julia> filename = joinpath(unzipped_folder_path, "idf_v3-30_2022_10_31_702_QC_702S006_MONTREAL_PIERRE_ELLIOTT_TRUDEAU_INTL.txt")
julia> df = CanadianClimateData.parse_idf_table(filename)

Convert the text file to a NetCDF file

The IDF text file can be converted to a NetCDF file as follows:

julia> CanadianClimateData.convert_idf_to_netcdf(filename)

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages