Commit 3cb21670 authored by Vigeesh Gangadharan's avatar Vigeesh Gangadharan
Browse files

multi maps done

parent 45eeaff3
Pipeline #2911 passed with stage
in 5 minutes and 21 seconds
......@@ -212,9 +212,6 @@ def vfisv(
vfisv_data = VFISVpackage(path, id, line, width)
print(vfisv_data.SI.dtype,vfisv_data.line_props,vfisv_data.map_props)
#sys.exit()
# Spawn jobs to the grisinv:master+slaves
pycomm = MPI.COMM_SELF.Spawn(get_executable(), maxprocs=numproc)
......@@ -282,8 +279,6 @@ def vfisv(
data, sifit, sqfit, sufit, svfit, vfisv_data
)
print('here',np.shape(inv_data['inte']),np.shape(stokes_data['Stokes_I']))
# change the vfisv_data to a header list here and pass the header for return
header = make_header(vfisv_data)
......@@ -335,18 +330,12 @@ class FitsCardGroup:
def get_imap_list(vfisv_params):
"""Get the imap number as a list corresponding to the sorted filenames"""
if vfisv_params.header['INSTRUME'] == 'GRIS':
return (vfisv_params.imap - 1).astype("int")
elif vfisv_params.header['INSTRUME'] == 'GRIS-IFU':
return int(vfisv_params.imap - 1)#.astype("int")
return (vfisv_params.imap - 1).astype("int")
def get_istep_list(vfisv_params):
"""Get the istep number as a list corresponding to the sorted filenames"""
return (vfisv_params.istep - 1).astype("int")
def get_result_shape_slit(vfisv_params):
"""Get the shape of the data"""
......@@ -356,7 +345,6 @@ def get_result_shape_slit(vfisv_params):
return [nmaps, nlength, nsteps]
def get_result_shape_ifu(vfisv_params):
"""Get the shape of the data"""
......@@ -366,8 +354,6 @@ def get_result_shape_ifu(vfisv_params):
return [nmaps, nlength, nsteps]
def get_stokes_shape(vfisv_params):
"""Get the shape of the data"""
......@@ -378,6 +364,15 @@ def get_stokes_shape(vfisv_params):
return [nmaps, nlength, nsteps, nwave]
def get_stokes_shape_ifu(vfisv_params):
"""Get the shape of the data"""
nmaps = vfisv_params.header["NMAPS"]
nsteps = vfisv_params.header["NAXIS1"]
nwave = vfisv_params.NUMW
nlength = vfisv_params.header["NAXIS2"]
return [nmaps, nlength, nsteps, nwave]
def get_quantity(data, vfisv_params, index: int, units=Unit.dimensionless_unscaled):
"""
......@@ -409,28 +404,25 @@ def get_quantity(data, vfisv_params, index: int, units=Unit.dimensionless_unscal
# Get the slit step ordering
isteps = get_istep_list(vfisv_params)
# the lx_range is the range the filenames are ordered.
lx_range = np.arange(vfisv_params.LX)
# reorder according to imap and istep.
# TODO: Check for the flip that is caused while reading the fits file
if vfisv_params.header['INSTRUME'] == 'GRIS':
# the lx_range is the range the filenames are ordered.
lx_range = np.arange(vfisv_params.LX)
# Get the shape for the output
data_shape = get_result_shape_slit(vfisv_params)
# initialize the empty numpy array
quantity = np.zeros(data_shape)
# print('GRIS')
# distribute data into maps from the requested index
quantity[imaps, :, isteps] = data[lx_range, ::-1, index]
elif vfisv_params.header['INSTRUME'] == 'GRIS-IFU':
# print('GRIS-IFU')
# Get the shape for the output
data_shape = get_result_shape_ifu(vfisv_params)
# initialize the empty numpy array
quantity = np.zeros(data_shape)
quantity[imaps, :, :] = data[:, :, index].T
#quantity[imaps, :, isteps] = data[lx_range, ::-1, index]
#print('here',data_shape, np.shape(data),np.shape(quantity))
# distribute data into maps from the requested index
for i_map in np.arange(vfisv_params.header['NMAPS']):
quantity[i_map, :, :] = data[i_map*vfisv_params.header['NAXIS1']:vfisv_params.header['NAXIS1']*(i_map+1), :, index].T
return quantity * units
......@@ -461,29 +453,28 @@ def get_stokes_fits(data, vfisv_params):
# Get the slit step ordering
isteps = get_istep_list(vfisv_params)
# the lx_range is the range the filenames are ordered.
lx_range = np.arange(vfisv_params.LX)
# reorder according to imap and istep.
# TODO: Check for the flip that is caused while reading the fits file
# quantity[imaps, :, isteps, :] = data[lx_range, ::-1, :]
if vfisv_params.header['INSTRUME'] == 'GRIS':
lx_range = np.arange(vfisv_params.LX)
# Get the shape for the output
data_shape = get_stokes_shape(vfisv_params)
# initialize the empty numpy array
quantity = np.zeros(data_shape)
# print('GRIS')
quantity[imaps, :, isteps, :] = data[lx_range, ::-1, :]
elif vfisv_params.header['INSTRUME'] == 'GRIS-IFU':
# print('GRIS-IFU')
data_shape = get_result_shape_ifu(vfisv_params)
data_shape = get_stokes_shape_ifu(vfisv_params)
# initialize the empty numpy array
quantity = np.zeros(data_shape)
quantity = data[:, ::-1, :]
for i_map in np.arange(vfisv_params.header['NMAPS']):
quantity[i_map, ...] = np.einsum("ijk->jik",data[
i_map * vfisv_params.header['NAXIS1']:vfisv_params.header['NAXIS1'] * (i_map + 1),
...])
return quantity
def process_vfisv_output(data, sifit, sqfit, sufit, svfit, vfisv_params):
"""
......@@ -1091,7 +1082,10 @@ def create_map(
fig.suptitle(title)
# set lon_lat axis
set_axis_lon_lat(ax, grid=grid)
if header['INSTRUME']=='GRIS':
set_axis_lon_lat(ax, grid=grid)
elif header['INSTRUME']=='GRIS-IFU':
set_axis_lon_lat(ax, grid=grid, spacing = 50 * Unit.arcsec)
# additonal axis
set_additional_axis(ax, header)
......@@ -1187,7 +1181,7 @@ def plot_image(
# create the title string
title = (
f"GRIS Inversions - {header['WAVE_STR']} {header['WAVELNTH']}"
f"{header['INSTRUME']} Inversions - {header['WAVE_STR']} {header['WAVELNTH']}"
+ " $\AA$\n"
+ header["POINT_ID"]
)
......@@ -1357,7 +1351,7 @@ def switch_coordinates(lon, lat, canvas):
canvas.draw()
def set_axis_lon_lat(ax, grid=None):
def set_axis_lon_lat(ax, grid=None,spacing=5 * Unit.arcsec):
"""Format the Longitude and Latitude axes"""
# get the longitude and latitude
lon = ax.coords["hpln"]
......@@ -1368,8 +1362,8 @@ def set_axis_lon_lat(ax, grid=None):
lat.set_axislabel("HPLT-TAN")
# set the ticks for the longitude and latitude
lon.set_ticks(spacing=5 * Unit.arcsec, color="dimgray")
lat.set_ticks(spacing=5 * Unit.arcsec, color="dimgray")
lon.set_ticks(spacing=spacing, color="dimgray")
lat.set_ticks(spacing=spacing, color="dimgray")
# draw the figure
canvas = ax.figure.canvas
......@@ -1621,18 +1615,10 @@ class VFISVpackage:
self.nmaps = self.header["NMAPS"] # Number of maps
self.nsteps = self.header["NSTEPS"] # Number of steps per map
if self.header['INSTRUME']=='GRIS':
#print('GRIS')
self.LX = len(self.filenames) # Number of slits
elif self.header['INSTRUME']=='GRIS-IFU':
#print('GRIS-IFU')
self.LX = self.header["NAXIS1"] # width
self.LX = self.header["NAXIS1"]*len(self.filenames) # width
self.LY = self.header["NAXIS2"] # Length of the slit
self.LZ = 16 # VFISV data structure
print(self.LX,self.LY)
@staticmethod
def get_line_list():
......@@ -1689,7 +1675,7 @@ class VFISVpackage:
LX = len(self.filenames)
elif self.header['INSTRUME']=='GRIS-IFU':
#print('GRIS-IFU')
LX = self.header['NAXIS1']
LX = self.header['NAXIS1']*len(self.filenames)
self.map_props = np.array(
(
......@@ -1894,17 +1880,17 @@ class VFISVpackage:
# Initialize the Stokes vector and continuum intensity arrays for VFISV
self.SI = np.zeros(
(len(self.filenames),nx, ny, self.pix_end - self.pix_ini + 1),
(len(self.filenames)*nx, ny, self.pix_end - self.pix_ini + 1),
dtype="float32",
)
self.SQ = np.zeros_like(self.SI, dtype="float32")
self.SU = np.zeros_like(self.SI, dtype="float32")
self.SV = np.zeros_like(self.SI, dtype="float32")
self.ICONT = np.zeros([len(self.filenames),nx, ny], dtype="float32")
self.ICONT = np.zeros([len(self.filenames)*nx, ny], dtype="float32")
self.imap = np.ones(len(self.filenames), dtype="int")
self.istep = np.zeros(len(self.filenames), dtype="int")
self.time = np.zeros(len(self.filenames), dtype="datetime64[s]")
self.imap = np.zeros(len(self.filenames)*nx, dtype="int")
self.istep = np.zeros(len(self.filenames)*nx, dtype="int")
self.time = np.zeros(len(self.filenames)*nx, dtype="datetime64[s]")
# # Iterate through the L1 split files/maps
# # for iff in tqdm(
......@@ -1933,15 +1919,16 @@ class VFISVpackage:
+ termcolors.end
+ "{percentage:3.0f}% ({elapsed_s:3.1f}s)",
):
(
self.SI[iff, ...],
self.SQ[iff, ...],
self.SU[iff, ...],
self.SV[iff, ...],
self.ICONT[iff, :],
self.imap[iff],
self.SI[nx*iff:nx*(iff+1), ...],
self.SQ[nx*iff:nx*(iff+1), ...],
self.SU[nx*iff:nx*(iff+1), ...],
self.SV[nx*iff:nx*(iff+1), ...],
self.ICONT[nx*iff:nx*(iff+1), :],
self.imap[nx*iff:nx*(iff+1)],
#self.istep[iff],
self.time[iff],
self.time[nx*iff:nx*(iff+1)],
) = self.read_fits_ifu(self.filenames[iff])
......
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