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

Add nomask option when computing histogram

Use default arguments for thresholds
parent fe7d38a2
......@@ -119,7 +119,7 @@ def main(args):
for v in ['hist_' + v for v in VARS]}
m_next("Executing computations / Writing to disk")
ofile = lib.data.hists.get_filename(args, var=var, zone=zone)
ofile = lib.data.hists.get_filename(args)
lib.check_output_dir(ofile, file=True)
hist.to_netcdf(ofile, encoding=encoding)
m_end()
......@@ -189,12 +189,11 @@ def get_bins(variable):
if __name__ == '__main__':
def add_args(parser):
parser.add_argument('-threshold', type=float, default=10.)
# Zone·s to compute
parser.add_argument('-zones', type=str, default='INS')
args = lib.get_args(['region', 'year', 'days', 'scale', 'number',
'coef', 'fixes'], add_args)
'coef', 'fixes', 'threshold'], add_args)
args['fixes']['Y'] = args['year']
args['Y'] = args['year']
......
......@@ -63,15 +63,18 @@ def main(args):
m_next("Applying static masks")
# Apply masks: land (enlarged), total zone, min front proba
ds['HI'] = ds.HI.where(~ds.land_large * ds.total * ds.p_frt)
static = ~ds.land_large * ds.total
if not args['nomask']:
static *= ds.p_frt
ds['HI'] = ds.HI.where(static)
ds = ds.drop_vars(['land_large', 'total', 'p_frt'])
m_next("Computing HI masks")
# Masks
ds['mask_low'] = ds.HI < args['thr_lo']
ds['mask_mid'] = (ds.HI > args['thr_lo']) * (ds.HI < args['thr_hi'])
ds['mask_hi'] = ds.HI > args['thr_hi']
ds = ds.drop_vars(['HI'])
ds['mask_mid'] = ~(ds['mask_low'] | ds['mask_hi'])
ds = ds.drop_vars(['HI', 'p_frt'])
m_next("Computing zones datasets")
# Datasets for each zone
......@@ -122,7 +125,7 @@ def main(args):
for v in ['hist_' + v for v in VARS]}
m_next("Executing computations / Writing to disk")
ofile = lib.data.hists.get_filename(args, var=var, zone=zone)
ofile = lib.data.hists.get_filename(args)
lib.check_output_dir(ofile, file=True)
hist.to_netcdf(ofile, encoding=encoding)
m_end()
......@@ -192,14 +195,12 @@ def get_bins(variable):
if __name__ == '__main__':
def add_args(parser):
# Frt/Bkg HI threshold
parser.add_argument('-thr_lo', type=float, default=5.)
parser.add_argument('-thr_hi', type=float, default=10.)
# Zone·s to compute
parser.add_argument('-zones', type=str, default='INS')
args = lib.get_args(['region', 'year', 'days', 'scale', 'number',
'coef', 'fixes'], add_args)
'coef', 'fixes', 'thr_lo', 'thr_hi', 'nomask'],
add_args)
args['fixes']['Y'] = args['year']
args['Y'] = args['year']
......
......@@ -22,6 +22,7 @@ pregex = ("number_%(number:fmt=d:rgx=%I)/"
"hist_GS3"
"_thr_%(thr_lo:fmt=.2f)_%(thr_hi:fmt=.2f)"
"_%(time:Y)"
"%(nomask:opt=:_nomask)"
".nc")
......@@ -32,9 +33,7 @@ def get_root(args=None, **kwargs):
return root
auto_attr = lib.data.create_data(
__name__, pregex, get_root, ARGS_DIR
)
auto_attr = lib.data.create_data(__name__, pregex, get_root, ARGS_DIR)
def get_data(args=None, remove_dims=None, **kwargs):
......
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