Skip to content

Latest commit

 

History

History
19 lines (10 loc) · 1.72 KB

README.md

File metadata and controls

19 lines (10 loc) · 1.72 KB

This Python script is designed to download files from a specified URL for a weather model. Here's a breakdown of what it does:

  1. The script defines a function download_file(url, save_path) which takes a URL and a save path. It sends a request to the URL using the requests library, and if the response status code is 200 (indicating success), it saves the content of the response to the specified file path.

  2. url: https://dd.weather.gc.ca/model_wcps/ocean-atmosphere/1km/

  3. Another function download_files(base_url, runs, outpath) is defined. This function is responsible for constructing specific URLs based on provided parameters and then calling download_file() to download the files.

  4. In the download_files() function, it iterates over each run and each prediction hour (from 0 to 24). For each combination of run and prediction hour, it constructs four URLs corresponding to different weather data types: WindU, WindV, SeaWaterVelocityX, and SeaWaterVelocityY.

  5. It then constructs file paths for saving these downloaded files based on the provided outpath, formatted_previous_date_for_output, and pred_hour.

  6. It downloads each file using the download_file() function and prints the path of the downloaded file.

  7. Finally, in the main block, it sets the base URL, output path, prediction hours, and runs. Then it iterates over the runs and calls the download_files() function to download the files for each run.

  8. Note that the script is set to download files for only one run (runs = ['00']), but it's commented that multiple runs can be specified for more data retrieval.

Overall, this script is a utility to automate the download of weather model data files for specific runs and prediction hours from a given URL.