analitics

Pages

Showing posts with label scipy. Show all posts
Showing posts with label scipy. Show all posts

Wednesday, March 1, 2023

Python 3.11.0 : The sunpy python package - part 002.

In the last article tutorial, I show some simple examples with the sunpy python package.
Today I installed it again with all of these python packages using the pip tool.
You don't need all of these if you just start, but in time you will need to install them:
pip install sunpy --user
Collecting sunpy
  Downloading sunpy-4.1.3.tar.gz (3.6 MB)
     ---------------------------------------- 3.6/3.6 MB 3.6 MB/s eta 0:00:00
     ...
     Successfully installed PyYAML-6.0 aioftp-0.21.4 astropy-5.2.1 pyerfa-2.0.0.1 sunpy-4.1.3
...
pip install zeep --user
Collecting zeep
  Using cached zeep-4.2.1-py3-none-any.whl (101 kB)  
  ...
  Successfully installed isodate-0.6.1 pytz-2022.7.1 requests-file-1.5.1 requests-toolbelt-0.10.1 zeep-4.2.1
  ...
pip install drms --user
Collecting drms
  Downloading drms-0.6.3-py3-none-any.whl (35 kB)
  ...
  Successfully installed drms-0.6.3 pandas-1.5.3
pip install hvpy --user
Collecting hvpy
  Downloading hvpy-1.0.1-py3-none-any.whl (44 kB)
     ---------------------------------------- 44.0/44.0 kB 359.5 kB/s eta 0:00:00
     ...
     Successfully installed hvpy-1.0.1
pip install scipy --user
Collecting scipy
  Downloading scipy-1.10.1-cp311-cp311-win_amd64.whl (42.2 MB)
     ---------------------------------------- 42.2/42.2 MB 7.4 MB/s eta 0:00:00
     ...
     Successfully installed scipy-1.10.1 
pip install glymur --user
Collecting glymur
  Downloading Glymur-0.12.2-py3-none-any.whl (2.7 MB)
     ---------------------------------------- 2.7/2.7 MB 4.2 MB/s eta 0:00:00
     ...
     Successfully installed glymur-0.12.2
     
Let's use the 1600 Angstrom from these all data of spectral range: 335 Angstrom, 131 Angstrom, 191-195 Angstrom, 211 Angstrom, 1600 Angstrom, 1700 Angstrom, 4500 Angstrom, 171-175 Angstrom, 304 Angstrom, 94 Angstrom
from datetime import datetime
from hvpy import createMovie, DataSource, create_events, create_layers
createMovie(
     startTime=datetime(2023, 2, 27),                    # start from 1st September 2022
     endTime=datetime(2023, 2, 28),                      # end at 5th September 2022
     layers=create_layers([(DataSource.AIA_1600, 100)]), # use AIA_193 Lens with 100% Opacity
     events=create_events(["CH"]),                      # show the Active regions
     eventsLabels=True,                                 # event labels should be included
     imageScale=1,                                      # Image scale in arcseconds per pixel
     hq=True,                                           # Download a higher-quality movie file
     timeout=10,                                        # Wait 10 minutes to get a response
     overwrite=True
)
The result is a video that looks like this :
There are easier ways to get information about the sun…
You can take one screenshot using the api.helioviewer.org feature in your browser.
https://api.helioviewer.org/v2/takeScreenshot/?imageScale=1&layers=[SDO,AIA,AIA,304,1,100]&events=&eventLabels=true&scale=true&scaleType=earth&scaleX=0&scaleY=0&date=2023-02-28T15:00:00.000Z&x1=-1100.0&x2=1100.0&y1=-1100.0&y2=1100.0&display=true&watermark=true&events=[CH,all,1]
You can find movies of the last two days of HMI magnetograms and intensitygrams on this webpage.

Sunday, December 11, 2016

The morse python module with pip installation versus precompiled archive wheel.

Today I try to deal with morse python module and it took me a while to install python modules because of their dependencies.
I started with the pip install of morse module but I got dependency errors in python modules
Because I try to fix this issue the result of this tutorial is more about how to install some python module: matplotlib, scipy, numpy, mkl and morse.
The all installation process will help you to understand how can be fix some pip installation versus precompiled archive wheel.
C:\Python27\Scripts>pip install matplotlib
Collecting matplotlib
  Downloading matplotlib-1.5.3-cp27-cp27m-win32.whl (6.0MB)
    100% |################################| 6.0MB 98kB/s
Requirement already satisfied: numpy>=1.6 in c:\python27\lib\site-packages (from
 matplotlib)
Collecting python-dateutil (from matplotlib)
  Downloading python_dateutil-2.6.0-py2.py3-none-any.whl (194kB)
    100% |################################| 194kB 1.4MB/s
Collecting cycler (from matplotlib)
  Downloading cycler-0.10.0-py2.py3-none-any.whl
Collecting pyparsing!=2.0.4,!=2.1.2,>=1.5.6 (from matplotlib)
  Downloading pyparsing-2.1.10-py2.py3-none-any.whl (56kB)
    100% |################################| 61kB 2.0MB/s
Collecting pytz (from matplotlib)
  Downloading pytz-2016.10-py2.py3-none-any.whl (483kB)
    100% |################################| 491kB 656kB/s
Collecting six>=1.5 (from python-dateutil->matplotlib)
  Downloading six-1.10.0-py2.py3-none-any.whl
Installing collected packages: six, python-dateutil, cycler, pyparsing, pytz, ma
tplotlib
Successfully installed cycler-0.10.0 matplotlib-1.5.3 pyparsing-2.1.10 python-da
teutil-2.6.0 pytz-2016.10 six-1.10.0

Download SciPy wheel file from here.
Install this file with:
C:\Python27\Scripts>pip install scipy-0.18.1-cp27-cp27m-win32.whl
Processing c:\python27\scripts\scipy-0.18.1-cp27-cp27m-win32.whl
Installing collected packages: scipy
Successfully installed scipy-0.18.1

Now you can install morse pyhon module.
pip install morse
If you installed the numpy by pip, but the scipy was installed by precompiled archive then expects numpy+mkl.
So to fix that issue, I download the numpy-1.12.0b1+mkl-cp27-cp27m-win32.whl file and install this with pip:
C:\Python27\Scripts>pip install "numpy-1.12.0b1+mkl-cp27-cp27m-win32.whl"
Processing c:\python27\scripts\numpy-1.12.0b1+mkl-cp27-cp27m-win32.whl
Installing collected packages: numpy
Found existing installation: numpy 1.11.2
Uninstalling numpy-1.11.2:
Successfully uninstalled numpy-1.11.2
Successfully installed numpy-1.12.0b1+mkl

Let's test the morse python module.
C:\Python27>python
Python 2.7.12 (v2.7.12:d33e0cf91556, Jun 27 2016, 15:19:22) [MSC v.1500 32 bit (
Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import morse
>>> dir(morse)
['__builtins__', '__doc__', '__file__', '__name__', '__package__', 'lookup', 'st
ring_to_morse']
>>> dir(morse.lookup)
['__class__', '__cmp__', '__contains__', '__delattr__', '__delitem__', '__doc__'
, '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__gt__',
'__hash__', '__init__', '__iter__', '__le__', '__len__', '__lt__', '__ne__', '_
_new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__setitem__'
, '__sizeof__', '__str__', '__subclasshook__', 'clear', 'copy', 'fromkeys', 'get
', 'has_key', 'items', 'iteritems', 'iterkeys', 'itervalues', 'keys', 'pop', 'po
pitem', 'setdefault', 'update', 'values', 'viewitems', 'viewkeys', 'viewvalues']
>>> print morse.lookup.keys()
['"', '$', '&', '(', ',', '.', '0', '2', '4', '6', '8', ':', '@', 'B', 'D', 'F',
'H', 'J', 'L', 'N', 'P', 'R', 'T', 'V', 'X', 'Z', '!', "'", ')', '+', '-', '/',
'1', '3', '5', '7', '9', ';', '=', '?', 'A', 'C', 'E', 'G', 'I', 'K', 'M', 'O',
'Q', 'S', 'U', 'W', 'Y', '_']
>>> print morse.lookup.items()
[('"', '.-..-.'), ('$', '...-..-'), ('&', '.-...'), ('(', '-.--.'), (',', '--..-
-'), ('.', '.-.-.-'), ('0', '-----'), ('2', '..---'), ('4', '....-'), ('6', '-..
..'), ('8', '---..'), (':', '---...'), ('@', '.--.-.'), ('B', '-...'), ('D', '-.
.'), ('F', '..-.'), ('H', '....'), ('J', '.---'), ('L', '.-..'), ('N', '-.'), ('
P', '.--.'), ('R', '.-.'), ('T', '-'), ('V', '...-'), ('X', '-..-'), ('Z', '--..
'), ('!', '-.-.--'), ("'", '.----.'), (')', '-.--.-'), ('+', '.-.-.'), ('-', '-.
...-'), ('/', '-..-.'), ('1', '.----'), ('3', '...--'), ('5', '.....'), ('7', '-
-...'), ('9', '----.'), (';', '-.-.-.'), ('=', '-...-'), ('?', '..--..'), ('A',
'.-'), ('C', '-.-.'), ('E', '.'), ('G', '--.'), ('I', '..'), ('K', '-.-'), ('M',
'--'), ('O', '---'), ('Q', '--.-'), ('S', '...'), ('U', '..-'), ('W', '.--'), (
'Y', '-.--'), ('_', '..--.-')]

You can see the python morse module is working well.