Numpy-style slicing

I’m back from holiday! I needed that!
Anyway, the last major update for cubes is that they now support numpy-style slicing and automatic conversion to other Sunpy types. For example, if you have a lambda-x-y cube (wavelength has priority over spatial coordinates, and time over wavelength), and you do cube[20, :, 10:40], that is an x-y slice, which is automatically converted into a map.if you have a time-lambda-y cube, and you do cube[:, 45, 10], you have a list of intensities at different times for a specified wavelength and point; that becomes a lightcurve!

The old style of converting to other objects – cube.slice_to_map, etc. – is still in place, so you can still send extra arguments to that object’s constructor.

Here’s a breakdown of the available conversions:
-Map when the result is an x-y slice
-Single-curve lightcurve when the only dimension is time and there is a wavelength present
-Multiple-curve lightcurve when one specifies a wavelength and a range of times and y-coordinates
-Spectrogram when the user chooses a time-lambda slice
-Spectrum when there’s a single lambda axis or a lambda and a spatial one. In the latter case, the slice is collapsed to the 1-D spectrum.

Any other conversion returns the raw data, unless the slicing didn’t reduce the number of dimensions, then a reduced cube is returned.



After a week or so of dealing with not-quite-official standards of time in FITS and rewriting large chunks of code to deal with arbitrary dimensions, finally cubes* can be converted into lightcurves!



I still need to tinker with the meta object to have it display the actual units and values instead of just dry numbers, but the main functionality is here!

*I changed the name from spectral_cube to cube because a spectral dimension is no longer necessary. Maybe cube by itself is too bland and ambiguous. Does anyone have a suggestion?

Converting to maps


The sunpy.cube module can now convert cubes to maps! It can convert either a single slice or collapse a given range. Here are some images:

Single Slice conversion


Partial Slab conversion


Full cube collapsed into a map


The artifacts are much more visible in the single slice. Note that that slice is at the center of Fe X’s main spectral line, so quite a lot is going on.

Plotting cubes!

Lately I’ve been working out how to plot the spectral cubes we need. Matplotlib doesn’t have the capability to do that, so I looked at Mayavi, SPy and yt. The only one I could get to work is SPy, but it’s GPL so we won’t be able to use it in SunPy. Still, I managed to get a few pictures, just so we can see we’re going in the right direction:

Spectral Cube at Fe X spectral lines




Another one at He II



And an interesting looking one at Si VII



Creating these s quite easy: after opening the FITS file using, I extracted each block into a 3D numpy ndarray and then used SPy view_cube(data). Sadly there is no way of adding axes, labels, or similar items. 

I also got a slice using matplotlib’s imshow:


I assume the black lines (and black dots on the cubes) are detector artifacts or defects. When using imshow, we have to transpose the array to get an array of x-by-y maps according to wavelength, as opposed to the FITS file’s arrangement of y-by-lambda arrays according to solar-x.

First Week

My firs official week at SOCIS has been very fun. We’re going to be working with the Extreme-ultraviolet Imaging Spectrometer. So far, I’ve been trying to make sense of the files sent out by the satellite. The format is perfectly standard FITS, and can access all of the data – except multi-line comments – without a hitch. The problem is that the structuring of the data is confusing, and a lot of the metadata is either missing or obviously incorrect.

EIS’s FITS files are in binary table format, in a 2D 101-row by 31-column format. Each cell can be anything, even another table. The last 20 columns are metadata, and the first 11 columns are the actual data. Each column is centered along a certain wavelength, and each row is a different solar-x coordinate. Each cell is a 72 x 512 table that varies across 72 wavelengths and gives 512 y-coordinates. This means that astropy’s spectral_cube can’t directly open the data, but we have to convert it into an ndarray. We could generalize spectral_cube and PR to their repository, but given EIS’s nonstandard organization of data in a standard format that is unlikely to help them, and we’d be better off by just sending things to SunPy. However, if we do end up using spectral_cube we would have to either add a requirement or copy all of their files into sunpy’s repository.

Next week I’ll find someone who can confirm that this is, in fact, how the data is structured. I’ll define the object’s interface and start outlining unit tests. We’ll also see if spectral_cube can satisfactorily display and manipulate the cube.

Windows 8

Yesterday I decided to try out Windows 8.1. I’ve been using Windows 7 for a couple of years now, because Linux’s RAID support is horrible, or at least it was at the time. It’s a lot less annoying than I thought – I went for a clean install instead of upgrading in-place.

The first out-of-the-box impression wasn’t great. My wireless adapter’s driver wasn’t included, which it had been in Windows 7. One RAID 0 drive was recognized instantly at installation, but not the RAID 5 I actually keep my data on*. Still, it includes lots of bloatware in the form of little apps – more on that in a moment – some of which are useful, some of which aren’t, thankfully all of which are easily removed. The weather one in particular seems like a good idea but has some awful shortcomings – I like having weather maps, and although they are not very detailed, they are reasonable for quickly checking weather patterns. Or at least, they would be if they weren’t designed by a child. You can’t zoom out to a view larger than about two thirds of Europe, and you can only view one continent at a time. If you have that restriction, at least take the opportunity to use a reasonable projection, but no, Mercator all the way.

I don’t like the distinction between “programs”, which run on the desktop, and “apps”, which are full screen. The included ones, at least, seem very bare-bones. The Mail app, for example, has no way of setting a signature or enabling desktop notifications. Skype came included, which I thought was nice until I tried logging in – there’s no way to do it if you only have a regular Skype account – you have to uninstall it and then download the “real” one from their website.

That being said, it has some very nice features. Win+Space changes keyboard layout, right-clicking the Start menu offers useful shortcuts, and ISO images can now be mounted natively. File deletion and copying are massively improved – conflicts when copying are saved until the end and finding locked files when deleting stops the whole operation. On the eye candy side of things, I enjoy being able to have different wallpapers on different monitors and having the taskbar natively extended. I still can’t find how to have the time displayed on both taskbars, though.

*As a side note, AMD seems to be unaware that they make products other than GPUs. The downloads section offered a wide selection of video card drivers, but no chipset or RAID drivers. I eventually found them in Gigabyte’s website.

First post

Hi all*, this is my first post! I’m looking forward to working with the SunPy community over the Summer.

I’ll post here occasional updates on my work, so that everybody who wants to know can keep track of the development.

*As of this post, the number of readers is exactly zero.