Skip to content

congrid was complaining if last dimension was 1 #1528

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/pro/congrid.pro
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ if (npar lt 2) or (npar gt 4) or KEYWORD_SET(help) then begin
print,' the pixel at (0,[0,[0]]) is clipped to 1/4 size.'
print,' Default is that pixel start (not center) is at index.'
print,' CUBIC=cubic: use a cubic interpolation. -0 to -1. -0.5 is recommended.'
print,' /MINUS_ONE: option will be ignored. MISSING can be used instead.'
print, ' /HELP gives this help.'
print,' NOTE: CONGRID performs a resampling. Does not conserve Fluxes.'
return,''
Expand All @@ -76,6 +75,11 @@ ON_ERROR, 2 ;Return to caller if error
;
ndim = SIZE(t, /N_DIMENSIONS)
dims = SIZE(t, /DIMENSIONS)
; remove spurious dimensions 1:
while dims[ndim-1] eq 1 do begin
ndim--
dims=dims[0:-2]
endwhile
;
if(ndim EQ 0) then MESSAGE, 'Array must have 1, 2, or 3 dimensions.'
if(ndim gt 3) then $
Expand Down
14 changes: 14 additions & 0 deletions testsuite/interactive_tests/test_congrid.pro
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,19 @@ end
;
; ---------------------------------
;
pro test_congrid_last_dimension_1,cumul_errors
catch,problem
if problem ne 0 then begin
BANNER_FOR_TESTSUITE, 'TEST_CONGRID_last_dimension_1', 1, /short
ERRORS_CUMUL, cumul_errors, 1
return
endif
z=indgen(256) & zz=reform(z, 256, 1)
zzz=congrid(zz,100,1)
end
;
; ---------------------------------
;
pro TEST_CONGRID, help=help, noexit=noexit, test=test
;
if KEYWORD_SET(help) then begin
Expand All @@ -153,6 +166,7 @@ TEST_CONGRID_BASIC, cumul_errors, nbp=121, /byte
TEST_CONGRID_ON_IMAGES, cumul_errors
;
TEST_CONGRID_ON_PLOT, cumul_errors
TEST_CONGRID_LAST_DIMENSION_1,cumul_errors
;
; AC 2022-Dec-15 : cleanup of the device + reset color table
;
Expand Down