Skip to content

Commit

Permalink
Minor mods and to decrease complexity and pass linting
Browse files Browse the repository at this point in the history
  • Loading branch information
marcosertoli committed Oct 11, 2023
1 parent 738d75f commit cb7908a
Show file tree
Hide file tree
Showing 4 changed files with 211 additions and 162 deletions.
16 changes: 13 additions & 3 deletions indica/operators/spline_fit_easy.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,14 @@ def fit_profile(
"""Fit a profile"""

def residuals(yknots):
spline = CubicSpline(xknots, yknots, axis=0, bc_type=bc_type,)
spline = CubicSpline(
xknots,
yknots,
axis=0,
bc_type=bc_type,
)
bckc = np.interp(x, xspl, spline(xspl))
residuals = np.sqrt((y - bckc) ** 2 / err ** 2)
residuals = np.sqrt((y - bckc) ** 2 / err**2)
return residuals

yspl = xr.DataArray(
Expand Down Expand Up @@ -76,7 +81,12 @@ def residuals(yknots):
bounds=(lower_bound, upper_bound),
verbose=verbose,
)
spline = CubicSpline(xknots, fit.x, axis=0, bc_type=bc_type,)
spline = CubicSpline(
xknots,
fit.x,
axis=0,
bc_type=bc_type,
)
_yspl = spline(xspl)
except ValueError:
_yspl = np.full_like(xspl, 0.0)
Expand Down
54 changes: 42 additions & 12 deletions indica/readers/available_quantities.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,19 @@
"te": ("temperature", "electrons"),
"chi2": ("chi-squared", "fit"),
},
"get_spectrometer": {"spectra": ("emission", "spectral"),},
"get_spectrometer": {
"spectra": ("emission", "spectral"),
},
"get_charge_exchange": {
# "angf": ("angular_freq", "ion"),
"vtor": ("linear_rotation", "ion"),
"ti": ("temperature", "ion"),
"spectra": ("spectra", "experimental"),
"fit": ("spectra", "fit"),
},
"get_bremsstrahlung_spectroscopy": {"zeff": ("effective_charge", "plasma"),},
"get_bremsstrahlung_spectroscopy": {
"zeff": ("effective_charge", "plasma"),
},
"get_helike_spectroscopy": {
"int_w": ("intensity", "spectral_line"),
"int_k": ("intensity", "spectral_line"),
Expand All @@ -34,8 +38,12 @@
"ti_z": ("temperature", "ions"),
"spectra": ("spectra", "passive"),
},
"get_diode_filters": {"brightness": ("luminous_flux", None),},
"get_interferometry": {"ne": ("density", "electrons"),},
"get_diode_filters": {
"brightness": ("luminous_flux", None),
},
"get_interferometry": {
"ne": ("density", "electrons"),
},
"get_equilibrium": {
"f": ("f_value", "plasma"),
"faxs": ("magnetic_flux_axis", "poloidal"),
Expand All @@ -55,8 +63,12 @@
"wp": ("energy", "plasma"),
"psin": ("poloidal_flux", "normalised"),
},
"get_cyclotron_emissions": {"te": ("temperature", "electrons"),},
"get_radiation": {"brightness": ("luminous_flux", None),},
"get_cyclotron_emissions": {
"te": ("temperature", "electrons"),
},
"get_radiation": {
"brightness": ("luminous_flux", None),
},
"get_astra": {
"f": ("f_value", "plasma"),
"faxs": ("magnetic_flux_axis", "poloidal"),
Expand All @@ -77,10 +89,22 @@
"rbnd": ("major_rad", "separatrix"),
"zbnd": ("z", "separatrix"),
"ipla": ("current", "plasma"),
"upl": ("voltage", "loop",), # Loop voltage V
"wth": ("stored_energy", "equilibrium",),
"wtherm": ("stored_energy", "thermal",),
"wfast": ("stored_energy", "fast",), # Thermal stored energy
"upl": (
"voltage",
"loop",
), # Loop voltage V
"wth": (
"stored_energy",
"equilibrium",
),
"wtherm": (
"stored_energy",
"thermal",
),
"wfast": (
"stored_energy",
"fast",
), # Thermal stored energy
"j_bs": ("current_density", "bootstrap"), # Bootstrap current density,MA/m2
"j_nbi": (
"current_density",
Expand All @@ -104,8 +128,14 @@
"electron",
), # Beam power density to electrons, MW/m3
"qnbi": ("power_density_nbi", "ion"), # Beam power density to ions, MW/m3
"q_oh": ("power_density_ohm", "total",), # Ohmic heating power profile, MW/m3
"q_rf": ("power_density_rf", "electron",), # RF power density to electron,MW/m3
"q_oh": (
"power_density_ohm",
"total",
), # Ohmic heating power profile, MW/m3
"q_rf": (
"power_density_rf",
"electron",
), # RF power density to electron,MW/m3
"sbm": ("particle_source", "nbi"), # Particle source from beam, 10^19/m^3/s
"swall": (
"particle_source",
Expand Down
2 changes: 1 addition & 1 deletion indica/readers/st40reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class ST40Reader(DataReader):
"tws_c": "get_spectrometer",
"ts": "get_thomson_scattering",
}
#TODO: this will not be necessary once the MDS+ standardisation is complete
# TODO: this will not be necessary once the MDS+ standardisation is complete
UIDS_MDS = {
"xrcs": "sxr",
"princeton": "spectrom",
Expand Down
Loading

0 comments on commit cb7908a

Please sign in to comment.