Progress of Spot Working with SeisDataContainer The most major thing I did for my work here is having spot to work with SeisDataContainer. It is still a work-in-progress and you can see the progress summary from my previous blog post. The codes are found on GitHub. SeisDataContainer and Spot. Checkout dhsieh branch or the commit code: 18a3cc5cd4c2d9c7e3ea9dc1819b868b2e7aed17 (Spot) 1d1503cc390e82328aaad2b2bf63eb8e3f18fdb8 (SeisDataContainer) How to use SeisDataContainer with Spot For now, people use the regular MATLAB array instead of SeisDataContainer: x = [2 5 9 7].’; % x is the data. It’s a regular MATLAB array. model.u = {‘m’}; % metadata: unit model.d = [10]; % metadata: delta A = opDFT(4); % Fourier Transform operator. The number 4 is there because there are 4 entries in the data res = A * x; % Do Fourier Transform on the data model.u = {‘1/m’}; % Modified metadata model.d = …………. % we have to modify the metadata one-by-one How we want to use the SeisDataContainer: x = iCon.load(<path to where the SeisDataContainer is stored>) x = iCon([2 5 9 7].’, ‘unit’, {‘m’}, ‘delta’,[10]) % or define it during runtime A = opDFT; % Fourier Transform operator (Dynamic) res = A * x; % Do Fourier Transform on both the data and metadata Motivation of Using SeisDataContainer Real world data consist of not only the data itself but also the metadata. For example, a seismogram not only has the seismogram value, but also the units for the axis and the sampling interval (delta). When a linear operation, say Fourier Transform, is done on the data, the metadata need to be changed. In this example, unit of time should change to frequency. Unfortunately, changing metadata is currently done by hard-coding, which is considered a bad programing practice. Using SeisDataContainer allows a programmer to: 1. Put data and metadata into one SeisDataContainer object Much cleaner code 2. Let Spot decide how to handle metadata automatically Avoid human error Help detect error during operation 3. Use Dynamic Spot Operator Further simplify the code. Will be discussed in the Dynamic Operator section Check out my PowerPoint presentation for more detail Rule Class The work on Rule class is an extension of work of SeisDataContainer. The purpose of a Rule object is to be the storage of all the function handlers and apply the handlers to the respective metadata fields in SeisDataContainer object. Currently I have it completed on opDFT. The Rule object is created at the moment the operator is created and the Rule object is stored as a field of the operator. Rule class usage Here I use opDFT as example: A = opDFT; % create the operator. The rule object is created as A’s field. C = iCon(randn(3,1), ‘unit’, {‘m’}, ‘delta’, [5]); % DataContainer A.metadataRule.setRule(‘delta’,3) A*C % the operation How to set rules There are two types of rule you can set: 1. Single Field Rule This changes just one rule handler ex: A.metadataRule.setRule(‘delta’,3); % here I set delta will always be 3 after the operation ex: A.metadataRule.setRule(‘delta’,@(header,op,mode)1./header.delta); % here I set that delta will be element-wise inverse of the current delta. ex: A.metadataRule.setRule(‘delta’,3,’unit’, {‘s’}); % I can set more than one Single Field Rule at a time. 2. Full Header Rule This takes care of the entire header A.metadataRule.setRule(‘full’, the_function_handle(header,op,mode)); About the handler: The handler could be one of the two: 1. Function handler If the user decides to put function handle, make sure the function accept 3 input arguments: header, op, mode. 2. A value Users still have the ability to hard-code the resulting metadata. Simply put down the value in the set rule function. Dynamic Operator Dynamic operators take the advantage of the use of SeisDataContainer to simplify the programing process. Dynamic operators do not require size argument(s) in their constructor, so programmers can focus on the mathematic. Here’s the comparison: Regular spot operator for Fourier Transform: x = [1 2 3 4]; % the data. 4 elements. A = opDFT(4) % Fourier Transform operator for 4 elements A*x % Fourier Transform operation Dynamic spot operator for Fourier Transform: x1 = [1 2 3 4]; x2 = [1 2 3 4 5 6 7 8]; A = opDFT; % Dynamic operator r1 = A * x1; % The same operator can be used for different r2 = A * x2; % sizes of data. Problem with Dynamic Operator For some operators, some information (including the original implicit dimension) is lost on the data after doing forward operation. Being highly dependent on the implicit size of SeisDataContainer, dynamic operators sometimes are unable to initialize. The current solution to this problem is to store the operation history on the data container. During forward operation, the implicit size of the data is stored on the SeisDataContainer object. When later the adjoint operation happens, the dynamic operator can retrieve the full implicit size information from the history. If there’s no forward operation done on the data before the adjoint operation, there would be no history for the dynamic operator, thus operation could not proceed. Check out the PowerPoint presentation for more detail Julia version of Spot We have been looking for free MATLAB alternatives due to the licensing cost. Julia Language appears to be a good candidate and we have started to write Spot in Julia. Goto: https://github.com/slimgroup/juliaSpot We haven’t implement much on Julia yet since we found that Julia is still a pre-mature language. We had identified a problem in its garbage collection. Checkout this discussion: https://github.com/JuliaLang/julia/issues/6103 opKron improvement There had been a change in opKron’s multiplication function for performance improvement on larger, higher dimensional data, and subsequent fixes had been done these days. Studying how opKron works will be important as it’s a widely used operator in this group; therefore, further improvements might be required.