Skip to content

Commit

Permalink
Fix/dset forats comptadors (et/somenergia-jardiner!111)
Browse files Browse the repository at this point in the history
Merge branch 'fix/dset_forats_comptadors' into 'main'
  • Loading branch information
Lugadur committed Feb 19, 2024
2 parents f4d66f6 + b7249eb commit d00f300
Showing 1 changed file with 32 additions and 33 deletions.
65 changes: 32 additions & 33 deletions dbt_jardiner/models/jardiner/marts/dm_plant_production_hourly.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,38 @@


select
start_hour as hora_inici,
start_hour + interval '1 hour' as hora_final,
plant_uuid,
plant_name as nom_planta,
technology as tecnologia,
peak_power_kw as potencia_pic_kw,
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,
meter_exported_energy_kwh as energia_exportada_comptador_kwh,
dset_meter_exported_energy_kwh as dset_energia_exportada_comptador_kwh,
erp_meter_exported_energy_kwh as erp_energia_exportada_comptador_kwh,
meter_imported_energy_kwh as energia_importada_comptador_kwh,
dset_meter_imported_energy_kwh as dset_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 - 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,
satellite_module_temperature_dc*100 as temperatura_modul_avg_c,
pr_hourly as pr_horari,
(pr_hourly > 0.7)::integer as hora_disponible,
(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,#}
(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 #}
start_hour as hora_inici,
start_hour + interval '1 hour' as hora_final,
plant_uuid,
plant_name as nom_planta,
technology as tecnologia,
peak_power_kw as potencia_pic_kw,
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,
meter_exported_energy_kwh as energia_exportada_comptador_kwh,
dset_meter_exported_energy_kwh as dset_energia_exportada_comptador_kwh,
erp_meter_exported_energy_kwh as erp_energia_exportada_comptador_kwh,
meter_imported_energy_kwh as energia_importada_comptador_kwh,
dset_meter_imported_energy_kwh as dset_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 - 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,
satellite_module_temperature_dc * 100 as temperatura_modul_avg_c,
pr_hourly as pr_horari,
(pr_hourly > 0.7)::integer as hora_disponible,
(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,#}
(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,
billed_energy/dset_meter_exported_energy_kwh as energia_liquidada_percent#}
from {{ ref("obt_hourly_incremental") }}

0 comments on commit d00f300

Please sign in to comment.