pyvlasiator 0.1.2__tar.gz → 0.1.3__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.
Potentially problematic release.
This version of pyvlasiator might be problematic. Click here for more details.
- {pyvlasiator-0.1.2 → pyvlasiator-0.1.3}/PKG-INFO +1 -1
- {pyvlasiator-0.1.2 → pyvlasiator-0.1.3}/pyproject.toml +1 -1
- {pyvlasiator-0.1.2 → pyvlasiator-0.1.3}/src/pyvlasiator/plot/__init__.py +1 -0
- {pyvlasiator-0.1.2 → pyvlasiator-0.1.3}/src/pyvlasiator/plot/plot.py +81 -13
- {pyvlasiator-0.1.2 → pyvlasiator-0.1.3}/LICENSE.md +0 -0
- {pyvlasiator-0.1.2 → pyvlasiator-0.1.3}/README.md +0 -0
- {pyvlasiator-0.1.2 → pyvlasiator-0.1.3}/src/pyvlasiator/__init__.py +0 -0
- {pyvlasiator-0.1.2 → pyvlasiator-0.1.3}/src/pyvlasiator/pyvlasiator.py +0 -0
- {pyvlasiator-0.1.2 → pyvlasiator-0.1.3}/src/pyvlasiator/vlsv/__init__.py +0 -0
- {pyvlasiator-0.1.2 → pyvlasiator-0.1.3}/src/pyvlasiator/vlsv/reader.py +0 -0
- {pyvlasiator-0.1.2 → pyvlasiator-0.1.3}/src/pyvlasiator/vlsv/variables.py +0 -0
|
@@ -96,24 +96,91 @@ def plot(
|
|
|
96
96
|
>>> axes = vlsv_file.plot("helium/vg_v", ax=my_axes) # Plot velocity on an existing axes
|
|
97
97
|
"""
|
|
98
98
|
|
|
99
|
-
|
|
99
|
+
fig, ax = set_figure(ax, figsize, **kwargs)
|
|
100
100
|
|
|
101
|
-
|
|
102
|
-
|
|
101
|
+
return _plot1d(
|
|
102
|
+
self,
|
|
103
|
+
ax.plot,
|
|
104
|
+
var=var,
|
|
105
|
+
**kwargs,
|
|
103
106
|
)
|
|
104
|
-
if ax is None:
|
|
105
|
-
ax = fig.gca()
|
|
106
107
|
|
|
107
|
-
if not self.has_variable(var):
|
|
108
|
-
raise ValueError(f"Variable {var} not found in the file")
|
|
109
108
|
|
|
110
|
-
|
|
109
|
+
def scatter(
|
|
110
|
+
self: Vlsv,
|
|
111
|
+
var: str = "",
|
|
112
|
+
ax=None,
|
|
113
|
+
figsize: tuple[float, float] | None = None,
|
|
114
|
+
**kwargs,
|
|
115
|
+
) -> matplotlib.collections.PathCollection:
|
|
116
|
+
"""
|
|
117
|
+
Plots 1D VLSV data as scattered points.
|
|
118
|
+
|
|
119
|
+
Parameters
|
|
120
|
+
----------
|
|
121
|
+
var : str
|
|
122
|
+
Name of the variable to plot from the VLSV file.
|
|
123
|
+
ax : matplotlib.axes._axes.Axes, optional
|
|
124
|
+
Axes object to plot on. If not provided, a new figure and axes will be created.
|
|
125
|
+
figsize : tuple[float, float], optional
|
|
126
|
+
Size of the figure in inches (width, height). Only used if a new
|
|
127
|
+
figure is created.
|
|
128
|
+
**kwargs
|
|
129
|
+
Additional keyword arguments passed to Matplotlib's `plot` function.
|
|
130
|
+
|
|
131
|
+
Returns
|
|
132
|
+
-------
|
|
133
|
+
matplotlib.collections.PathCollection
|
|
134
|
+
|
|
135
|
+
Raises
|
|
136
|
+
------
|
|
137
|
+
ValueError
|
|
138
|
+
If the specified variable is not found in the VLSV file.
|
|
139
|
+
|
|
140
|
+
Examples
|
|
141
|
+
--------
|
|
142
|
+
>>> vlsv_file = Vlsv("my_vlsv_file.vlsv")
|
|
143
|
+
>>> axes = vlsv_file.scatter("proton/vg_rho") # Plot density on a new figure
|
|
144
|
+
"""
|
|
145
|
+
|
|
146
|
+
fig, ax = set_figure(ax, figsize, **kwargs)
|
|
111
147
|
|
|
112
|
-
|
|
113
|
-
|
|
148
|
+
return _plot1d(
|
|
149
|
+
self,
|
|
150
|
+
ax.scatter,
|
|
151
|
+
var=var,
|
|
152
|
+
**kwargs,
|
|
153
|
+
)
|
|
114
154
|
|
|
115
|
-
return axes
|
|
116
155
|
|
|
156
|
+
def _plot1d(
|
|
157
|
+
meta: Vlsv,
|
|
158
|
+
plot_func: Callable,
|
|
159
|
+
var: str = "",
|
|
160
|
+
**kwargs,
|
|
161
|
+
):
|
|
162
|
+
"""
|
|
163
|
+
Plot 1d data with `plot_func`.
|
|
164
|
+
|
|
165
|
+
Parameters
|
|
166
|
+
----------
|
|
167
|
+
var : str
|
|
168
|
+
Variable name from the VLSV file.
|
|
169
|
+
|
|
170
|
+
Returns
|
|
171
|
+
-------
|
|
172
|
+
|
|
173
|
+
"""
|
|
174
|
+
|
|
175
|
+
if not meta.has_variable(var):
|
|
176
|
+
raise ValueError(f"Variable {var} not found in the file")
|
|
177
|
+
|
|
178
|
+
x = np.linspace(meta.coordmin[0], meta.coordmax[0], meta.ncells[0])
|
|
179
|
+
y = meta.read_variable(var)
|
|
180
|
+
|
|
181
|
+
c = plot_func(x, y, **kwargs)
|
|
182
|
+
|
|
183
|
+
return c
|
|
117
184
|
|
|
118
185
|
def pcolormesh(
|
|
119
186
|
self: Vlsv,
|
|
@@ -839,13 +906,13 @@ def configure_plot(
|
|
|
839
906
|
cb.ax.set_ylabel(colorbar_title)
|
|
840
907
|
cb.ax.tick_params(direction="in")
|
|
841
908
|
|
|
842
|
-
# Set
|
|
909
|
+
# Set title and labels
|
|
843
910
|
ax.set_title(title, fontweight="bold")
|
|
844
911
|
ax.set_xlabel(x_label)
|
|
845
912
|
ax.set_ylabel(y_label)
|
|
846
913
|
ax.set_aspect("equal")
|
|
847
914
|
|
|
848
|
-
# Style
|
|
915
|
+
# Style borders and ticks
|
|
849
916
|
for spine in ax.spines.values():
|
|
850
917
|
spine.set_linewidth(2.0)
|
|
851
918
|
ax.tick_params(axis="both", which="major", width=2.0, length=3)
|
|
@@ -1110,6 +1177,7 @@ def prep_vdf(
|
|
|
1110
1177
|
|
|
1111
1178
|
# Append plotting functions
|
|
1112
1179
|
Vlsv.plot = plot
|
|
1180
|
+
Vlsv.scatter = scatter
|
|
1113
1181
|
Vlsv.pcolormesh = pcolormesh
|
|
1114
1182
|
Vlsv.contourf = contourf
|
|
1115
1183
|
Vlsv.contour = contour
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|