Skip to content

Commit

Permalink
Add check for if database_result is None when assigning
Browse files Browse the repository at this point in the history
Can catch missing data from reader (e.g. if a quantity isn't always
produced) if the specific implementation sets missing results to None.
  • Loading branch information
pixelifytica committed Jul 16, 2024
1 parent 96e2145 commit c3bc685
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions indica/readers/abstractreader.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ def get_thomson_scattering(
data = {}
dims = ["t", "channel"]
for quantity in quantities:
if database_results.get(quantity) is None:
continue
data[quantity] = self.assign_dataarray(
instrument,
quantity,
Expand Down Expand Up @@ -205,6 +207,8 @@ def get_ppts(

data = {}
for quantity in quantities:
if database_results.get(quantity) is None:
continue
if "_R" in quantity:
dims = ["t", "R"]
elif "_rho" in quantity:
Expand Down Expand Up @@ -284,6 +288,8 @@ def get_charge_exchange(

data = {}
for quantity in quantities:
if database_results.get(quantity) is None:
continue
if quantity == "spectra" or quantity == "fit":
dims = ["t", "channel", "wavelength"]
else:
Expand Down Expand Up @@ -353,6 +359,8 @@ def get_spectrometer(

data = {}
for quantity in quantities:
if database_results.get(quantity) is None:
continue
if quantity == "spectra":
dims = ["t", "channel", "wavelength"]
else:
Expand Down Expand Up @@ -421,6 +429,8 @@ def get_equilibrium(

data: Dict[str, DataArray] = {}
for quantity in quantities:
if database_results.get(quantity) is None:
continue
if quantity == "psi":
dims = ["t", "z", "R"]
elif quantity in sep_vars:
Expand Down Expand Up @@ -528,6 +538,8 @@ def get_radiation(
data = {}
dims = ["t", "channel"]
for quantity in quantities:
if database_results.get(quantity) is None:
continue
quant_data = self.assign_dataarray(
instrument,
quantity,
Expand Down Expand Up @@ -586,6 +598,8 @@ def get_bremsstrahlung_spectroscopy(
data = {}
dims = ["t"]
for quantity in quantities:
if database_results.get(quantity) is None:
continue
quant_data = self.assign_dataarray(
instrument,
quantity,
Expand Down Expand Up @@ -644,6 +658,8 @@ def get_helike_spectroscopy(

data: dict = {}
for quantity in quantities:
if database_results.get(quantity) is None:
continue
if quantity in ["spectra", "raw_spectra"]:
dims = ["t", "wavelength"]
else:
Expand Down Expand Up @@ -706,6 +722,8 @@ def get_diode_filters(
data: dict = {}
dims = ["t", "channel"]
for quantity in quantities:
if database_results.get(quantity) is None:
continue
quant_data = self.assign_dataarray(
instrument,
quantity,
Expand Down Expand Up @@ -765,6 +783,8 @@ def get_interferometry(
data: dict = {}
dims = ["t"]
for quantity in quantities:
if database_results.get(quantity) is None:
continue
quant_data = self.assign_dataarray(
instrument,
quantity,
Expand Down Expand Up @@ -803,6 +823,8 @@ def get_zeff(

data = {}
for quantity in quantities:
if database_results.get(quantity) is None:
continue
_path: str = database_results[f"{quantity}_records"]
print(_path)
if "global" in _path.lower():
Expand Down

0 comments on commit c3bc685

Please sign in to comment.