import cdsapi

c = cdsapi.Client()

for format_file in ['grib','netcdf']:
    if format_file == 'grib':
        extension = '.grib'
    else:
        extension = '.nc'
    
    filename = '../archives/reanalysis/35-reanalysis-efas_forecast-soil_levels' + extension

    c.retrieve(
        'efas-forecast',
        {
            'format':format_file,
            'origin':'ecmwf',
            'type':'ensemble_control_forecast',
            'variable':[
                'soil_depth','volumetric_soil_moisture'
            ],
            'model_levels':'soil_levels',
            'soil_level':'1',
            'year':'2019',
            'month':[
                '02','04','06'
            ],
            'day':[
                '01','15'
            ],
            'time':'00:00',
            'step':[
                '0','24','48',
                '72'
            ]
        },
        filename)
