File: ssw.rst

package info (click to toggle)
sunpy 7.0.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 12,592 kB
  • sloc: python: 41,765; ansic: 1,710; makefile: 39
file content (89 lines) | stat: -rw-r--r-- 2,293 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
************************
SSWIDL/sunpy Cheat Sheet
************************

`SolarSoft (SSWIDL) <https://sohowww.nascom.nasa.gov/solarsoft/>`__ is a popular IDL software library  for solar data analysis, and in fact, many parts of sunpy are inspired by data structures and  functions in SSWIDL.
Though IDL and Python are very different it sometimes helps to consider how to translate simple tasks between the two languages.
The primary packages which provide much of the functionality for scientific data analysis in Python are  NumPy and SciPy.
In the following we assume that those packages are available to you and that you have imported Numpy with the following import statement:


.. code-block:: python

    import numpy as np
    import scipy as sp

In the following examples, ``a`` and ``b`` could be arrays.
For python the arrays must be numpy arrays which can be created simply through:

.. code-block:: python

    np.array(a)

where a is a Python list of numbers.

**Relational Operators**

=========  ========
IDL        Python
=========  ========
a EQ b     a == b
a LT b     a < b
a GT b     a > b
a GE b     a >= b
a LE b     a <= b
a NE b     a != b
=========  ========

**Logical Operators**

=========  ========
IDL        Python
=========  ========
a and b    a and b
a or b     a or b
=========  ========

**Math Functions**

=========  ========
IDL        Python
=========  ========
cos(a)     np.cos(a)
alog(a)    np.log(a)
alog10(a)  np.alog(a)
exp(a)     np.exp(a)
=========  ========

**Math Constants**

=========  ========
IDL        Python
=========  ========
!pi        np.pi
exp(1)     np.e
=========  ========

**Arrays Sequences**

============  ========
IDL           Python
============  ========
indgen(10)    np.arange(0,10)
findgen(10)   np.arange(0,10,dtype=np.float)
============  ========

**Array Creation**

=============  =========
IDL            Python
=============  =========
dblarr(3,5)    np.zeros((3,5))
intarr(3,5)    np.zeros((3,5),dtype=np.int)
dblarr(3,5)+1  np.ones((3,5))
intarr(3,5)+9  np.zeros((3,5),dtype=np.int) + 9
boolarr(10)    np.zeros(10,dtype=bool)
identity(3)    np.identity(3)
=============  =========

Many more examples can be found on this `NumPy for IDL users page <https://mathesaurus.sourceforge.net/idl-numpy.html>`__