louis-richard / irfu-python Goto Github PK
View Code? Open in Web Editor NEWPython routines to work with space data, particularly with MMS data. Also some general plasma routines.
License: MIT License
Python routines to work with space data, particularly with MMS data. Also some general plasma routines.
License: MIT License
Hi Louis,
I created a new virtual environment to demonstrate this issue. I'm having it on my work copy of pyrfu (2.4.1) as well as the latest version which I installed today. The problem occurs when using get_data() on local files when it has not been downloaded in the same kernel run. It throws out an exception: AttributeError: 'NoneType' object has no attribute 'items'
.
from pyrfu import mms
data_path = "D://MMS"
mms.db_init(data_path)
tint = ["2017-07-11T22:33:00.000", "2017-07-11T22:34:00.000"]
mms.download_data("pdi_fpi_brst_l2", tint, 1, data_path=data_path)
result = mms.get_data("pdi_fpi_brst_l2", tint, 1, data_path=data_path)
result = mms.get_data("pdi_fpi_brst_l2", tint, 1, data_path=data_path)
Throws the AttributeError exception.
I have this issue on most of my data intervals, but some do work. Another member in my department has the same problem on her installation, even when not using previously-downloaded data.
The full error is:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[2], [line 1](vscode-notebook-cell:?execution_count=2&line=1)
----> [1](vscode-notebook-cell:?execution_count=2&line=1) result = mms.get_data("pdi_fpi_brst_l2", tint, 1, data_path=data_path)
File [d:\Anaconda\envs\helpingcara\lib\site-packages\pyrfu\mms\get_data.py:126], in get_data(var_str, tint, mms_id, verbose, data_path, from_sdc)
[123] file = os.path.normpath(file_name)
[125] if "-dist" in var["dtype"]:
--> [126] out = dist_append(out, get_dist(file, cdf_name, tint))
[128] else:
[129] out = ts_append(out, get_ts(file, cdf_name, tint))
File [d:\Anaconda\envs\helpingcara\lib\site-packages\pyrfu\mms\get_dist.py:88] in get_dist(file_path, cdf_name, tint)
[84]file = load(file_path)
[86]# with CDF(file_path) as file:
[87]# Get the relevant CDF file information (zVariables)
---> [88]z_vars = [z_var[0] for z_var in file.items()]
[90]# Get the global attributes
[91] glob_attrs = _pycdfpp_attributes_to_dict(file.attributes)
AttributeError: 'NoneType' object has no attribute 'items'
The following routines read data only with local directory resources:
Compatibility with MMS SDC should be enabled.
Dear Louis Richard,
I do not know how to set the path of MMS database of pyrfu.
for example, in irf-matlab-master, we have to type:
mms.db_init (' local_file_db ', path of database);
But I do not know how to do it in this python code
thanks a lot!
within the file pyrfu/mms/make_model_vdf.py
there is an error TypeError: 'module' object is not callable
on line 104.
I believe this is because on line 15 you are importing the module not the function within that module. When I changed line 15 to from .rotate_tensor import rotate_tensor
it fixed the problem.
Hi Louis,
I created a new environment to install the latest pyrfu version, and I encounter an error with metadata generation during installation of the package dependencies. I do not encounter the problem for pyrfu version 2.4.11.
I am using pip to install the pyrfu package on a fresh conda environment (version 22.9.0). It seems as though this might be an error with the pycdfpp package?
I am not an expert in these things so I thought I would bring this to your attention in case any of this is within your control.
Collecting pycdfpp==0.6.0 (from pyrfu)
Using cached pycdfpp-0.6.0.tar.gz (1.2 MB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Installing backend dependencies ... done
Preparing metadata (pyproject.toml) ... error
error: subprocess-exited-with-error
× Preparing metadata (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [22 lines of output]
+ meson setup /private/var/folders/w1/vm9pp8qn443d01jr2j6tw41r0000gp/T/pip-install-zl9wk08i/pycdfpp_dd5575d2677f45aea33b2dd730546a9a /private/var/folders/w1/vm9pp8qn443d01jr2j6tw41r0000gp/T/pip-install-zl9wk08i/pycdfpp_dd5575d2677f45aea33b2dd730546a9a/.mesonpy-639kkxhx -Dbuildtype=release -Db_ndebug=if-release -Db_vscrt=md -Doptimization=3 --native-file=/private/var/folders/w1/vm9pp8qn443d01jr2j6tw41r0000gp/T/pip-install-zl9wk08i/pycdfpp_dd5575d2677f45aea33b2dd730546a9a/.mesonpy-639kkxhx/meson-python-native-file.ini
WARNING: Recommend using either -Dbuildtype or -Doptimization + -Ddebug. Using both is redundant since they override each other. See: https://mesonbuild.com/Builtin-options.html#build-type-options
The Meson build system
Version: 1.4.0
Source dir: /private/var/folders/w1/vm9pp8qn443d01jr2j6tw41r0000gp/T/pip-install-zl9wk08i/pycdfpp_dd5575d2677f45aea33b2dd730546a9a
Build dir: /private/var/folders/w1/vm9pp8qn443d01jr2j6tw41r0000gp/T/pip-install-zl9wk08i/pycdfpp_dd5575d2677f45aea33b2dd730546a9a/.mesonpy-639kkxhx
Build type: native build
WARNING: You should add the boolean check kwarg to the run_command call.
It currently defaults to false,
but it will default to true in future releases of meson.
See also: https://github.com/mesonbuild/meson/issues/9300
Project name: pycdfpp
Project version: 0.6.0
../meson.build:1:0: ERROR: Unknown compiler(s): [['cc'], ['gcc'], ['clang'], ['nvc'], ['pgcc'], ['icc'], ['icx']]
The following exception(s) were encountered:
Running `nvc --version` gave "[Errno 2] No such file or directory: 'nvc'"
Running `pgcc --version` gave "[Errno 2] No such file or directory: 'pgcc'"
Running `icc --version` gave "[Errno 2] No such file or directory: 'icc'"
Running `icx --version` gave "[Errno 2] No such file or directory: 'icx'"
A full log can be found at /private/var/folders/w1/vm9pp8qn443d01jr2j6tw41r0000gp/T/pip-install-zl9wk08i/pycdfpp_dd5575d2677f45aea33b2dd730546a9a/.mesonpy-639kkxhx/meson-logs/meson-log.txt
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
note: This is an issue with the package mentioned above, not pip.
I hope this helps,
Harry
Update requirements with numba>=0.59.0 to support Python>=3.9,<=3.12 https://numba.readthedocs.io/en/stable/release/0.59.0-notes.html
The problem seems to come from the vdf_projection
function, which is taking the square root of shifted energy bins. When the bins are smaller than the spacecraft potential, they are shifted to negative numbers and the np.sqrt()
function is returning nan
. The pcolormesh
function can't accept nan
s as bin coordinates, which causes an error in plot_projection.py
.
To fix this, I suggest np.sqrt(..., dtype=np.csingle)
or np.emath.sqrt(...)
on line 348 of vdf_projection.py
.
Doing this gives 0 for the "negative" velocity bins, which I believe to be your intention based on the np.real()
function on line 349. However, it might not be the perfect solution as it stretches the innermost bin to the center of the polar plot.
If you need an example timestep, use 1475257837.6974614
a.k.a ['2016-09-30T17:50:37.697']
.
Running on pyrfu version 2.4.12 but with dependencies installed for 2.4.11 (see my other issue).
Hope this helps.
In pyrfu.mms.load_ancillary.py
FutureWarning: The 'delim_whitespace' keyword in pd.read_csv is deprecated and will be removed in a future version. Use sep='\s+'
instead
The required entries to the table would be:
"tperpi_fpi_brst_l2": {
"dtype": "dis-moms",
"cdf_name": "dis_tempperp_brst"
},
"tparai_fpi_brst_l2": {
"dtype": "dis-moms",
"cdf_name": "dis_temppara_brst"
},
Hi, when I use the mms.psd_moments function, (I'm using the example you gave) I always get the following error: Traceback (most recent call last).
File "C:\Users\eric\AppData\Roaming\JetBrains\PyCharmCE2023.1\scratches\demo6.py", line 585, in
moments_e = mms.psd_moments(vdf_e, scpot, **options)
File "C:\anaconda\envs\pyrfu\lib\site-packages\pyrfu\mms\psd_moments.py", line 251, in psd_moments
field_name = vdf.attrs["FIELDNAM"]
KeyError: 'FIELDNAM'
from pyrfu import mms
tint_brst = ["2015-09-01T12:15:28.000", "2015-09-01T12:24:00.000"]
mms.download_data('pdi_fpi_brst_l2',tint_brst,1,data_path="C:\MMS\volumes")
scpot = mms.get_data("V_edp_brst_l2", tint_brst, 1)
vdf_e = mms.get_data("pde_fpi_brst_l2", tint_brst, 1)
options = dict(energy_range=[1, 1000])
moments_e = mms.psd_moments(vdf_e, scpot, **options)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.