-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmuse_tools_mora_test.py
96 lines (69 loc) · 2.34 KB
/
muse_tools_mora_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import astropy.io.fits as pyfits
import sys,os,string
import numpy as np
def MUSE_delta_pix(cubo):
header=pyfits.getheader(cubo)
return(header['CD3_3'])
##################################
def MUSE_lamda_inicial(cubo):
header=pyfits.getheader(cubo)
return(header['CRVAL3'])
################################
def MUSE_SIZE_xyz(cubo):
"""muestra tama~No del CUBO x,y,z
"""
imagen=pyfits.getdata(cubo,header=False)
z_dim,y_dim,x_dim=imagen.shape
return(x_dim,y_dim,z_dim)
##############################################
def MUSE_READ(cubo):
""" lee MUSE CUBO (solo el DAT) y lo deja en memoria y header
"""
imagen=pyfits.getdata(cubo,header=False)
header=pyfits.getheader(cubo)
return(imagen,header)
#######################################
def MUSE_lee_spectra(cubo,x,y):
""" LEE un spaxel como spectra
"""
imagen=pyfits.getdata(cubo,header=False)
header=pyfits.getheader(cubo)
z_dim,y_dim,x_dim=imagen.shape
LAMBDA=np.arange(1,z_dim+1)*header['CD3_3']+header['CRVAL3']
FLUX=imagen[:,y,x]
return(LAMBDA,FLUX)
##########################################
def MUSE_lee_slide(cubo,pixel):
""" LEE un slide del cubo
"""
imagen=pyfits.getdata(cubo,header=False)
header=pyfits.getheader(cubo)
z_dim,y_dim,x_dim=imagen.shape
data_cube=imagen[pixel-1,:,:]
return(data_cube)
########################################
def MUSE_to_xy_lambda_flux(cubo):
"""Lee cubo (DAT) y entrega array de lambda y cubo (cuentas,eje y, eje x)
"""
imagen=pyfits.getdata(cubo,header=False)
header=pyfits.getheader(cubo)
z_dim,y_dim,x_dim=imagen.shape
LAMBDA=np.arange(1,z_dim+1)*header['CD3_3']+header['CRVAL3']
return(LAMBDA,imagen)
#############################################
def MUSE_lambda(cubo):
imagen=pyfits.getdata(cubo,header=False)
header=pyfits.getheader(cubo)
z_dim,y_dim,x_dim=imagen.shape
LAMBDA=np.arange(1,z_dim+1)*header['CD3_3']+header['CRVAL3']
return(LAMBDA)
#############################################
def array_map(i,j):
""" Creates an x,y array for map function and thus avoid loops
use:
p,q=array_map(y_dim,x_dim)
"""
tmp= [(x, y) for x in range(int(j)) for y in range(int(i)) ]
p,q=np.asarray(tmp).reshape(-1,2).T
#p,q=np.asarray(tmp).reshape(-1,2).T
return(p,q)