Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions ccsr/config-defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,20 @@ maprooms:
flex_fcst:

# App set up
- title: flex_cst_precip
- title: flex_fcst_precip
core_path: flex_fcst_precip
forecast_path: /Data/data21/iri/FD.3
variable: Precipitation
y_transform: False
method: elr # or pycpt
var: precip
issue_format: "%b %Y"
issue_format: "%b %Y"

terc_fcst:
- title: terc_fcst_precip
core_path: terc_fcst_precip
forecast_path: /Data/data21/iri/FD/NMME_Seasonal_Forecast/Precipitation_ELR
variable: Precipitation
var: precip
issue_format: "%b %Y"

8 changes: 8 additions & 0 deletions ccsr/config-iri.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,11 @@ maprooms:
method: elr # or pycpt
var: precip
issue_format: "%b %Y"

terc_fcst:
- title: terc_fcst_precip
core_path: terc_fcst_precip
forecast_path: /Data/data21/iri/FD/NMME_Seasonal_Forecast/Precipitation_ELR
variable: Precipitation
var: precip
issue_format: "%b %Y"
5 changes: 1 addition & 4 deletions ccsr/flex_fcst/layout.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
from dash import dcc
from dash import html
import dash_bootstrap_components as dbc
import dash_leaflet as dlf
from fieldsets import Block, Select, PickPoint, Month, Number
from fieldsets import Block, Select, PickPoint, Number
import layout_utilities as lou

from globals_ import GLOBAL_CONFIG
Expand Down
3 changes: 2 additions & 1 deletion ccsr/flex_fcst_calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
import pingrid
import numpy as np
import datetime
import predictions


def get_targets_dict(fcst_conf, fcst_ds, start_date):
if fcst_conf["method"] == "pycpt":
return pycpt.pycptv2_targets_dict(fcst_ds, start_date=start_date)
else:
S = datetime.datetime(
int(start_date[4:8]), ife.strftimeb2int(start_date[0:3]), 1
int(start_date[4:8]), predictions.strftimeb2int(start_date[0:3]), 1
)
return ife.targets_dict(fcst_ds, S)

Expand Down
39 changes: 1 addition & 38 deletions ccsr/iri_fd_elr.py
Original file line number Diff line number Diff line change
@@ -1,47 +1,10 @@
from pathlib import Path
import xarray as xr
import datetime
import predictions
from dateutil.relativedelta import relativedelta
import numpy as np


def strftimeb2int(strftimeb):
Comment thread
remicousin marked this conversation as resolved.
"""Convert month values to integers (1-12) from strings.

Parameters
----------
strftimeb : str
String value representing months of year.
Returns
-------
strftimebint : int
Integer value corresponding to month.
See Also
--------
Notes
-----
Examples
--------
"""
strftimeb_all = {
"Jan": 1,
"Feb": 2,
"Mar": 3,
"Apr": 4,
"May": 5,
"Jun": 6,
"Jul": 7,
"Aug": 8,
"Sep": 9,
"Oct": 10,
"Nov": 11,
"Dec": 12,
}
strftimebint = strftimeb_all[strftimeb]
return strftimebint


def get_elr_S(data_path, var):
"""Returns list of dates of forecast issues.

Expand All @@ -58,7 +21,7 @@ def get_elr_S(data_path, var):
files_list = data_path.glob(f"forecast_mean_{var}_*.nc")
return sorted([datetime.datetime(
int(f.name[-7:-3]),
strftimeb2int(f.name[-10:-7]),
predictions.strftimeb2int(f.name[-10:-7]),
1,
) for f in files_list], reverse=True)

Expand Down
19 changes: 9 additions & 10 deletions ccsr/layout_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,10 @@ def description(title, subtitle, *elems):
def map(
default_zoom,
layers_control_position="topleft", scale_control_position="bottomright",
cb_nTicks=9, cb_opacity=1, cb_tooltip=True,
cb_position="topright", cb_width=10, cb_height=300,
colorbars={"colorbar" : {
"nTicks": 9, "opacity": 1, "tooltip": True, "position": "topright",
"width": 10, "height": 300
}},
Comment thread
remicousin marked this conversation as resolved.
):
"""
A dlf map topped with and H5 title,
Expand Down Expand Up @@ -134,21 +136,18 @@ def map(
dlf.ScaleControl(
imperial=False, position=scale_control_position
),
] + [
dlf.Colorbar(
id="colorbar",
nTicks=cb_nTicks,
opacity=cb_opacity,
tooltip=cb_tooltip,
position=cb_position,
width=cb_width,
height=cb_height,
id=cb,
className="p-1",
style={
"background": "white", "border-style": "inset",
"-moz-border-radius": "4px", "border-radius": "4px",
"border-color": "LightGrey",
},
),
**cbd,
)
for cb, cbd in colorbars.items()
],
id="map",
center=None,
Expand Down
35 changes: 35 additions & 0 deletions ccsr/predictions.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,38 @@ def target_range_formatting(target_start, target_end, time_units):
date_range = f"{target_start_str}-{target_end_str}"
return date_range


def strftimeb2int(strftimeb):
"""Convert month values to integers (1-12) from strings.

Parameters
----------
strftimeb : str
String value representing months of year.
Returns
-------
strftimebint : int
Integer value corresponding to month.
See Also
--------
Notes
-----
Examples
--------
"""
strftimeb_all = {
"Jan": 1,
"Feb": 2,
"Mar": 3,
"Apr": 4,
"May": 5,
"Jun": 6,
"Jul": 7,
"Aug": 8,
"Sep": 9,
"Oct": 10,
"Nov": 11,
"Dec": 12,
}
strftimebint = strftimeb_all[strftimeb]
return strftimebint
1 change: 1 addition & 0 deletions ccsr/terc_fcst/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .maproom import register
56 changes: 56 additions & 0 deletions ccsr/terc_fcst/layout.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
from dash import html
from fieldsets import Block, PickPoint
import layout_utilities as lou

from globals_ import GLOBAL_CONFIG

IRI_BLUE = "rgb(25,57,138)"
IRI_GRAY = "rgb(113,112,116)"
LIGHT_GRAY = "#eeeeee"

def app_layout():

return lou.app_1(

lou.navbar("Forecast",
Block("issue_block", "Issue", html.Div(id="start_div")),
Block("target_block", "Target Period", html.Div(id="lead_div")),
PickPoint(width="8em"),
),

lou.description(
"Precipitation Terciles Seasonal Forecast",
"""
The seasonal forecast for above-, below- and near-normal precipitation
from the IRI.
""",
html.P(
"""
The default map shows globally the seasonal precipitation forecast
tercile probability. The historical climatology used is 1982-2010 up
to the forecast issued in August 2021, and is 1991-2020 from the
forecast issued in September 2021. The forecast shown is the latest
forecast made (e.g. Dec 2017) for the next season to come
(e.g. Jan-Mar 2018). Four different seasons are forecasted and it is
also possible to consult forecasts made previously. The forecasts
are directly computed from the extended logistic regression model as
tercile probabilities.
"""
),
),

lou.map(GLOBAL_CONFIG["zoom"], scale_control_position="bottomleft", colorbars={
"below_cb" : {
"nTicks": 6, "min": 37.5, "max": 100, "tickDecimals": 1, "unit": "%",
"opacity": 1, "tooltip": True, "position": "bottomright",
"width": 10, "height": 140,
},
"above_cb" : {
"nTicks": 6, "min": 37.5, "max": 100, "tickDecimals": 1, "unit": "%",
"opacity": 1, "tooltip": True, "position": "topright",
"width": 10, "height": 140,
},
}),
Comment thread
remicousin marked this conversation as resolved.

lou.local_single_tabbed("Tercile Probabilities"),
)
Loading
Loading