2.4 KiB
2.4 KiB
jupytext
jupytext | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
Fiab
Model Selection
This is a demo of using qubed to select from a set of forecast models that each produce a set of output variables.
First let's construct some models represented as qubes:
from qubed import Qube
model_1 = Qube.from_datacube({
"levtype": "pl",
"param" : ["q", "t", "u", "v", "w", "z"],
"level" : [100, 200, 300, 400, 50, 850, 500, 150, 600, 250, 700, 925, 1000],
}) | Qube.from_datacube({
"levtype": "sfc",
"param" : ["10u", "10v", "2d", "2t", "cp", "msl", "skt", "sp", "tcw", "tp"],
})
model_1 = "model=1" / ("frequency=6h" / model_1)
model_1
This is the most complete model. Now let's do one with fewer variables and levels:
model_2 = Qube.from_datacube({
"levtype": "pl",
"param" : ["q", "t"],
"level" : [100, 200, 300, 400, 50, 850, 500, 150, 600, 250, 700, 925, 1000],
}) | Qube.from_datacube({
"levtype": "sfc",
"param" : ["2t", "cp", "msl"],
})
model_2 = "model=2" / ("frequency=continuous" / model_2)
model_3 = Qube.from_datacube({
"levtype": "pl",
"param" : ["q", "t"],
"level" : [100, 200, 300, 400, 50, 850, 500, 150, 600, 250, 700, 925, 1000],
}) | Qube.from_datacube({
"levtype": "sfc",
"param" : ["2t", "cp", "msl"],
})
model_3 = "model=3" / ("frequency=6h" / model_3)
model_3
Now we can combine the three models into a single qube:
all_models = model_1 | model_2 | model_3
all_models
Now we can perform queries over the models. We can get all models that produce 2m temperature:
all_models.select({
"param" : "2t",
})
Filter on both parameter and frequency:
all_models.select({
"param" : "2t",
"frequency": "continuous",
})
Find all models that have some overlap with this set of parameters:
all_models.select({
"param" : ["q", "t", "u", "v"],
})
Choosing a set of models based on the requested parameter set
all_models.select({
"param" : ["q", "t", "u", "v"],
"frequency": "6h",
})