Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def load_omas_dx(filename, consistency_check=True):
"""
Load ODX from xarray dataset
:param filename: filename or file descriptor to load from
:param consistency_check: verify that data is consistent with IMAS schema
:return: OMAS data xarray
"""
import xarray
DS = xarray.open_dataset(filename)
DS.load()
DS.close()
return ODX(DS)
def load_omas_ds(filename, consistency_check=True):
"""
Load ODS from xarray dataset
:param filename: filename or file descriptor to load from
:param consistency_check: verify that data is consistent with IMAS schema
:return: OMAS data set
"""
import xarray
DS = xarray.open_dataset(filename)
DS.load()
DS.close()
odx = ODX(DS)
ods = odx_2_ods(odx, consistency_check=consistency_check)
return ods
def through_omas_dx(odx, method=['function', 'class_method'][1]):
"""
Test save and load OMAS data xarray via xarray file format
:param ods: OMAS data xarray
:return: OMAS data xarray
"""
filename = omas_testdir(__file__) + '/test.dx'
if method == 'function':
save_omas_dx(odx, filename)
odx1 = load_omas_dx(filename)
else:
odx.save(filename)
odx1 = ODX().load(filename)
return odx1
def ods_2_odx(ods):
'''
Map ODS to an ODX
:param ods: OMAS data set
:return: OMAS data xarray
'''
return ODX(ods.dataset())