File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -502,7 +502,12 @@ def resample(
502
502
raise ValueError ("Number of bins must be positive." )
503
503
504
504
flux = spectrum .flux .value
505
- ucty = spectrum .uncertainty .represent_as (VarianceUncertainty ).array
505
+ if spectrum .uncertainty is not None :
506
+ ucty = spectrum .uncertainty .represent_as (VarianceUncertainty ).array
507
+ ucty_type = type (spectrum .uncertainty )
508
+ else :
509
+ ucty = np .zeros_like (flux )
510
+ ucty_type = VarianceUncertainty
506
511
npix = flux .size
507
512
nbins = npix if nbins is None else nbins
508
513
if wlbounds is None :
@@ -535,8 +540,7 @@ def resample(
535
540
flux_wl [i ] = (bin_edges_pix [i + 1 ] - bin_edges_pix [i ]) * flux [i1 ] * dldx [i1 ]
536
541
ucty_wl [i ] = (bin_edges_pix [i + 1 ] - bin_edges_pix [i ]) * ucty [i1 ] * dldx [i1 ]
537
542
flux_wl = (flux_wl * n ) * spectrum .flux .unit
538
- ucty_wl = VarianceUncertainty (ucty_wl * n ).represent_as (type (spectrum .uncertainty ))
539
-
543
+ ucty_wl = VarianceUncertainty (ucty_wl * n ).represent_as (ucty_type )
540
544
return Spectrum (flux_wl , bin_centers_wav * u .angstrom , uncertainty = ucty_wl )
541
545
542
546
def pix_to_wav (self , pix : MaskedArray | ndarray | float ) -> ndarray | float :
You can’t perform that action at this time.
0 commit comments