@@ -43,7 +43,7 @@ def add_gaussian_noise(x: npt.ArrayLike, dx: npt.ArrayLike, seed: int | None = N
4343
4444 # Generate and add noise
4545 rng = np .random .default_rng (seed )
46- noise = rng .normal (0 , std_dev )
46+ noise = rng .normal (0.0 , std_dev )
4747 noisy_data = data + noise
4848
4949 return noisy_data
@@ -120,7 +120,7 @@ def fit_func(x: npt.ArrayLike, b: float) -> npt.ArrayLike:
120120 # Fit both the power and scale
121121
122122 fit_func = line_func
123- init_guess = (linearized_data .y [0 ], 4 )
123+ init_guess = (linearized_data .y [0 ], 4.0 )
124124
125125 param_result , pcov = optimize .curve_fit (
126126 fit_func , linearized_data .x , linearized_data .y , init_guess , sigma = linearized_data .dy
@@ -145,7 +145,7 @@ def ellipse_volume(rp: float, re: float) -> float:
145145 :param re: equatorial radius
146146 :return: volume of the ellipsoid
147147 """
148- return (4 * np .pi / 3 ) * rp * re ** 2
148+ return (4.0 * np .pi / 3.0 ) * rp * re ** 2.0
149149
150150
151151class sizeDistribution :
@@ -160,8 +160,8 @@ def __init__(self, data: Data1D):
160160 self ._ndx_qmax : int = - 1
161161
162162 # MaxEntropy bin parameters
163- self ._diamMin : float = 10
164- self ._diamMax : float = 100000
163+ self ._diamMin : float = 10.0
164+ self ._diamMax : float = 100000.0
165165 self ._nbins : int = 2
166166 self ._logbin : bool = True
167167 self ._bins : np .ndarray | None = None
@@ -508,18 +508,18 @@ def calc_volume_weighted_dist(self, binmag: np.ndarray) -> None:
508508 Calculate the volume weighted distribution.
509509 """
510510 if self .logbin :
511- radbins = np .logspace (np .log10 (self .diamMin ), np .log10 (self .diamMax ), self .nbins + 1 , True ) / 2
511+ radbins = np .logspace (np .log10 (self .diamMin ), np .log10 (self .diamMax ), self .nbins + 1 , True ) * 0.5
512512
513513 else :
514- radbins = np .linspace (self .diamMin , self .diamMax , self .nbins + 1 , True ) / 2
514+ radbins = np .linspace (self .diamMin , self .diamMax , self .nbins + 1 , True ) * 0.5
515515
516516 self .volume_bins = ellipse_volume (self .aspectRatio * radbins , radbins )
517517 self .vbin_diff = np .diff (self .volume_bins )
518- self .volume_bins = self .volume_bins [:- 1 ] + self .vbin_diff / 2
519- self .volume_fraction = binmag * self .volume_bins / (2 * self .vbin_diff )
518+ self .volume_bins = self .volume_bins [:- 1 ] + self .vbin_diff * 0.5
519+ self .volume_fraction = binmag * self .volume_bins / (2.0 * self .vbin_diff )
520520
521521 if self .BinMagnitude_Errs is not None :
522- self .volume_fraction_errs = self .BinMagnitude_Errs * (self .volume_bins / (2 * self .vbin_diff ))
522+ self .volume_fraction_errs = self .BinMagnitude_Errs * (self .volume_bins / (2.0 * self .vbin_diff ))
523523 else :
524524 self .volume_fraction_errs = None
525525
@@ -673,19 +673,19 @@ def calculate_statistics(self, bin_mag: npt.ArrayLike) -> None:
673673 :param bin_mag: list of bin magnitudes from the MaxEnt fits
674674 """
675675 bin_mag = np .asarray (bin_mag )
676- maxent_cdf_array = integrate .cumulative_trapezoid (bin_mag / (2 * self ._binDiff ), 2 * self .bins , axis = 1 )
676+ maxent_cdf_array = integrate .cumulative_trapezoid (bin_mag / (2.0 * self ._binDiff ), 2.0 * self .bins , axis = 1 )
677677 self .BinMag_numberDist = self .BinMagnitude_maxEnt / ellipse_volume (self .aspectRatio * self .bins , self .bins )
678678
679679 rvdist = stats .rv_histogram (
680- (self .BinMagnitude_maxEnt , self ._bin_edges * 2 ), density = True
680+ (self .BinMagnitude_maxEnt , self ._bin_edges * 2.0 ), density = True
681681 ) # volume fraction weighted
682- number_cdf = integrate .cumulative_trapezoid (self .BinMag_numberDist , 2 * self .bins )
682+ number_cdf = integrate .cumulative_trapezoid (self .BinMag_numberDist , 2.0 * self .bins )
683683 self .number_cdf = number_cdf / number_cdf [- 1 ]
684684
685685 self .volumefrac_cdf = np .mean (maxent_cdf_array , axis = 0 ) / np .mean (maxent_cdf_array [:, - 1 ])
686686 self .MaxEnt_statistics ["volume" ] = np .mean (maxent_cdf_array [:, - 1 ])
687687 self .MaxEnt_statistics ["volume_err" ] = np .std (maxent_cdf_array [:, - 1 ])
688- self .MaxEnt_statistics ["mode" ] = 2 * self .bins [np .argmax (self .BinMag_numberDist )] # number density
688+ self .MaxEnt_statistics ["mode" ] = 2.0 * self .bins [np .argmax (self .BinMag_numberDist )] # number density
689689 ndx_med = np .where (self .volumefrac_cdf >= 0.5 )[0 ][0 ]
690- self .MaxEnt_statistics ["median" ] = 2 * self .bins [ndx_med ] # volume fraction weighted Median
690+ self .MaxEnt_statistics ["median" ] = 2.0 * self .bins [ndx_med ] # volume fraction weighted Median
691691 self .MaxEnt_statistics ["mean" ] = rvdist .mean () # volume fraction weighted mean
0 commit comments