Migrating to Lightweaver 1.0
Lightweaver 1.0 renames its public API to PEP 8 snake_case, e.g.
lw.Context(atmos, spect, eqPops, conserveCharge=True) becomes
lw.Context(atmos, spect, eq_pops, conserve_charge=True), and
ctx.activeAtoms becomes ctx.active_atoms.
Your existing scripts will continue working for now. The old names are still accepted, and emit a LightweaverDeprecationWarning e.g.:
LightweaverDeprecationWarning: `conserveCharge` is deprecated, use
`conserve_charge` instead (it will be removed in a future version of
Lightweaver). Run `python -m lightweaver.migrate <files>` to update scripts
automatically.
Each warning is shown once per line of your code that uses an old name. The old
names will be removed in the future.
Silencing the warnings
To run old scripts without the warnings (to auto-update them, see below), call:
import lightweaver as lw
lw.silence_deprecations()
or equivalently, with the standard library:
import warnings
from lightweaver import LightweaverDeprecationWarning
warnings.filterwarnings('ignore', category=LightweaverDeprecationWarning)
Updating scripts automatically
Lightweaver includes a tool that rewrites scripts to the new names:
python -m lightweaver.migrate my_script.py my_analysis_dir/
By default this only prints a diff of the proposed changes. When you’re happy
with them, modify the files in place with --inplace:
python -m lightweaver.migrate --inplace my_script.py my_analysis_dir/
The tool renames:
keyword arguments in calls to Lightweaver functions, methods and classes
(lw.iterate_ctx_se(ctx, popsTol=1e-3) → pops_tol=1e-3), including
atomic model definitions (LinearCoreExpWings(qCore=..., qWing=...));
attributes (ctx.activeAtoms, atmos.nHTot, update.dJMax);
keys of a Context state dict’s kwargs (sd['kwargs']['eqPops']);
the 'nPrev' key of a time_dependent_data dict passed to
nr_post_update ({'dt': dt, 'nPrev': prev_state}).
It never renames your own variables or functions: eqPops = ... and
def synth(eqPops): ... are left as they are. Attribute renames are applied
to any object, so if your own classes reuse a Lightweaver attribute name (e.g.
self.eqPops), that attribute is renamed consistently too; such renames are
listed in the summary printed at the end for you to review. Formatting and
comments are preserved.
Naming rule
Ordinary camelCase words become snake_case: eqPops → eq_pops,
vlosMu → vlos_mu.
Physics symbols keep their case: JTol → J_tol, dJMax →
dJ_max, phiQ → phi_Q, gammaB → gamma_B.
Element symbols are lowercase: nHTot → nh_tot, hPops →
h_pops, massPerH → mass_per_h.
Names that are only a count or a symbol are unchanged: Nspace,
Nrays, Nthreads, Aji, Gamma, B, T.
Counts with a trailing word keep the N attached to the first word:
NlambdaGen → Nlambda_gen.
NmaxIter (iterate_ctx_se) and maxIter both become max_iter.
Other changes
Subclasses of Lightweaver’s extension points (CollisionalRates,
LineBroadener, BackgroundProvider, BoundaryCondition,
ConvergenceCriteria) that use the old parameter names in their method
signatures keep working, as Lightweaver calls these methods positionally.
The keys of Context.kwargs (and of a state dict’s kwargs) use the new
names. Old keys are still accepted by
Context.construct_from_state_dict_with.
The time_dependent_data dict passed to Context.nr_post_update now
uses the key 'n_prev' (previously 'nPrev'). The old key is still
accepted, with a warning.
Pickled Context objects and state dicts from earlier versions can’t be
loaded. These have only ever been intended as transient caches; recreate them
with the new version.
All renamed names
Old name |
New name |
abundanceData
|
abundance_data
|
abundDex
|
abund_dex
|
activeAtoms
|
active_atoms
|
activeSet
|
active_set
|
activeTrans
|
active_trans
|
activeWavelengths
|
active_wavelengths
|
aDamp
|
a_damp
|
alphaGrid
|
alpha_grid
|
atomicAbundance
|
atomic_abundance
|
atomicModel
|
atomic_model
|
atomicPops
|
atomic_pops
|
avgMass
|
avg_mass
|
backgroundProvider
|
background_provider
|
barklemVals
|
barklem_vals
|
blueIdx
|
blue_idx
|
chiB
|
chi_B
|
chiIn
|
chi_in (no deprecated alias)
|
chunkSize
|
chunk_size
|
computeDiff
|
compute_diff (no deprecated alias)
|
configPath
|
config_path
|
conserveCharge
|
conserve_charge
|
convertScales
|
convert_scales
|
cosGamma
|
cos_gamma
|
crswCallback
|
crsw_callback
|
crswDone
|
crsw_done
|
cStark23
|
c_stark_23
|
deltaLambda
|
delta_lambda
|
depthData
|
depth_data
|
depthScale
|
depth_scale
|
detailedAtomPrd
|
detailed_atom_prd
|
detailedAtoms
|
detailed_atoms
|
detailedStaticSet
|
detailed_static_set
|
dJMax
|
dJ_max
|
dJMaxIdx
|
dJ_max_idx
|
dJPrdMax
|
dJ_prd_max
|
dJPrdMaxIdx
|
dJ_prd_max_idx
|
dNeMax
|
dne_max
|
dNeMaxIdx
|
dne_max_idx
|
dPops
|
dpops
|
dPopsMax
|
dpops_max
|
dPopsMaxIdx
|
dpops_max_idx
|
dRho
|
drho
|
dRhoMax
|
drho_max
|
dRhoMaxIdx
|
drho_max_idx
|
electronExp
|
electron_exp
|
elementCount
|
element_count
|
eqcCoeffs
|
eqc_coeffs
|
eqPops
|
eq_pops
|
etaIn
|
eta_in (no deprecated alias)
|
extendGridNm
|
extend_grid_nm
|
extraParams
|
extra_params
|
extraWavelengths
|
extra_wavelengths
|
fdCollisionRates
|
fd_collision_rates
|
filePath
|
file_path
|
fillDiagonal
|
fill_diagonal
|
fixCollisionalRates
|
fix_collisional_rates
|
formalSolver
|
formal_solver
|
formationTempRange
|
formation_temp_range
|
fsIterScheme
|
fs_iter_scheme
|
fsIterSchemeProperties
|
fs_iter_scheme_properties (no deprecated alias)
|
gammaB
|
gamma_B
|
gLandeEff
|
g_lande_eff
|
HminPops
|
hmin_pops
|
hOnly
|
h_only
|
hPops
|
h_pops
|
hydrogenExp
|
hydrogen_exp
|
hydrogenPops
|
hydrogen_pops
|
iLevel
|
i_level
|
implLibs
|
impl_libs
|
inConstructor
|
in_constructor (no deprecated alias)
|
indexVector
|
index_vector
|
initSol
|
init_sol
|
initVal
|
init_val
|
interpFn
|
interp_fn
|
ionPot
|
ion_pot
|
isotopeProportions
|
isotope_proportions
|
jLevel
|
j_level
|
JTol
|
J_tol
|
JUpdate
|
J_update
|
kuruczPfPath
|
kurucz_pf_path
|
lambdaEdge
|
lambda_edge
|
lambdaIterate
|
lambda_iterate
|
lambdaReference
|
lambda_reference
|
logG
|
log_g
|
lowerBc
|
lower_bc
|
lowerThreshold
|
lower_threshold
|
lsCoupling
|
LS_coupling
|
massData
|
mass_data
|
massPerH
|
mass_per_h
|
maxIter
|
max_iter
|
maxPrdSubIter
|
max_prd_sub_iter
|
minLambda
|
min_lambda
|
minWavelength
|
min_wavelength
|
modelPops
|
model_pops
|
molecularPops
|
molecular_pops
|
molecularTable
|
molecular_table
|
nameMapping
|
name_mapping
|
nEff
|
n_eff
|
ngAccelerated
|
ng_accelerated
|
ngOptions
|
ng_options
|
ngUpdate
|
ng_update
|
nHTot
|
nh_tot
|
NlambdaGen
|
Nlambda_gen
|
nlteStartingPops
|
nlte_starting_pops
|
NmaxIter
|
max_iter
|
NprdSubIter
|
Nprd_sub_iter
|
NprdTrans
|
Nprd_trans
|
nrHOnly
|
nr_h_only
|
nStar
|
n_star
|
nTotal
|
n_total
|
outUnits
|
out_units
|
overlyingContinuumLevel
|
overlying_continuum_level
|
passiveAtoms
|
passive_atoms
|
passiveSet
|
passive_set
|
PeTop
|
Pe_top
|
pfCoeffs
|
pf_coeffs
|
phiQ
|
phi_Q
|
phiU
|
phi_U
|
phiV
|
phi_V
|
popsOnly
|
pops_only
|
popsTol
|
pops_tol
|
popsUpdate
|
pops_update
|
prdIterTol
|
prd_iter_tol
|
prdUpdate
|
prd_update
|
preserveProfiles
|
preserve_profiles
|
prevNeRatio
|
prev_ne_ratio
|
prevSpect
|
prev_spect
|
prevState
|
prev_state
|
prevTimePops
|
prev_time_pops
|
printInterval
|
print_interval
|
psiQ
|
psi_Q
|
psiU
|
psi_U
|
psiV
|
psi_V
|
pyAtmos
|
py_atmos
|
qCore
|
q_core
|
qWing
|
q_wing
|
radiativeRates
|
radiative_rates
|
radSet
|
rad_set
|
redIdx
|
red_idx
|
refinePrd
|
refine_prd
|
reproduceOldRHBug
|
reproduce_old_RH_bug
|
returnCtx
|
return_ctx
|
returnFinalConvergence
|
return_final_convergence
|
rhoPrd
|
rho_prd
|
rhoTol
|
rho_tol
|
scaIn
|
sca_in (no deprecated alias)
|
sortedAtoms
|
sorted_atoms
|
specInt
|
spec_int
|
tauRef
|
tau_ref
|
temperatureExp
|
temperature_exp
|
tempRange
|
temp_range
|
timeDependentData
|
time_dependent_data
|
toObs
|
to_obs
|
totalAbundance
|
total_abundance
|
transId
|
trans_id
|
transModel
|
trans_model
|
transWavelengths
|
trans_wavelengths
|
update_lte_atoms_Hmin_pops
|
update_lte_atoms_hmin_pops
|
update_nTotal
|
update_n_total
|
updateBcs
|
update_bcs
|
updatedJ
|
updated_J
|
updatedJPrd
|
updated_J_prd
|
updatedNe
|
updated_ne
|
updatedPops
|
updated_pops
|
updatedRho
|
updated_rho
|
updateJ
|
update_J
|
updateTotals
|
update_totals
|
upOnly
|
up_only
|
upperBc
|
upper_bc
|
vBroad
|
v_broad
|
vlosMu
|
vlos_mu
|
vMicroChar
|
v_micro_char
|
vRel35H
|
v_rel_35_h
|
vRel35He
|
v_rel_35_he
|
warmUp
|
warm_up
|
wavelengthGrid
|
wavelength_grid
|
writeConfig
|
write_config
|
xLowerBc
|
x_lower_bc
|
xUpperBc
|
x_upper_bc
|
yLowerBc
|
y_lower_bc
|
yUpperBc
|
y_upper_bc
|
zLowerBc
|
z_lower_bc
|
zUpperBc
|
z_upper_bc
|