Commit bc9d5935 authored by Clément Haëck's avatar Clément Haëck
Browse files

Add HF average over grid and data

add download ERA5 script
parent 8b07db06
"""Compute heat fluxes timeseries over grid boxes."""
import lib
def main():
args = lib.get_args(['region', 'grid_file', 'days', 'fixes', 'year'])
grid_file =
boxes =
args['fixes']['Y'] = args['year']
ds =
for box in lib.progressbar(boxes):
args['fixes']['idx'] = box.idx
ofile =['fixes'])
lib.check_output_dir(ofile, file=True)
dst = box.extract(ds)
dst = dst.hf.mean(['lat', 'lon'])
if __name__ == '__main__':
"""Download land mask for ERA5 GLOBAL_025 grid.
First to download the land/sea fraction the code below can be used in the
Copernicus Climate Data Store toolbox at
Place the file in
Then /Compute/ can be run.
import cdstoolbox as ct
@ct.application(title='Download data')
def download_application():
data = ct.catalogue.retrieve(
'product_type': 'reanalysis',
'variable': 'land_sea_mask',
'year': '2000',
'month': '01',
'day': '01',
'time': '00:00',
'area': [
60, -85, 0, 0, # Same as /Download/
return data
"""Time series of heat fluxes in grided boxes."""
from os import path
import lib
ARGS_DIR = {'region', 'days'}
pregex = '%(idx:fmt=04d)/HF_TS_%(Y).nc'
def get_root(args=None, **kwargs):
args =, args, **kwargs)
root = path.join(lib.root_data, args['region'], 'HF_TS',
return root
def add_idx_dim(ds, filename, finder):
idx = finder.get_matches(filename)['idx'].match_str
ds = ds.expand_dims({'idx': [idx]})
return ds, pregex, get_root, ARGS_DIR,
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment