Doing combined analysis on separate simulations

Hi Sim4life community,
Is it somehow possible to do analysis on two separate simulations in sim4life without exporting the data to for example Matlab?
For example if I have almost the same simulation twice but with some parameter changed and I want to compare the SAR of each simulation by subtracting or normalizing the SAR simulations.Best,
Frodi Gregersen 
Hi Ofli,
Thank you for the answer but I don't think it solves my problem. Maybe I wasn't clear enough. I'm talking about doing post processing on the SAR data from two different simulations (not combining one multiport simulation). Is it for example possible to subtract the SAR data from two different simulations and display the resulting SAR (or SAR difference)?
Thanks,
Frodi 
Hey,
I don't think there is a direct method to do so within Sim4Life, however, you could always use the method by ofli and then use the python extension in Sim4Life to subtract two results. Make sure that both simulations are on the same grid before subtracting (otherwise you need to interpolate one of the fields to the same dimensions). If you are unsure on how to do this let me know and I can see if I can whip up some codeCheers,
peter 
Hi Peter,
Thank you for the answer. I have no experience using the python extension in Sim4Life, so it would be highly appreciated if you would be willing to make a simple example for this. Just the most basic situation you can make and then I can take it from there.
Best,
Frodi 
Hey Frodi,
So I made a "small" script for you. It is by no means perfect but it gets the job done (I modified some script I had available). This does assume you have both simulations in the same Sim4Life project, however, I think this should still work if you would import the results from another project. Only selecting the simulation gets a bit trickier probably.
Hopefully, this helps!Cheers,
Peter# done with Sim4Life V3.4 # import the functions you will need import s4l_v1 as s4l import s4l_v1.simulation as simulation import s4l_v1.document as doc # I think using pyplot is a little easier for this instance, you could use the sim4life viewers too I think. import matplotlib.pyplot as plt import numpy as np # function to reshape the sar fields to the correct dimensions def reshapeSim4LifeField(tempField,simulationInstance,flagAxes): gridsize = np.array(simulationInstance.Data.Grid.Dimensions)  1 tempField = tempField.reshape(gridsize, order = 'F') #only 1 component (magnitude of SAR) # Export the axes in case you need to reshape (only needed if you have different grids) if flagAxes: Axis0 = simulationInstance.Data.Grid.XAxis Axis1 = simulationInstance.Data.Grid.YAxis Axis2 = simulationInstance.Data.Grid.ZAxis else: Axis0 = 0 Axis1 = 0 Axis2 = 0 return tempField,Axis0,Axis1,Axis2 # set some options # normalize the field to input power flagNormalize = True # reshape the fields flagReshape = True # export the axes if you want to interpolate flagAxes = False # make a list of all the simulations in your file sims = list(s4l.document.AllSimulations) # select the 2 you want from the list (0,1 chosen here) sim1 = sims[0] sim2 = sims[1] # get all the object with all the available fields for the first simulation sim1Results = sim1.Results() availableFields1 = sim1Results["Overall Field"] availableFields1.FrequencySettings.ExtractedFrequency = u"All" # and for the second sim2Results = sim2.Results() availableFields2 = sim2Results["Overall Field"] availableFields2.FrequencySettings.ExtractedFrequency = u"All" # normalize to input power if you want to if flagNormalize: availableFields1.Normalization.Normalize = True availableFields2.Normalization.Normalize = True # you can also choose another normalization reference availableFields1.Normalization.AvailableReferences = "EM Input Power(f)" availableFields2.Normalization.AvailableReferences = "EM Input Power(f)" # set the value (this is 1W input power now) availableFields1.Normalization.NewReferenceValue = 1 availableFields2.Normalization.NewReferenceValue = 1 # select the field you want (SAR in your case) sim1SAR = availableFields1["SAR(x,y,z,f0)"] sim2SAR = availableFields2["SAR(x,y,z,f0)"] # actually extract the field (most of the memory is allocated here) sim1SAR.Update() sim2SAR.Update() # select the frequency index (chosen the first, if you did your simulation at more frequencies you can change the 0 to some other index) sim1SARAtFreq = np.array(sim1SAR.Data.Field(0)) sim2SARAtFreq = np.array(sim2SAR.Data.Field(0)) # reshape the fields if flagReshape: sim1SARAtFreq,Sim1Axis0,Sim1Axis1,Sim1Axis2 = reshapeSim4LifeField(sim1SARAtFreq,sim1SAR,flagAxes) sim2SARAtFreq,Sim2Axis0,Sim2Axis1,Sim2Axis2 = reshapeSim4LifeField(sim2SARAtFreq,sim2SAR,flagAxes) # take the difference diffSAR = sim1SARAtFreq  sim2SARAtFreq # plot an arbitrary slice plt.pcolormesh(diffSAR[:,:,1]) plt.show()

Hi, sorry to jump in, but in general it is possible to compare simulation results within Sim4Life without going into Python (though python is really handy for this stuff). In the analysis tab, you need to select the two Sensors of interest (select while holding the control key) and different options will pop up in the ribbon  It seems what you want is a field combiner, where you can add fields (weight the first with 1.0 and the second with 1.0 to subtract them). You can do the same for 2d plots, where you can plot lines together by selecting multiple plots in postpro and then clicking on Combine Plots in the ribbon.
It's a neat tool I use a lot but is a bit hidden in sim4life since you only get access to it once you select two elements in the analysis tab.

Note that the Field Combiner only works for fields that are represented on the same grid. If the fields you want to compare are from simulations done with different grids, you will have to first interpolate one field onto the grid of the other (select both fields and use the Interpolator algorithm).

@montanaro ,
Ohh that is maybe a better solution to the current problem, awesome:)