Coder Social home page Coder Social logo

lennard0011 / energy-costs-calculator Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 16 KB

Code to calculate the costs of energy consumption based on the input in a CSV format where every row is a 15-minute bucket with the current energy usage.

License: MIT License

Go 100.00%

energy-costs-calculator's Introduction

energy-costs-calculator

Code to calculate the costs of energy consumption based on the input in a CSV format where every row is a 15-minute bucket with the current energy usage.

How to run

  1. Clone the repository.
  2. Adjust the pricing.csv according to the electricity prices. Configured per weekday per interval of the day. See the current pricing.csv as a reference. If you want to use a different name for the file, change the value of pricingRatesFileName in main.go.
  3. Upload the readings of the meters in the input-data folder in a csv format. See the current test-readings.csv as a reference. The filename is not important, only that is is a csv file. If there are multiple csv files in the folder, then the first one is used.
  4. Run the command go run .
  5. The calculated costs will be returned in costs.csv.

Assumptions

  • The firs row of the CVS file contains the names of the columns.
  • The timezone of the location is Europe/Amsterdam. This can be adjusted in the main.go
  • The CSV file is ordered on metering point ids and ascending dates.
  • There are no missing entries in the file.
  • The first reading is correct.
  • If a pricerate is not defined in the pricing.csv, it is assumed that the price is 0.

General idea

The general idea of the code is as follows:

  1. When run, the main module looks for a CSV file in the input-data folder.
  2. This CSV file is then converted to a measuring data structure per measuring id.
  3. The measuring data is filtered for wrong readings.
  4. The missing usage between two buckets is imputed by equally dividing the usage of two points. If the last readings are incorrect, we forward impute this from the two readings before.
  5. With the complete measuring data, the cost is calculated.
  6. Configuration parameters like usageLowerBound and timezoneLocation can be adjusted in the top of the main.go file.

Architecture

The data is represented in different classes. The idea is that the codebase is split in different modulair parts where each has a single functionality. The higher-order functions should not care about the complexities of the lower order functions and structs.

The reading and writing of the CSV files is done on a more higher level. Once the data is loaded, it is converted to different classes that handle the logic on the different levels.

Parameters like the usageLowerBound and usageUpperBound can be configured seperatly in the main.go file.

Classes

Measuring Data entry

This contains a time (time.Time) and a value (int64). This represents an single readingentry.

Measuring Data

This represents collection of measuring reading for a single measuring point.

WeekdayPriceRate

This is a period within the week defined by the weekday and period in the day with a certain price.

WeekdayPriceRateOverview

This represents a collection of rates which should cover a whole week together used to calculate the prices of usage.

Next steps

  • Define more testcases to fortify the codebase.
  • Improve logging to improve user experience.
  • Implement different imputation techniques

energy-costs-calculator's People

Contributors

lennard0011 avatar

Watchers

 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.