Unable to run pykalma example code that is reading MAT file with scipy - scipy

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).

Related

How to get Metadata in python ONVIF?

Currently, I'm looking for metadata access functions using the in Python-onvif.
I want to get the coordinates of "BoundingBox" inside the red box.
How to i access data?
https://www.onvif.org/ver20/analytics/wsdl/analytics.wsdl#op.GetSupportedMetadata
This function was used, but an AttributeError occurred.
from onvif import ONVIFCamera
cam = ONVIFCamera('192.168.100.133', 80, 'ID', 'P/W')
cam.create_analytics_service()
meta = cam.analytics.GetSupportedMetadata()
print(meta)
result:
Traceback (most recent call last):
File "C:\Users\User\anaconda3\envs\py310\lib\site-packages\zeep\proxy.py", line 97, in __getitem__
return self._operations[key]
KeyError: 'GetSupportedMetadata'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\User\AppData\Roaming\JetBrains\PyCharmCE2021.2\scratches\meta_data.py", line 24, in <module>
meta = cam.analytics.GetSupportedMetadata()
File "C:\Users\User\anaconda3\envs\py310\lib\site-packages\onvif\client.py", line 167, in __getattr__
return self.service_wrapper(getattr(self.ws_client, name))
File "C:\Users\User\anaconda3\envs\py310\lib\site-packages\zeep\proxy.py", line 88, in __getattr__
return self[key]
File "C:\Users\User\anaconda3\envs\py310\lib\site-packages\zeep\proxy.py", line 99, in __getitem__
raise AttributeError("Service has no operation %r" % key)
AttributeError: Service has no operation 'GetSupportedMetadata'
I need your help.
I'm not exactly using the same onvif package you are, and I'm not so sure myself how to achieve this, but this is what I've got so far:
Both the package python-onvif, that you are using, and the Valkka inspired implementation I'm using, rely on a folder WSDL which contains pretty old versions of Onvif operations. It seems we both were using version 2.2 while the current version is 20.12.
So what I did was to download the newer versions at their repository and replace the contents of the WSDL folder with the content of the new WSDL folder.
I also had to replace how the paths were built since now there is some folder hierarchy inplace to reach the WSDL files, but after that I was able to call GetSupportedMetadata successfully.

QGIS: Problems creating an HTML web map of my project

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.

Could not load mat file generated from Visual SFM with scipy loadmat

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?

Issue with whois and subprocess (Python 3.4; 64-bit Windows)

So I'm just trying to get the suggested query (domain = whois.query("google.com")) working. But whenever I run it, I get the following traceback:
File "file.py", line x, in weight_sources
domain = whois.query("google.com")
File "C:\Users\User Name\Anaconda3\lib\site-packages\whois\__init__.py", line 50, in query
pd = do_parse(do_query(d, force, cache_file, slow_down, ignore_returncode), tld)
File "C:\Users\User Name\Anaconda3\lib\site-packages\whois\_1_query.py", line 44, in do_query
_do_whois_query(dl, ignore_returncode),
File "C:\Users\User Name\Anaconda3\lib\site-packages\whois\_1_query.py", line 58, in _do_whois_query
p = subprocess.Popen(['whois', '.'.join(dl)], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
File "C:\Users\User Name\Anaconda3\lib\subprocess.py", line 856, in __init__
restore_signals, start_new_session)
File "C:\Users\User Name\Anaconda3\lib\subprocess.py", line 1111, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
I've seen some other questions/answers point to line 1111 in subprocess, but I think the issue might be in whois as I have used subprocess extensively without error on my device. Since the non-existent file seems to be related to the whois package, I don't think this question is related to this one, although the two could be related?
Essentially, is there any work around for this error or if I need to edit the whois package code, how would I go about that? I'm not exactly sure I even fully understand what "file" is missing...
The missing file is the whois executable, which is opened here:
subprocess.Popen(['whois', '.'.join(dl)]
The package description says whois is a wrapper for the Linux whois command. That means you must be running on Linux and have whois installed, but you are running Windows.
So I think you're out of luck with this package, maybe another one (such as python-whois) supports Windows.

How do I use environment variables in Supervisord's [supervisord] config section?

I use environment variables in Supervisord's program section, and they work just fine:
[program:some_prog]
command=%(ENV_env_var_name)s/...
I can't figure out though how to do the same in the [supervisord] section.
I tried using the same syntax with and without the ENV_ prefix, but getting the following error:
Traceback (most recent call last):
File "/usr/local/bin/supervisord", line 9, in <module>
load_entry_point('supervisor==3.0a12', 'console_scripts', 'supervisord')()
File "/usr/local/lib/python2.7/dist-packages/supervisor-3.0a12-py2.7.egg/supervisor/supervisord.py", line 356, in main
options.realize(args, doc=__doc__)
File "/usr/local/lib/python2.7/dist-packages/supervisor-3.0a12-py2.7.egg/supervisor/options.py", line 419, in realize
Options.realize(self, *arg, **kw)
File "/usr/local/lib/python2.7/dist-packages/supervisor-3.0a12-py2.7.egg/supervisor/options.py", line 284, in realize
self.process_config_file()
File "/usr/local/lib/python2.7/dist-packages/supervisor-3.0a12-py2.7.egg/supervisor/options.py", line 478, in process_config_file
Options.process_config_file(self, do_usage=do_usage)
File "/usr/local/lib/python2.7/dist-packages/supervisor-3.0a12-py2.7.egg/supervisor/options.py", line 292, in process_config_file
self.read_config(self.configfile)
File "/usr/local/lib/python2.7/dist-packages/supervisor-3.0a12-py2.7.egg/supervisor/options.py", line 527, in read_config
section.directory = existing_directory(directory)
File "/usr/local/lib/python2.7/dist-packages/supervisor-3.0a12-py2.7.egg/supervisor/datatypes.py", line 336, in existing_directory
nv = v % {'here':here}
KeyError: 'var_name'
Is there a way to achieve that?
Supervisor only supports expansions with environment variables in a limited number of locations, each of which is documented in the configuration documentation.
Unfortunately, the [supervisord] directory option is not one of those; it only supports the %(here) variable, nothing else.
You could file a feature request for this in the supervisord issue tracker if this an important issue for you.
In my projects, we generally use zc.buildout to make deployment and development environment setup predictable and repeatable, and generate the supervisor configuration from a template. There is a specialized buildout recipe to make this task easier.