Skip to content

Commit c0fd117

Browse files
author
IlkaCu
committed
divide versioning skript
1 parent c96fb1a commit c0fd117

3 files changed

Lines changed: 260 additions & 250 deletions

File tree

dataprocessing/eGo_data_processing.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -96,22 +96,23 @@ def data_processing():
9696
# 'ego_dp_powerflow_assignment_otgid.sql', # assign otg_id to pp lists
9797
# 'ego_dp_powerflow_assignment_unid.sql', # create a unified_id over all pp (res and conv)
9898
# 'ego_dp_powerflow_create_pp_mview.sql', # create mviews to display power plants per scenario
99-
'ego_dp_powerflow_voronoi_weatherpoint.sql', # Create voronoi cells based on weather points
100-
'ego_dp_powerflow_hv_setup.sql', # Set schema/tables for EHV/HV powerflow calculations up
101-
'ego_dp_powerflow_osmtgmod_to_pypsa.sql', # Include data from osmTGmod into EHV/HV powerflow schema
102-
'ego_dp_powerflow_electrical_neighbour.sql', # Create border crossing lines and buses in neighbouring countries
103-
'ego_dp_powerflow_grid_future_scenarios.sql', # Copy grid to future scenarios
104-
'ego_dp_powerflow_assignment_generator.sql', # Assign generators to corresponding substation (SQ, NEP2035, eGo100)
105-
'ego_dp_powerflow_assignment_load.sql', # Assign loads to their corresponding substation (SQ, NEP2035, eGo100)
106-
'ego_dp_powerflow_assignment_storage.sql', # Assign storages to their corresponding substation (SQ, NEP 2035, eGo 100)
107-
'ego_dp_powerflow_timeseries_generator.sql', # Transfer renpassG!S results into the corresponding powerflow table
108-
'ego_dp_powerflow_griddistrict_demand.py', # Demand per MV Griddistrict
109-
'ego_dp_powerflow_timeseries_demand.sql', # Insert demand series into corresponding powerflow table (SQ, NEP2035, eGo100)
110-
'ego_dp_powerflow_lopf_data.sql', # Set marginal costs for generators and storages
99+
# 'ego_dp_powerflow_voronoi_weatherpoint.sql', # Create voronoi cells based on weather points
100+
# 'ego_dp_powerflow_hv_setup.sql', # Set schema/tables for EHV/HV powerflow calculations up
101+
# 'ego_dp_powerflow_osmtgmod_to_pypsa.sql', # Include data from osmTGmod into EHV/HV powerflow schema
102+
# 'ego_dp_powerflow_electrical_neighbour.sql', # Create border crossing lines and buses in neighbouring countries
103+
# 'ego_dp_powerflow_grid_future_scenarios.sql', # Copy grid to future scenarios
104+
# 'ego_dp_powerflow_assignment_generator.sql', # Assign generators to corresponding substation (SQ, NEP2035, eGo100)
105+
# 'ego_dp_powerflow_assignment_load.sql', # Assign loads to their corresponding substation (SQ, NEP2035, eGo100)
106+
# 'ego_dp_powerflow_assignment_storage.sql', # Assign storages to their corresponding substation (SQ, NEP 2035, eGo 100)
107+
# 'ego_dp_powerflow_timeseries_generator.sql', # Transfer renpassG!S results into the corresponding powerflow table
108+
# 'ego_dp_powerflow_griddistrict_demand.py', # Demand per MV Griddistrict
109+
# 'ego_dp_powerflow_timeseries_demand.sql', # Insert demand series into corresponding powerflow table (SQ, NEP2035, eGo100)
110+
# 'ego_dp_powerflow_lopf_data.sql', # Set marginal costs for generators and storages
111111

112112

113113
## VERSIONING
114-
# 'ego_dp_versioning.sql', # Versioning
114+
'ego_dp_versioning.sql', # Versioning
115+
'ego_dp_versioning_mviews.sql' , # Versioning of mviews
115116

116117
## VACUUM FULL
117118
# 'ego_dp_vacuum_full.sql'

dataprocessing/sql_snippets/ego_dp_versioning.sql

Lines changed: 0 additions & 237 deletions
Original file line numberDiff line numberDiff line change
@@ -524,240 +524,3 @@ UNION ALL
524524
GROUP BY version
525525
;
526526

527-
528-
-- Create MView with full dataset per scenario and conventional power plants for schema supply
529-
530-
-- MView for Status Quo
531-
DROP MATERIALIZED VIEW IF EXISTS supply.ego_dp_conv_powerplant_sq_mview CASCADE;
532-
CREATE MATERIALIZED VIEW supply.ego_dp_conv_powerplant_sq_mview AS
533-
SELECT *
534-
FROM supply.ego_dp_conv_powerplant
535-
WHERE scenario = 'Status Quo'
536-
AND shutdown IS NULL or shutdown >= 2015
537-
AND capacity > 0
538-
AND preversion = 'v0.3.0'
539-
AND version = 'v0.3.0';
540-
541-
ALTER MATERIALIZED VIEW supply.ego_dp_conv_powerplant_sq_mview
542-
OWNER TO oeuser;
543-
544-
-- MView for NEP 2035
545-
DROP MATERIALIZED VIEW IF EXISTS supply.ego_dp_conv_powerplant_nep2035_mview CASCADE;
546-
CREATE MATERIALIZED VIEW supply.ego_dp_conv_powerplant_nep2035_mview AS
547-
SELECT *
548-
FROM supply.ego_dp_conv_powerplant
549-
WHERE scenario = 'NEP 2035'
550-
AND capacity > 0
551-
AND fuel not in ('hydro', 'run_of_river', 'reservoir')
552-
AND shutdown IS NULL or shutdown >= 2034
553-
AND preversion = 'v0.3.0'
554-
AND version = 'v0.3.0';
555-
556-
ALTER MATERIALIZED VIEW supply.ego_dp_conv_powerplant_nep2035_mview
557-
OWNER TO oeuser;
558-
559-
-- MView for eGo 100
560-
DROP MATERIALIZED VIEW IF EXISTS supply.ego_dp_conv_powerplant_ego100_mview CASCADE;
561-
CREATE MATERIALIZED VIEW supply.ego_dp_conv_powerplant_ego100_mview AS
562-
SELECT
563-
preversion,
564-
gid,
565-
bnetza_id,
566-
company,
567-
name,
568-
postcode,
569-
city,
570-
street,
571-
state,
572-
block,
573-
commissioned_original,
574-
commissioned,
575-
retrofit,
576-
shutdown,
577-
status,
578-
fuel,
579-
technology,
580-
type,
581-
eeg,
582-
chp,
583-
capacity,
584-
capacity_uba,
585-
chp_capacity_uba,
586-
efficiency_data,
587-
efficiency_estimate,
588-
network_node,
589-
voltage,
590-
network_operator,
591-
name_uba,
592-
lat,
593-
lon,
594-
'pumed storage for eGo 100'::text as comment,
595-
geom,
596-
voltage_level,
597-
subst_id,
598-
otg_id,
599-
un_id,
600-
la_id,
601-
'eGo 100'::text as scenario,
602-
'constantly'::text as flag,
603-
nuts
604-
FROM supply.ego_dp_conv_powerplant
605-
WHERE scenario in('NEP 2035')
606-
AND fuel = 'pumped_storage'
607-
AND capacity > 0
608-
AND shutdown IS NULL or shutdown >= 2049
609-
AND preversion = 'v0.3.0'
610-
AND version = 'v0.3.0';
611-
612-
ALTER MATERIALIZED VIEW supply.ego_dp_conv_powerplant_ego100_mview
613-
OWNER TO oeuser;
614-
615-
-- ego scenario log (version,io,schema_name,table_name,script_name,comment)
616-
SELECT ego_scenario_log('v0.3.0','output','supply','ego_dp_conv_powerplant_sq_mview','ego_dp_powerflow_create_pp_mview.sql',' ');
617-
SELECT ego_scenario_log('v0.3.0','output','supply','ego_dp_conv_powerplant_nep2035_mview','ego_dp_powerflow_create_pp_mview.sql',' ');
618-
SELECT ego_scenario_log('v0.3.0','output','supply','ego_dp_conv_powerplant_ego100_mview','ego_dp_powerflow_create_pp_mview.sql',' ');
619-
620-
-- Create View with full dataset per scenario and renewables power plants
621-
622-
-- MView for Status Quo
623-
DROP MATERIALIZED VIEW IF EXISTS supply.ego_dp_res_powerplant_sq_mview CASCADE;
624-
CREATE MATERIALIZED VIEW supply.ego_dp_res_powerplant_sq_mview AS
625-
SELECT *
626-
FROM supply.ego_dp_res_powerplant
627-
WHERE scenario = 'Status Quo'
628-
AND electrical_capacity > 0
629-
AND preversion = 'v0.3.0'
630-
AND version = 'v0.3.0';
631-
632-
ALTER MATERIALIZED VIEW supply.ego_dp_res_powerplant_sq_mview
633-
OWNER TO oeuser;
634-
635-
-- MView for NEP 2035
636-
DROP MATERIALIZED VIEW IF EXISTS supply.ego_dp_res_powerplant_nep2035_mview CASCADE;
637-
CREATE MATERIALIZED VIEW supply.ego_dp_res_powerplant_nep2035_mview AS
638-
SELECT
639-
sub.*
640-
FROM (
641-
SELECT DISTINCT ON (id)
642-
*
643-
FROM
644-
supply.ego_dp_res_powerplant
645-
WHERE id not in (
646-
SELECT id
647-
FROM supply.ego_dp_res_powerplant
648-
WHERE version = 'v0.3.0'
649-
Group BY id
650-
HAVING count(*) > 1
651-
Order by id)
652-
AND scenario = 'Status Quo'
653-
And preversion = 'v0.3.0'
654-
AND electrical_capacity > 0
655-
ORDER BY id
656-
) as sub
657-
UNION
658-
SELECT
659-
sub2.*
660-
FROM (
661-
SELECT DISTINCT ON (id)
662-
*
663-
FROM
664-
supply.ego_dp_res_powerplant
665-
WHERE id in (
666-
SELECT id
667-
FROM supply.ego_dp_res_powerplant
668-
WHERE scenario in ('NEP 2035')
669-
AND version = 'v0.3.0'
670-
Group BY id
671-
Order by id)
672-
AND scenario in ('NEP 2035')
673-
And preversion = 'v0.3.0'
674-
AND version = 'v0.3.0'
675-
AND electrical_capacity > 0
676-
ORDER BY id
677-
) sub2
678-
Order by id;
679-
680-
ALTER MATERIALIZED VIEW supply.ego_dp_res_powerplant_nep2035_mview
681-
OWNER TO oeuser;
682-
683-
-- MView for eGo 100
684-
DROP MATERIALIZED VIEW IF EXISTS supply.ego_dp_res_powerplant_ego100_mview CASCADE;
685-
CREATE MATERIALIZED VIEW supply.ego_dp_res_powerplant_ego100_mview AS
686-
SELECT DISTINCT ON (id)
687-
sub.*
688-
FROM (
689-
SELECT DISTINCT ON (id)
690-
*
691-
FROM
692-
supply.ego_dp_res_powerplant
693-
WHERE id not in (
694-
SELECT id
695-
FROM supply.ego_dp_res_powerplant
696-
WHERE version = 'v0.3.0'
697-
Group BY id
698-
HAVING count(*) > 1
699-
Order by id)
700-
AND scenario = 'Status Quo'
701-
AND preversion = 'v0.3.0'
702-
AND version = 'v0.3.0'
703-
AND electrical_capacity > 0
704-
AND generation_type in ('solar','wind')
705-
AND generation_subtype not in ('wind_offshore')
706-
ORDER BY id
707-
) as sub
708-
UNION
709-
SELECT DISTINCT ON (id)
710-
sub2.*
711-
FROM (
712-
SELECT DISTINCT ON (id)
713-
*
714-
FROM
715-
supply.ego_dp_res_powerplant
716-
WHERE id in (
717-
SELECT id
718-
FROM supply.ego_dp_res_powerplant
719-
WHERE scenario in ('eGo 100')
720-
AND generation_type not in ('gas')
721-
AND version = 'v0.3.0'
722-
AND flag in ('commissioning', 'repowering')
723-
Group BY id
724-
Order by id)
725-
AND scenario in ('eGo 100')
726-
And preversion = 'v0.3.0'
727-
AND version = 'v0.3.0'
728-
AND electrical_capacity > 0
729-
ORDER BY id
730-
) sub2
731-
UNION
732-
SELECT DISTINCT ON (id)
733-
sub3.*
734-
FROM (
735-
SELECT DISTINCT ON (id)
736-
*
737-
FROM
738-
supply.ego_dp_res_powerplant
739-
WHERE id in (
740-
SELECT id
741-
FROM supply.ego_dp_res_powerplant
742-
WHERE scenario in ('NEP 2035')
743-
AND version = 'v0.3.0'
744-
AND generation_type not in ('biomass','gas','reservoir','run_of_river')
745-
AND flag in ('commissioning', 'repowering')
746-
AND generation_subtype not in ('wind_offshore')
747-
Group BY id
748-
Order by id)
749-
AND scenario in ('NEP 2035')
750-
And preversion = 'v0.3.0'
751-
AND version = 'v0.3.0'
752-
AND electrical_capacity > 0
753-
ORDER BY id
754-
) sub3
755-
Order by id;
756-
757-
ALTER MATERIALIZED VIEW supply.ego_dp_res_powerplant_ego100_mview
758-
OWNER TO oeuser;
759-
760-
-- ego scenario log (version,io,schema_name,table_name,script_name,comment)
761-
SELECT ego_scenario_log('v0.3.0','output','supply','ego_dp_res_powerplant_sq_mview','ego_dp_powerflow_create_pp_mview.sql',' ');
762-
SELECT ego_scenario_log('v0.3.0','output','supply','ego_dp_res_powerplant_nep2035_mview','ego_dp_powerflow_create_pp_mview.sql',' ');
763-
SELECT ego_scenario_log('v0.3.0','output','supply','ego_dp_res_powerplant_ego100_mview','ego_dp_powerflow_create_pp_mview.sql',' ');

0 commit comments

Comments
 (0)