import cdsapi

c = cdsapi.Client()

for format_file in ['grib','netcdf']:
    if format_file == 'grib':
        extension = '.grib'
    else:
        extension = '.nc'
    
    filename = '../archives/reanalysis/39_reanalysis-era5-land-hourly' + extension

    c.retrieve(
        'reanalysis-era5-land',
        {
            'format':format_file,
            'time':[
                '00:00','12:00'
            ],
            'day':'01',
            'month':'01',
            'year':'2005',
            'variable':'2m_temperature'
        },
        filename)