CoolPlot 1.3.0__tar.gz → 1.5.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {coolplot-1.3.0/src/CoolPlot.egg-info → coolplot-1.5.0}/PKG-INFO +2 -2
- {coolplot-1.3.0 → coolplot-1.5.0}/README.md +1 -1
- {coolplot-1.3.0 → coolplot-1.5.0/src/CoolPlot.egg-info}/PKG-INFO +2 -2
- {coolplot-1.3.0 → coolplot-1.5.0}/src/CoolPlot.egg-info/SOURCES.txt +5 -0
- {coolplot-1.3.0 → coolplot-1.5.0}/src/coolplot/__init__.py +3 -2
- {coolplot-1.3.0 → coolplot-1.5.0}/src/coolplot/__version__.py +1 -1
- {coolplot-1.3.0 → coolplot-1.5.0}/src/coolplot/chart.py +162 -21
- {coolplot-1.3.0 → coolplot-1.5.0}/src/coolplot/compose/__init__.py +5 -5
- {coolplot-1.3.0 → coolplot-1.5.0}/src/coolplot/compose/builder.py +359 -38
- {coolplot-1.3.0 → coolplot-1.5.0}/src/coolplot/compose/layout.py +82 -0
- {coolplot-1.3.0 → coolplot-1.5.0}/src/coolplot/core/cycle.py +19 -1
- {coolplot-1.3.0 → coolplot-1.5.0}/src/coolplot/core/diagram_type.py +4 -0
- {coolplot-1.3.0 → coolplot-1.5.0}/src/coolplot/core/quantities.py +3 -1
- coolplot-1.5.0/src/coolplot/core/symbols.py +63 -0
- {coolplot-1.3.0 → coolplot-1.5.0}/src/coolplot/corelib.py +57 -8
- {coolplot-1.3.0 → coolplot-1.5.0}/src/coolplot/diagram.py +66 -3
- {coolplot-1.3.0 → coolplot-1.5.0}/src/coolplot/engine/engine.py +79 -6
- {coolplot-1.3.0 → coolplot-1.5.0}/src/coolplot/engine/planning.py +22 -1
- {coolplot-1.3.0 → coolplot-1.5.0}/src/coolplot/psychrometric.py +3 -1
- {coolplot-1.3.0 → coolplot-1.5.0}/src/coolplot/render/base.py +11 -5
- {coolplot-1.3.0 → coolplot-1.5.0}/src/coolplot/render/pdf.py +4 -2
- {coolplot-1.3.0 → coolplot-1.5.0}/src/coolplot/render/plotly.py +40 -2
- {coolplot-1.3.0 → coolplot-1.5.0}/src/coolplot/render/static/scene_svg.js +81 -1
- {coolplot-1.3.0 → coolplot-1.5.0}/src/coolplot/render/svg.py +7 -7
- {coolplot-1.3.0 → coolplot-1.5.0}/src/coolplot/render/web.py +4 -4
- {coolplot-1.3.0 → coolplot-1.5.0}/src/coolplot/scene.py +2 -2
- {coolplot-1.3.0 → coolplot-1.5.0}/src/coolplot/spec/__init__.py +3 -3
- {coolplot-1.3.0 → coolplot-1.5.0}/src/coolplot/spec/diagram.py +224 -10
- {coolplot-1.3.0 → coolplot-1.5.0}/src/coolplot/spec/settings.py +48 -12
- {coolplot-1.3.0 → coolplot-1.5.0}/src/coolplot/style/__init__.py +1 -1
- {coolplot-1.3.0 → coolplot-1.5.0}/src/coolplot/style/theme.py +87 -35
- {coolplot-1.3.0 → coolplot-1.5.0}/src/coolplot/thermo/cycles/models.py +3 -3
- {coolplot-1.3.0 → coolplot-1.5.0}/src/coolplot/thermo/fluid.py +49 -0
- {coolplot-1.3.0 → coolplot-1.5.0}/src/coolplot/thermo/provider.py +91 -0
- {coolplot-1.3.0 → coolplot-1.5.0}/src/coolplot/thermo/references.py +116 -11
- {coolplot-1.3.0 → coolplot-1.5.0}/tests/test_api_vocabulary.py +5 -3
- {coolplot-1.3.0 → coolplot-1.5.0}/tests/test_architecture.py +19 -0
- {coolplot-1.3.0 → coolplot-1.5.0}/tests/test_branding.py +80 -21
- {coolplot-1.3.0 → coolplot-1.5.0}/tests/test_cycles.py +132 -1
- {coolplot-1.3.0 → coolplot-1.5.0}/tests/test_diagram.py +17 -1
- coolplot-1.5.0/tests/test_dome_labels.py +108 -0
- {coolplot-1.3.0 → coolplot-1.5.0}/tests/test_engine.py +1 -1
- {coolplot-1.3.0 → coolplot-1.5.0}/tests/test_examples.py +38 -12
- {coolplot-1.3.0 → coolplot-1.5.0}/tests/test_layout.py +1 -1
- coolplot-1.5.0/tests/test_marked_points.py +117 -0
- {coolplot-1.3.0 → coolplot-1.5.0}/tests/test_native_core.py +330 -5
- {coolplot-1.3.0 → coolplot-1.5.0}/tests/test_pdf.py +1 -1
- {coolplot-1.3.0 → coolplot-1.5.0}/tests/test_psychro.py +7 -7
- {coolplot-1.3.0 → coolplot-1.5.0}/tests/test_rails.py +2 -2
- {coolplot-1.3.0 → coolplot-1.5.0}/tests/test_saturation_anchors.py +5 -5
- coolplot-1.5.0/tests/test_saturation_scale.py +119 -0
- coolplot-1.5.0/tests/test_single_lines.py +201 -0
- {coolplot-1.3.0 → coolplot-1.5.0}/tests/test_spec.py +15 -0
- {coolplot-1.3.0 → coolplot-1.5.0}/tests/test_style.py +22 -9
- {coolplot-1.3.0 → coolplot-1.5.0}/LICENSE +0 -0
- {coolplot-1.3.0 → coolplot-1.5.0}/pyproject.toml +0 -0
- {coolplot-1.3.0 → coolplot-1.5.0}/setup.cfg +0 -0
- {coolplot-1.3.0 → coolplot-1.5.0}/src/CoolPlot.egg-info/dependency_links.txt +0 -0
- {coolplot-1.3.0 → coolplot-1.5.0}/src/CoolPlot.egg-info/requires.txt +0 -0
- {coolplot-1.3.0 → coolplot-1.5.0}/src/CoolPlot.egg-info/top_level.txt +0 -0
- {coolplot-1.3.0 → coolplot-1.5.0}/src/coolplot/compose/branding.py +0 -0
- {coolplot-1.3.0 → coolplot-1.5.0}/src/coolplot/compose/corners.py +0 -0
- {coolplot-1.3.0 → coolplot-1.5.0}/src/coolplot/compose/rails.py +0 -0
- {coolplot-1.3.0 → coolplot-1.5.0}/src/coolplot/core/__init__.py +0 -0
- {coolplot-1.3.0 → coolplot-1.5.0}/src/coolplot/core/errors.py +0 -0
- {coolplot-1.3.0 → coolplot-1.5.0}/src/coolplot/core/events.py +0 -0
- {coolplot-1.3.0 → coolplot-1.5.0}/src/coolplot/core/floats.py +0 -0
- {coolplot-1.3.0 → coolplot-1.5.0}/src/coolplot/core/images.py +0 -0
- {coolplot-1.3.0 → coolplot-1.5.0}/src/coolplot/core/implementation.py +0 -0
- {coolplot-1.3.0 → coolplot-1.5.0}/src/coolplot/core/limits.py +0 -0
- {coolplot-1.3.0 → coolplot-1.5.0}/src/coolplot/core/numbers.py +0 -0
- {coolplot-1.3.0 → coolplot-1.5.0}/src/coolplot/core/state.py +0 -0
- {coolplot-1.3.0 → coolplot-1.5.0}/src/coolplot/core/textwidth.py +0 -0
- {coolplot-1.3.0 → coolplot-1.5.0}/src/coolplot/core/units.py +0 -0
- {coolplot-1.3.0 → coolplot-1.5.0}/src/coolplot/engine/__init__.py +0 -0
- {coolplot-1.3.0 → coolplot-1.5.0}/src/coolplot/engine/background.py +0 -0
- {coolplot-1.3.0 → coolplot-1.5.0}/src/coolplot/engine/cache.py +0 -0
- {coolplot-1.3.0 → coolplot-1.5.0}/src/coolplot/engine/store.py +0 -0
- {coolplot-1.3.0 → coolplot-1.5.0}/src/coolplot/export.py +0 -0
- {coolplot-1.3.0 → coolplot-1.5.0}/src/coolplot/interaction.py +0 -0
- {coolplot-1.3.0 → coolplot-1.5.0}/src/coolplot/py.typed +0 -0
- {coolplot-1.3.0 → coolplot-1.5.0}/src/coolplot/render/__init__.py +0 -0
- {coolplot-1.3.0 → coolplot-1.5.0}/src/coolplot/render/mpl.py +0 -0
- {coolplot-1.3.0 → coolplot-1.5.0}/src/coolplot/render/ticks.py +0 -0
- {coolplot-1.3.0 → coolplot-1.5.0}/src/coolplot/spec/fluid.py +0 -0
- {coolplot-1.3.0 → coolplot-1.5.0}/src/coolplot/style/values.py +0 -0
- {coolplot-1.3.0 → coolplot-1.5.0}/src/coolplot/testing/__init__.py +0 -0
- {coolplot-1.3.0 → coolplot-1.5.0}/src/coolplot/testing/kit.py +0 -0
- {coolplot-1.3.0 → coolplot-1.5.0}/src/coolplot/testing/pdf_reader.py +0 -0
- {coolplot-1.3.0 → coolplot-1.5.0}/src/coolplot/thermo/__init__.py +0 -0
- {coolplot-1.3.0 → coolplot-1.5.0}/src/coolplot/thermo/cycles/__init__.py +0 -0
- {coolplot-1.3.0 → coolplot-1.5.0}/src/coolplot/thermo/cycles/paths.py +0 -0
- {coolplot-1.3.0 → coolplot-1.5.0}/src/coolplot/thermo/humid_air.py +0 -0
- {coolplot-1.3.0 → coolplot-1.5.0}/src/coolplot/thermo/isolines.py +0 -0
- {coolplot-1.3.0 → coolplot-1.5.0}/src/coolplot/thermo/limits.py +0 -0
- {coolplot-1.3.0 → coolplot-1.5.0}/src/coolplot/thermo/native.py +0 -0
- {coolplot-1.3.0 → coolplot-1.5.0}/src/coolplot/thermo/process.py +0 -0
- {coolplot-1.3.0 → coolplot-1.5.0}/src/coolplot/thermo/stepping.py +0 -0
- {coolplot-1.3.0 → coolplot-1.5.0}/src/coolplot/thermo/tracer.py +0 -0
- {coolplot-1.3.0 → coolplot-1.5.0}/tests/test_backend_conformance.py +0 -0
- {coolplot-1.3.0 → coolplot-1.5.0}/tests/test_background.py +0 -0
- {coolplot-1.3.0 → coolplot-1.5.0}/tests/test_contracts.py +0 -0
- {coolplot-1.3.0 → coolplot-1.5.0}/tests/test_curve_store.py +0 -0
- {coolplot-1.3.0 → coolplot-1.5.0}/tests/test_events.py +0 -0
- {coolplot-1.3.0 → coolplot-1.5.0}/tests/test_native.py +0 -0
- {coolplot-1.3.0 → coolplot-1.5.0}/tests/test_numerics.py +0 -0
- {coolplot-1.3.0 → coolplot-1.5.0}/tests/test_plotly.py +0 -0
- {coolplot-1.3.0 → coolplot-1.5.0}/tests/test_scene_js.py +0 -0
- {coolplot-1.3.0 → coolplot-1.5.0}/tests/test_scene_render.py +0 -0
- {coolplot-1.3.0 → coolplot-1.5.0}/tests/test_thermo.py +0 -0
- {coolplot-1.3.0 → coolplot-1.5.0}/tests/test_typing.py +0 -0
- {coolplot-1.3.0 → coolplot-1.5.0}/tests/test_web.py +0 -0
- {coolplot-1.3.0 → coolplot-1.5.0}/tests/test_web_server.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: CoolPlot
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.5.0
|
|
4
4
|
Summary: Thermodynamic property diagrams with CoolProp as data source.
|
|
5
5
|
Author-email: Jorrit Wronski <coolplot@jorrit.org>
|
|
6
6
|
License: MIT License
|
|
@@ -71,7 +71,7 @@ from coolplot import PropertyDiagram
|
|
|
71
71
|
from coolplot.thermo.cycles import simple_compression
|
|
72
72
|
|
|
73
73
|
diagram = PropertyDiagram("R290", "ph", units="engineering", tp_limits="ACHP")
|
|
74
|
-
diagram.set_default_lines(labels=True)
|
|
74
|
+
diagram.set_default_lines(labels=True, rounding=True)
|
|
75
75
|
diagram.add_cycle(simple_compression("R290", T_evap_C=-5, T_cond_C=45, dT_sh_K=5))
|
|
76
76
|
diagram.save("R290_ph.png") # or .pdf, .svg; show() opens a window
|
|
77
77
|
```
|
|
@@ -22,7 +22,7 @@ from coolplot import PropertyDiagram
|
|
|
22
22
|
from coolplot.thermo.cycles import simple_compression
|
|
23
23
|
|
|
24
24
|
diagram = PropertyDiagram("R290", "ph", units="engineering", tp_limits="ACHP")
|
|
25
|
-
diagram.set_default_lines(labels=True)
|
|
25
|
+
diagram.set_default_lines(labels=True, rounding=True)
|
|
26
26
|
diagram.add_cycle(simple_compression("R290", T_evap_C=-5, T_cond_C=45, dT_sh_K=5))
|
|
27
27
|
diagram.save("R290_ph.png") # or .pdf, .svg; show() opens a window
|
|
28
28
|
```
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: CoolPlot
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.5.0
|
|
4
4
|
Summary: Thermodynamic property diagrams with CoolProp as data source.
|
|
5
5
|
Author-email: Jorrit Wronski <coolplot@jorrit.org>
|
|
6
6
|
License: MIT License
|
|
@@ -71,7 +71,7 @@ from coolplot import PropertyDiagram
|
|
|
71
71
|
from coolplot.thermo.cycles import simple_compression
|
|
72
72
|
|
|
73
73
|
diagram = PropertyDiagram("R290", "ph", units="engineering", tp_limits="ACHP")
|
|
74
|
-
diagram.set_default_lines(labels=True)
|
|
74
|
+
diagram.set_default_lines(labels=True, rounding=True)
|
|
75
75
|
diagram.add_cycle(simple_compression("R290", T_evap_C=-5, T_cond_C=45, dT_sh_K=5))
|
|
76
76
|
diagram.save("R290_ph.png") # or .pdf, .svg; show() opens a window
|
|
77
77
|
```
|
|
@@ -34,6 +34,7 @@ src/coolplot/core/limits.py
|
|
|
34
34
|
src/coolplot/core/numbers.py
|
|
35
35
|
src/coolplot/core/quantities.py
|
|
36
36
|
src/coolplot/core/state.py
|
|
37
|
+
src/coolplot/core/symbols.py
|
|
37
38
|
src/coolplot/core/textwidth.py
|
|
38
39
|
src/coolplot/core/units.py
|
|
39
40
|
src/coolplot/engine/__init__.py
|
|
@@ -84,10 +85,12 @@ tests/test_contracts.py
|
|
|
84
85
|
tests/test_curve_store.py
|
|
85
86
|
tests/test_cycles.py
|
|
86
87
|
tests/test_diagram.py
|
|
88
|
+
tests/test_dome_labels.py
|
|
87
89
|
tests/test_engine.py
|
|
88
90
|
tests/test_events.py
|
|
89
91
|
tests/test_examples.py
|
|
90
92
|
tests/test_layout.py
|
|
93
|
+
tests/test_marked_points.py
|
|
91
94
|
tests/test_native.py
|
|
92
95
|
tests/test_native_core.py
|
|
93
96
|
tests/test_numerics.py
|
|
@@ -96,8 +99,10 @@ tests/test_plotly.py
|
|
|
96
99
|
tests/test_psychro.py
|
|
97
100
|
tests/test_rails.py
|
|
98
101
|
tests/test_saturation_anchors.py
|
|
102
|
+
tests/test_saturation_scale.py
|
|
99
103
|
tests/test_scene_js.py
|
|
100
104
|
tests/test_scene_render.py
|
|
105
|
+
tests/test_single_lines.py
|
|
101
106
|
tests/test_spec.py
|
|
102
107
|
tests/test_style.py
|
|
103
108
|
tests/test_thermo.py
|
|
@@ -46,8 +46,8 @@ if TYPE_CHECKING:
|
|
|
46
46
|
from .scene import Scene as Scene
|
|
47
47
|
from .spec import (BrandingSettings as BrandingSettings, CalcSettings as CalcSettings, CycleSpec as CycleSpec,
|
|
48
48
|
DiagramSpec as DiagramSpec, FluidSpec as FluidSpec, HumidAirSpec as HumidAirSpec,
|
|
49
|
-
IsolineSet as IsolineSet, LabelSettings as LabelSettings,
|
|
50
|
-
ProcessSpec as ProcessSpec, Settings as Settings)
|
|
49
|
+
IsolineSet as IsolineSet, LabelSettings as LabelSettings, LineSpec as LineSpec,
|
|
50
|
+
PageSettings as PageSettings, ProcessSpec as ProcessSpec, Settings as Settings)
|
|
51
51
|
from .style.theme import Theme as Theme, get_theme as get_theme
|
|
52
52
|
from .style.values import (AxesStyle as AxesStyle, Font as Font, LegendStyle as LegendStyle,
|
|
53
53
|
LineStyle as LineStyle, MarkerStyle as MarkerStyle, TextStyle as TextStyle)
|
|
@@ -67,6 +67,7 @@ _LAZY = {
|
|
|
67
67
|
"DiagramSpec": ".spec",
|
|
68
68
|
"FluidSpec": ".spec",
|
|
69
69
|
"IsolineSet": ".spec",
|
|
70
|
+
"LineSpec": ".spec",
|
|
70
71
|
"ProcessSpec": ".spec",
|
|
71
72
|
"Settings": ".spec",
|
|
72
73
|
"CalcSettings": ".spec",
|
|
@@ -29,9 +29,9 @@ computed (:class:`coolplot.core.errors.PropertyError`) are written in
|
|
|
29
29
|
the chart's units too.
|
|
30
30
|
|
|
31
31
|
The verbs of a chart are ``set_lines``, ``remove_lines``,
|
|
32
|
-
``set_line_style``, ``
|
|
33
|
-
``update_scene``, ``draw`` and ``save``;
|
|
34
|
-
warn (see the CHANGELOG for 0.5).
|
|
32
|
+
``set_line_style``, ``add_line``, ``remove_line``, ``add_cycle``,
|
|
33
|
+
``remove_cycle``, ``set_view``, ``update_scene``, ``draw`` and ``save``;
|
|
34
|
+
the older names still work and warn (see the CHANGELOG for 0.5).
|
|
35
35
|
"""
|
|
36
36
|
from __future__ import annotations
|
|
37
37
|
|
|
@@ -45,7 +45,7 @@ from typing import (TYPE_CHECKING, Any, Callable, Dict, Mapping, Optional, Seque
|
|
|
45
45
|
|
|
46
46
|
import numpy as np
|
|
47
47
|
|
|
48
|
-
from .compose import compose
|
|
48
|
+
from .compose import compose, label_text
|
|
49
49
|
from .core.cycle import Cycle, StateInput
|
|
50
50
|
from .core.diagram_type import DiagramType, Family
|
|
51
51
|
from .core.errors import PropertyError
|
|
@@ -53,13 +53,15 @@ from .core.quantities import quantity_key
|
|
|
53
53
|
from .core.state import StatePoint, with_mollier_temperature
|
|
54
54
|
from .core.units import Unit, UnitsLike, UnitSystem, get_unit_system
|
|
55
55
|
from .engine import BackgroundEngine, CurveCache, Engine, plan
|
|
56
|
+
from .engine.planning import snap
|
|
56
57
|
from .scene import Scene
|
|
57
|
-
from .spec import (CycleSpec, DiagramSpec, FluidSpec, HumidAirSpec, IsolineSet,
|
|
58
|
-
get_settings)
|
|
58
|
+
from .spec import (CycleSpec, DiagramSpec, FluidSpec, HumidAirSpec, IsolineSet, LineSpec, SaturationAnchor,
|
|
59
|
+
Settings, get_settings)
|
|
59
60
|
from .spec.diagram import ANCHOR_KEYS
|
|
60
61
|
from .style.theme import Theme, get_theme
|
|
61
62
|
from .style.values import LineStyle, MarkerStyle
|
|
62
63
|
from .thermo.cycles.paths import resolve_state
|
|
64
|
+
from .thermo.fluid import Fluid
|
|
63
65
|
from .thermo.provider import PropertyProvider
|
|
64
66
|
|
|
65
67
|
if TYPE_CHECKING: # only for the type checker: the renderers are imported when a chart is drawn
|
|
@@ -201,6 +203,38 @@ REMOVED_NAMES = {
|
|
|
201
203
|
}
|
|
202
204
|
|
|
203
205
|
|
|
206
|
+
def _fluid_text(name: str, model: Tuple) -> str:
|
|
207
|
+
"""A fluid for a message: its name, and the basis of a mixture's fractions when that is mass or volume.
|
|
208
|
+
|
|
209
|
+
"HEOS::R32[0.5]&R125[0.5]" reads as mole fractions; given by mass it is
|
|
210
|
+
written "HEOS::R32[0.5]&R125[0.5] (fractions by mass)". A fluid of one
|
|
211
|
+
component keeps its name; so does an INCOMP fluid, which is one
|
|
212
|
+
component in CoolProp ("MEG" in "INCOMP::MEG[0.3]").
|
|
213
|
+
"""
|
|
214
|
+
if not model or len(model[1]) < 2 or model[3] not in ("mass", "volu"):
|
|
215
|
+
return name
|
|
216
|
+
return "{0} (fractions by {1})".format(name, "volume" if model[3] == "volu" else "mass")
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
def _model_name(model: Tuple) -> str:
|
|
220
|
+
"""A fluid string for a model key, "HEOS::R32[0.5]&R125[0.5]", for a cycle that kept no name."""
|
|
221
|
+
backend, components, fractions, basis = model[:4]
|
|
222
|
+
try:
|
|
223
|
+
return str(FluidSpec(backend=backend, components=tuple(components), fractions=tuple(fractions), basis=basis))
|
|
224
|
+
except (TypeError, ValueError): # a model FluidSpec does not take: the components at least
|
|
225
|
+
return "&".join(components)
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
def _other_fluid_message(cycle: Cycle, chart_fluid: str, chart_model: Tuple) -> str:
|
|
229
|
+
"""Why a cycle does not belong on a chart; says so when the two fluids print alike."""
|
|
230
|
+
theirs = _fluid_text(cycle.fluid or _model_name(cycle.fluid_model), cycle.fluid_model)
|
|
231
|
+
mine = _fluid_text(chart_fluid, chart_model)
|
|
232
|
+
if theirs == mine:
|
|
233
|
+
return ("Cycle '{0}' was computed for another model of {1} than this chart's (other fractions, "
|
|
234
|
+
"basis of the fractions or interaction parameters).".format(cycle.name, mine))
|
|
235
|
+
return "Cycle '{0}' was computed for {1}, but this chart shows {2}.".format(cycle.name, theirs, mine)
|
|
236
|
+
|
|
237
|
+
|
|
204
238
|
class Chart:
|
|
205
239
|
"""A chart built from a spec; see :class:`PropertyDiagram` and :class:`PsychrometricChart`
|
|
206
240
|
|
|
@@ -292,6 +326,7 @@ class Chart:
|
|
|
292
326
|
if isinstance(self.engine, BackgroundEngine):
|
|
293
327
|
return self.engine.progress
|
|
294
328
|
n = sum(len(s.values_SI or ()) or s.num for s in self.spec.isolines)
|
|
329
|
+
n += sum(1 for line in self.spec.lines if not self.spec.diagram.is_axis(line.key)) # axis lines need no curve
|
|
295
330
|
return n, n
|
|
296
331
|
|
|
297
332
|
def wait(self, timeout: Optional[float] = None) -> bool:
|
|
@@ -470,7 +505,7 @@ class Chart:
|
|
|
470
505
|
``"range": (lo, hi)`` limits the saturation temperatures or
|
|
471
506
|
pressures. Steps and range are in ``units``. The labels show the
|
|
472
507
|
lines' own values ("s=2.321 kJ/kg/K"); ``"label": "saturation"``
|
|
473
|
-
shows the saturation state instead ("T_sat=0
|
|
508
|
+
shows the saturation state instead ("T_sat=0" with its unit). Charts of
|
|
474
509
|
a fluid only.
|
|
475
510
|
|
|
476
511
|
Examples
|
|
@@ -559,6 +594,90 @@ class Chart:
|
|
|
559
594
|
"""The families of lines by quantity key, as :class:`coolplot.spec.IsolineSet` values."""
|
|
560
595
|
return {s.key: s for s in self.spec.isolines}
|
|
561
596
|
|
|
597
|
+
def add_line(self, key: str, value: float, name: Optional[str] = None, line_style: Optional[LineStyle] = None,
|
|
598
|
+
label: Union[bool, str] = True, units: Optional[UnitsLike] = None,
|
|
599
|
+
points: Optional[int] = None) -> str:
|
|
600
|
+
"""Add or replace a single line of constant ``key``, drawn on top of the families.
|
|
601
|
+
|
|
602
|
+
For example a design temperature, or the pressure at which a relief
|
|
603
|
+
valve or burst disk opens. The line is independent of the families:
|
|
604
|
+
:meth:`set_lines` and :meth:`set_default_lines` leave it alone.
|
|
605
|
+
|
|
606
|
+
Parameters
|
|
607
|
+
----------
|
|
608
|
+
key : str
|
|
609
|
+
Quantity held constant: any quantity :meth:`set_lines` takes in
|
|
610
|
+
this chart, or one of the two axis quantities (p and h in a
|
|
611
|
+
log(p)-h chart). A line of an axis quantity is a straight line
|
|
612
|
+
across the plot, and the axes widen to show it.
|
|
613
|
+
value : float
|
|
614
|
+
The constant value, in the chart's units or in ``units``.
|
|
615
|
+
name : str, optional
|
|
616
|
+
Shown in the legend; adding a line under a name that is taken
|
|
617
|
+
replaces that line. Default: the label text, e.g. "p=130 bar",
|
|
618
|
+
numbered ("p=130 bar (2)") when a line of another value has it.
|
|
619
|
+
A name may not end in "/label".
|
|
620
|
+
line_style : LineStyle, optional
|
|
621
|
+
Default: the style of the family (the colour of the saturation
|
|
622
|
+
curve for an axis quantity) at twice its width.
|
|
623
|
+
label : bool or str
|
|
624
|
+
True writes the value on the line, False nothing; a text is
|
|
625
|
+
written instead of the value.
|
|
626
|
+
units : str or UnitSystem, optional
|
|
627
|
+
Units of ``value``; default the chart's units.
|
|
628
|
+
points : int, optional
|
|
629
|
+
Points of a curved line; default from ``settings.calc``.
|
|
630
|
+
|
|
631
|
+
Returns
|
|
632
|
+
-------
|
|
633
|
+
str
|
|
634
|
+
The name of the line, for :meth:`remove_line`.
|
|
635
|
+
|
|
636
|
+
Examples
|
|
637
|
+
--------
|
|
638
|
+
One isotherm highlighted among the default lines, and the pressure at
|
|
639
|
+
which the burst disks of a CO2 plant open:
|
|
640
|
+
|
|
641
|
+
>>> diagram.set_default_lines(labels=True, rounding=True) # doctest: +SKIP
|
|
642
|
+
>>> diagram.add_line("T", 22) # doctest: +SKIP
|
|
643
|
+
>>> red = LineStyle(color="red", width_pt=2.0) # doctest: +SKIP
|
|
644
|
+
>>> diagram.add_line("p", 130, name="Burst disk", line_style=red) # doctest: +SKIP
|
|
645
|
+
"""
|
|
646
|
+
key = quantity_key(key)
|
|
647
|
+
diagram = self.spec.diagram
|
|
648
|
+
unit = self._units(units)[key]
|
|
649
|
+
values_SI = np.atleast_1d(unit.to_SI(np.asarray(value, dtype=float)))
|
|
650
|
+
if len(values_SI) != 1:
|
|
651
|
+
raise ValueError("A line has one value, not {0}; give a family of lines with set_lines.".format(value))
|
|
652
|
+
value_SI = float(values_SI[0])
|
|
653
|
+
if not diagram.is_axis(key):
|
|
654
|
+
self._family(key).check_values((value_SI,), diagram.quantity_label(key))
|
|
655
|
+
if name is None:
|
|
656
|
+
name = self._line_name(key, snap(value_SI)) # the value as the line holds it
|
|
657
|
+
self.spec = self.spec.with_line(LineSpec(name=name, key=key, value_SI=value_SI, label=label,
|
|
658
|
+
line_style=line_style, points=points))
|
|
659
|
+
return name
|
|
660
|
+
|
|
661
|
+
def _line_name(self, key: str, value_SI: float) -> str:
|
|
662
|
+
"""The default name of a line: its label text, e.g. "p=30 bar".
|
|
663
|
+
|
|
664
|
+
A line of another value can have the same label text (30.001 and
|
|
665
|
+
30.002 bar both read "p=30 bar"); the new line then gets a number,
|
|
666
|
+
"p=30 bar (2)", and does not replace it. A line of the same value
|
|
667
|
+
keeps its name and is replaced.
|
|
668
|
+
"""
|
|
669
|
+
text = label_text(self.spec, key, value_SI)
|
|
670
|
+
taken = {line.name: (line.key, line.value_SI) for line in self.spec.lines}
|
|
671
|
+
name, number = text, 1
|
|
672
|
+
while name in taken and taken[name] != (key, value_SI):
|
|
673
|
+
number += 1
|
|
674
|
+
name = "{0} ({1})".format(text, number)
|
|
675
|
+
return name
|
|
676
|
+
|
|
677
|
+
def remove_line(self, name: str) -> None:
|
|
678
|
+
"""Remove the single line called ``name``; nothing happens if there is none."""
|
|
679
|
+
self.spec = self.spec.without_line(name)
|
|
680
|
+
|
|
562
681
|
# Names removed in 1.0 for this kind of chart, see REMOVED_NAMES
|
|
563
682
|
_removed_names = REMOVED_NAMES
|
|
564
683
|
|
|
@@ -656,9 +775,10 @@ class Chart:
|
|
|
656
775
|
line_style: Optional[LineStyle], marker_style: Optional[MarkerStyle], steps: int,
|
|
657
776
|
labels: Labels = None) -> CycleSpec:
|
|
658
777
|
"""A CycleSpec for a computed Cycle, after checking that it belongs to this chart's fluid."""
|
|
659
|
-
if cycle.fluid and self._other_fluid(cycle
|
|
660
|
-
|
|
661
|
-
|
|
778
|
+
if (cycle.fluid or cycle.fluid_model) and self._other_fluid(cycle):
|
|
779
|
+
own = self.fluid
|
|
780
|
+
chart_model = own.model_key if isinstance(own, Fluid) else ()
|
|
781
|
+
raise ValueError(_other_fluid_message(cycle, str(self.spec.fluid), chart_model))
|
|
662
782
|
states = tuple((n, check_state(state, self.fluid)) for n, state in cycle.states)
|
|
663
783
|
cycle = replace(cycle, states=states) # with v filled in for a cycle computed before 0.7
|
|
664
784
|
return CycleSpec.from_cycle(cycle, name=name, loops=loops, paths=paths, numbers=numbers,
|
|
@@ -681,12 +801,20 @@ class Chart:
|
|
|
681
801
|
where = "{0} '{1}'".format(e.where, cycle.name) if e.where else "Cycle '{0}'".format(cycle.name)
|
|
682
802
|
raise self._in_units(e).with_where(where) from None
|
|
683
803
|
|
|
684
|
-
def _other_fluid(self,
|
|
685
|
-
"""Whether
|
|
686
|
-
|
|
687
|
-
|
|
804
|
+
def _other_fluid(self, cycle: Cycle) -> bool:
|
|
805
|
+
"""Whether ``cycle`` was computed for another fluid than this chart's.
|
|
806
|
+
|
|
807
|
+
The cycle's fluid is rebuilt from its model (:attr:`Cycle.fluid_model`,
|
|
808
|
+
which the cycle models fill in), or from its name for a cycle without
|
|
809
|
+
one, and compared with :meth:`coolplot.thermo.Fluid.same_fluid`: the
|
|
810
|
+
same mixture given by mass, by mole or as a predefined blend, with
|
|
811
|
+
its components in the same order, counts as one fluid.
|
|
812
|
+
"""
|
|
813
|
+
own = self.fluid
|
|
814
|
+
if not isinstance(own, Fluid): # humid air: a cycle of a fluid does not belong on it
|
|
688
815
|
return True
|
|
689
|
-
|
|
816
|
+
theirs = Fluid.from_model(cycle.fluid_model, cycle.fluid) if cycle.fluid_model else Fluid(cycle.fluid)
|
|
817
|
+
return not theirs.same_fluid(own)
|
|
690
818
|
|
|
691
819
|
def move_cycle_state(self, name: str, number: int, x: float, y: float,
|
|
692
820
|
units: Optional[UnitsLike] = None) -> None:
|
|
@@ -735,9 +863,14 @@ class Chart:
|
|
|
735
863
|
units: Optional[UnitsLike] = None) -> Union[Dict[int, StatePoint], Dict[int, Dict[str, float]]]:
|
|
736
864
|
"""The states of a cycle by state number in ascending order.
|
|
737
865
|
|
|
738
|
-
|
|
739
|
-
unit system
|
|
740
|
-
is in deg C).
|
|
866
|
+
Without ``units`` the states are StatePoints in SI units. With
|
|
867
|
+
``units`` they are plain dicts of values in that unit system
|
|
868
|
+
(``cycle_states("hp", units="engineering")[2]["T"]`` is in deg C).
|
|
869
|
+
A StatePoint always holds SI values, so converted values come as
|
|
870
|
+
dicts and cannot be mistaken for SI states. Both are read by key,
|
|
871
|
+
``states[2]["T"]``; only a StatePoint also allows ``states[2].T``.
|
|
872
|
+
To keep the StatePoints and still read converted values, convert
|
|
873
|
+
one state with ``states[2].in_units("engineering")``.
|
|
741
874
|
"""
|
|
742
875
|
cycle = next((c for c in self.spec.cycles if c.name == name), None)
|
|
743
876
|
if cycle is None:
|
|
@@ -758,6 +891,10 @@ class Chart:
|
|
|
758
891
|
engineering units, or a StatePoint (returned as it is, after a
|
|
759
892
|
check that it belongs to this chart). A "via" needs a state before
|
|
760
893
|
it and is not accepted here.
|
|
894
|
+
|
|
895
|
+
``units`` applies to ``entry`` only; the StatePoint returned is
|
|
896
|
+
always in SI units. ``state.in_units("engineering")`` gives its
|
|
897
|
+
values in another unit system.
|
|
761
898
|
"""
|
|
762
899
|
given = state_input(entry, self._units(units), self.fluid)
|
|
763
900
|
if given.via is not None:
|
|
@@ -773,7 +910,11 @@ class Chart:
|
|
|
773
910
|
# ------------------------------------------------------------------
|
|
774
911
|
def state_at(self, x: float, y: float, units: Optional[UnitsLike] = None) -> StatePoint:
|
|
775
912
|
"""The full state (SI units) at a point given in the chart's units or
|
|
776
|
-
in ``units``, e.g. under the mouse.
|
|
913
|
+
in ``units``, e.g. under the mouse.
|
|
914
|
+
|
|
915
|
+
``units`` applies to ``x`` and ``y`` only; the StatePoint returned
|
|
916
|
+
is always in SI units (``state.in_units(...)`` converts it).
|
|
917
|
+
"""
|
|
777
918
|
diagram, unit_system = self.spec.diagram, self._units(units)
|
|
778
919
|
x_SI = float(unit_system[diagram.x].to_SI(x))
|
|
779
920
|
y_SI = float(unit_system[diagram.y].to_SI(y))
|
|
@@ -934,8 +1075,8 @@ class Chart:
|
|
|
934
1075
|
but no line is calculated. An application can use it to tell a
|
|
935
1076
|
request that only draws from one that calculates.
|
|
936
1077
|
|
|
937
|
-
It counts the final lines of the isoline families
|
|
938
|
-
left out, and with a background engine a line counts until its
|
|
1078
|
+
It counts the final lines of the isoline families and the single
|
|
1079
|
+
lines of :meth:`add_line`: cycles are left out, and with a background engine a line counts until its
|
|
939
1080
|
final version is in the cache, also while a job for it is running.
|
|
940
1081
|
"""
|
|
941
1082
|
spec = self.spec
|
|
@@ -19,14 +19,14 @@ def compose(spec, domain, curves, plot_size_pt=None, previous_labels=None, cycle
|
|
|
19
19
|
|
|
20
20
|
Composed by coolplot-core when it is installed and the native mode is
|
|
21
21
|
"on" (see :func:`coolplot.corelib.enabled`), by the Python composer
|
|
22
|
-
otherwise; both give the same scene. coolplot-core
|
|
23
|
-
|
|
24
|
-
the Python composer.
|
|
22
|
+
otherwise; both give the same scene. coolplot-core composes a badge of
|
|
23
|
+
text lines (references, versions, lines of your own) but no pictures,
|
|
24
|
+
so a chart with a logo or a watermark always takes the Python composer.
|
|
25
25
|
"""
|
|
26
26
|
branding = spec.settings.branding
|
|
27
|
-
if corelib.enabled() and not (branding.
|
|
27
|
+
if corelib.enabled() and not (branding.logo or branding.watermark):
|
|
28
28
|
try:
|
|
29
|
-
result = corelib.compose(spec, domain, curves, plot_size_pt, previous_labels, cycles)
|
|
29
|
+
result = corelib.compose(spec, domain, curves, plot_size_pt, previous_labels, cycles, sources)
|
|
30
30
|
except corelib.CoreRefusal as error:
|
|
31
31
|
# Something the port does not know (yet). The Python composer is
|
|
32
32
|
# the reference: it draws the chart, or raises the real error.
|