Skip to content

Commit

Permalink
Replacing variable with climatic_indicator (wip)
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardogsilva committed Nov 14, 2024
1 parent 7e7a25a commit 088c933
Show file tree
Hide file tree
Showing 29 changed files with 134 additions and 6,490 deletions.
107 changes: 29 additions & 78 deletions arpav_ppcv/bootstrapper/cliapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,26 @@
tr as tr_climatic_indicators,
)

# from .variables import generate_variable_configurations
from .configurationparameters import generate_configuration_parameters

app = typer.Typer()


@app.command("municipalities")
def bootstrap_municipalities(
ctx: typer.Context, municipalities_dataset: Path, force: bool = False
ctx: typer.Context,
municipalities_dataset: Annotated[
Path,
typer.Argument(
help=(
"Path to the municipalities geoJSON dataset. Example: "
"/home/appuser/app/data/municipalities-istat-2021.geojson"
)
),
],
force: bool = False,
) -> None:
"""Bootstrap Italian municipalities"""
# data_directory = Path(__file__).parents[2] / "data"
# municipalities_dataset = data_directory / "limits_IT_municipalities.geojson"
to_create = []

should_bootstrap = False
Expand Down Expand Up @@ -178,26 +185,6 @@ def bootstrap_station_variables(
print("Done!")


# @app.command("observation-variables")
# def bootstrap_observation_variables(
# ctx: typer.Context,
# ):
# """Create initial observation variables."""
# variables = generate_variable_configurations()
# with sqlmodel.Session(ctx.obj["engine"]) as session:
# for var_create in variables:
# try:
# db_variable = database.create_variable(session, var_create)
# print(f"Created observation variable {db_variable.name!r}")
# except IntegrityError as err:
# print(
# f"Could not create observation "
# f"variable {var_create.name!r}: {err}"
# )
# session.rollback()
# print("Done!")


@app.command("climatic-indicators")
def bootstrap_climatic_indicators(
ctx: typer.Context, name_filter: Optional[str] = None
Expand Down Expand Up @@ -291,11 +278,9 @@ def bootstrap_coverage_configurations(
):
"""Create initial coverage configurations."""
with sqlmodel.Session(ctx.obj["engine"]) as session:
all_vars = database.collect_all_variables(session)
all_conf_param_values = database.collect_all_configuration_parameter_values(
session
)
variables = {v.name: v for v in all_vars}
conf_param_values = {
(pv.configuration_parameter.name, pv.name): pv
for pv in all_conf_param_values
Expand All @@ -307,27 +292,19 @@ def bootstrap_coverage_configurations(
cdd_forecast.generate_configurations(conf_param_values, clim_indicator_ids)
)
coverage_configurations.extend(
cdds_forecast.generate_configurations(
conf_param_values, variables, clim_indicator_ids
)
cdds_forecast.generate_configurations(conf_param_values, clim_indicator_ids)
)
coverage_configurations.extend(
fd_forecast.generate_configurations(
conf_param_values, variables, clim_indicator_ids
)
fd_forecast.generate_configurations(conf_param_values, clim_indicator_ids)
)
coverage_configurations.extend(
hdds_forecast.generate_configurations(
conf_param_values, variables, clim_indicator_ids
)
hdds_forecast.generate_configurations(conf_param_values, clim_indicator_ids)
)
coverage_configurations.extend(
hwdi_forecast.generate_configurations(conf_param_values, clim_indicator_ids)
)
coverage_configurations.extend(
pr_forecast.generate_configurations(
conf_param_values, variables, clim_indicator_ids
)
pr_forecast.generate_configurations(conf_param_values, clim_indicator_ids)
)
coverage_configurations.extend(
r95ptot_forecast.generate_configurations(conf_param_values, clim_indicator_ids)
Expand All @@ -336,74 +313,48 @@ def bootstrap_coverage_configurations(
snwdays_forecast.generate_configurations(conf_param_values, clim_indicator_ids)
)
coverage_configurations.extend(
su30_forecast.generate_configurations(
conf_param_values, variables, clim_indicator_ids
)
su30_forecast.generate_configurations(conf_param_values, clim_indicator_ids)
)
coverage_configurations.extend(
tas_forecast.generate_configurations(
conf_param_values, variables, clim_indicator_ids
)
tas_forecast.generate_configurations(conf_param_values, clim_indicator_ids)
)
coverage_configurations.extend(
tasmax_forecast.generate_configurations(
conf_param_values, variables, clim_indicator_ids
)
tasmax_forecast.generate_configurations(conf_param_values, clim_indicator_ids)
)
coverage_configurations.extend(
tasmin_forecast.generate_configurations(
conf_param_values, variables, clim_indicator_ids
)
tasmin_forecast.generate_configurations(conf_param_values, clim_indicator_ids)
)
coverage_configurations.extend(
tr_forecast.generate_configurations(
conf_param_values, variables, clim_indicator_ids
)
tr_forecast.generate_configurations(conf_param_values, clim_indicator_ids)
)
coverage_configurations.extend(
cdds_historical.generate_configurations(
conf_param_values, variables, clim_indicator_ids
)
cdds_historical.generate_configurations(conf_param_values, clim_indicator_ids)
)
coverage_configurations.extend(
fd_historical.generate_configurations(
conf_param_values, variables, clim_indicator_ids
)
fd_historical.generate_configurations(conf_param_values, clim_indicator_ids)
)
coverage_configurations.extend(
hdds_historical.generate_configurations(
conf_param_values, variables, clim_indicator_ids
)
hdds_historical.generate_configurations(conf_param_values, clim_indicator_ids)
)
coverage_configurations.extend(
prcptot_historical.generate_configurations(
conf_param_values, variables, clim_indicator_ids
conf_param_values, clim_indicator_ids
)
)
coverage_configurations.extend(
su30_historical.generate_configurations(
conf_param_values, variables, clim_indicator_ids
)
su30_historical.generate_configurations(conf_param_values, clim_indicator_ids)
)
coverage_configurations.extend(
tdd_historical.generate_configurations(
conf_param_values, variables, clim_indicator_ids
)
tdd_historical.generate_configurations(conf_param_values, clim_indicator_ids)
)
coverage_configurations.extend(
tnd_historical.generate_configurations(
conf_param_values, variables, clim_indicator_ids
)
tnd_historical.generate_configurations(conf_param_values, clim_indicator_ids)
)
coverage_configurations.extend(
tr_historical.generate_configurations(
conf_param_values, variables, clim_indicator_ids
)
tr_historical.generate_configurations(conf_param_values, clim_indicator_ids)
)
coverage_configurations.extend(
txd_historical.generate_configurations(
conf_param_values, variables, clim_indicator_ids
)
txd_historical.generate_configurations(conf_param_values, clim_indicator_ids)
)

for cov_conf_create in coverage_configurations:
Expand Down
Loading

0 comments on commit 088c933

Please sign in to comment.