Skip to content
Snippets Groups Projects
Commit 7b017320 authored by David Akim's avatar David Akim
Browse files

Update file 0_download_data.ipynb

parent 9b8075f7
No related branches found
No related tags found
No related merge requests found
Pipeline #2932 failed with stages
in 1 minute and 37 seconds
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
Load libraries # Load libraries
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` ```
# CDS API # CDS API
import cdsapi import cdsapi
``` ```
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
Directories for Data # Directories for Data
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` ```
DATADIR = 'era5/' DATADIR = 'era5/'
LABELDIR = 'fire_danger/' LABELDIR = 'fire_danger/'
``` ```
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
Download ERA5 data for Argentina from 2002 to 2022 # Download ERA5 data for Argentina from 2002 to 2022
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` ```
for year in range(2002,2023): for year in range(2002,2023):
target_file = DATADIR + f'{year}.nc' target_file = DATADIR + f'{year}.nc'
c = cdsapi.Client() c = cdsapi.Client()
c.retrieve( c.retrieve(
'reanalysis-era5-single-levels', 'reanalysis-era5-single-levels',
{ {
'product_type': 'reanalysis', 'product_type': 'reanalysis',
'format': 'netcdf', 'format': 'netcdf',
'month': [ 'month': [
'01','02','12' '01','02','12'
], ],
'day': [ 'day': [
'01', '02', '03', '01', '02', '03',
'04', '05', '06', '04', '05', '06',
'07', '08', '09', '07', '08', '09',
'10', '11', '12', '10', '11', '12',
'13', '14', '15', '13', '14', '15',
'16', '17', '18', '16', '17', '18',
'19', '20', '21', '19', '20', '21',
'22', '23', '24', '22', '23', '24',
'25', '26', '27', '25', '26', '27',
'28', '29', '30', '28', '29', '30',
'31', '31',
], ],
'time': [ 'time': [
'15:00', '15:00',
], ],
'variable': [ 'variable': [
'10m_u_component_of_wind', '10m_v_component_of_wind', '2m_temperature', '10m_u_component_of_wind', '10m_v_component_of_wind', '2m_temperature',
'leaf_area_index_high_vegetation', 'leaf_area_index_low_vegetation', 'total_precipitation', 'leaf_area_index_high_vegetation', 'leaf_area_index_low_vegetation', 'total_precipitation',
], ],
'year': [str(year)], 'year': [str(year)],
'area': [ 'area': [
-20, -79, -57, # North West South East -20, -79, -57, # North West South East
-43, -43,
], ],
}, },
target_file) target_file)
``` ```
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
Download Fire Danger Index # Download Fire Danger Index
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` ```
for year in range(2002,2023): for year in range(2002,2023):
target_file = LABELDIR + f'{year}.nc' target_file = LABELDIR + f'{year}.nc'
c = cdsapi.Client() c = cdsapi.Client()
c.retrieve( c.retrieve(
'cems-fire-historical-v1', 'cems-fire-historical-v1',
{ {
'product_type': 'reanalysis', 'product_type': 'reanalysis',
'variable': 'fire_danger_index', 'variable': 'fire_danger_index',
'dataset_type': 'consolidated_dataset', 'dataset_type': 'consolidated_dataset',
'system_version': '4_1', 'system_version': '4_1',
'year': '2002', 'year': '2002',
'month': [ 'month': [
'01', '02', '12', '01', '02', '12',
], ],
'day': [ 'day': [
'01', '02', '03', '01', '02', '03',
'04', '05', '06', '04', '05', '06',
'07', '08', '09', '07', '08', '09',
'10', '11', '12', '10', '11', '12',
'13', '14', '15', '13', '14', '15',
'16', '17', '18', '16', '17', '18',
'19', '20', '21', '19', '20', '21',
'22', '23', '24', '22', '23', '24',
'25', '26', '27', '25', '26', '27',
'28', '29', '30', '28', '29', '30',
'31', '31',
], ],
'area': [ 'area': [
-20, -79, -57, -20, -79, -57,
-43, -43,
], ],
'grid': '0.25/0.25', 'grid': '0.25/0.25',
'format': 'netcdf', 'format': 'netcdf',
}, },
target_file) target_file)
``` ```
%% Output %% Output
2023-07-28 12:15:49,638 INFO Welcome to the CDS 2023-07-28 12:15:49,638 INFO Welcome to the CDS
2023-07-28 12:15:49,639 INFO Sending request to https://cds.climate.copernicus.eu/api/v2/resources/cems-fire-historical-v1 2023-07-28 12:15:49,639 INFO Sending request to https://cds.climate.copernicus.eu/api/v2/resources/cems-fire-historical-v1
2023-07-28 12:15:49,854 INFO Request is completed 2023-07-28 12:15:49,854 INFO Request is completed
2023-07-28 12:15:49,855 INFO Downloading https://download-0004-clone.copernicus-climate.eu/cache-compute-0004/cache/data0/adaptor.mars.external-1690558130.304354-9896-9-762d05cd-253d-467d-99ae-08ef92f88bbd.nc to fire_danger/2019.nc (7.4M) 2023-07-28 12:15:49,855 INFO Downloading https://download-0004-clone.copernicus-climate.eu/cache-compute-0004/cache/data0/adaptor.mars.external-1690558130.304354-9896-9-762d05cd-253d-467d-99ae-08ef92f88bbd.nc to fire_danger/2019.nc (7.4M)
2023-07-28 12:15:52,491 INFO Download rate 2.8M/s 2023-07-28 12:15:52,491 INFO Download rate 2.8M/s
2023-07-28 12:15:53,197 INFO Welcome to the CDS 2023-07-28 12:15:53,197 INFO Welcome to the CDS
2023-07-28 12:15:53,199 INFO Sending request to https://cds.climate.copernicus.eu/api/v2/resources/cems-fire-historical-v1 2023-07-28 12:15:53,199 INFO Sending request to https://cds.climate.copernicus.eu/api/v2/resources/cems-fire-historical-v1
2023-07-28 12:15:53,439 INFO Request is completed 2023-07-28 12:15:53,439 INFO Request is completed
2023-07-28 12:15:53,440 INFO Downloading https://download-0004-clone.copernicus-climate.eu/cache-compute-0004/cache/data0/adaptor.mars.external-1690558130.304354-9896-9-762d05cd-253d-467d-99ae-08ef92f88bbd.nc to fire_danger/2020.nc (7.4M) 2023-07-28 12:15:53,440 INFO Downloading https://download-0004-clone.copernicus-climate.eu/cache-compute-0004/cache/data0/adaptor.mars.external-1690558130.304354-9896-9-762d05cd-253d-467d-99ae-08ef92f88bbd.nc to fire_danger/2020.nc (7.4M)
2023-07-28 12:15:54,590 INFO Download rate 6.5M/s 2023-07-28 12:15:54,590 INFO Download rate 6.5M/s
2023-07-28 12:15:54,976 INFO Welcome to the CDS 2023-07-28 12:15:54,976 INFO Welcome to the CDS
2023-07-28 12:15:54,977 INFO Sending request to https://cds.climate.copernicus.eu/api/v2/resources/cems-fire-historical-v1 2023-07-28 12:15:54,977 INFO Sending request to https://cds.climate.copernicus.eu/api/v2/resources/cems-fire-historical-v1
2023-07-28 12:15:55,220 INFO Request is completed 2023-07-28 12:15:55,220 INFO Request is completed
2023-07-28 12:15:55,221 INFO Downloading https://download-0004-clone.copernicus-climate.eu/cache-compute-0004/cache/data0/adaptor.mars.external-1690558130.304354-9896-9-762d05cd-253d-467d-99ae-08ef92f88bbd.nc to fire_danger/2021.nc (7.4M) 2023-07-28 12:15:55,221 INFO Downloading https://download-0004-clone.copernicus-climate.eu/cache-compute-0004/cache/data0/adaptor.mars.external-1690558130.304354-9896-9-762d05cd-253d-467d-99ae-08ef92f88bbd.nc to fire_danger/2021.nc (7.4M)
2023-07-28 12:15:56,690 INFO Download rate 5.1M/s 2023-07-28 12:15:56,690 INFO Download rate 5.1M/s
2023-07-28 12:15:57,082 INFO Welcome to the CDS 2023-07-28 12:15:57,082 INFO Welcome to the CDS
2023-07-28 12:15:57,083 INFO Sending request to https://cds.climate.copernicus.eu/api/v2/resources/cems-fire-historical-v1 2023-07-28 12:15:57,083 INFO Sending request to https://cds.climate.copernicus.eu/api/v2/resources/cems-fire-historical-v1
2023-07-28 12:15:57,301 INFO Request is completed 2023-07-28 12:15:57,301 INFO Request is completed
2023-07-28 12:15:57,302 INFO Downloading https://download-0004-clone.copernicus-climate.eu/cache-compute-0004/cache/data0/adaptor.mars.external-1690558130.304354-9896-9-762d05cd-253d-467d-99ae-08ef92f88bbd.nc to fire_danger/2022.nc (7.4M) 2023-07-28 12:15:57,302 INFO Downloading https://download-0004-clone.copernicus-climate.eu/cache-compute-0004/cache/data0/adaptor.mars.external-1690558130.304354-9896-9-762d05cd-253d-467d-99ae-08ef92f88bbd.nc to fire_danger/2022.nc (7.4M)
2023-07-28 12:15:58,812 INFO Download rate 4.9M/s 2023-07-28 12:15:58,812 INFO Download rate 4.9M/s
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment