Code Monkey home page Code Monkey logo

vedar's Introduction

vedar

A collection of functions to enable the import and analysis of the outputs of Veda TIMES runs in R.

Installation

Install vedar from GitHub with:

# install.packages("devtools")
devtools::install_github("datasciencescotland/vedar", build_vignettes = T)

If the above does not work, you can install from source:

  1. Go to the vedar repository on GitHub

  2. Click Clone or download then Download ZIP

  3. Save the file locally and Unzip

  4. Install with install.packages()

    install.packages("your/directory/vedar", repos = NULL, type="source")

Usage

  • import_vd("vd_filename.VD") imports the VD data to a tibble
  • import_vds("vd_filename.VDS") imports the VDS set information to tibble
  • import_vde("vd_filename.VDE") imports the VDE description information to tibble
  • import_vdt("vd_filename.VDT") imports the structural data that is available to the model, as well as user constraints. The latter is indicated by direction == "uc".
  • prep_data("vd_filename_base") calls the three import_* functions, joins data, and standardises case and missing data.
  • prep_sector_dat(sector_dat) converts cases to lower and removes spaces from column names in sector_dat. sector_dat needs to exist as a tibble. Can be imported with read_*()
  • prep_vdt_data calls import_vdt() and import_vde joins the data, standardises case and missing data.
  • define_sector_from_list(dat, join_variable_name, sector_dat, sector_info_column, sector_dat_join_variable_colsector_dat) appends the sector information in sector_dat to dat joining on join_variable_name. See ?define_sector_from_list
  • make_res(dat, node_labels, edge_labels, sankey_width, sankey_height, font_size, use_weights, input_data_type) creates a RES from vd or vdt tibble. Data must only contain a single region. Magnitudes of flows are represented if data includes only a single period, and if use_weights = F.
  • make_graph_from_veda_df(dat, node_labels, edge_labels, input_data_type) creates an igraph graph object from a vd or vdt tibble. If only a single period in vd data, the weights of the edges are set to the value of a var_fout of the commodity. Data must only contain single region in case process names are repeated across regions.
  • make_res_from_graph(g, edge_labels, sankey_width, sankey_height, font_size) creates a RES from an igraph object created by make_graph_from_veda_df, or a subgraph. Sankey edge widths represent the edge_weights.
  • check_in_path(node_regex, path): Check whether a process (graph node) containing a specified regular expression is present in a list of paths
  • syscost(dat) extract the system cost by region

vedar's People

Contributors

irisoren-sg avatar

Stargazers

merlijn avatar Jason Mc Guire avatar Olexandr Balyk avatar James Glynn avatar  avatar

Watchers

James Cloos avatar utilum avatar Jeremy Darot avatar Jo Watts avatar  avatar  avatar  avatar  avatar  avatar

Forkers

ramap27

vedar's Issues

fix make_graph_from_veda_df for R4.1.1

use of summarise in computation of edge weights causes an issue when values of non-grouped variables are distinct. Replace summarise call with left_join()

fix make_graph_from_veda_df generation of duplicate rows

make_graph_from_veda_df assigns duplicate rows from

edges <- edges %>%
      dplyr::left_join(dat %>%
                       dplyr::filter(attribute == "var_fout") %>%
                       dplyr::select(commodity, commodity_description, pv) %>%
                       unique()

Need to join on process/source and possibly sum over timeslice

Fix the plot render size in the vignette to be consistent

Plot rendering size differs on different machines when vignette is built. The sankey_height and sankey_width options control this, but appear to work differently on different machines. So this needs to be investigated and fixed

make_res requires dat to have a sector column

https://github.com/DataScienceScotland/vedar/blob/0d45a8155c3710d9cc2f9a85879bc1ce2974f560/R/network_analysis.R#L45

 if(sector_select %in% dat$sector == F){

The column name for the sectors is hardcoded here - whereas in my messing around I have a process_sector and a commodity_sector, much like the example output of define_sector_from_list which has the column name process_major_sector.

There are also many cases where process_sector and commodity_sector don't match, so not easy to know which to pick. Probably process_sector, as the Sankey diagram has the commodities as flows between processes?

prep_sector_dat not removing capitals from process names

https://github.com/DataScienceScotland/vedar/blob/0d45a8155c3710d9cc2f9a85879bc1ce2974f560/R/get_veda_dat.R#L231

I think this needs to change from:

sector_dat %>%
#strings to lower
dplyr::mutate_if(is.character, stringr::str_to_lower)

to:

sector_dat <- sector_dat %>%
#strings to lower
dplyr::mutate_if(is.character, stringr::str_to_lower)

Otherwise the mutate output is not being stored anywhere?

(Sorry if this is in the wrong place, I don't know how to use GitHub!)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.