Skip to content

Commit

Permalink
Remove old files not used
Browse files Browse the repository at this point in the history
  • Loading branch information
adrivinca committed Dec 2, 2024
1 parent 2416c9f commit ce5ec04
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 107 deletions.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -200,101 +200,3 @@ cooltech_cost_shares_c <- cooltech_cost_shares %>%
cooltech_cost_shares_c[is.na(cooltech_cost_shares_c)] <- 0
# write new file
write.csv(cooltech_cost_shares_c, paste0(data_subf, "/cooltech_cost_and_shares_country.csv"), row.names = FALSE)


# OLD DATABASE, with the new one, most of this processing is done already by the script
# https://github.com/OFR-IIASA/message_data/blob/RES_add_5_year_timesteps2/data/model/platts_historical_capacity/merge_WEPP_Raptis_CARMA.py

# # loading
# temp = readOGR(path.expand(paste0(data_subf,'\\delineation')),'MSG11_reg_simpl',verbose=FALSE)
#
# # the input shape file should come externally, in some model setup
# # usually it has two columns, the first should be called 'PID', the second 'REGION'
# # only the second column matter in terms of name, and should have the region names used in the model
#
# region_units.spdf = spTransform(temp, CRS("+proj=longlat"))
# rm(temp)

# # Read in Raptis et al data
# ppl.df = data.frame(read.csv(paste0(data_subf,'/ppl_cooling_tech/POWER_PLANTS_2016_Raptis.csv'),stringsAsFactors=FALSE))
# raptis_types_map_cooling.df = data.frame(read.csv(paste0(data_subf,'/ppl_cooling_tech/raptis_types_map_cooling_type.csv'),stringsAsFactors=FALSE))
# raptis_types_map_unit.df = data.frame(read.csv(paste0(data_subf,'/ppl_cooling_tech/raptis_types_map_unit_type.csv'),stringsAsFactors=FALSE))
#
# # MESSAGE technologies
# msg_types.df = data.frame(read.csv(paste0(data_subf,'/ppl_cooling_tech/tech_names_ssp_msg.csv'),stringsAsFactors=FALSE))
# msg_ppl = unique(c(raptis_types_map_unit.df$msgssp_type,raptis_types_map_unit.df$alt1,raptis_types_map_unit.df$alt2,raptis_types_map_unit.df$alt3))
# msg_ppl = msg_ppl[-1*(which(msg_ppl==''))]
# msg_cool = unique(raptis_types_map_cooling.df$msgssp_type)
#
# fuel_group = lapply(1:length(msg_ppl),function(x){
# ind1 = which( as.character(raptis_types_map_unit.df$msgssp_type) == as.character(msg_ppl[x]) | as.character(raptis_types_map_unit.df$alt1) == as.character(msg_ppl[x]) | as.character(raptis_types_map_unit.df$alt2) == as.character(msg_ppl[x]) | as.character(raptis_types_map_unit.df$alt3) == as.character(msg_ppl[x]) )
# return(unique(unlist(strsplit( as.character(raptis_types_map_unit.df$raptis_type[ind1]),'[.]' ))[seq(1,length(unlist(strsplit( as.character(raptis_types_map_unit.df$raptis_type[ind1]),'[.]' ))),b=2)]))
# })
#
# utype = lapply(1:length(msg_ppl),function(x){
# ind1 = which( as.character(raptis_types_map_unit.df$msgssp_type) == as.character(msg_ppl[x]) | as.character(raptis_types_map_unit.df$alt1) == as.character(msg_ppl[x]) | as.character(raptis_types_map_unit.df$alt2) == as.character(msg_ppl[x]) | as.character(raptis_types_map_unit.df$alt3) == as.character(msg_ppl[x]) )
# return(unique(unlist(strsplit( as.character(raptis_types_map_unit.df$raptis_type[ind1]),'[.]' ))[seq(2,length(unlist(strsplit( as.character(raptis_types_map_unit.df$raptis_type[ind1]),'[.]' ))),b=2)]))
# } )
#
# cool = lapply(1:length(msg_cool),function(x){ as.character(raptis_types_map_cooling.df$raptis_type[which( as.character(raptis_types_map_cooling.df$msgssp_type) == as.character(msg_cool[x]) )])})
#
# # Pull out data for this specific technology for each region
# cool_techs = unlist(lapply(1:length(msg_cool), function(x){as.matrix(unlist(lapply(1:length(msg_ppl),function(y){paste(msg_ppl[y],msg_cool[x],sep='.')})))}))
# xs = rep(seq(1,length(msg_ppl),by=1),length(msg_cool))
# ys = unlist(lapply(1:length(msg_cool),function(dd){ rep(dd,length(msg_ppl)) }))
#
# # Cooling techs by pid
# cool_techs_by_pid = data.frame(do.call(rbind, lapply(1:length(cool_techs), function(z){
# xx = xs[z]
# yy = ys[z]
# temp = ppl.df[which( as.character(ppl.df$Fuel_group) %in% as.character(fuel_group[[xx]]) &
# as.character(ppl.df$UTYPE) %in% as.character(utype[[xx]]) &
# as.character(ppl.df$COOL_complete) %in% as.character(cool[[yy]]) ),]
# if(nrow(temp)>0)
# {
# temp$x = temp$long
# temp$y = temp$lat
# coordinates(temp) = ~ x + y
# proj4string(temp) = proj4string(region_units.spdf)
# temp$pid = unlist(over(temp,region_units.spdf[,which(names(region_units.spdf) == 'PID')]))
# temp = temp[-1*(which(is.na(temp$pid) | is.na(temp$MW))),]
# mw_by_pid = unlist(lapply(1:length(region_units.spdf@data$PID), function(bb){ max(0, sum( temp$MW[ which( as.character(temp$pid) == as.character(region_units.spdf@data$PID[bb]) ) ], na.rm=TRUE ), na.rm=TRUE) } ) )
# return(mw_by_pid)
# }else
# {
# mw_by_pid = rep(0,length(region_units.spdf@data$REGION))
# return(mw_by_pid)
# }
# })))
# row.names(cool_techs_by_pid) = cool_techs
#
# type_general = unlist(strsplit( cool_techs, '[.]' ))[seq(1,length(unlist(strsplit( cool_techs, '[.]' ))),by=2)]
# cool_general = unlist(strsplit( cool_techs, '[.]' ))[seq(2,length(unlist(strsplit( cool_techs, '[.]' ))),by=2)]
# cool_techs_shares_by_pid = data.frame( do.call( cbind, lapply(1:length(region_units.spdf@data$REGION), function(r){ as.matrix( unlist( lapply( 1:length(cool_techs), function(z){
# share = cool_techs_by_pid[z,r] / sum( c( cool_techs_by_pid[ which( as.character(type_general) == as.character(type_general[z]) ), r] ), na.rm = TRUE)
# if( is.na(share) | length(share) == 0 ){share = round( sum( c( cool_techs_by_pid[ which( as.character(cool_general) == as.character(cool_general[z]) ), r] ), na.rm = TRUE) / sum( c( cool_techs_by_pid[ , r] ), na.rm = TRUE), digits = 3)}
# return(round(share, digits = 3)) } ) ) ) } ) ) )
# row.names(cool_techs_shares_by_pid) = cool_techs
# names(cool_techs_shares_by_pid) = as.character(region_units.spdf@data$REGION)
# cool_techs_shares_by_pid$cooling_utype = as.character(cool_techs)
# cool_techs_shares_by_pid$cooling = as.character(cool_general)
# cool_techs_shares_by_pid$utype = as.character(type_general)
# cool_techs_shares_by_pid = cool_techs_shares_by_pid[,c('utype','cooling',as.character(region_units.spdf@data$REGION))]
# cool_techs_shares_by_pid = cool_techs_shares_by_pid[ order( cool_techs_shares_by_pid$utype ), ]
#
# # This will be the file
# write.csv(cool_techs_shares_by_pid,paste0(data_subf,'/cool_techs_region_share.csv'),row.names = FALSE)
#
# #add 'mix_' to the columns names for regions
# cool_techs_shares_by_pid2 = cool_techs_shares_by_pid
# new_names = paste0('mix_', names(cool_techs_shares_by_pid2)[!names(cool_techs_shares_by_pid2) %in% c('utype','cooling')] )
# names(cool_techs_shares_by_pid2)[!names(cool_techs_shares_by_pid2) %in% c('utype','cooling')] = new_names
#
# # add the data to the cooltech_cost_and_shares_ssp_msg.csv file
# cooltech_cost_shares = read.csv(paste0(data_subf,'/cooltech_cost_and_shares_ssp_msg.csv'),stringsAsFactors=FALSE)
# cooltech_cost_shares = cooltech_cost_shares %>%
# select(utype, cooling,investment_million_USD_per_MW_low, investment_million_USD_per_MW_mid, investment_million_USD_per_MW_high) %>%
# left_join(cool_techs_shares_by_pid2)
#
# # write new file
# write.csv(cool_techs_shares_by_pid,paste0(data_subf,'/cooltech_cost_and_shares_ssp_msg.csv'),row.names = FALSE)

0 comments on commit ce5ec04

Please sign in to comment.