I was trying to read mat file generated from Visual SFM through scipy loadmat function as follows:
import scipy.io as scio
data = scio.loadmat("IMG_5589.mat")
However, an error occurred as:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/wangxinqi/Python35/lib/python3.5/site-packages/scipy/io/matlab/mio.py", line 207, in loadmat
MR, file_opened = mat_reader_factory(file_name, appendmat, **kwargs)
File "/home/wangxinqi/Python35/lib/python3.5/site-packages/scipy/io/matlab/mio.py", line 63, in mat_reader_factory
mjv, mnv = get_matfile_version(byte_stream)
File "/home/wangxinqi/Python35/lib/python3.5/site-packages/scipy/io/matlab/miobase.py", line 241, in get_matfile_version
raise ValueError('Unknown mat file type, version %s, %s' % ret)
ValueError: Unknown mat file type, version 20, 0
The mat file is from Visual SFM. In the Visual SFM pipeline, pictures captured from different perspectives with a camera will be gathered for 3D reconstruction. Each image will produce a mat file and a sift file in the Visual SFM processing. I have been stuck in loading data in the mat file.
Can someone help me?
Related
I'm converting my Main.py python code to .exe application and I need to load ids.txt there are some values line by line, but after converting is done the Auto-py-to-exe-master free Github app says this error message:
Traceback (most recent call last):
File "main.py", line 37, in <module>
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\janka\\AppData\\Local\\Temp\\_MEI200202\\base_library.zip\\ids.txt'
By the way my file location of ids.txt is called in other directory and from application path as follows:
with open(os.path.join(sys.path[0], "ids.txt"), "r") as f:
devIds = f.read().splitlines()
With my project settled, I have exported it to GeoPDF and would also like to create an HTML version.
Added qgis2web in the Plugins Manager, re-started QGIS.
When I choose Web/qgis2web/create a web map, the program gives me a spinning mouse for 2-3 minutes, then displays some Python errors, which are beyond my pay-grade.
QGIS 3.15
GDAL 3
Python 3.7
OSX High Sierra (10.13.6)
Mac mini mid 2011
2.3 ghz i5
16 GB RAM
The errors I receive look like this:
An alternative, ballpark-only transform was used when transforming coordinates between EPSG:26919 - NAD83 / UTM zone 19N and EPSG:3857 - WGS 84 / Pseudo-Mercator. The results may not match those obtained by using the preferred operation:
Possibly an incorrect choice of operation was made for transformations between these reference systems. Check the Project Properties and ensure that the selected transform operations are applicable over the whole extent of the current project.
2020-10-25T00:43:03 WARNING Python error : An error has occurred while executing Python code: See message log (Python Error) for more details.
2020-10-25T00:43:03 WARNING Used a ballpark transform from EPSG:26919 to EPSG:3857
Python Error
2020-10-25T00:43:03 WARNING Traceback (most recent call last):
File "/Users/house/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/qgis2web/utils.py", line 442, in exportRaster
"OUTPUT": out_raster})
File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/plugins/processing/tools/general.py", line 108, in run
return Processing.runAlgorithm(algOrName, parameters, onFinish, feedback, context)
File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/plugins/processing/core/Processing.py", line 153, in runAlgorithm
raise QgsProcessingException(msg)
_core.QgsProcessingException: Unable to execute algorithm
Could not load source layer for INPUT: /var/folders/kn/4rm9tz_s6y39mr0rvfjjq3k80000gp/T/small_point_nw121603600920_piped_3857.tif not found
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/house/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/qgis2web/qgis2web.py", line 59, in run
self.dlg = MainDialog(self.iface)
File "/Users/house/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/qgis2web/maindialog.py", line 159, in __init__
self.autoUpdatePreview()
File "/Users/house/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/qgis2web/maindialog.py", line 334, in autoUpdatePreview
self.previewMap()
File "/Users/house/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/qgis2web/maindialog.py", line 337, in previewMap
preview_file = self.createPreview()
File "/Users/house/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/qgis2web/maindialog.py", line 300, in createPreview
dest_folder=utils.tempFolder()).index_file
File "/Users/house/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/qgis2web/olwriter.py", line 91, in write
folder=dest_folder)
File "/Users/house/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/qgis2web/olwriter.py", line 131, in writeOL
popup, json, restrictToExtent, extent, feedback, matchCRS)
File "/Users/house/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/qgis2web/utils.py", line 237, in exportLayers
exportRaster(layer, count, layersFolder, feedback, iface, matchCRS)
File "/Users/house/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/qgis2web/utils.py", line 444, in exportRaster
shutil.copyfile(piped_3857, out_raster)
File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/shutil.py", line 120, in copyfile
with open(src, 'rb') as fsrc:
FileNotFoundError: [Errno 2] No such file or directory: '/var/folders/kn/4rm9tz_s6y39mr0rvfjjq3k80000gp/T/small_point_nw121603600920_piped_3857.tif'
I had a similar error on QGIS 3.20.0 "Odense" (I posted the whole error message at the end of this blog post). My solution was to export the map on qgis2web plugin through QGIS 3.16 "Hannover" (LTS), this way, the algorithm ran without issues.
Keep getting this error message when I enter this code :
data = pd.read_csv('1.01. Simple linear regression.csv')
Traceback (most recent call last):
File "<pyshell#7>", line 1, in <module>
data = pd.read_csv('1.01. Simple linear regression.csv')
File "/usr/lib/python3/dist-packages/pandas/io/parsers.py", line 678, in parser_f
return _read(filepath_or_buffer, kwds)
File "/usr/lib/python3/dist-packages/pandas/io/parsers.py", line 440, in _read
parser = TextFileReader(filepath_or_buffer, **kwds)
File "/usr/lib/python3/dist-packages/pandas/io/parsers.py", line 787, in __init__
self._make_engine(self.engine)
File "/usr/lib/python3/dist-packages/pandas/io/parsers.py", line 1014, in _make_engine
self._engine = CParserWrapper(self.f, **self.options)
File "/usr/lib/python3/dist-packages/pandas/io/parsers.py", line 1708, in __init__
self._reader = parsers.TextReader(src, **kwds)
File "pandas/_libs/parsers.pyx", line 384, in pandas._libs.parsers.TextReader.__cinit__
File "pandas/_libs/parsers.pyx", line 695, in pandas._libs.parsers.TextReader._setup_parser_source
And the message :
FileNotFoundError: File b'1.01. Simple linear regression.csv' does not exist
(Best end a question with the question.) The current working directory for the program does not have a file by that name. Possible solutions:
Give a complete path to the file to read_csv.
Change the working directory in the program to the one that contain that file using os.chdir. See chdir doc.
Start python in that directory, with or without IDLE, from a command line.
Below is the line of the code that pykalman example is using to load the matlab file robot.mat. However, it is throwing an error with message ValueError: Unknown mat file type, version 100, 110.
I am new to reading matlab files in Python. Can anyone help me understand exactly what version it is expecting and how to get around the issue?
data = io.loadmat(join(module_path, 'data', 'robot.mat'))
Traceback (most recent call last):
File "C:\ProgramData\Anaconda2\lib\site-
packages\IPython\core\interactiveshell.py", line 2881, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-4-0439d709929f>", line 1, in <module>
data = load_robot()
File "C:\ProgramData\Anaconda2\lib\site-packages\pykalman\datasets\base.py",
line 45, in load_robot
data = io.loadmat(join(module_path, 'data', 'robot.mat'))
File "C:\ProgramData\Anaconda2\lib\site-packages\scipy\io\matlab\mio.py",
line 135, in loadmat
MR = mat_reader_factory(file_name, appendmat, **kwargs)
File "C:\ProgramData\Anaconda2\lib\site-packages\scipy\io\matlab\mio.py",
line 59, in mat_reader_factory
mjv, mnv = get_matfile_version(byte_stream)
File "C:\ProgramData\Anaconda2\lib\site-
packages\scipy\io\matlab\miobase.py",
line 241, in get_matfile_version
raise ValueError('Unknown mat file type, version %s, %s' % ret)
ValueError: Unknown mat file type, version 100, 110
I'm guessing here (and adding one more idea to hpaulj's good overview):
First i checked the file manually and opening in an editor reads as:
MATLAB 5.0 MAT-file, Platform: MACI64, Created on: Tue Jun 26 00:59:04 2012
...
Therefore there should be no problem in regards to scipy (if the mat-file is actually following this "header").
Now it seems there are some open issues with that project with the most relevant beeing:
Unable to load robot.mat #59
(Don't be surprised too much with the different eror-values as i would expect possibly indeterministic stuff like that when bad IO is beeing done)
and: pykalman/datasets/ not copied when pykalman is installed with pip #66
So it seems this dataset does not come with pip-install automatically, which looks like your problem and should be easily handled (manually obtaining the data!). It is also compatible with hpaulj's wondering about that strange error (one could argue if there is no better error-handling possible).
I followed the Matlab Interface User’s Guide on website http://www.cantera.org/docs/sphinx/html/matlab/code-docs/utilities.html to convert a CHEMKIN input file to Cantera format,the steps are
adddir('the directory of chem.inp,therm.dat and tran.dat')
f = ck2cti('chem.inp', 'therm.dat', 'tran.dat')
but an error occurred.
************************************************
Cantera Error!
************************************************
Procedure: ck2cti
Error: Error converting input file "chem.inp" to CTI.
Python command was: 'C:\Python34\python.exe'
The exit code was: 7
-------------- start of converter log --------------
Traceback (most recent call last):
File "<stdin>", line 9, in <module>
File "C:\Python34\lib\site-packages\cantera\ck2cti.py", line 1899, in convertMech
raise IOError('Missing input file: {0!r}'.format(inputFile))
OSError: Missing input file: 'chem.inp'
--------------- end of converter log ---------------
error ck2cti (line 47)
iok = ctmethods(0, 1, infile, thermo, transport, idtag, 0, 0);
Is there a solution for the problem? any reply will be appreciated!!
Adddir is not a built-in matlab function, you should use addpath instead.
So it become:
addpath('the directory of chem.inp,therm.dat and tran.dat')
f = ck2cti('chem.inp', 'therm.dat', 'tran.dat')
Check also that your file 'chem.inp' exist and is placed in the right folder.