Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Clément Haëck
submeso-color
Commits
95fdae24
Commit
95fdae24
authored
Nov 24, 2021
by
Clément Haëck
Browse files
Limit frt proba to northern region
parent
66c7c9dc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
8 deletions
+19
-8
Compute/front_probability.py
Compute/front_probability.py
+15
-4
lib/data/front_probability.py
lib/data/front_probability.py
+4
-4
No files found.
Compute/front_probability.py
View file @
95fdae24
"""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'
))
...
...
lib/data/front_probability.py
View file @
95fdae24
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment