gafusion / omas

Ordered Multidimensional Array Structure
http://gafusion.github.io/omas
MIT License
30 stars 15 forks source link

Pad arrays to same length in case of uneven lengths #123

Closed eldond closed 3 years ago

eldond commented 3 years ago

Sometimes, individual channels within a diagnostic system can have independent time bases. This causes calls like ods['langmuir_probes.embedded.:.saturation_current_ion.data'] to fail. It would be more useful to just pad the probes with shorter time histories with NaNs.

Here's a legal ODS that breaks : slicing:

ods = ODS()
ods['langmuir_probes.embedded.0.name'] = '1'
ods['langmuir_probes.embedded.0.position.r'] = 1.235
ods['langmuir_probes.embedded.0.position.z'] = -0.952
ods['langmuir_probes.embedded.0.position.phi'] = 0.0
ods['langmuir_probes.embedded.1.name'] = '2'
ods['langmuir_probes.embedded.1.position.r'] = 1.3
ods['langmuir_probes.embedded.1.position.z'] = -0.99
ods['langmuir_probes.embedded.1.position.phi'] = 0.0
ods['langmuir_probes.embedded.2.name'] = '3'
ods['langmuir_probes.embedded.2.position.r'] = 1.332
ods['langmuir_probes.embedded.2.position.z'] = -1.023
ods['langmuir_probes.embedded.2.position.phi'] = 0.0
  t = ods['langmuir_probes.embedded.0.time'] = np.arange(0.5, 5.72, 0.001)
ods['langmuir_probes.embedded.0.saturation_current_ion.data'] = (
    0.0056 + (t / 5.2) * 1.2 + ((t - 2.3) / 2.4) ** 2 * 0.223 - ((t - 4.15) / 3.5) ** 2 * 0.45
)
t1 = ods['langmuir_probes.embedded.1.time'] = np.arange(0.5, 5.54, 0.001)
ods['langmuir_probes.embedded.1.saturation_current_ion.data'] = (
    -0.01893 + (t1 / 4.9) * 0.025 + ((t1 - 2.7) / 2.35) ** 2 * 0.45 - ((t1 - 3.9) / 3.4) ** 2 * 0.654
)
ods['langmuir_probes.embedded.2.time'] = t
ods['langmuir_probes.embedded.2.potential_plasma.data'] = 0.041 + 0.042 * t - 3.297e-3 * t ** 2
ods['langmuir_probes.embedded.2.potential_floating.data'] = 0.001 + 0.023 * t - 4.121e-6 * t ** 2
ods['langmuir_probes.embedded.2.t_e.data'] = 11.23 + 2.356 * cos(t / 0.789)
ods['langmuir_probes.embedded.2.n_e.data'] = 10.9 + 35.6 / ods['langmuir_probes.embedded.2.t_e.data']