-
Notifications
You must be signed in to change notification settings - Fork 2
/
Creating_landmasks.py
36 lines (28 loc) · 1.1 KB
/
Creating_landmasks.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Jul 22 14:26:54 2020
@author: anjakatzenberger
"""
import subprocess
import os
###########################################################
# LANDMASKS #
# anja.katzenberger@pik-potsdam.de #
# 18.06.2020 #
###########################################################
# ceils fx/sftlf variable to create landmasks:
# If any percentage of grid cell is covered by land, it is classified as land entirely
dir = ""
files = os.listdir(os.sep.join((dir,"landmasks")))
files.remove('.DS_Store')
for file in files:
file_dir = os.sep.join(("~","landmasks", file))
print(file_dir)
print(file)
table = file.split('_')[1]
vbl = file.split('_')[0]
model = file.split('_')[2]
outdir_ceil = os.sep.join(("~", "landmasks_masks",'_'.join((table, vbl, model, "masked.nc"))))
cdo_cmd_ceil = ' '.join(("cdo expr,'mask=ceil(sftlf/100);' ", file, outdir_ceil))
subprocess.check_call(cdo_cmd_ceil, shell=True)