I am have used both the API and the toolbox to fetch data from CARRA. When I try to get a subsample

of the data (a smaller area within the domain) I get an error.  Is this something that cannot be done

as part of the request?



2 Comments

  1. This never got answered. But can be done with a grid and area keywords. See example from the toolbox that reads in orography interpolates to a grid (lat lon) that is

    approx 2x2 km  and returns. The same idea can be used for other data. The output will however be on lat lon grid but not on original carra grid.


    H


    import cdstoolbox as ct

    @ct.application(title='Download data')
    @ct.output.download()
    def download_application():
        data = ct.catalogue.retrieve(
            'reanalysis-carra-single-levels',
            {
                'domain': 'west_domain',
                'level_type': 'surface_or_atmosphere',
                'variable': 'orography',
                'product_type': 'analysis',
                'time': '00:00',
                'year': '2023',
                'month': '01',
                'day': '01',
                'grid': [0.04180602,0.01826484],
                'area': [67, -25,63, -12.5 ],
            }
        )
        return data

  2. And another follow up on this, notice this seems to work in grib, but not always in netcdf.


    Following up on this, if you want to interpolate on a custom grid it seems that you need to:

    1. specify the resolution as 90/N where N is an integer (https://confluence.ecmwf.int/pages/viewpage.action?pageId=123799065)
    2. specify the format as .grib




    If you try and download .netcdf it seems to give bad data except for some magic numbers that just work for some reason (if anybody knows why this is please let me know!). Here's an example:


    import cdsapi


    c = cdsapi.Client()




    num_samples_in_90_degrees = 3000


    resolution = 90/num_samples_in_90_degrees


    c.retrieve(
        'reanalysis-carra-single-levels',
        {
            'domain': 'west_domain',
            'level_type': 'surface_or_atmosphere',
            'variable': 'orography',
            'product_type': 'analysis',
            'time': '00:00',
            'year': '2023',
            'month': '01',
            'day': '01',
            'format': 'grib',
            'grid':[resolution,resolution],
            'area': [67, -25, 63, -12.5 ],
        },
        'orogISL.grib')