SpacePy - Space Science Library for Python


SpacePy is a package for Python, targeted at the space sciences, that aims to make basic data analysis, modeling and visualization easier. It builds on the capabilities of the well-known NumPy and MatPlotLib packages. Publication quality output direct from analyses is emphasized among other goals:

  • Quickly obtain data
  • Read (and write) data from (and to) data formats like NASA CDF and HDF5
  • Create publications quality plots
  • Perform complicated analysis easily
  • Run common empirical models
  • Change coordinates and time systems effortlessly
  • Harness the power of Python

The SpacePy project seeks to promote accurate and open research standards by providing an open environment for code development. In the space physics community there has long been a significant reliance on proprietary languages that restrict free transfer of data and reproducibility of results. By providing a comprehensive, open-source library of widely-used analysis and visualization tools in a free, modern and intuitive language, we hope that this reliance will be diminished.

To help foster an open and welcoming environment, we have adopted a code of conduct that we encourage members of the SpacePy community to read and follow.

Getting SpacePy

Our latest release version is available through PyPI and can be installed using

pip install spacepy --user

This will also automatically install most dependencies. To permit binary installations without a compiler, this will not install ffnet on Windows. Users needing the LANLstar module can install ffnet separately (requires Fortran compiler); this can be done before or after the SpacePy install.

The latest "bleeding-edge" source code is available from our github repository at and can be installed using the standard

python install --user

Further installation documentation can be found here Mac-specific information can be found here Full documentation is at

SpacePy supports both Python 2.7 and 3.x.


SpacePy has a number of well-maintained dependencies, most of which are automatically installed by pip. These include:

  • numpy (>=1.10, !=1.15.0)
  • scipy (>=0.11)
  • matplotlib (>=1.5)
  • h5py

Soft dependencies (that are required only for a very limited part of SpacePy's functionality) are:

  • ffnet

For complete installation, excepting pre-built Windows binaries, SpacePy also requires C and Fortran compilers. We test with GCC compilers but try to maintain support for all major compilers.


If you wish to use CDF files, download and install the NASA CDF library. The default installation directory is recommended to help SpacePy find the library. Get the package from


When publishing research which used SpacePy, please provide appropriate credit to the SpacePy team via citation or acknowledgement.

To cite SpacePy in publications, use (BibTeX code):

author = {{Morley}, S.~K. and {Koller}, J. and {Welling}, D.~T. and {Larsen}, B.~A. and {Henderson}, M.~G. and {Niehof}, J.~T.},
title = "{Spacepy - A Python-based library of tools for the space sciences}",
booktitle = "{Proceedings of the 9th Python in science conference (SciPy 2010)}",
year = 2011,
address = {Austin, TX}

Certain modules may provide additional citations in the __citation__ attribute. Contact a module's author before publication or public presentation of analysis performed by that module. This allows the author to validate the analysis and receive appropriate credit for his or her work.

For acknowledging SpacePy, please provide the URL to our github repository.

Download Details:
Author: spacepy
The Demo/Documentation: View The Demo/Documentation
Download Link: Download The Source Code
Official Website: 

#python #spacepy #datascience 

What is GEEK

Buddha Community

SpacePy - Space Science Library for Python
Ray  Patel

Ray Patel


top 30 Python Tips and Tricks for Beginners

Welcome to my Blog , In this article, you are going to learn the top 10 python tips and tricks.

1) swap two numbers.

2) Reversing a string in Python.

3) Create a single string from all the elements in list.

4) Chaining Of Comparison Operators.

5) Print The File Path Of Imported Modules.

6) Return Multiple Values From Functions.

7) Find The Most Frequent Value In A List.

8) Check The Memory Usage Of An Object.

#python #python hacks tricks #python learning tips #python programming tricks #python tips #python tips and tricks #python tips and tricks advanced #python tips and tricks for beginners #python tips tricks and techniques #python tutorial #tips and tricks in python #tips to learn python #top 30 python tips and tricks for beginners

Ray  Patel

Ray Patel


Lambda, Map, Filter functions in python

Welcome to my Blog, In this article, we will learn python lambda function, Map function, and filter function.

Lambda function in python: Lambda is a one line anonymous function and lambda takes any number of arguments but can only have one expression and python lambda syntax is

Syntax: x = lambda arguments : expression

Now i will show you some python lambda function examples:

#python #anonymous function python #filter function in python #lambda #lambda python 3 #map python #python filter #python filter lambda #python lambda #python lambda examples #python map

Teresa  Jerde

Teresa Jerde


Space Science with Python — A very bright Opposition


This is the 19th part of my Python tutorial series “Space Science with Python”. All codes that are shown here are uploaded on GitHub. Enjoy!


Today, we will cover another brightness related topic: the computation and determination of the apparent magnitude of asteroids. We cover some more conceptual topics in the next article and then we will start with an asteroid related science project, coming with tutorial #20! If you need some information about the magnitude scale in astronomy, I would recommend to go first with my previous article:

Space Science with Python — Bright Dots in the Dark Sky

Part 16 of the tutorial series describes another important basic concept in Space Science: the brightness of objects.

The complex nature of reflections

Did you take a look in the mirror this morning? Probably. But this space science article is not about your perception of yourself; it is about the laws of physics behind it. Plane mirrors and their reflective properties can easily be explained: Entrance Angle of the light = Exit Angle of the light. Done.But in space we do not have mirrors or simple geometries that allow us to compute the brightness of e.g., comets, meteors or asteroids. Most equations in this regard are empirically determined and are only valid within a certain solution space. In this article, we will continue with the topic that started some sessions ago: Asteroids.

#python #space #science #data-science #space-science-with-python

Space Science with Python — Density Estimators in the Sky

Last time

Last week was Asteroid Day! A day that was introduced to remind us that cosmic threats are real … not only for the Dinosaurs, but also in recent decades like the Tunguska event in 1908 or the Meteor of Chelyabinsk in the year 2013.

Observation surveys, follow up measurements, simulations, and so on are required to catalogue and understand our very cosmic vicinity. Currently, there are no larger objects on a direct collision course with our blue planet. However, observational errors propagate through to data and do not allow us to determine the position of an object with 100 % accuracy. The error-bars depend on the number of observations, observational conditions, total observation time, the distance to the object, its movement and brightness and other factors. It is a multi-dimensional error that can only be faced with more and more and even more data.Luckily, 2020 JX1 is a “good” asteroid and the error-bars during the recent fly-by were quite small (considering cosmic scales).But X, Y and Z coordinates do not help us at all … we need to set ecliptic, equatorial or azimuthal coordinates for our telescopes. Further, we have a solution space of Cartesian coordinates. _How can we translate this solution space to a proper ecliptic coordinate system function? _Let’s find out!

Space Science with Python — Space maps

Part 5 of the tutorial series shows how to calculate and understand coordinate systems that are used for all upcoming…

Multidimensional Kernel Density Estimators

scikit-learnis a great resource for data science and machine learning algorithms. The library covers classifications, dimension reduction, as well as feature engineering and also clustering methods. The sophisticated documentation provides examples for miscellaneous use cases: One example covers the application of Kernel Density Estimators (KDEs) in spherical coordinates. Instead of the Euclidean metric, this example uses the so-called Haversine metric that is applied on the longitude and latitude values in radians:

A KDE for ecliptic longitude and latitude coordinates appears suitable: Let’s go.For this tutorial, we use the already introduced libraries numpypandastqdm and maptlotlib. We then load the data that were created last time (the file is also part of the GitHub repository).

#data-science #science #space #space-science-with-python #python

Space Science with Python - Uncertain Movements of an Asteroid

Tunguska 1908

It’s the 30th June 1908. A huge explosion devastated in a short period of time hundreds of square-kilometres in the Russian region of Tunguska. Millions of trees were bend and burnt down in this Siberian region. For the researchers and people who live there, this so-called Tunguska Event was a mystery of unknown cause.

This coloured photo was taken 21 years after the Tunguska Event. The logs point away from a theoretical shock wave direction (right to left). Image from Wikipedia; Credit: Vokrug Sveta

_What happened? _Well, there are several explanations:

  • A gas explosion. A large amount of methane or other gases ignited and caused this event.Another geophysical explanation: A volcanic-like eruption was mistaken for an explosion and devastated everything around the eruption centreAn asteroid or comet entered the Earth’s atmosphere and exploded on its way to the surface. Similar as the Meteor of Chelyabinsk in the year 2013 that had a diameter of only 20 m

Dash cam footage of the Chelyabinsk meteor in Russia. An explosion, several km above the surface caused a shock wave that destroyed doors, gates and windows. Hundreds of people have been injured, but luckily no one died.

The last option is currently the most accepted theory. One assumes that the diameter of this asteroid was between 30 and 70 metres. It shows that even small celestial objects can have a catastrophic environmental impact on our home planet .
To remind us of cosmic hazards the Asteroid Day was introduced a few years ago. The date: 30th June — The day of the Tunguska Event.

#python #data-science #space-science-with-python #science #space