Matplotlib for SUMO - matplotlib

Is it possible to create plots of vehicles let through on a lane using matplotlib in the Python script that acts as as the controller for SUMO ?
What if an OSM map were to be used?
I'm asking if this could essentially replace the use of NS-2 dependent Xgraph.

I don't see why this shouldn't be possible, but you need to do it on your own. You might consider existing scripts as partyrender.
Maybe a better idea is to use a screenrecorder to make movies out of the animations of the eWorld frontend: http://eworld.sourceforge.net

Related

direct inclusion of lammps commands in PyIron

I want to impose reflecting BCs at the non-periodic direction of my simulation box. To this end I need to use fix wall/reflect
Is there any way for direct inclusion of this command in PyIron?
Best regards
wall/reflect is currently not natively supported by pyiron, but if you know the LAMMPS command, you can include it for example via:
job.input.control['fix___fixname'] = 'all wall/reflect xlo EDGE xhi EDGE'
(I took the first example on the LAMMPS page you shared). If your LAMMPS input is not too complicated, this pyiron should be able to place this command in the appropriate position.
Sams's solution is definitely the easiest way if you just want to insert one fix. But you can even load full LAMMPS scripts inside pyiron, here is an example:
https://github.com/jan-janssen/pyiron-free-energy/blob/master/free_energy.ipynb
The important part is to keep the read_data structure.inp and the include potential.inp to use the structure and interatomic potential defined by pyiron. Finally if you also copy the dump, dump_modify and thermo part you can use the pyiron parsers, otherwise you can always parse the output yourself, like I demonstrated in the above example.

Is there a way of using the <prosody> tag in SSML to adjust individual words without a pause (without using a post-processor)

When using the prosody tag in SSML with Google Cloud TTS, I cannot adjust the attributes of individual words without creating an unwanted pause.
The code below creates a lag between 'New' and 'Video'. It has been suggested that a postprocessor can remove these pauses, but I'd like to know if there's a way of doing it directly within the code itself?
<speak>
Hello, and welcome to this<prosody pitch="+3st">New</prosody>Video Tutorial.
</speak>
After testing, it appears there isn't a way of doing this using Google Cloud TTS. You can manually edit the sound file after generating it, but thay defeats the object of the exercise.
I don't have the cleanest answer, as what you are asking is not very supported. Prosody's pitch contour let's you change the tone of voice at different parts of the sentence.
Example of Prosody contour
<speak><prosody contour="(0%, +20Hz) (20%, +30%) (100%, +20%)"> Hello friends! </prosody></speak>
I am still playing around with this, but it seems like a tedious way of getting what you want done.
Using contour
contour takes a string of tuples "(%position in sentence, pitch adjustment) (..., ...)
I hope this helped and best of luck on your work!

What is a good workflow for developing Julia modules with IPython/Jupyter?

I find myself frequently developing new Julia modules while at the same time using those modules for my work. So I'll have an IPython (Jupyter) notebook, with something like:
using DataFrames
using MyModule
Then I'll do something like:
x = myfunction(7, 3)
But I'll have to modify that function, and unfortunately by that point I can't simply do
using MyModule
again. I'm not really sure why; I thought that calling using simply declares available modules in order to make the global scope aware of them, and then when a name is actually needed, the runtime searches for the definition among the currently loaded modules (starting with Main).
So shouldn't using MyModule simply just refresh the definitions of the items in the already declared module? Why do I have to completely stop and restart the kernel in order to use my updated functions? (Is it because names are bound only once to functions that are declared using the function keyword?)
I've looked at Julia Workflow Tips, but I don't find the whole Tmp, tst.jl system very simple or elegant... at least for a notebook.
Any suggestions?
I think there's a lot of truth in this statement attributed to one of the Juno developers: Jupyter notebook is for working with data. Juno IDE is for working with code.
Jupyter is great for using modules in a notebook style that the output you're getting is reproducible. Juno and the REPL have less overhead that let you keep starting new sessions (faster testing, and fixes the problem you noted), have multiple tabs open to follow code around a complex module, and can use the debugger (in v0.5). They address different development issues for difference stages of use. I think you're pushing against the tide if you're using the wrong tool for the wrong job.

Projecting an instance from a A4Solution

I'm trying to make a new UI to visualize my Alloy instances. I've got an A4Solution and have been successful in extracting atoms, relations, checking atom signatures BUT I can't seem to understand how to project the instance on some sig.
I've noticed that I can try to use the edu.mit.csail.sdg.alloy4viz.AlloyInstance, I've got options to project there, but that'd imply in starting over, from a different angle.
Would that be the way to go? I'd prefer to extract that from the A4Solution object.
Thanks
You might want to look at the edu.mit.csail.sdg.alloy4viz.StaticProjector class and its project methods---that's how the Alloy Visualizer implements projections. If your visualization uses the edu.mit.csail.sdg.alloy4viz.AlloyModel class, you should be able to reuse the existing code in StaticProjector; from your post it seems, however, that you'd prefer not use any of the alloy4viz classes, in which case it should not be too difficult to understand how StaticProjector works and reapply the same ideas to your project. Or you could convert an A4Solution object to an AlloyInstance[1] and build your visualizer around the alloy4viz classes, which, in my opinion, would be a good way to go about your project.
[1] something like:
a4sol.writeXML("instance.xml")
AlloyInstance inst = StaticInstanceReader.parseInstance(new File("instance.xml"));

passing options to a matplotlib backend in a clean way

For my personal use, several times I have modified the matplotlib gtk backend (also the tk and wx) , replacing the window with a notebook. This is because I use too many plots at the same time.
This time around I feel I can take the challenge to do a pull-request for my changes. But I want to do it as clean as possible. That is where I need advice (clean is the key).
I would like to place my class TabbedFigureManagerGTK3 inside
backend_gtk3.py
The problem is that using
matplotlib.use('gtk3cairo')
or
matplotlib.use('gtk3agg')
Directs the specified backend (gtk3cairo or gtk3agg) to use backend_gtk3.FigureManagerGTK3
I do not want to replicate backend_gtk3agg.py and backend_gtk3cairo.py just to change the call to backend_gtk3.FigureManagerGTK3
I would like to implement a solution that allows the user to pass an option to the backend, and from there it choses the traditional FigureManagerGTK3 or my TabbedFigureManagerGTK3
I am looking for a recomendation on how to do it that has more chances to be accepted upstream (after pull-request and the whole shebang).
Do I modify matplotlib.use to add something like **kwargs?
Do I just recreate the whole backend_gtk3agg.py and backend_gtk3cairo.py (subclassing of course)
Do I forget about trying to get this accepted and do it breaking the Coding guide
Thanks
Federico
This does sound like a nifty feature.
I would do it by modifying the existing manager and following how the PySide vs PyQt issue is handled (by using a secondary rcParams which controls which one the backend imports). In your case, I would add backend.gtk3.tabbed, or something similarly named, which controls how the manager behaves.
Write your modifications so that changes as little of the existing api as possible (breaking backwards compatibility is a no-go) and make it so a user that doesn't explicitly enable your changes won't even know they are there.
Also email the dev list, they are all pretty friendly. Or just open a PR, that is the most effective way to get feed back.