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

Add front presence probability mask data

parent d87c295c
"""Create mask where presence of front is probable."""
import lib
import lib.data.front_probability
import lib.data.p_frt_mask
import lib.zones
def main(args):
args['period'] = 'total'
ds = lib.data.front_probability.get_data(args)
mask = ds.p_frt > args['threshold']
mask.name = 'mask'
land = lib.zones.get_land(args, grid=lib.data.front_probability.grid)
mask *= ~land['land_large']
mask = mask.where(~land['land'])
ofile = lib.data.p_frt_mask.get_filename(args)
lib.check_output_dir(ofile, file=True)
mask.to_dataset().to_netcdf(ofile, encoding={'mask': {'zlib': True}})
return mask
if __name__ == '__main__':
def add_args(parser):
parser.add_argument('-threshold', type=float,
default=lib.data.p_frt_mask.default_threshold)
args = lib.get_args(lib.data.p_frt_mask.ARGS_DIR, add_args)
ds = main(args)
"""High frontal presence probability mask.
ie pixels where probability of front presence (all data considered) is above a
threshold.
"""
from os import path
import lib
import lib.data
ARGS_DIR = {'region'}
pregex = 'mask_thr_%(threshold:fmt=.1e).nc'
grid = '4km_EPSG4326'
default_threshold = 1e-2
def get_root(args=None, **kwargs):
args = lib.data.process_args(ARGS_DIR, args, **kwargs)
root = path.join(lib.root_data, args['region'], 'p_frt_mask')
return root
lib.data.create_data(
__name__, 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