Export electric field distribution image with DGTD script
I am working with DGTD in Lumerical and I am using a script to help me obtain several results. I want to represent the electric field values obtained with the simulations. My aim is that the scipt calculates the electric field in the simulation region and then I can export a figure with the electric field distribution. I would like to automatically export the figures that I can see in DGTD>monitor>Visualize>fields when I run DGTD simulation and obtain an image like the one shown bellow. I have a code that works for the FDTD but the data output of the DGTD is different and I cannot manage to do so:
lambda=785e-9;temp_E1 = getresult("DGTD::monitor2D","fields"); #Obtaining the datalamb = temp_E1.lambda; #vetor containing the wavelengths
n = find(lamb,lambda); #search the index of the desired wavelength
temp_E2=pinch(temp_E1.E2,2,n); #Compute E^2 and extract E at the desired lambda
temp_str="ElectricField.png"; #name the figure
exportfigure(temp_str); #Export the figure
Thank you very much!