How to install netCDF4 and extract netCDF data file in Python? - python

I want to extract a netCDF data file using Python. I installed Numpy, netCDF4-Python and h5py for this purpose. But, it gives an error message
ImportError: numpy.core.multiarray failed to import
What's wrong with that? Or, is there any easier way to extract netCDF files in python?

Related

Error in installing 'qd' library! How do we read or manipulate the Key file for LS Dyana?

Goal: I have .Key file for preprocessing data file for LS Dyna simulation. From that .Key file, I want to extract certain node numbers lying under certain Part ID (PID).
In order to achieve above goal, I got to know that there is a one python library named 'qd' (https://qd-cae.github.io/qd-cae-python/build/html/qd_cae_dyna_KeyFile.html) which helps to manipulate the key files and extract certain lines according to the Keyword.
However, when I wrote from qd.cae.dyna import *, I got an error ModuleNotFoundError: from qd.cae.dyna import *. Therefore, I tried to install qd in python using pip pip install qd, but I got an error and at the end, this library could not be installed.
My question is:
(1) How can we install qd library in python through Anaconda?
(2) Is there any available python tools or library to read and extract some parameters from the Key files?

Importing 3D CAD files in python as dask array

I am trying to import a 3D file created by TexGen in python. I would like to have a dask array at the end for further analysis. My file is in ".igs" format. I can open it with FreeCAD and export it in a variety of formats. I just don't know which format to use and which library in python is more helpful.
I found this question (Import CAD object in Python and store as array) and tried installing FreeCAD package in python but I was unsuccessful. I get a conflict error (incompatible packages) which I can't solve.
I found this question (3D CAD to OpenGL) and installed PyOpenGL but I don't know how to use OpenGL to import STL file.
Any suggestions?
You can have a look at the opencascade python module
OpenCascade is the library FreeCAD is based on, it can also import/export .stp (and I guess .igs) files and transform it into a mesh.

is there another way to read stl file in python?

whenever I try to do (from stl import mesh) I got this error: "No name 'mesh' in module 'stl' pylint(no-name-in-module)"
I tried to do this :
pip install stl
pip install numpy-stl
and is there any possible way to convert stl files into G-code using python?

load .mat file from python

I am trying to run from Python a script in Matlab that run a Simulink mode, save a variable as Power.mat and read this variable in Python. I am using Python 2.7 on Windows.
I've tried to use the library hdf5storage to read the file:
import hdf5storage
x=hdf5storage.loadmat('Power.mat','r')
but I get the error attached.
Which could be the problem?
I have also tried with the library h5py but I get the same error.
The file .mat seems not to be corrupted since I open it without any problem in Matlab.
Thanks!
You can use scipy.io to exchange data between Python and Matlab. There are functions named savemat and loadmat for this purpose.
Something like this should work:
import scipy.io
mat = scipy.io.loadmat('Power.mat')
For reference, http://docs.scipy.org/doc/scipy/reference/generated/scipy.io.loadmat.html
Try this code :
import h5py
Data = h5py.File('File.mat')

Can I update a part of HDF5 file using h5py python library?

Can't find any command at http://docs.h5py.org/en/latest/high/file.html to do that.

Categories