Skip to main content

Dear all,



 



I am running customized analyzes and would like to adress different types of MTF inputs. However, changing the MTF Type does not seem to work properly. I am not an expert in python or the ZOS API, so there might be an error in the code.



But all other settings work properly. Here is a simplified part of the code with which I tested:





---

tf = System.Analyses.New_Analysis(ZOSAPI.Analysis.AnalysisIDM.FftThroughFocusMtf)

mtf_settings = mtf.GetSettings()

mtf_settings.Wavelength.SetWavelengthNumber(wavenumber)

mtf_settings.Field.SetFieldNumber(0)

mtf_settings.Frequency = frequency

mtf_settings.NumberOfSteps = 40

mtf_settings.DeltaFocus = 1.5

mtf_settings.Type = ZOSAPI.Analysis.Settings.Mtf.MtfTypes.SquareWave





mtf_settings.SampleSize = ZOSAPI.Analysis.SampleSizes.S_256x256


mtf.ApplyAndWaitForCompletion()



------



I checked with the debugger, what happens from step to step - and the type value is passed correctly and translated into the correct number of the 'enum' list of types. But the graphics window does not use this type.



The other way round - I preconfigured my settings file with 'SquareWave' input and looked what type number is shown in the settings by use of the debugger. The number is '9' - which is out of the enum range of type.



Can anyone help to identify what is wrong?



 



Thanks a lot and kind regards!



 



 

Hi Karen



Thank you for reporting this. I did the same test in Matlab and it seems like it doesn't pass the MTF type to the analysis.



I will check with my colleagues and will let you know.



Sandrine


Hey Karen,



I checked on my machine with Python, I get the precise same behavior. Other settings besides Type work fine and the Type setting works fine for the usual FFT MTF. Strange!



Seems like some sort of a bug?



As a temporary workaround, you can manually set it to Square Wave, then access and save the settings through the API by using:



TheSystem.Analyses.Get_AnalysisAtIndex(1).GetSettings().SaveTo('Your Desired Path\\mtf_settings.cfg')   (the index 1 of the analysis can change depending on what other analysis windows you have open. I'd suggest closing all others for this step)



 



After you have it saved, during your code execution you can just load the settings file. This seems to work, at least for me. You can load it via:



mtf_settings.LoadFrom('Your Desired Path\\mtf_settings.cfg')



 



Check if this workaround works for you.



Mikayel


Thank you Mikayel for your suggestion. Sorry for not making it clear, but yes I have reported a bug. 



And your suggestion makes me think that there is actually a workaround. I have copied my code here (in Matlab):



TheApplication = ans;


System = TheApplication.PrimarySystem;


mtf = System.Analyses.New_Analysis(ZOSAPI.Analysis.AnalysisIDM.FftThroughFocusMtf);


mtf_settings = mtf.GetSettings();





FftThroughFocusMtf_cfgFile = 'C:\Data\Zemax\Configs\TFM.CFG';


mtf_settings.SaveTo(FftThroughFocusMtf_cfgFile);


mtf_settings.ModifySettings(FftThroughFocusMtf_cfgFile, 'TFM_TYPE', '4');


mtf_settings.LoadFrom(FftThroughFocusMtf_cfgFile);





mtf_settings.Wavelength.SetWavelengthNumber(1);


mtf_settings.Field.SetFieldNumber(0);


mtf_settings.Frequency = 50;


mtf_settings.NumberOfSteps = 40;


mtf_settings.DeltaFocus = 1.5;


mtf_settings.SampleSize = ZOSAPI.Analysis.SampleSizes.S_256x256;


%mtf_settings.Type = ZOSAPI.Analysis.Settings.Mtf.MtfTypes.SquareWave;





mtf.ApplyAndWaitForCompletion();


There are actually 2 ways to access the settings of an analysis:



- the 1st one is directly with the settings in the API



- the 2nd one is via modifysettings. We usually only use this way when an analysis is not fully implemented in the API but in this case it works as a workaround. There is a forum thread giving more explanation. I'll search for it.



Sandrine


It is here: How do I perform analysis of my system using the ZOS-API? 


Dear all,



Thank you for the link. The modify-settings approach is familiar to me from the usual macro programming. I have now used the workaround to set the settings in by the window and save this in the *.cfg file. Since I do only need one type for all images for this specific project, this works fine for now.



 



Best regards,






Karen


Hi Karen



Our developers have fixed it so the fix will be available in 21.2.



Sandrine


Reply