From 9e8b954ca23b7e15eaf6b1a2d735fead5e9f3035 Mon Sep 17 00:00:00 2001 From: dvt Date: Wed, 11 Jun 2025 17:04:17 -0500 Subject: [PATCH 1/2] Update ionization_balance_class.py --- colradpy/ionization_balance_class.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/colradpy/ionization_balance_class.py b/colradpy/ionization_balance_class.py index d5afa8b..c553794 100644 --- a/colradpy/ionization_balance_class.py +++ b/colradpy/ionization_balance_class.py @@ -4,21 +4,22 @@ from scipy.interpolate import RectBivariateSpline from colradpy.read_adf11 import * -def interp_rates_adf11(logged_temp,logged_dens,temp,dens,logged_gcr): # y are logged_temp and logged_dens args alongside temp and dens? seems redundant? +def interp_rates_adf11(original_logged_temp, original_logged_dens, new_temp, new_dens, original_logged_gcr): + # changed some variable names to more accurately represent what they are # Dane did some optimization, Curt seemed to cobble this together (Dane optimized just this block of code as a self-contained unit) # parallelization should be implemented if more performance is needed - gcr_arr = np.zeros( (np.shape(logged_gcr)[0],np.shape(logged_gcr)[1],len(temp),len(dens)) ) + new_logged_gcr = np.zeros((*np.shape(original_logged_gcr)[:2], len(new_temp), len(new_dens))) - logged_temp, logged_dens = np.log10(temp), np.log10(dens) # pre-compute to save time + new_logged_temp, new_logged_dens = np.log10(new_temp), np.log10(new_dens) # pre-compute to save time - for i in range(0,np.shape(logged_gcr)[0]): - for j in range(0,np.shape(logged_gcr)[1]): - interp_gcr = RectBivariateSpline(logged_temp, - logged_dens, - logged_gcr[i,j,:,:], + for i in range(0,np.shape(new_logged_gcr)[0]): + for j in range(0,np.shape(new_logged_gcr)[1]): + interp_gcr = RectBivariateSpline(original_logged_temp, + original_logged_dens, + original_logged_gcr[i,j,:,:], ) - gcr_arr[i,j] = interp_gcr(logged_temp, logged_dens) # array size matching works when Dane tests it - return 10**gcr_arr + new_logged_gcr[i,j] = interp_gcr(new_logged_temp, new_logged_dens) # array size matching works when Dane tests it + return 10**new_logged_gcr class ionization_balance(): From bf371015010722960cf9e83dd20469748adb44a4 Mon Sep 17 00:00:00 2001 From: dvt Date: Thu, 26 Jun 2025 14:46:17 -0500 Subject: [PATCH 2/2] Update ionization_balance_class.py Fix variable names in interp_rates_adf11 to original names --- colradpy/ionization_balance_class.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/colradpy/ionization_balance_class.py b/colradpy/ionization_balance_class.py index c553794..13d3f23 100644 --- a/colradpy/ionization_balance_class.py +++ b/colradpy/ionization_balance_class.py @@ -4,19 +4,20 @@ from scipy.interpolate import RectBivariateSpline from colradpy.read_adf11 import * -def interp_rates_adf11(original_logged_temp, original_logged_dens, new_temp, new_dens, original_logged_gcr): +def interp_rates_adf11(logged_temp, logged_dens, temp, dens, logged_gcr): # changed some variable names to more accurately represent what they are - # Dane did some optimization, Curt seemed to cobble this together (Dane optimized just this block of code as a self-contained unit) - # parallelization should be implemented if more performance is needed - new_logged_gcr = np.zeros((*np.shape(original_logged_gcr)[:2], len(new_temp), len(new_dens))) + # logged_ indicates the INITIAL grid of values, also is log base 10'd + # absence of logged_ indicates the grid to INTERPOLATE onto, also is the straight value (not log base 10'd) + # Dane sped up array processing, parallelization should be implemented if more performance is needed + new_logged_gcr = np.zeros((*np.shape(logged_gcr)[:2], len(temp), len(dens))) - new_logged_temp, new_logged_dens = np.log10(new_temp), np.log10(new_dens) # pre-compute to save time + new_logged_temp, new_logged_dens = np.log10(temp), np.log10(dens) # pre-compute to save time for i in range(0,np.shape(new_logged_gcr)[0]): for j in range(0,np.shape(new_logged_gcr)[1]): - interp_gcr = RectBivariateSpline(original_logged_temp, - original_logged_dens, - original_logged_gcr[i,j,:,:], + interp_gcr = RectBivariateSpline(logged_temp, + logged_dens, + logged_gcr[i,j,:,:], ) new_logged_gcr[i,j] = interp_gcr(new_logged_temp, new_logged_dens) # array size matching works when Dane tests it return 10**new_logged_gcr