Tjwb

Latest version: v3.1.0

Safety actively analyzes 685525 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 1 of 2

3.1.0

python
from datetime import datetime
from tjwb.dataset import Dataset, ComponentConfig
from tjwb.tjwb import calculate

dataset = (
Dataset()
.time_series([datetime(2023, 1, 1), datetime(2023, 1, 2)])
.water_level([2.0, 3.0])
.pump("pump1", [0.5, 0.6]) (m3/s)
.pump("pump2", [0.4, 0.4]) (m3/s)
.box_culvert("culvert1", ComponentConfig(elevation=1.0, height=2.0), [0.7, 0.8]) (m)
.valve_overflow(
"overflow1", ComponentConfig(elevation=1.0, height=2.0), [
[0.4, 0.3], port 0 (m)
[0.4, 0.3], port 1 (m)
[0.4, 0.3], port 2 (m)
]
)
.custom_outflows('custom1', [0.4, 0.7]) v3.1.0 (m3/s)
.capacity([2.0, 3.0]) v3.1.0
)

result_df = calculate(
dataset=dataset,
water_level_capacity_map={2.0: 100, 3.0: 200},
round_to=None,
nearest_mapping=False,
capacity_from_dataset_first=True v3.1.0 set True if you want to use the capacity in dataset instead of water_level_capacity_map
)

3.0.0

2.2.0

Major Changes
- **Added `water_level` and `capacity` variables**: Two new variables, `water_level` and `capacity`, have been added to the `TJWBResult` class to make it more detailed and comprehensive.

- **Implemented nearest mapping feature**: Introduced a `nearest_mapping` attribute to handle cases where the input water level does not have a corresponding capacity mapping. This feature helps avoid errors by using the nearest available mapping, but caution is advised if there is a large discrepancy in capacity between adjacent water levels.

Detailed Changes
- **`TJWBResult` Class**:
- Added `water_level: pd.Series` to store water level information.
- Added `capacity: pd.Series` to store capacity data.
- The `to_dataframe()` method has been updated to include both `water_level` and `capacity` variables in the returned DataFrame.

- **`calculate()` Function**:
- Added `nearest_mapping` parameter: When set to `True`, the function uses the nearest available water level mapping to avoid errors if the input water level does not have a direct capacity mapping. Be cautious if there is a significant difference in capacity between adjacent water levels.

Usage Example
python
import pandas as pd

Create a TJWBResult object with sample data
result = TJWBResult(
datetime=pd.Series([pd.Timestamp('2024-08-28 00:00'), pd.Timestamp('2024-08-28 01:00')]),
inflow_speed=pd.Series([1.0, 2.0]),
outflow_speed=pd.Series([0.5, 1.5]),
components_outflow_speed={'component1': pd.Series([0.2, 0.3])},
water_level=pd.Series([100.0, 101.5]),
capacity=pd.Series([200.0, 210.0])
)

Convert to DataFrame
df = result.to_dataframe()
print(df)


Some configuration code...
Perform calculation with nearest mapping
calculation_result = calculate(
df,
water_level_capacity_mapping_df,
WaterLevelCapacityMappingColumnsName(),
RequiredColumnsName(),
box_culvert_configs=box_culvert_configs,
valve_overflow_configs=valve_overflow_configs,
nearest_mapping=True
)

2.1.0

Major Changes
- **Added `datetime` variable**: A new variable `datetime` has been added to the `TJWBResult` class. This variable stores time-related data and is included in the DataFrame returned by the `to_dataframe` method.

Detailed Changes
- **`TJWBResult` Class**:
- Added `datetime: pd.Series` to store time information.
- The `to_dataframe()` method has been updated to include the `datetime` variable in the returned DataFrame.

Usage Example
python
import pandas as pd

Create a TJWBResult object with sample data
result = TJWBResult(
datetime=pd.Series([pd.Timestamp('2024-08-28 00:00'), pd.Timestamp('2024-08-28 01:00')]),
inflow_speed=pd.Series([1.0, 2.0]),
outflow_speed=pd.Series([0.5, 1.5]),
components_outflow_speed={'component1': pd.Series([0.2, 0.3])}
)

Convert to DataFrame
df = result.to_dataframe()
print(df)

2.0.0

1.1.1

1. Fix missing __init__.py
2. Fix Box Drain calculating problem.

Page 1 of 2

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.