SyntaxHighlightingSandbox

From SPEDAS Wiki
Revision as of 02:55, 29 December 2023 by Jwl (talk | contribs) (Created page with "Python highlighting examples: <syntaxhighlight lang="python"> def ex_analysis(plot=True): """Create a plot with THEMIS data.""" # Delete any existing pytplot variables del_data() # Download THEMIS state data for 2015-12-31 time_range = ['2015-12-31 00:00:00', '2015-12-31 23:59:59'] state(probe='a', trange=time_range) # Use some analysis functions on tplot variables subtract_average('tha_pos') subtract_median('tha_pos') # Plot...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Python highlighting examples:

<syntaxhighlight lang="python"> def ex_analysis(plot=True):

   """Create a plot with THEMIS data."""
   # Delete any existing pytplot variables
   del_data()
   # Download THEMIS state data for 2015-12-31
   time_range = ['2015-12-31 00:00:00', '2015-12-31 23:59:59']
   state(probe='a', trange=time_range)
   # Use some analysis functions on tplot variables
   subtract_average('tha_pos')
   subtract_median('tha_pos')
   # Plot
   if plot:
       tplot(["tha_pos", "tha_pos-d", "tha_pos-m"])
   # Return 1 as indication that the example finished without problems.
   return 1


  1. Run the example code

if __name__ == '__main__':

   ex_analysis()

</syntaxhighlight>