Changes between Initial Version and Version 1 of installSunpy


Ignore:
Timestamp:
07/09/21 15:53:01 (3 years ago)
Author:
niles
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • installSunpy

    v1 v1  
     1 
     2== Installing sunPy in a python virtual environment == 
     3 
     4A python virtual environment on linux or MacOS is a good way to experiment in python without affecting the system setup of python. Modules can be installed 
     5aside from the system version. Afterwards, the virtual environment can be deleted. Here, we install sunPy and use it in a simple 
     6example. 
     7 
     8First, make sure you have a fairly recent version of python. At the bare minimum, make sure it's release 3 or more : 
     9 
     10{{{ 
     11$ python --version 
     12Python 3.9.6 
     13}}} 
     14 
     15Note that in order to get python version three, on some systems you may have to use "python3" rather than "python" for all commands. 
     16 
     17First, build a virtual environment in an appropriately name directory and enter into it by sourcing the activation file : 
     18 
     19{{{ 
     20$ python -m venv /home/oien/johnBsunPy 
     21$ source /home/oien/johnBsunPy/bin/activate 
     22}}} 
     23 
     24At this point the system prompt will change to reflect the fact that you're in the virtual environment. 
     25To be sure you're in the virtual environment, check that the virtual environment versions of python and pip 
     26are being used : 
     27 
     28{{{ 
     29(johnBsunPy) $ which python 
     30/home/oien/johnBsunPy/bin/python 
     31(johnBsunPy) $ which pip 
     32/home/oien/johnBsunPy/bin/pip 
     33}}} 
     34 
     35That looks good. Now upgrade pip to the latest version, and install sunPy : 
     36 
     37{{{ 
     38(johnBsunPy) $ pip install --upgrade pip 
     39(johnBsunPy) $ pip install sunpy[all] 
     40}}} 
     41 
     42You can now use sunPy in the virtual environment : 
     43 
     44{{{ 
     45(johnBsunPy) $ python 
     46Python 3.9.6 (default, Jun 30 2021, 10:22:16)  
     47[GCC 11.1.0] on linux 
     48Type "help", "copyright", "credits" or "license" for more information. 
     49>>> from sunpy.net import Fido, attrs as a 
     50>>> result = Fido.search(a.Time('2021/02/02 16:00:00', '2021/02/02 16:30:00'), a.Instrument('big bear'), a.Physobs('intensity')) 
     51>>> print(result.show("Provider","Source","fileurl")) 
     52Results from 1 Provider: 
     53 
     5414 Results from the VSOClient: 
     55Provider Source                               fileurl                               
     56-------- ------ ------------------------------------------------------------------- 
     57     NSO   GONG ftp://gong2.nso.edu/HA/haf/202102/20210202/20210202160950Bh.fits.fz 
     58     NSO   GONG ftp://gong2.nso.edu/HA/haf/202102/20210202/20210202161050Bh.fits.fz 
     59     NSO   GONG ftp://gong2.nso.edu/HA/haf/202102/20210202/20210202161450Bh.fits.fz 
     60     NSO   GONG ftp://gong2.nso.edu/HA/haf/202102/20210202/20210202161650Bh.fits.fz 
     61     NSO   GONG ftp://gong2.nso.edu/HA/haf/202102/20210202/20210202161750Bh.fits.fz 
     62     NSO   GONG ftp://gong2.nso.edu/HA/haf/202102/20210202/20210202161850Bh.fits.fz 
     63     NSO   GONG ftp://gong2.nso.edu/HA/haf/202102/20210202/20210202161950Bh.fits.fz 
     64     NSO   GONG ftp://gong2.nso.edu/HA/haf/202102/20210202/20210202162050Bh.fits.fz 
     65     NSO   GONG ftp://gong2.nso.edu/HA/haf/202102/20210202/20210202162150Bh.fits.fz 
     66     NSO   GONG ftp://gong2.nso.edu/HA/haf/202102/20210202/20210202162250Bh.fits.fz 
     67     NSO   GONG ftp://gong2.nso.edu/HA/haf/202102/20210202/20210202162350Bh.fits.fz 
     68     NSO   GONG ftp://gong2.nso.edu/HA/haf/202102/20210202/20210202162450Bh.fits.fz 
     69     NSO   GONG ftp://gong2.nso.edu/HA/haf/202102/20210202/20210202162650Bh.fits.fz 
     70     NSO   GONG ftp://gong2.nso.edu/HA/haf/202102/20210202/20210202162750Bh.fits.fz 
     71 
     72>>> exit() 
     73 
     74}}} 
     75 
     76You can leave the virtual environment with the "deactivate" command at the linux command line prompt, at which point your prompt will change back : 
     77 
     78{{{ 
     79(johnBsunPy) $ deactivate 
     80$  
     81}}} 
     82