quintel / merit

A system for calculating hourly electricity and heat loads with a merit order
MIT License
3 stars 2 forks source link

Add a method to determine the number of blackout hours per year #144

Closed jorisberkhout closed 8 years ago

jorisberkhout commented 8 years ago

As discussed in https://github.com/quintel/etmodel/issues/2058, we would like to give the user insight in the number of hours per year that the total electricity plus imported electricity cannot meet the demand.

As @grdw pointed out to me, implementing such a method in merit is fairly similar to the number_of_excess_events method that he implemented in https://github.com/quintel/merit/commit/00e3dcc4d5b2a085efa6ce0cd6440bef9c8098ab. Assigning him to implement a number_of_blackout_hours method as well. This method does not take any arguments and should return the number of hours per year where production - consumption < 0.

This method should also be available in GQL, such that it can be used in the dashboard item described in https://github.com/quintel/etmodel/issues/2058.

grdw commented 8 years ago

So, it should just print out an integer?

Like:

def number_of_blackout_hours
   (production - consumption).select { |num| num < 0 }.size
end
jorisberkhout commented 8 years ago

So, it should just print out an integer?

Yes!

Like:

def number_of_blackout_hours
   (production - consumption).select { |num| num < 0 }.size
end

Sounds like a solution to me!