Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
3fc4c8c
typos in obliqueshock.py corrected: the polynome input has VuHT inste…
alalahti Mar 25, 2025
38737e3
obliqueshock.py and obliqueshock_nif.py revised based on Markus' comm…
alalahti Mar 27, 2025
b00606b
Time evolution over a point w/ interpolation
alhom Sep 19, 2024
8018803
update documentations
alhom Apr 1, 2025
60dffbf
Legacy parameters guarding, expose point_time_evolution
alhom Apr 1, 2025
fac6f26
Merge pull request #319 from alhom/pointwise_time_evolution
alhom Apr 1, 2025
197a6a9
Allow ionosphere plots without a valid times value.
ursg Apr 2, 2025
f07a99c
Merge pull request #320 from ursg/ionosphereWithoutTime
alhom Apr 2, 2025
e565741
Add mlt check for vg and ig, also open-closed field line classificati…
Apr 4, 2025
7bca3c8
Update reduction.py
taoshi-117 Apr 4, 2025
30b7bf5
updated reducers
Apr 7, 2025
55b7dfd
resolve the comments
Apr 7, 2025
62f9062
Merge pull request #318 from mattia-l/branchMatti
alhom Apr 7, 2025
6ea360d
Enforce TMPDIR for pip in GithHub workflows for Turso UH#768 (#322)
alhom Apr 7, 2025
5792cf5
rename to ig_openclosed
alhom Apr 7, 2025
48a6db7
avoid loop in ig_open_closed
Apr 8, 2025
24823ba
Merge branch 'oc_val_mlt' of github.com:taoshi-117/analysator into oc…
Apr 8, 2025
234f82c
change oc values from 0/1 to 1/2
Apr 8, 2025
42b75f5
obliqueshock.py and obliqueshock_nif.py revised by adding docstring-s…
alalahti Apr 8, 2025
8a43932
Added obliqueshock scripts to Sphinx indexing
alhom Apr 8, 2025
ab88f33
obliqueshock.py and obliqueshock_nif.py revised by adding docstring-s…
alalahti Apr 9, 2025
e91f02e
Merge remote-tracking branch 'origin' into branchMatti
alalahti Apr 9, 2025
3386b67
Merge branch 'branchMatti' of github.com:mattia-l/analysator into bra…
alalahti Apr 9, 2025
d36da04
Merge pull request #324 from mattia-l/branchMatti
alhom Apr 9, 2025
b13be1f
Update CITATION.cff version number to match latest
alhom Apr 17, 2025
575e04d
Fix pathological cases of bin edges coinciding with v-cell coordinates
alhom Jun 10, 2025
56d5a00
An actual fix the actual problem: cpeak re-centers velocity coordinat…
alhom Jun 10, 2025
a2fd617
Merge pull request #327 from alhom/plot_vdf_binedges
alhom Jun 10, 2025
6fe67af
Merge pull request #321 from taoshi-117/oc_val_mlt
alhom Jun 16, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 2 additions & 26 deletions .github/workflows/test_python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ name: Python import test

on:
push:
branches: [ master ]
branches: [ master, dev ]
pull_request:
branches: [ master ]
branches: [ master, dev ]
schedule:
- cron: '0 8 * * MON'
workflow_dispatch:
Expand Down Expand Up @@ -60,30 +60,6 @@ jobs:
- name: Trial imports
run: python -c 'import analysator as pt'

turso_system:

runs-on: carrington
strategy:
fail-fast: false
matrix:
extras: ["none", "vtk", "all", "bvtk"]

steps:
- uses: actions/checkout@v4
- name: Set up Python
run: |
python3 -m venv test_venv
- name: Install dependencies
run: |
source ./test_venv/bin/activate
python -m pip install --upgrade pip
python -m pip install --editable ../analysator[${{ matrix.extras }}]
- name: Trial imports
run: |
source ./test_venv/bin/activate
python -c 'import analysator as pt'


lint:

runs-on: ubuntu-latest
Expand Down
42 changes: 42 additions & 0 deletions .github/workflows/test_python_turso.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Turso import test

on:
push:
branches: [ master, dev ]
pull_request:
branches: [ master, dev ]
schedule:
- cron: '0 8 * * MON'
workflow_dispatch:

jobs:

turso_system:
if: github.repository_owner == 'fmihpc'
runs-on: carrington
strategy:
fail-fast: false
matrix:
extras: ["none", "vtk", "all", "bvtk"]
steps:
- uses: actions/checkout@v4
- name: Set up Python
run: |
export TMPDIR=$RUNNER_TEMP
python3 -m venv test_venv
- name: Install dependencies
run: |
export TMPDIR=$RUNNER_TEMP
source ./test_venv/bin/activate
python -m ensurepip
python -m pip install --upgrade pip
python -m pip install --editable ../analysator[${{ matrix.extras }}]
- name: Trial imports
run: |
export TMPDIR=$RUNNER_TEMP
source ./test_venv/bin/activate
python -c 'import analysator as pt'

2 changes: 1 addition & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ authors:
- family-names: "Reimi"
given-names: "Johanna"
title: "Analysator"
version: 0.9.5
version: 0.9.6
doi: 10.5281/zenodo.4462514
date-released: 2024-11-26
url: "https://github.com/fmihpc/analysator"
5 changes: 5 additions & 0 deletions Documentation/sphinx/obliqueshock.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
obliqueshock
------------

.. automodule:: obliqueshock
:members:
5 changes: 5 additions & 0 deletions Documentation/sphinx/obliqueshock_nif.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
obliqueshock_nif
----------------

.. automodule:: obliqueshock_nif
:members:
20 changes: 20 additions & 0 deletions Documentation/sphinx/scripts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,24 @@ magnetopause3d

------------

obliqueshock
------------
:doc:`obliqueshock`

.. automodule:: obliqueshock
:no-index:

------------

obliqueshock_nif
----------------
:doc:`obliqueshock_nif`

.. automodule:: obliqueshock_nif
:no-index:

----------------

shue
--------------
:doc:`shue`
Expand All @@ -65,6 +83,8 @@ tsyganenko
gics
magnetopause2d
magnetopause3d
obliqueshock
obliqueshock_nif
shue
tsyganenko

2 changes: 1 addition & 1 deletion analysator/pyCalculations/calculations.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
from fourier import fourier
from spectra import get_spectrum_energy, get_spectrum_alongaxis_vel
from variable import VariableInfo
from timeevolution import cell_time_evolution
from timeevolution import cell_time_evolution,point_time_evolution
from pitchangle import pitch_angles
#from backstream import extract_velocity_cells_sphere, extract_velocity_cells_non_sphere
from gyrophaseangle import gyrophase_angles_from_file
Expand Down
104 changes: 102 additions & 2 deletions analysator/pyCalculations/timeevolution.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,19 @@ def cell_time_evolution( vlsvReader_list, variables, cellids, units="" ):
vlsvReader_list = np.atleast_1d(vlsvReader_list)
variables = np.atleast_1d(variables)
cellids = np.atleast_1d(cellids)
parameters = ["t","tstep","fileIndex"]
parameter_units=["s","",""]
reader_0 = vlsvReader_list[0]

# Check against legacy files with tstep instead of timestep:
if reader_0.check_parameter("tstep"):
parameters = ["t","tstep","fileIndex"]
parameter_units=["s","",""]
elif reader_0.check_parameter("timestep"):
parameters = ["t","timestep","fileIndex"]
parameter_units=["s","",""]
else:
logging.warning("Could not obtain tstep or timestep from readers. Returning only t and fileIndex.")
parameters = ["t","fileIndex"]
parameter_units=["s",""]
#construct empty units, if none are given
if (units == "") or (len(units) != len(variables)):
units=[ "" for i in range(len(variables))]
Expand All @@ -86,6 +97,95 @@ def cell_time_evolution( vlsvReader_list, variables, cellids, units="" ):
# Save the data into the right slot in the data array:
for i in range(len(cellids)):
data[len(parameters)+i*len(variables)+j].append(vlsvReader.read_variable( variable, cellids[i] ))
#TODO Use vectorization over cellids!

# For optimization purposes we are now freeing vlsvReader's memory
# Note: Upon reading data vlsvReader created an internal hash map that takes a lot of memory
vlsvReader.optimize_clear_fileindex_for_cellid()
# Close the vlsv reader's file:
vlsvReader.optimize_close_file()
from output import output_1d
return output_1d( data,
parameters + [variables[(int)(i)%(int)(len(variables))] for i in range(len(data)-len(parameters))],
parameter_units + [units[(int)(i)%(int)(len(units))] for i in range(len(data)-len(parameters))] )


def point_time_evolution( vlsvReader_list, variables, coordinates, units="", method='nearest'):
''' Returns variable data from a time evolution of some certain cell ids

:param vlsvReader_list: List containing VlsvReaders with a file open
:type vlsvReader_list: :class:`vlsvfile.VlsvReader`
:param variables: Name of the variables
:param coordinates: List of coordinates [n,3]
:param units: List of units for the variables (OPTIONAL)
:param method: name of interpolation method ['nearest','linear']
:returns: an array containing the data for the time evolution for every coordinate

.. code-block:: python

import pytools as pt; import pylab as pl
# Example of usage:
time_data = pt.calculations.point_time_evolution( vlsvReader_list=[VlsvReader("bulk.000.vlsv"), VlsvReader("bulk.001.vlsv"), VlsvReader("bulk.002.vlsv")], variables=["rho", "Pressure", "B"], coordinates=[[1e8,0,0],[1.2e8,0,0]], units=["N", "Pascal", "T"] )

# Check output
logging.info time_data

# Now plot the results:
time = time_data[0]
rho = time_data[3]
pt.plot.plot_variables(time, rho)
pl.show()

# Do post processing:
rho_data = rho.data
non_existing_example_function(rho_data)


'''
vlsvReader_list = np.atleast_1d(vlsvReader_list)
variables = np.atleast_1d(variables)
coordinates = np.array(coordinates)
if coordinates.ndim == 1:
coordinates = coordinates[np.newaxis,:]
reader_0 = vlsvReader_list[0]

# Check against legacy files with tstep instead of timestep:
if reader_0.check_parameter("tstep"):
parameters = ["t","tstep","fileIndex"]
parameter_units=["s","",""]
elif reader_0.check_parameter("timestep"):
parameters = ["t","timestep","fileIndex"]
parameter_units=["s","",""]
else:
logging.warning("Could not obtain tstep or timestep from readers. Returning only t and fileIndex.")
parameters = ["t","fileIndex"]
parameter_units=["s",""]
#construct empty units, if none are given
if (units == "") or (len(units) != len(variables)):
units=[ "" for i in range(len(variables))]
#construct data
data = [[] for i in range(len(parameters)+coordinates.shape[0]*len(variables))]
for t in range(len(vlsvReader_list)):
# Get the vlsv reader
vlsvReader = vlsvReader_list[t]
# Open the vlsv reader's file:
vlsvReader.optimize_open_file()
#go through parameters
for j in range(len(parameters)):
# Read the parameter
# Save the data into the right slot in the data array:
data[j].append(vlsvReader.read_parameter( parameters[j]))

# Go through variables:
for j in range(len(variables)):
variable = variables[j]
# Read the variable for all cell ids
#variables_for_cellids = vlsvReader.read_variables_for_cellids( variable, cellids )
# Save the data into the right slot in the data array:
for i in range(coordinates.shape[0]):
data[len(parameters)+i*len(variables)+j].append(vlsvReader.read_interpolated_variable( variable, coordinates[i,:], method=method ))
#TODO Use vectorization over coordinates!

# For optimization purposes we are now freeing vlsvReader's memory
# Note: Upon reading data vlsvReader created an internal hash map that takes a lot of memory
vlsvReader.optimize_clear_fileindex_for_cellid()
Expand Down
7 changes: 6 additions & 1 deletion analysator/pyPlots/plot_ionosphere.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,12 @@ def plot_ionosphere(filename=None,
fontsize3=8*scale # Colour bar ticks and title

# Plot title with time
timeval=f.read_parameter("time")
try:
timeval=f.read_parameter("time")
except:
# The ionosphere solver miniApp writes outputfiles without a valid
# time value.
timeval=None

# Plot title with time
if title is None or title=="msec" or title=="musec":
Expand Down
7 changes: 6 additions & 1 deletion analysator/pyPlots/plot_vdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,8 @@ def vSpaceReducer(vlsvReader, cid, slicetype, normvect, VXBins, VYBins, pop="pro
Vpeak = V[peakindex,:]
V = V - Vpeak
logging.info(peakindex)
VXBins -= 0.5*inputcellsize
VYBins -= 0.5*inputcellsize
logging.info("Transforming to frame of peak f-value, travelling at speed "+str(Vpeak))
elif not center is None:
# assumes it's a vector, either provided or extracted from bulk velocity
Expand Down Expand Up @@ -689,7 +691,7 @@ def plot_vdf(filename=None,
vysize = int(vysize)
vzsize = int(vzsize)
[vxmin, vymin, vzmin, vxmax, vymax, vzmax] = vlsvReader.get_velocity_mesh_extent(pop=pop)
inputcellsize=(vxmax-vxmin)/vxsize


# Account for WID3 cells per block
widval=4 #default WID=4
Expand All @@ -699,6 +701,9 @@ def plot_vdf(filename=None,
vysize = widval*vysize
vzsize = widval*vzsize

inputcellsize=(vxmax-vxmin)/(vxsize)
# print(inputcellsize)

Re = 6.371e+6 # Earth radius in m
# unit of velocity
velUnit = 1e3
Expand Down
Loading
Loading