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

Limit frt proba to northern region

parent 66c7c9dc
"""Compute monthly frontal presence probability."""
"""Compute probability for a front to be present.
in a given time, at a given pixel.
"""
from os import path
......@@ -7,25 +10,33 @@ import pandas as pd
import lib
import lib.data.front_probability
import lib.data.hi
import lib.data.jet_zones
import lib.data.ostia
from lib.xarray_utils import save_chunks_by_date
def main():
def add_args(parser):
parser.add_argument('-threshold', type=float, default=15.)
parser.add_argument('-period', type=str, default='monthly')
args = lib.get_args(['region', 'days', 'year',
'scale', 'number', 'fixes'],
add_args=add_args)
if args['period'] != 'monthly':
raise ValueError("Script only supports monthly probability")
args['fixes']['Y'] = args['year']
ds = lib.data.hi.get_data(args)
sst = lib.data.ostia.get_data(args)
thr = lib.data.jet_zones.get_data(args)['threshold']
hi = lib.data.hi.apply_coef(ds, lib.data.hi.get_coef(args))
frt = (hi > args['threshold']) * 1.
hi = hi.where(sst.analysed_sst < thr)
frt = (hi > args['threshold']) * 1.
mth = frt.groupby('time.month').mean()
mth = mth.rename(month='time')
......@@ -36,7 +47,7 @@ def main():
mth = mth.to_dataset(name='frt_p')
outdir = lib.data.front_probability.get_root(args, days='monthly')
outdir = lib.data.front_probability.get_root(args, period='monthly')
lib.check_output_dir(path.join(outdir, str(args['year'])))
save_chunks_by_date(mth, path.join(outdir, '%Y/%Y%m.nc'))
......
......@@ -6,17 +6,17 @@ import lib
import lib.data
ARGS_DIR = {'region', 'days'}
pregex = '%(Y)/%(Y)%(m).nc'
ARGS_DIR = {'region', 'period'}
pregex = '%(Y)/%(Y)%(m)%(d).nc'
grid = '4km_EPSG4326'
defaults = dict(days='monthly')
defaults = dict(period='monthly')
def get_root(args=None, **kwargs):
args = lib.data.process_args(ARGS_DIR | {'climato'}, args,
defaults, **kwargs)
root = path.join(lib.root_data, args['region'], 'Frt_proba',
lib.data.get_time_folder(args))
args['period'])
return root
......
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