Evgenii Kovrigin (C) 2022

 

 



  KovriginNMR Workflows: Practical Examples


Return to main document

 

All practical examples of the code are given in knmr_workflow_template.py

Below you will find some miscellaneous tips on how to program with KovriginNMR in Topspin.

 

Contents

Debugging and checking values of variables


 

 

 

Debugging and checking values of variables

When you are writing your Python code in Topspin, you cannot use print() statement to observe values of variables. There are two main ways to monitor execution of the code in topspin:

    Without interrupting code execution, via a display of a message on the Topspin status line (underneath the Topspin command line):

    from TopCmds import *
    # A monitoring message
    test_value=10 test_message = "Report test value: %f" % test_value SHOW_STATUS(test_message) wait_time_sec = 1 SLEEP(wait_time_sec)

    The SLEEP() command after the show status command is there to keep the message on the status line for long enough for you to see. Many Topspin operations display some info on the status line, including when your script finished, therefore, your message will be quickly replaced by a message of any other following command if not to pause the program for at least a second.

     

    With pausing execution of the code for you to be able to inspect the experimental parameters, output files and interrupt the code if needed.

    This method allows to install checkpoints along your code and be able to execute your entire code still monitoring specific values and with a chance to abort execution if needed:

    from TopCmds import *        
    # A checkpoint
    test_value=10 test_message = "Report test value: %f" % test_value MSG(test_message)

    Here, the MSG() produces a dialogue box and pauses execution of your code until you click a [Close] button. The dialogue box will contain your message. You may look at parameter files in Topspin, acquisition results, spectrometer status, etc. but you must use the new Topspin window for your examinations. To open a new Topspin window, click [New Topspin] on KovriginNMR toolbar.

    Click [Close] in the dialog, if you want to resume execution of your code.

    Click [Stop Workflow] button on KovriginNMR toolbar, if you wish to abort execution of your code. See How to abort KovriginNMR script for details.

 

Back to Contents



Evgenii Kovrigin (C) 2022