simpeg / aurora

software for processing natural source electromagnetic data
MIT License
15 stars 2 forks source link

Add wrapping logic from TFestBand to transfer function codes #10

Closed kkappler closed 3 years ago

kkappler commented 3 years ago

This relates to #7 #54 and #61

kkappler commented 3 years ago

We have the ability to regress each output channel independently as of the closure of issue #7. The needed elements now are to add weights: channel_weights, segement_weights, edf_weights and test that these all run.

Here is a matlab snippet that interprets an array of weights based on the array shape.

              if nargin==4
                    [m,n] = size(wt);
                    if m==obj.Nseg && n == 1
                        obj.WtSeg = wt;
                        obj.weights = 'Seg';
                    else
                        if n~=obj.NchOut || m== obj.Nseg
                            obj.WtCh = wt;
                            obj.weights = 'Ch';
                        else
                            error('TTFestBand: WtCh must be same size as Y');
                        end

After discussing with Gary - the channel weights and segment weights are just to be left as placeholders - they are used in MMT not tranmt, or tranmt_rr (which are the F77 codes the matlab codes emulate).

kkappler commented 3 years ago

edf_weights are implemented as of 27 Aug 2021. Pasted below are a few of my notes from implementing edf_weights.

2021-08-26

After discovering the xr.stack() command there is no longer a need to ravel() the data to prepare the 3d arrays to 2d for regression. We simply use stack.

Tasks: The code needs to be modified so that the 2D xarrays are input directly to regression. For now I would like to keep the X, _X access, so the xarray is _X and X is the data. The nan-handling also needs to be modified to handle the 2d arrays, culling on the “observation”, not on “time” TRME_RR needs to be modified for Z as well to remove the 3d2d casting DONE Once the stacked arrays are working, add the edfwts function (put it in transfer_function/weighting_schemes.py). The output of edfwts should be an xarray having the same number of elements as there are observations in the 2D stft representation.
The key issue here is to make sure that we are acting on the correct indices of weights There are probably some cool ways to take advantage of xarray here, but for a first cut I will use Gary’s method of tracking indX which are the indices of the data DONE We then need to make a method to apply the weights. Application of the weights is to multiply these weights against the 2D array so that each observation (for all channels) is weighted with the same edfwt value. This will be much like the taper method, just use broadcasting. DONE Once a first cut of edfweights is running we need to address the following: Numerical correctness: we can export the 2d stft array to a .mat file and then read it into octave and run Gary’s edfwts on it and compare the output weights DONE Test use cases: With / Without Nan With Nan With RR Without RR DONE The edfwts parameters should then be added to the config file Commit Add edfweights description to the FTR.

Besides documenting edf_weights and validating with Gary the implementation this also closes issue #54