Skip to content

Commit c27f0de

Browse files
committed
pass kwargs to the header finder so we can choose our frame
1 parent 33cd6ff commit c27f0de

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

spectral_cube/cube_utils.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,7 @@ def bunit_converters(obj, unit, equivalencies=(), freq=None):
752752
# Slice along first axis to return a 1D array.
753753
return factors[0]
754754

755-
def combine_headers(header1, header2):
755+
def combine_headers(header1, header2, **kwargs):
756756
'''
757757
Given two Header objects, this function returns a fits Header of the optimal wcs.
758758
@@ -779,7 +779,8 @@ def combine_headers(header1, header2):
779779
s2 = w2.array_shape
780780

781781
# Get the optimal wcs and shape for both fields together
782-
wcs_opt, shape_opt = find_optimal_celestial_wcs([(s1, w1), (s2, w2)], auto_rotate=False)
782+
wcs_opt, shape_opt = find_optimal_celestial_wcs([(s1, w1), (s2, w2)], auto_rotate=False,
783+
**kwargs)
783784

784785
# Make a new header using the optimal wcs and information from cubes
785786
header = header1.copy()
@@ -791,7 +792,7 @@ def combine_headers(header1, header2):
791792
header['WCSAXES'] = 3
792793
return header
793794

794-
def mosaic_cubes(cubes, spectral_block_size=100, **kwargs):
795+
def mosaic_cubes(cubes, spectral_block_size=100, header_kwargs={}, **kwargs):
795796
'''
796797
This function reprojects cubes onto a common grid and combines them to a single field.
797798
@@ -813,7 +814,7 @@ def mosaic_cubes(cubes, spectral_block_size=100, **kwargs):
813814

814815
# Create a header for a field containing all cubes
815816
for cu in cubes[1:]:
816-
header = combine_headers(header, cu.header)
817+
header = combine_headers(header, cu.header, **header_kwargs)
817818

818819
# Prepare an array and mask for the final cube
819820
shape_opt = (header['NAXIS3'], header['NAXIS2'], header['NAXIS1'])
@@ -824,11 +825,16 @@ def mosaic_cubes(cubes, spectral_block_size=100, **kwargs):
824825
# Reproject cubes to the header
825826
try:
826827
if spectral_block_size is not None:
827-
cube_repr = cube.reproject(header, block_size=[spectral_block_size, cube.shape[1], cube.shape[2]], **kwargs)
828+
cube_repr = cube.reproject(header,
829+
block_size=[spectral_block_size,
830+
cube.shape[1],
831+
cube.shape[2]],
832+
**kwargs)
828833
else:
829834
cube_repr = cube.reproject(header, **kwargs)
830835
except TypeError:
831-
warnings.warn("The block_size argument is not accepted by `reproject`. A more recent version may be needed.")
836+
warnings.warn("The block_size argument is not accepted by `reproject`. "
837+
"A more recent version may be needed.")
832838
cube_repr = cube.reproject(header, **kwargs)
833839

834840
# Create weighting mask (2D)

0 commit comments

Comments
 (0)