pyvlasiator 0.1.4__tar.gz → 0.1.5__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.

@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.3
2
2
  Name: pyvlasiator
3
- Version: 0.1.4
3
+ Version: 0.1.5
4
4
  Summary: Python utilities for processing Vlasiator data
5
5
  Author: Hongyang Zhou
6
6
  Author-email: hyzhou@umich.edu
@@ -34,7 +34,7 @@ Description-Content-Type: text/markdown
34
34
  </a>
35
35
  </p>
36
36
 
37
- Lightweight Python package for processing Vlasiator data.
37
+ Lightweight Python package for processing [Vlasiator](https://github.com/fmihpc/vlasiator) data, alternative to [Analysator](https://github.com/fmihpc/analysator).
38
38
 
39
39
  ## Installation
40
40
 
@@ -18,7 +18,7 @@
18
18
  </a>
19
19
  </p>
20
20
 
21
- Lightweight Python package for processing Vlasiator data.
21
+ Lightweight Python package for processing [Vlasiator](https://github.com/fmihpc/vlasiator) data, alternative to [Analysator](https://github.com/fmihpc/analysator).
22
22
 
23
23
  ## Installation
24
24
 
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "pyvlasiator"
3
- version = "0.1.4"
3
+ version = "0.1.5"
4
4
  description = "Python utilities for processing Vlasiator data"
5
5
  authors = ["Hongyang Zhou <hyzhou@umich.edu>"]
6
6
  readme = "README.md"
@@ -12,4 +12,6 @@ from pyvlasiator.plot.plot import (
12
12
  contourf,
13
13
  streamplot,
14
14
  vdfslice,
15
+ AxisUnit,
16
+ ColorScale,
15
17
  )
@@ -9,7 +9,7 @@ from collections import namedtuple
9
9
  from enum import Enum
10
10
  from pyvlasiator.vlsv import Vlsv
11
11
  from pyvlasiator.vlsv.reader import _getdim2d
12
- from pyvlasiator.vlsv.variables import RE
12
+ from pyvlasiator.vlsv.variables import RE, RMERCURY
13
13
 
14
14
 
15
15
  class ColorScale(Enum):
@@ -36,8 +36,10 @@ class AxisUnit(Enum):
36
36
  - SI (2): Units from the International System of Units (SI), such as meters, seconds, kilograms, etc.
37
37
  """
38
38
 
39
- EARTH = 1
40
- SI = 2
39
+ SI = 1
40
+ KSI = 2
41
+ EARTH = 3
42
+ MERCURY = 4
41
43
 
42
44
 
43
45
  # Plotting arguments
@@ -611,8 +613,12 @@ def set_args(
611
613
 
612
614
  if axisunit == AxisUnit.EARTH:
613
615
  unitstr = r"$R_E$"
614
- else:
615
- unitstr = r"$m$"
616
+ elif axisunit == AxisUnit.SI:
617
+ unitstr = "m"
618
+ elif axisunit == AxisUnit.MERCURY:
619
+ unitstr = r"$R_M$"
620
+ elif axisunit == AxisUnit.KSI:
621
+ unitstr = "km"
616
622
  strx = axislabels[0] + " [" + unitstr + "]"
617
623
  stry = axislabels[1] + " [" + unitstr + "]"
618
624
 
@@ -773,7 +779,15 @@ def get_axis(axisunit: AxisUnit, plotrange: tuple, sizes: tuple) -> tuple:
773
779
  A tuple containing the x and y axis coordinates.
774
780
  """
775
781
 
776
- scale_factor = 1.0 / RE if axisunit == AxisUnit.EARTH else 1.0
782
+ if axisunit == AxisUnit.EARTH:
783
+ scale_factor = 1.0 / RE
784
+ elif axisunit == AxisUnit.MERCURY:
785
+ scale_factor = 1.0 / RMERCURY
786
+ elif axisunit == AxisUnit.KSI:
787
+ scale_factor = 1.0 / 1e3
788
+ else: # SI
789
+ scale_factor = 1.0
790
+
777
791
  start = tuple(s * scale_factor for s in plotrange[:2])
778
792
  stop = tuple(s * scale_factor for s in plotrange[2:])
779
793
 
@@ -796,7 +810,6 @@ def set_colorbar(
796
810
  v2: float = np.nan,
797
811
  data: np.ndarray = np.array([1.0]),
798
812
  linthresh: float = 1.0,
799
- logstep: float = 1.0,
800
813
  linscale: float = 0.03,
801
814
  ):
802
815
  """
@@ -818,8 +831,6 @@ def set_colorbar(
818
831
  not provided. Defaults to np.array([1.0]).
819
832
  linthresh: float, optional
820
833
  The threshold value for symmetric log color scales. Defaults to 1.0.
821
- logstep: float, optional
822
- The step size for tick values in log color scales. Defaults to 1.0.
823
834
  linscale: float, optional
824
835
  A scaling factor for linear regions in symmetric log color scales.
825
836
  Defaults to 0.03.
@@ -835,10 +846,6 @@ def set_colorbar(
835
846
  ------
836
847
  ValueError
837
848
  If an invalid colorscale type is provided.
838
-
839
- Notes
840
- -----
841
- - The 'SymLog' colorscale is currently not fully implemented.
842
849
  """
843
850
  import matplotlib
844
851
 
@@ -851,13 +858,10 @@ def set_colorbar(
851
858
  norm = matplotlib.colors.LogNorm(vmin, vmax)
852
859
  ticks = matplotlib.ticker.LogLocator(base=10, subs=range(0, 9))
853
860
  else: # symmetric log
854
- logthresh = int(math.floor(math.log10(linthresh)))
855
- minlog = int(math.ceil(math.log10(-vmin)))
856
- maxlog = int(math.ceil(math.log10(vmax)))
857
- # TODO: fix this!
858
- # norm = matplotlib.colors.SymLogNorm(linthresh, linscale, vmin, vmax, base=10)
859
- # ticks = [ [-(10.0**x) for x in minlog:-logstep:logthresh]..., 0.0,
860
- # [10.0**x for x in logthresh:logstep:maxlog]..., ]
861
+ norm = matplotlib.colors.SymLogNorm(
862
+ linthresh=linthresh, linscale=linscale, vmin=vmin, vmax=vmax, base=10
863
+ )
864
+ ticks = matplotlib.ticker.SymmetricalLogLocator(linthresh=linthresh, base=10)
861
865
 
862
866
  return norm, ticks
863
867
 
@@ -1021,6 +1025,10 @@ def prep_vdf(
1021
1025
 
1022
1026
  if unit == AxisUnit.EARTH:
1023
1027
  location = [loc * RE for loc in location]
1028
+ elif unit == AxisUnit.MERCURY:
1029
+ location = [loc * RMERCURY for loc in location]
1030
+ elif unit == AxisUnit.KSI:
1031
+ location = [loc * 1e3 for loc in location]
1024
1032
 
1025
1033
  # Set unit conversion factor
1026
1034
  unitvfactor = 1e3 if unitv == "km/s" else 1.0
@@ -11,6 +11,7 @@ MU0 = 4 * pi * 1e-7 # Vacuum permeability, [H/m]
11
11
  EPSILON0 = 1 / (C**2 * MU0) # Vacuum permittivity, [F/m]
12
12
  KB = 1.38064852e-23 # Boltzmann constant, [m²kg/(s²K)]
13
13
  RE = 6.371e6 # Earth radius, [m]
14
+ RMERCURY = 4.8794e6 # Mercury radius, [m]
14
15
 
15
16
  speciesdict = {
16
17
  "avgs": "p",
File without changes