Code Monkey home page Code Monkey logo

sdg_base's Introduction

Introduction

The Sustainable Development Goals (SDGs) are part of the UN 2030 Agenda for Sustainable Development. The Office for National Statistics (ONS) reports some of the UK data for the SDG indicators on the UK SDG data webpage, contributing to progress towards a sustainable global future.

In total, there are 17 Sustainable Development Goals and 169 indicators to be reported, covering themes such as equality, climate action, and energy and infrastructure. This code provides a base class with methods that form a standardised template that supports the automated calculation of SDG indicators to assist in the timely reporting of progress towards sustainable development.

Scope

The methods of this base class provide common functionality applicable to the calculation of all SDG indicators, such as inputting data and exporting results. This promotes reuse of code to avoid the duplication of work.

This class is inherited into the template for SDG indicators using a git submodule located in the src folder. Scripts for the calculation of individual SDG indicators built from this template will inherit these methods and attributes allowing for the quick development of individual SDG indicator calculations as required.

Changes made to the base class will also apply to the other SDGs. Modifications to the base class should as such only be considered if they are also applicable to the calculation of other SDG indicators.

Set-up and usage

If re-running an existing SDG calculator with new input data:

  1. Clone the repository of the calculator into your local folder.

  2. Install the base class: Open git BASH and run the following two commands:

git submodule init

git submodule update

  1. Follow the set-up instructions listed in the README.md of the indicator.

If creating a new SDG calculator:

This can be achieved easily using the template repository to create your repo:

  1. See here for template repository

  2. See here for instructions

Structure of template

The expected file structure for an SDG project is as follows:

sdg-x-x-x
+-- .github
| +-- workflows
| | +-- test.yml
+-- src
| +-- sdg_x_x_x_src
| | +-- sdg_base (this submodule)
| | +-- __init__.py
| | +-- sdg_x_x_x.py
+-- tests
| +-- __init__.py
| +-- test_sdg_x_x_x.py
+-- .env
+-- .gitignore
+-- .gitmodules
+-- pyproject.toml
+-- README.md
+-- Calculate_SDGx_x_x.ipynb
+-- user_params.py

If designing a new calculator without using the template:

  1. Set-up base class submodule: go to the sdg_x_x_x_src folder in the file tree you wish to work from (see expected structure above) and open git BASH. Run the following command:

git submodule add https://github.com/ONSgeo/sdg_base.git

to add the submodule to the SDG project that you're developing. You can then use the features of the base class.

Methods offered by the base class:

These methods are accessible to all classes that inherit from the base class.

  • set_input_data_dir() sets directory and creates folders from which data is input.
  • get_input_data_dir() returns main directory in which data is stored.
  • set_output_data_dir() sets directory and creates folders for data outputs.
  • get_output_data_dir() returns directory in which outputs are stored.
  • set_file_tree() sets file tree for input and output data.
  • create_folders() creates folders to store output data.
  • get_ext_files() retrieves input files by extension with optional file name filtering.
  • _get_read_function() returns the relevant read method based on the input extension.
  • load_data() joins and loads data as a data frame.
  • save_data() saves data as .csv or .shp, dependent on dataframe.
  • calculate_sdg() is an abstract method; this must be implemented in the SDG subclasses.

Authors

Ed Cuss (EdCussONS) and Lucy Astley-Jones (LucyAstleyJonesONS).

sdg_base's People

Contributors

edcussons avatar lucyastleyjonesons avatar

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.