Skip to content

Commit

Permalink
Resolve "Grafica Energia Exportada i PR - més decimals" (et/somenergi…
Browse files Browse the repository at this point in the history
…a-jardiner!135)

Closes #208

Merge branch '208-grafica-energia-exportada-i-pr-mes-decimals' into 'main'
  • Loading branch information
diegoquintanav committed Mar 8, 2024
2 parents ffecb5b + 4fb2f87 commit 819e5e4
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions dbt_jardiner/models/jardiner/marts/dm_plant_production_monthly.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,26 @@ select
potencia_pic_kw as potencia_pic_kw,
sum(energia_instantania_inversor_kwh) / 1000.0 as energia_instantania_inversor_mwh,
count(energia_instantania_inversor_kwh) as energia_inversor_count,
round((sum(energia_exportada_instantania_comptador_kwh) / 1000.0)::numeric, 1) as energia_exportada_instantania_comptador_mwh,
(sum(energia_exportada_instantania_comptador_kwh) / 1000.0)::numeric as energia_exportada_instantania_comptador_mwh,
count(energia_exportada_instantania_comptador_kwh) as energia_exportada_instantania_comptador_count,
round((sum(energia_exportada_comptador_kwh) / 1000.0)::numeric, 1) as energia_exportada_comptador_mwh,
round((sum(energia_importada_comptador_kwh) / 1000.0)::numeric, 1) as energia_importada_comptador_mwh,
(sum(energia_exportada_comptador_kwh) / 1000.0)::numeric as energia_exportada_comptador_mwh,
(sum(energia_importada_comptador_kwh) / 1000.0)::numeric as energia_importada_comptador_mwh,
--min(data_prediccio) as data_prediccio,
round((sum(energia_predita_meteologica_kwh) / 1000.0)::numeric, 1) as energia_predita_meteologica_mwh,
round((sum(energia_esperada_solargis_kwh) / 1000.0)::numeric, 1) as energia_esperada_solargis_mwh,
(sum(energia_predita_meteologica_kwh) / 1000.0)::numeric as energia_predita_meteologica_mwh,
(sum(energia_esperada_solargis_kwh) / 1000.0)::numeric as energia_esperada_solargis_mwh,
avg(preu_omie_eur_mwh) as preu_omie_eur_mwh,
sum(irradiation_wh_m2) as irradiation_wh_m2,
sum(irradiacio_satellit_wh_m2) as irradiacio_satellit_wh_m2,
--avg(temperatura_modul_avg_c) as temperatura_modul_avg_c,
round((sum(energia_exportada_comptador_kwh / potencia_pic_kw) / (nullif(sum(irradiacio_satellit_wh_m2), 0.0) / 1000.0))::numeric, 3) as pr,
round((sum(energia_exportada_comptador_kwh) / potencia_pic_kw)::numeric, 2) as hores_equivalents,
(sum(energia_exportada_comptador_kwh / potencia_pic_kw) / (nullif(sum(irradiacio_satellit_wh_m2), 0.0) / 1000.0))::numeric as pr,
(sum(energia_exportada_comptador_kwh) / potencia_pic_kw)::numeric as hores_equivalents,
sum(hora_disponible) as hora_disponible,
sum(hora_total) as hora_total,
sum(hora_disponible) / nullif(sum(hora_total), 0) as disponibilitat,
round((sum(energia_desviada_omie_kwh) / 1000.0)::numeric, 1) as energia_desviada_omie_mwh,
round((sum(abs(energia_desviada_omie_kwh_absolute)) / 1000.0)::numeric, 1) as energia_desviada_omie_mwh_absolute, {# should it be abs or we let compensate itself? #}
round((sum(energia_perduda_kwh) / 1000.0)::numeric, 1) as energia_perduda_mwh,
round((1 - sum(energia_predita_meteologica_kwh) / nullif(sum(energia_exportada_comptador_kwh), 0))::numeric, 2) as energia_desviada_percent
(sum(energia_desviada_omie_kwh) / 1000.0)::numeric as energia_desviada_omie_mwh,
(sum(abs(energia_desviada_omie_kwh_absolute)) / 1000.0)::numeric as energia_desviada_omie_mwh_absolute, {# should it be abs or we let compensate itself? #}
(sum(energia_perduda_kwh) / 1000.0)::numeric as energia_perduda_mwh,
(1 - sum(energia_predita_meteologica_kwh) / nullif(sum(energia_exportada_comptador_kwh), 0))::numeric as energia_desviada_percent
from {{ ref("dm_plant_production_daily") }}
group by date_trunc('month', dia), plant_uuid, nom_planta, tecnologia, potencia_pic_kw
order by month desc

0 comments on commit 819e5e4

Please sign in to comment.