# Subset a CARRA region

**URL:** <https://forum.ecmwf.int/t/subset-a-carra-region/1041>\
**Category:** C3S - Datasets and Usage\
**Tags:** c3s, carra, regional\_reanalysis\
**Created:** [16 March 2021 16:42 UTC](https://forum.ecmwf.int/t/subset-a-carra-region/1041 "2021-03-16T16:42:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Halldor\_Bjornsson](https://forum.ecmwf.int/letter_avatar_proxy/v4/letter/h/edb3f5/32.png) [@Halldor\_Bjornsson](https://forum.ecmwf.int/u/Halldor_Bjornsson)\
**Post date:** [16 March 2021 16:42 UTC](https://forum.ecmwf.int/t/subset-a-carra-region/1041/1 "2021-03-16T16:42:21Z")

</div>

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.&nbsp; Is this something that cannot be done

as part of the request?

---

<div class="post-metadata">

**Author:** ![Halldor\_Bjornsson](https://forum.ecmwf.int/letter_avatar_proxy/v4/letter/h/edb3f5/32.png) [@Halldor\_Bjornsson](https://forum.ecmwf.int/u/Halldor_Bjornsson)\
**Post date:** [17 January 2024 14:08 UTC](https://forum.ecmwf.int/t/subset-a-carra-region/1041/2 "2024-01-17T14:08:43Z")

</div>

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&nbsp; 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():  
 &nbsp; &nbsp; data = ct.catalogue.retrieve(  
 &nbsp; &nbsp; &nbsp; &nbsp; 'reanalysis-carra-single-levels',  
 &nbsp; &nbsp; &nbsp; &nbsp; {  
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'domain': 'west\_domain',  
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'level\_type': 'surface\_or\_atmosphere',  
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'variable': 'orography',  
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'product\_type': 'analysis',  
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'time': '00:00',  
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'year': '2023',  
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'month': '01',  
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'day': '01',  
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'grid': [0.04180602,0.01826484],  
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'area': [67, -25,63, -12.5],  
 &nbsp; &nbsp; &nbsp; &nbsp; }  
 &nbsp; &nbsp; )  
 &nbsp; &nbsp; return data

---

<div class="post-metadata">

**Author:** ![Halldor\_Bjornsson](https://forum.ecmwf.int/letter_avatar_proxy/v4/letter/h/edb3f5/32.png) [@Halldor\_Bjornsson](https://forum.ecmwf.int/u/Halldor_Bjornsson)\
**Post date:** [30 January 2024 17:30 UTC](https://forum.ecmwf.int/t/subset-a-carra-region/1041/3 "2024-01-30T17:30:46Z")

</div>

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](https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fconfluence.ecmwf.int%2Fpages%2Fviewpage.action%3FpageId%3D123799065&data=05%7C02%7Challdor%40vedur.is%7C07337ef465c14080c4cf08dc20ca1561%7C4166ef56345a4554b3c93bb706823ae7%7C1%7C0%7C638421299524132722%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=219FAR%2BDEi0vseVIT381P2BN%2B30KVKsJt5zuQA8yS7Q%3D&reserved=0))
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(   
&nbsp; &nbsp; 'reanalysis-carra-single-levels',   
&nbsp; &nbsp; {   
&nbsp; &nbsp; &nbsp; &nbsp; 'domain': 'west\_domain',   
&nbsp; &nbsp; &nbsp; &nbsp; 'level\_type': 'surface\_or\_atmosphere',   
&nbsp; &nbsp; &nbsp; &nbsp; 'variable': 'orography',   
&nbsp; &nbsp; &nbsp; &nbsp; 'product\_type': 'analysis',   
&nbsp; &nbsp; &nbsp; &nbsp; 'time': '00:00',   
&nbsp; &nbsp; &nbsp; &nbsp; 'year': '2023',   
&nbsp; &nbsp; &nbsp; &nbsp; 'month': '01',   
&nbsp; &nbsp; &nbsp; &nbsp; 'day': '01',   
&nbsp; &nbsp; &nbsp; &nbsp; 'format': 'grib',   
&nbsp; &nbsp; &nbsp; &nbsp; 'grid':[resolution,resolution],   
&nbsp; &nbsp; &nbsp; &nbsp; 'area': [67, -25, 63, -12.5],   
&nbsp; &nbsp; },   
&nbsp; &nbsp; 'orogISL.grib')
