Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

terminal-command for saving fit #41

Open
NicolaasvanderVoort opened this issue Jun 8, 2020 · 2 comments
Open

terminal-command for saving fit #41

NicolaasvanderVoort opened this issue Jun 8, 2020 · 2 comments

Comments

@NicolaasvanderVoort
Copy link

Is your feature request related to a problem? Please describe.
I would like to save-fits from the command line or from a script

Describe the solution you'd like
To know the command which is run when the button File>Save Fit Results>Save Current Fit is pressed

Describe alternatives you've considered
I've tried the command:
cs.current_fit.save(path, name)
But it seems that is must be embedded to create a dir etc.

Additional context
I've visited the google groups page as was suggested on the github welcome page, but I was denied access.

@NicolaasvanderVoort
Copy link
Author

NicolaasvanderVoort commented Jun 11, 2020

To update on this thread:

I've found the command to save fits. It's:

cd.current_fit = mfm.fits[_my_fit_number_]
os.mkdir (path)
cd.save_fit(directory = path)

However it does not work out-of-the box as the screenshots require the corresponding gui fit-window to be active. I've found a workaround:
cs.mdiarea.activateNextSubWindow()

This seems to cycle between active plot windows. This approach has a downside that I don't know what my current position in the window list is. And the code fails if somehow the start position of cs.mdiarea.activeSubWindow gets changed. Is there a way to link the cs.current_fit to the corresponding plot window?

Thanks

@tpeulen
Copy link
Member

tpeulen commented Jun 11, 2020

Hi,
you can also check the "macro" folder in the installation directory. In the macro folder you will find the file "save_fit.py". When you click on "save fit" the macro in the folder gets executed via the ipython command line.

All created fits (objects of the type Fit that were created via the UI) and the corresponding fit windows, i,.e. PyQt objects, can be iterated using the variables fit_windows and fits. The two mentionend variables are defined in the mfm python module. When you create a new fit via the UI the fit and the corresponding window (PyQt object) are appended to these variables.

Using these variables you can iterate over the fits and save the fits by:

import mfm for fit in mfm.fits: fit.save(filename)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants