Commit 3fa2658b authored by bepinat's avatar bepinat

update

parent 47df8d7c
import numpy as np
from astropy.io import fits
from scipy.interpolate import interp2d
import Tools.tools as tools
class Cube:
"""
Stocks a fits file and determines all parameters like size etc ...
:param string or ndarray filename: path+name of the file, can be a numpy array.
"""
def __init__(self, filename, mask=None):
self.data_rebin = None
if type(filename) is str:
self.header = fits.getheader(filename)
self.data = fits.getdata(filename)
self.length = self.header['NAXIS1']
self.height = self.header['NAXIS2']
self.sizez = self.header['NAXIS3']
self.size = np.array(np.shape(self.data))
self.len = self.length*self.height
self.oversample = 1
if mask is None:
self.mask = np.logical_not(np.isnan(self.data))
else:
self.mask = mask
self.nan_to_num()
# Add for create model without Image's class
if type(filename) is np.ndarray:
self.header = None
self.data = np.nan_to_num(filename)
self.size = np.array(np.shape(self.data))
self.height = self.size[2]
self.length = self.size[1]
self.sizez = self.size[0]
self.len = self.length*self.height
self.oversample = 1
if mask is None:
self.mask = np.logical_not(np.isnan(self.data))
else:
self.mask = mask
self.nan_to_num()
def nan_to_num(self):
"""
Converts 'nan' into 0
"""
self.data = np.nan_to_num(self.data)
def get_size(self):
return self.size
def get_lenght(self):
return self.length
def get_height(self):
return self.height
def set_oversamp(self, oversamp):
self.oversample = oversamp
def get_oversamp(self):
return self.oversample
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