semvec/pypi-packages huggingface dataset:
psrmodels 1.2.7
Models for security of supply in power systems' reliability
License: MIT

# psrmodels: a package for adequacy of supply analysis in power systems

This packages implements some useful functions to do adequacy of supply analysis in single area and 2-area power systems. The focus is on time-collapsed models, but efficient simulation functionality is also implemented for time-sequential analysis. In the case of time-collapse models, some semi-parametric extreme value models are available for analysing both net demand (demand minus renewables) and power margins.

## Installation

The package is on PyPi, so 

```
pip install psrmodels 
```

is enough to install the package. It runs on Python `>=3.6`

## Usage

You can see the full documentation [here](https://nestorsag.github.io/psrmodels/index.html#package). Below some toy models are created for time-collapsed and time-sequential analysis

### toy bivariate time-collapsed and time-sequential models

```py
import numpy as np
import pandas as pd

from psrmodels.time_collapsed import BivariateHindcastMargin as tc_model
from psrmodels.time_collapsed import ConvGenDistribution as tc_convgen

from psrmodels.time_dependent import BivariateHindcastMargin as td_model
from psrmodels.time_dependent import ConvGenDistribution as td_convgen

# create toy demand and wind data with 100 observations
np.random.seed(1)

demand = np.random.normal(loc=1000,scale=50,size=(100,2))

wind = np.random.normal(loc=250,scale=50,size=(100,2))

# create toy generator data

gens =  pd.DataFrame({"Capacity": 50*np.ones(15), "Availability": 0.95*np.ones(15)})

# create 2 (identical) conventional generation distributions from generator data

convgen_dists = [tc_convgen(gens),tc_convgen(gens)]

# create time-collapsed bivariate hindcast model

model1 = tc_model(demand=demand,renewables=wind,gen_dists=convgen_dists)

## compute LOLE for area 1 under a 'veto' policy an 1000MW interconnection capacity
model1.lole(c=1000,policy="veto",axis=0)

# now, create a time-sequential model

# first, create time-sequential generators. We need to add a 'TTR' (time to repair) column to our generator data
gens["TTR"] = 50 #50 hours to repair on average
td_convgen_dists = [td_convgen(gens),td_convgen(gens)]

# create time-sequential model
model2 = td_model(demand=demand,renewables=wind,gen_dists=td_convgen_dists)

# simulate post-interconnection sequential power margin values under a veto policy and 1000MW interconnection
sim_data = model2.simulate_post_itc(n_sim=1000,c=1000,policy="veto")
```
auto-logger 0.1.2
Automatically add function call logs and method call logs for Python code.
License: MIT
Requires Python: >=3.8,<4.0

# Auto-logger

![CI](https://github.com/duyixian1234/auto-logger/workflows/CI/badge.svg?branch=master)

Automatically add function call logs and method call logs for Python code.

## Install

```bash
pip install -U auto-logger
```

## Use

```python
import logging
from dataclasses import dataclass

from auto_logger import Config, MethodLoggerMeta, logFuncCall,formatJson

logging.basicConfig(level=logging.INFO)


@logFuncCall
def add(a: int, b: int):
    return a + b


add(1, 2) # INFO:auto_logger:CALL FUCNTION <add> WITH ARGS (1, 2) KWARGS {} RETURNS  3
add(a=1, b=2) # INFO:auto_logger:CALL FUCNTION <add> WITH ARGS () KWARGS {'a': 1, 'b': 2} RETURNS  3


@dataclass
class A(metaclass=MethodLoggerMeta):
    a: int = 0

    def add(self, n: int):
        self.a += 1

    def abs(self):
        return abs(self.a)

A().add(1)  # INFO:auto_logger:CALL METHOD <add> OF A(a=0) WITH ARGS (1,) KWARGS {} RETURNS  None


Config.format = formatJson
A().add(1) # INFO:auto_logger:{"args": [1], "kwargs": {}, "ret": null, "method": "add", "object": "A(a=0)"}

Config.ignoreMethods[A] = {'abs'}
A().abs() # Log nothing
```