inconsistencies in algorithms modules #489
Replies: 3 comments 1 reply
-
Yeah, I think they are all pretty good ideas. We should implement them. In item 1, I don't think we have to complicate it, at least for now. I think it is sufficient to just have a loop over members. The other more complex cases may not be that common and decorator will not be necessary in that case. |
Beta Was this translation helpful? Give feedback.
-
I ran across a subtle and obnoxious python anomaly on this issue that I think we have discussed previously. That is, there are two ways you can apply an atomic-level function to an ensemble
I don't know if it is a python anomaly or something about our pybind11 binding code, but they do not give the same answer. 1 works but 2 does nothing except consume cycles. We should resolve this. The iterator way is natural to most python programmers and it produces mysterious results when it does nothing,. |
Beta Was this translation helpful? Give feedback.
-
Working on this a bit more I remembered this is a weird python problem, not a pybind11 issue in our implementation. The iterator example I gave above illustrates the problem. If the loop is of that basic form all the loop does is continuously recycle the symbol d. I think one way to say it is that d has scope limited to the loop so python never associates it with the symbol The really odd behavior comes when you use a loop like this one:
Turns out that works because rota is a method of the object d points to so the action is pushed to the actual data object. Similar things work if you do constructs like:
In that case d actually worms its way into e to alter that data. This is going to be very very confusing to almost anyone, Three actions:
|
Beta Was this translation helpful? Give feedback.
-
I thought about posting this as an issues page, but I think it need a bit of online discussion as a preface to addressing the problem. The issue we have is that the standard mspass algorithms modules are not consistent in handling ensembles. Many of them do but many do not either. Worse, is that the documentation doesn't alway make it clear what data types an algorithm supports. The reason it is not a simple "fix this problem" is that some algorithms make sense only on certain kinds of data. e.g. rotation of a Seismogram object to R-T-Z from ENZ only makes sense really for Seismogram objects. (Obspy actually has a way to handle that be that is not the point.) Another example is that an ensemble stack algorithm is not at all the same thing as atomic sums done with reduce. Hence, a (hypothetical in this case since it doesn't currently exist in mspass) ensemble_stack function would only want to accept ensembles as inputs. Add to that the
Gather
version of ensembles and it gets even messier.I think the things we need to do are:
:return:
section in the docstring that clarifies what exactly the algorithm will return as well as what it accepts as inputs.Gather
object but the table could define a standard symbol for that tooPlease let me know what any of you think about this.
Beta Was this translation helpful? Give feedback.
All reactions