A Python 3 library to make psychrometric charts and overlay information on them.
scipy.interpolate.interp1d
scipy.spatial.ConvexHull
scipy
dependencyMove to recent versions of pydantic
, and also upgrade internal linters, moving to ruff-format
pydantic
v2ruff-format
From @tadashiorigami in #44, thanks!
constant_h_labels_loc
settings, to strech the constant h line to the left inside the saturated area, giving the chart an aspect closer to the popular ASHRAE chart.Define new kinds of enclosed areas in chart, between constant RH lines and constant volume or enthalpy values (zone_kind: "volume-rh"/"enthalpy-rh"
),
and enable full potencial for SVG customization by including CSS and/or <defs>
inside it.
chart.remove_zones()
method, like the existent .remove_legend()
and .remove_annotations()
, to clear matplotlib current Axes from each kind of annotated objectschart.plot()
is invokedchart.make_svg()
, to include extra-styling inside the produced SVG ๐chart.plot_over_saturated_zone()
to create a filled patch in the over-saturated zone of the psychrochart, to colorize that areaNow all chart-data parameters, including the overlayed zones, are included in the ChartConfig
,
and curve-generation only happens when chart is plotted (or saved to disk, or if chart.process_chart()
is invoked ๐).
Any change in the chart configuration will trigger a data-regen for all items before plotting.
When plotting over some matplotlib Axes
, all objects created now have meaningful (and deterministic) ids,
and are tracked and accessible under chart.artists
, for easier customization of single matplotlib objects,
also adding a recognizable hierarchy in generated SVGs, (enabling potential for CSS over SVG charts ๐)
Artist
obj in plot with custom readable IDs, for easier recognition and readable object hierarchy in SVGs, and maintain a registry of all objects in plot to access them by kind under chart.artists
property, allowing fine-grain control to customize all details in the psychrochartPsychroCurve
, with ZoneStyle
) on-demand, same as the other chart curves, generating new 'xy' points when config is changed. If ChartParams.with_zones
is enabled, but there are no zones in config when chart is created, the default winter/summer 'dbt-rh' zones are added.chart.process_chart()
method to trigger data regeneration if the chart config has changed or there is no chart data yetchart.saturation
a single PsychroCurve
, instead of a collection of curveschart.artists
usageBefore, chart customization was done by creating a new Psychrochart
object based on some modified chart configuration,
so creating custom plots, or even changing chart limits, was challenging ๐
Now, when chart.config
changes, any call to chart.save()
, chart.make_svg()
, or chart.plot()
will regenerate the chart data (limits, enabled curves, styling, etc.) before plotting, with only the visible curves inside limits,
(no more 0-size artifacts in SVGs, and most errors because some var is out of range should be gone now ๐ค)
chart.make_svg()
as the recommended method to generate SVGsChartFigure.dpi
to chart config, for easy customization of matplotlib Figure DPIPsychroCurve
/PsychroCurves
for a more functional approach, using methods in plot_logic.py
PsychroCurve.internal_value
field, to identify the trigger value for each curve (constant H/V/RH...), and evolve validation of data arrays๐งน Internal evolution to update the code style to the latest versions and de facto standards, with better typing, input validation, and serialization.
Hardly any new features (.make_svg()
), but some bug fixes.
BREAKING-CHANGE: Now the chart creation from a configuration key/file/dict is done with
PsychroChart.create(config)
, instead of oldPsychroChart(config)
๐๏ธ Add pydantic
models for chart + annotations styling and config, for better (de)serialization and parameter validation.
New models are:
CurveStyle
, LabelStyle
, TickStyle
, ZoneStyle
:= to parse & handle defaults for matplotlib styling parametersChartConfig
for the full chart configuration, including sub-models ChartFigure
, ChartLimits
, and ChartParams
, to mirror the old obfuscated config, with the same default values as beforeChartPoint
and ChartSeries
for styled single-point or array-data annotationsChartLine
for styled connectors between named points (now without outline 'marker' by default)ChartArea
for styled convex areas delimited by a list of named pointsChartAnnots
as container for all of the aboveChartZone
(and ChartZones
as a list), for styled fixed areas (like the default winter/summer comfort zones)โป๏ธ Evolve load methods to parse inputs into pydantic models with near-zero (expected ๐ค) breaks when reading old data
๐ฅ Rework PsychroChart
class to work with pydantic PsychroChartModel
. As the chart is now a pydantic model, there is a chart.json(...)
method, and loading from serialized data is available with PsychroChart.parse_file(
/ .validate(
/ etc ๐คฉ
โจ Add .make_svg()
method to produce a SVG file as text, and evolve .save(...)
with optional canvas_cls: Type[FigureCanvasBase]
, to select kind of matplotlib canvas where to print the chart
โจ Support file creation in subfolders with chart.save(dest)
๐ rsc: Deterministic SVG output in tests, and README images without date metadata
โ
tests: Adapt API changes in unit tests, remove usages of unittest.TestCase
, add new tests for pydantic models, annotations, and serialization methods.