How to shift buffers? - Printable Version +- phyphox Forums (https://phyphox.org/forums) +-- Forum: Discussion (https://phyphox.org/forums/forumdisplay.php?fid=1) +--- Forum: Experiments and Ideas (https://phyphox.org/forums/forumdisplay.php?fid=4) +--- Thread: How to shift buffers? (/showthread.php?tid=1893) Pages:
1
2
|
How to shift buffers? - Trikes - 06-24-2024 Hello there, I want to ask about some best practices for shifting buffer content. My current implementation of such a buffer shift is a combination of append and subrange modules, is a little lengthy, and consumes probably too much power during the experiment. The append module seems to add buffer values each time it is being executed, which would be more often than the (location) sensor delivers new data (approx. at 1 Hz); interestingly the append module seems to be slower that the linear acceleration sensor (approx. 208.9 Hz on my device). To avoid an ever growing buffer (due to appending all the time) a subrange module needs to cut off the buffer in the frequency of new sensor data. Buffer shift could be used for several things:
In the attached example the lat buffer (size 0) is being counted and the third most recent position (size 1) is taken (subtract/subrange modules). Then there is the append/subrange combination which feeds in their output as input for each other. From what I understand currently this crossed reverse input would correspond to a sub-cycle resolution in the implementation which does not seem to be supported by the visual editor. This only works when I put these two module manually in the XML file in the correct order (subrange ahead of append). Yep, it might be that this technique will not work on each mobile device, but on mine it does. The if condition is just to only output data if at least 3 GPS fixes are there and I have a set of 3 points to work on. The subrange module then is to cut off the first buffer element which is an artifact by the append/subrange combination before. If I'm not wrong some shift buffer module could do the job more easily. Such a module could have two inputs, the original buffer and the number of positions the original buffer should be shifted (+/-). It just might be like the append buffer with settings in which the position shift could be configured. Or it might be just some shifting in the function module, where the (1st) input buffer is being refeneces as [1_], isn't it? Some shifting could be configured as [1_(-1)] when using buffer [1] in the formular. I outlined this just for giving these example and a better understanding of my intention. Since I'm a new user of phyphox there is a lot I do not know, of course. Maybe you already have something I could use for shifting buffers. Any idea welcome. Thanks and kind regards, Trikes. RE: How to shift buffers? - Sebastian Staacks - 06-24-2024 Sorry, I am a bit in a hurry right now and did not have a chance to thorowly look into your example, but I have a few pointers that I would like to drop quickly. I hope they are not beside the topic:
Now, that reply became longer than expected, so I hope there is something helpful in there RE: How to shift buffers? - Trikes - 06-25-2024 Thanks a lot for all the suggestions. I believe that the split module should be able to reduce some containers in my experiment, because the split could, of course, as well happens at the start of a buffer. In the exported data file I would expect for the split buffers some NaN entries at the most recent positions when compared to the one un-split buffer which I still need for the building up the data (details skipped). I tried to enter the split module in the XML file but failed somehow, I would wait for some example given in the documentation you linked. The visual editor has some input validation? When adding a not yet supported module manually to the XML file the visual editor won't accept that XML anymore, because it could not save later on that unsupported module? Ah, the visual editor accepts reading yet unsupported attributes, but does not write them back. Then I will continue with the visual editor to finish the experiment and only later on would try the manual optimization in the XML file. The requireFill attribute should save some if modules in my experiment. This attribute I can use multiple times, I would expect. But the other two, requireFillThreshold and requireFillDynamic, I can only define one time, because they do not related to a specific buffer? No, also requireFill I can define only one time, isn't? It is an attribute to the analysis module and not to the data container (buffer). Next thing I want to try is to relate in a meaningful way the accelerations from the linear acceleration sensor with the calculated lateral accelaration in a curve to verify the g's against each other. Don't see yet any strong correlation between the numbers. Cheers RE: How to shift buffers? - Sebastian Staacks - 06-25-2024 Seems like you answered most of the questions yourself The visual editor does some half-hearted validation. But it can only use modules that are known to it and it will generate the entire XML file from scratch, so there is no way to use it with new modules. requireFill is only designed to observe a single buffer and it is indeed an attribute to the analysis tag. Since it controls if the analysis modules are executed at all, there is no workaround to observe multiple buffers at the moment. Here is an example of how I use the split module to calculate a moving average of 100 values. The split module keeps enough values (99) around for the next iteration, so the moving average has enough historic values to continue with the next new value. Note, that this is somewhat specific to the moving average module as it has the option to only output results when it has consumed enough values. Also note, that if you would try this example, the results on Android would be wrong as I made a mistake when implementing the movingaverage. It will be fixed in the next release. Code: <phyphox version="1.18" locale="en"> If I ever come across a time machine I will rewrite phyphox with Python support instead of its own exotic XML-based language RE: How to shift buffers? - Trikes - 06-27-2024 For now only a quick update on the order of modules in the XML file as exported by the editor:
RE: How to shift buffers? - Jens Noriʇzsɔɥ - 06-27-2024 You are right: the (old) editor is reading from left to right. The new editor is blockly based, so there is a strict vertical order – and almost no flexibility to spend time on arranging elements on the screen… RE: How to shift buffers? - Sebastian Staacks - 06-28-2024 Yeah, that is another reason why we are abandoning the old editor. They way it presents the experiment suggests an order based on connections. You would expect that if you connect module A to module B, A would be executed first (like in LabView if youa re familiar with that). But phyphox does not have such hirachy and infact there are some cases in which you might get a result from the last module that is executed and want to use that result in the next iteration. So, to be clear: The posx and posy (like anything with an "editor:"-prefix in the XML file) is entirely ignored by phyphox. If you change these, it will affect how the configuration is loaded in the editor, but not how it is interpreted by phyphox. It only has an effect in phyphox if you load it into the editor and then export it again, because the editor will generate the order of the module in the analysis-block based on the x-position. (A desperate attempt to be able to represent experiments with different module order in the editor while remaining intuitiv for users with simple configurations.) RE: How to shift buffers? - Trikes - 06-29-2024 Well, don't bash the old editor too hard. It offers a low entry level for a seldom programming experience. What I mean: When you discover Phyphox some first thought is, wow, I can do something with the sensors, cool. When you start developing your own experiment some dark thoughts arise, how could this be working at all? What is the base frequency in which the experiment is being executed? The location sensor is at about 1 Hz, the linear acceleration is at something above 200 Hz, and an independent append module is at something in-between. A linear programming paradigm does not apply. How could I develop anything at all in Phyphox? I started developing my (first) experiment about 4 weeks ago. And only 3 weeks ago I got some understanding of how I could do things, when I was thinking about analogue computers and how to program them. With the visual editor you do not implement directly your algorithm as you do in the more common linear programming languages. Instead you define bondary conditions for the data flow routes (modules, buffers, connections; notice that buffers themselves are also kind of a module with which you can encode some behavior). Just as you would design for an analogue computer the size of containers, the diameter of tubes, the resistence of a wire, etc. And instead of water or electrical current, sensor data is running through the experiment, with each data source having its own frequency. I think, it is more like some multi-frequency, parallel spreadsheet calculation than like a shell script. For me it is a seldom opportunity to have this kind of programming experience. And maybe this kind of programming experience is even more important in terms of didactics than "just" reading out some sensor data. Sure, the sensor data is important if you want to use Phyphox for your physical experiments. Maybe this unique programming experience is an equally important feature of your app and deserves some own article; which might already exist, I cannot tell. In the end, Phyphox is providing its own programming language for an event-driven real time environment, isn't it? Maybe this is not seen in the public as Phyphox' major feature. (Not sure about your Python statement. Better to not provide the opportunity of code injection to a mobile phone. Currently you have with your own programming language an encapsulated system in which only your rules apply, I would not allow experiments defined as Python or any other code.) Only when I had that non-linear understanding of what I do in the editor, I was able to shortcut the modules (that evil "X" in the module connectins in my screenshots before) and could rip apart buffers and build them up again with each cycle, at whatever frequency the cycles would have, the frequency is no longer important. Hmm, sometimes I understand how this "X" works, but then there are also times when I'm no longer that sure how it could work at all. For sure it is not trivially working, and for sure it is only working when several of these modules are being executed in the correct order, not only the two modules connected with the "X", but others as well. Would be interested in your detailed explanation how this would really work. I would have the hope that the new editor does not introduce limitations compared to the old editor, meaning that I could use the new editor to continue to edit experiments that I started to develop in the old one (that evil "X"). Sure, would be also nice if the new editor would offer some help for this "non-linear" programming style. Maybe also that the new editor could be completely independant from any module specific definition, in a way that it does not get outdated when you invent new modules. You could consider to have the module definitions independently from the editor implemention as some schema that you could separately provide and update any time when you come up with a new module or enhance an existing one. My hope would be that the new editor could do the thing from my attachment without the need to change anything in the implementation of this experiment. If you deprecate the old editor it would be still around and could be used in some legacy mode? Which more or less is already the current status quo, isn't? Well, it is only my personal opinion and I do not claim to have understood it completely. Cheers RE: How to shift buffers? - Jens Noriʇzsɔɥ - 06-29-2024 (Top secret: a link to the new editor is already in this forum. Expect –hopefully less'n'less– breakages. ) RE: How to shift buffers? - Trikes - 06-29-2024 (I won't tell anybody. Thanks.) (I loaded my experiment into the new editor, changed only its name, nothing else, and loaded it via QR into the same mobil phone. Experiment does not work.) First difference in the XML created by the new editor is that there are no buffer size "1" attributes. Old editor: Quote:<container size="1" static="false">lat_count</container> New editor: Quote:<container>lat_count</container> I use other buffer sizes as well, "0", "3", "10", and "1000", they all are available in the new editor's XML, but all buffer size "1" attributes are missing in the XML, but are displayed as "1" in the Web UI of the new editor. New editor: Quote:<container size="3">UTM_Easting</container> People will miss the map and the lines which provide some higher view on more complex algorithms. The new editor provides a more linear programming experience. I can see the advantages of both editors. For the moment I stay with the old one. (Is there already some secret documentation for the new editor?) |