Commit abc70312 authored by Owen Arnold's avatar Owen Arnold
Browse files

Merge branch 'use_astropy' into 'master'

Porting to use astropy from pyfits

See merge request !2
parents af5aeb5e bb5302b9
......@@ -29,7 +29,7 @@ which yields, if installed correctly, something like the following:
Name: wfm-stitching
Version: 0.1.0
Location: ~/virtualenvironments/v20/lib/python2.7/site-packages
Requires: pyfits
Requires: astropy
```
6. You are done, you should be able to import from `wfm_stitching`, i.e.
......
import os.path
import numpy as np
try:
from astropy.io import fits
except ImportError:
import pyfits as fits
from astropy.io import fits
from mantid.simpleapi import SaveNexusProcessed, mtd
from mantid.api import AlgorithmManager as am
......
......@@ -28,7 +28,7 @@ with open(path.join(here, 'README.md'), encoding='utf-8') as f:
setup(
name='wfm_stitching',
version='0.1.0',
version='0.1.1',
description='Tools for Wavelength Frame Multiplication stiching in Mantid',
long_description=long_description,
url='https://git.esss.dk/wedel/wfm_stitching',
......@@ -48,5 +48,5 @@ setup(
],
keywords='neutron scattering, science',
packages=find_packages(),
install_requires=['pyfits'],
install_requires=['astropy'],
)
......@@ -20,8 +20,7 @@
from mantid.simpleapi import LoadAscii, LoadNexus, DeleteWorkspace, CloneWorkspace, \
Divide, ReplaceSpecialValues
from mantid.simpleapi import mtd
import pyfits
from astropy.io import fits
import numpy as np
import math
import os
......@@ -115,15 +114,15 @@ def save_fits_stack(base_path, base_image_name, workspace, pixels=None):
for i in range(0, size_x):
image_2d = stack_y[:, :, i]
header = pyfits.Header([
pyfits.Card('Z_UNIT', workspace_unit, 'Unit of z-axis along stack'),
pyfits.Card('Z_VALUE', x_values[i], 'Value of z-coordinate')])
header = fits.Header([
fits.Card('Z_UNIT', workspace_unit, 'Unit of z-axis along stack'),
fits.Card('Z_VALUE', x_values[i], 'Value of z-coordinate')])
filename = '{}{}.fits'.format(
os.path.sep.join((base_path, base_image_name)),
str(i).rjust(num_digits, '0'))
pyfits.writeto(filename, image_2d, header)
fits.writeto(filename, image_2d, header)
__all__ = ['load', 'normalize', 'save_fits_stack']
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment