Skip to content

Commit

Permalink
Handle no good points for rest wavelengths on a side for #136
Browse files Browse the repository at this point in the history
  • Loading branch information
mgalloy committed Feb 6, 2024
1 parent 961e861 commit dc95f64
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/level2/comp_compute_rest_wavelength.pro
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@ function comp_compute_rest_wavelength, primary_header, $
velocity, $
intensity, $
line_width, $
method=method, $
indices=indices
compile_opt strictarr

_method = n_elements(method) eq 0L ? 'median' : method

mask = comp_l2_mask(primary_header)

dims = size(velocity, /dimensions)
Expand All @@ -52,10 +55,18 @@ function comp_compute_rest_wavelength, primary_header, $
east = where(threshold_condition and x lt 0.0, n_east, /null)
west = where(threshold_condition and x gt 0.0, n_west, /null)

if (method eq 'mean') then begin
if (n_east eq 0L && n_west eq 0L) then return, !values.f_nan

if (_method eq 'mean') then begin
if (n_east eq 0L) then return, mean([velocity[west]], /nan)
if (n_west eq 0L) then return, mean([velocity[east]], /nan)

rest_velocity = mean([mean([velocity[east]], /nan), $
mean([velocity[west]], /nan)], /nan)
endif else begin
if (n_east eq 0L) then return, median([velocity[west]])
if (n_west eq 0L) then return, median([velocity[east]])

rest_velocity = mean([median([velocity[east]]), $
median([velocity[west]])], /nan)
endelse
Expand Down

0 comments on commit dc95f64

Please sign in to comment.