From 9ce136ecda68d6656ef1e8f61a5de259fc0ec9f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pol=20Mons=C3=B3=20Purt=C3=AD?= Date: Mon, 29 Jan 2024 14:20:43 +0100 Subject: [PATCH] change: use meter measurements from dset instead of gisce in datamarts (et/somenergia-jardiner!84) * dset does not provide meter_import_energy at the moment * switch energia_exportada_comptador to dset_meter_exported_energy_kwh, keep erp_ until satisfied --- .../intermediate/obt/obt_hourly_incremental.sql | 6 +++--- .../jardiner/marts/dm_plant_production_hourly.sql | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/dbt_jardiner/models/jardiner/intermediate/obt/obt_hourly_incremental.sql b/dbt_jardiner/models/jardiner/intermediate/obt/obt_hourly_incremental.sql index bad7c797..697b2742 100644 --- a/dbt_jardiner/models/jardiner/intermediate/obt/obt_hourly_incremental.sql +++ b/dbt_jardiner/models/jardiner/intermediate/obt/obt_hourly_incremental.sql @@ -16,8 +16,8 @@ select dset.irradiation as dset_irradiation_wh, dset.inverter_exported_energy as dset_inverter_energy_kwh, dset.meter_exported_energy as dset_meter_instant_exported_energy_kwh, - NULL::integer as dset_meter_exported_energy_kwh, - NULL::integer as dset_meter_imported_energy_kwh, + dset.meter_exported_energy as dset_meter_exported_energy_kwh, + NULl::integer as dset_meter_imported_energy_kwh, forecast.forecastdate as forecast_date, forecast.energy_kwh as forecast_energy_kwh, sr.tilted_irradiation_wh_m2 as satellite_irradiation_wh_m2, @@ -37,7 +37,7 @@ left join {{ ref('int_dset_metrics_wide_hourly') }} dset using(start_hour, plant left join {{ ref('int_energy_forecasts__best_from_plantmonitordb') }} forecast using(start_hour, plant_uuid) left join {{ ref('int_satellite_readings__hourly') }} sr using(start_hour, plant_uuid) left join {{ ref('raw_plantlake_omie_historical_price__with_row_number_per_date') }} omie using(start_hour) -{#- temporarely use plantmonitors' meterregistry until dset provides it #} +{#- temporarely use plantmonitors' meterregistry until dset is reliable #} left join {{ref('int_erp_meter_registry__hourly')}} as meter_registry using(start_hour, plant_uuid) left join {{ ref('int_plantmonitordb_solarevent__generous') }} as solar_events on solar_events.plant_uuid = plant_metadata.plant_uuid and solar_events.day = spine.start_hour::date diff --git a/dbt_jardiner/models/jardiner/marts/dm_plant_production_hourly.sql b/dbt_jardiner/models/jardiner/marts/dm_plant_production_hourly.sql index 66d5df53..b10cdcdd 100644 --- a/dbt_jardiner/models/jardiner/marts/dm_plant_production_hourly.sql +++ b/dbt_jardiner/models/jardiner/marts/dm_plant_production_hourly.sql @@ -12,14 +12,14 @@ select dset_inverter_energy_kwh as energia_instantania_inversor_kwh, dset_meter_instant_exported_energy_kwh as energia_exportada_instantania_comptador_kwh, 1 - {{dbt_utils.safe_divide('dset_inverter_energy_kwh','dset_meter_instant_exported_energy_kwh')}} as energia_perduda_inversor_a_comptador, - --dset_meter_exported_energy_kwh as energia_exportada_comptador_kwh, -- plantmonitor la té, però dset ens la donarà - erp_meter_exported_energy_kwh as energia_exportada_comptador_kwh, - --dset_meter_imported_energy_kwh as energia_importada_comptador_kwh, -- idem - erp_meter_imported_energy_kwh as energia_importada_comptador_kwh, + dset_meter_exported_energy_kwh as energia_exportada_comptador_kwh, + erp_meter_exported_energy_kwh as erp_energia_exportada_comptador_kwh, + dset_meter_imported_energy_kwh as energia_importada_comptador_kwh, + erp_meter_imported_energy_kwh as erp_energia_importada_comptador_kwh, date_trunc('day',forecast_date,'Europe/Madrid')::date as data_prediccio, forecast_energy_kwh as energia_predita_meteologica_kwh, satellite_energy_output_kwh as energia_esperada_solargis_kwh, - (satellite_energy_output_kwh - erp_meter_exported_energy_kwh) as energia_perduda_kwh, + (satellite_energy_output_kwh - dset_meter_exported_energy_kwh) as energia_perduda_kwh, omie_price_eur_mwh as preu_omie_eur_mwh, dset_irradiation_wh as irradiation_wh_m2, satellite_irradiation_wh_m2 as irradiacio_satellit_wh_m2, @@ -29,8 +29,8 @@ select (satellite_irradiation_wh_m2 > 5)::integer as hora_total, {# hd/ht only makes sense in daily and up#} {#(pr_hourly > 0.7)/NULLIF(satellite_irradiation_wh_m2 > 5,0) as disponibilitat,#} - (erp_meter_exported_energy_kwh - forecast_energy_kwh) as energia_desviada_omie_kwh, - 1 - forecast_energy_kwh/NULLIF(erp_meter_exported_energy_kwh,0) as energia_desviada_percent, + (dset_meter_exported_energy_kwh - forecast_energy_kwh) as energia_desviada_omie_kwh, + 1 - forecast_energy_kwh/NULLIF(dset_meter_exported_energy_kwh,0) as energia_desviada_percent, is_daylight_generous as is_daylight {# HMCIL #} {# billed_energy as energia_liquidada,