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.
To install the package, run the following command in the Julia REPL:
julia> import Pkg
julia> Pkg.add("CanadianClimateData.jl")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.
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")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.
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")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.
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)The IDF text file can be converted to a NetCDF file as follows:
julia> CanadianClimateData.convert_idf_to_netcdf(filename)