import cdsapi

c = cdsapi.Client()

for format_file in ['grib','netcdf']:
    if format_file == 'grib':
        extension = '.grib'
    else:
        extension = '.nc'

    filename = '../archives/reanalysis/36-reanalysis-efas_historical-soil_levels' + extension

    c.retrieve(
        'efas-historical',
        {
            'format':format_file,
            'variable':[
                'soil_depth','volumetric_soil_moisture'
            ],
            'model_levels':'soil_levels',
            'hyear':'2018',
            'hmonth':'january',
            'hday':[
                '01','15'
            ],
            'simulation_version':'version_3',
            'soil_level':'1',
        },
        filename)
