|
| 1 | + |
| 2 | +year_strings = [ |
| 3 | + '185001010600-187001010000', |
| 4 | + '187001010600-189001010000', |
| 5 | + '189001010600-191001010000', |
| 6 | + '191001010600-193001010000', |
| 7 | + '193001010600-195001010000', |
| 8 | + '195001010600-197001010000', |
| 9 | + '197001010600-199001010000', |
| 10 | + '199001010600-201001010000', |
| 11 | + '201001010600-201501010000', |
| 12 | +] |
| 13 | + |
| 14 | +print(config) |
| 15 | + |
| 16 | +rule download: |
| 17 | + output: |
| 18 | + "{dataset}/raw/{name}/{name}_{year_str}_raw.nc", |
| 19 | + shell: |
| 20 | + "wget https://esgf-data1.llnl.gov/thredds/fileServer/css03_data/CMIP6/CMIP/HAMMOZ-Consortium/MPI-ESM-1-2-HAM/historical/{config[" |
| 21 | + "run]}/6hrPlevPt/" |
| 22 | + "{config[cmip_name]}/gn/{config[version]}/" |
| 23 | + "{config[cmip_name]}_6hrPlevPt_MPI-ESM-1-2-HAM_historical_{config[run]}_gn_{wildcards.year_str}.nc " |
| 24 | + "-O {wildcards.dataset}/raw/{config[name]}/{config[name]}_{wildcards.year_str}_raw.nc" |
| 25 | + |
| 26 | +rule regrid: |
| 27 | + input: |
| 28 | + "{dataset}/raw/{name}/{name}_{year_str}_raw.nc" |
| 29 | + output: |
| 30 | + "{dataset}/{res}deg/{name}/{name}_{year_str}_{res}deg.nc.tmp" |
| 31 | + shell: |
| 32 | + "python ../../src/data_preprocessing/regrid.py \ |
| 33 | + --input_fns {input} \ |
| 34 | + --output_dir {wildcards.dataset}/{wildcards.res}deg/{wildcards.name} \ |
| 35 | + --ddeg_out {wildcards.res} \ |
| 36 | + --cmip 1 \ |
| 37 | + --rename {config[cmip_name]} {config[era_name]} \ |
| 38 | + --file_ending nc.tmp" |
| 39 | + |
| 40 | +rule delete: |
| 41 | + input: |
| 42 | + expand("{{dataset}}/{res}deg/{{name}}/{{name}}_{{year_str}}_{res}deg.nc.tmp", |
| 43 | + res=config['res']), |
| 44 | + output: |
| 45 | + expand("{{dataset}}/{res}deg/{{name}}/{{name}}_{{year_str}}_{res}deg.nc", |
| 46 | + res=config['res']) |
| 47 | + priority: 100 |
| 48 | + run: |
| 49 | + for i, o in zip(input, output): |
| 50 | + shell("mv {i} {o}") |
| 51 | + # shell("rm {wildcards.dataset}/raw/{wildcards.name}/{wildcards.name}_{wildcards.year_str}_raw.nc"), |
| 52 | + |
| 53 | + |
| 54 | +rule all: |
| 55 | + input: |
| 56 | + expand("{datadir}/{res}deg/{name}/{name}_{year_str}_{res}deg.nc", |
| 57 | + datadir=config['datadir'], res=config['res'], name=config['name'], year_str=year_strings) |
| 58 | + |
| 59 | + |
0 commit comments