Comparisons: Difference between revisions
Jump to navigation
Jump to search
(Created page with "= Comparisons of pySPEDAS to IDL SPEDAS = Some examples that show how to achieve the same results using either IDL SPEDAS or python pySPEDAS. == Smooth function == * IDL c...") |
No edit summary |
||
(3 intermediate revisions by the same user not shown) | |||
Line 2: | Line 2: | ||
Some examples that show how to achieve the same results using either IDL SPEDAS or python pySPEDAS. | Some examples that show how to achieve the same results using either IDL SPEDAS or python pySPEDAS. | ||
* [[Smooth function]] | |||
* [[Spectrogram]] | |||
Line 12: | Line 15: | ||
; smooth data | ; smooth data | ||
t = | t = [1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12.] | ||
y = [3., 5., 8., 15., 20., 1., 2., 3., 4., 5., 6., 4.] | y = [3., 5., 8., 15., 20., 1., 2., 3., 4., 5., 6., 4.] | ||
Line 27: | Line 30: | ||
get_data, 'smooth', data=d | get_data, 'smooth', data=d | ||
print, 'Smooth data:', d.y | print, 'Smooth data:', d.y | ||
; Results: | ; Results: | ||
Line 65: | Line 67: | ||
Smooth data: [ 3., 5., 10.2, 9.8, 9.2, 8.2 6., 3., 4., 4.4, 6., 4.] | Smooth data: [ 3., 5., 10.2, 9.8, 9.2, 8.2 6., 3., 4., 4.4, 6., 4.] | ||
""" | """ | ||
# Run the example code | # Run the example code | ||
ex_test_smooth() | ex_test_smooth() | ||
</pre> | </pre> |
Latest revision as of 22:55, 24 April 2020
Comparisons of pySPEDAS to IDL SPEDAS
Some examples that show how to achieve the same results using either IDL SPEDAS or python pySPEDAS.
Smooth function
- IDL code:
pro test_smooth ; smooth data t = [1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12.] y = [3., 5., 8., 15., 20., 1., 2., 3., 4., 5., 6., 4.] store_data, 'original', data={x:t, y:y} tsmooth2, 'original', 5, newname = 'smooth' ylim, 'original', 0, 20 ylim, 'smooth', 0, 20 tplot, ['original', 'smooth'] get_data, 'original', data=d0 print, 'Original data:', d0.y get_data, 'smooth', data=d print, 'Smooth data:', d.y ; Results: ;Original data: 3.00000 5.00000 8.00000 15.0000 20.0000 1.00000 2.00000 3.00000 4.00000 5.00000 6.00000 4.00000 ;Smooth data: 3.00000 5.00000 10.2000 9.80000 9.20000 8.20000 6.00000 3.00000 4.00000 4.40000 6.00000 4.00000 end
- Python code:
import pytplot from pyspedas.analysis.tsmooth import tsmooth def ex_test_smooth(): t = [1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12.] y = [3., 5., 8., 15., 20., 1., 2., 3., 4., 5., 6., 4.] pytplot.store_data('original', data={'x': t, 'y': y}) tsmooth('original', width=5, new_names='smooth', preserve_nans=1) pytplot.tplot(['original', 'smooth']) d0 = pytplot.get_data('original') print('Original data: ', d0[1]) d = pytplot.get_data('smooth') print('Smooth data: ', d[1]) """ Results: Original data:[ 3., 5., 8., 15., 20., 1., 2., 3., 4., 5., 6., 4.] Smooth data: [ 3., 5., 10.2, 9.8, 9.2, 8.2 6., 3., 4., 4.4, 6., 4.] """ # Run the example code ex_test_smooth()