Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if cocos_and_coords is not None and self.consistency_check and not isinstance(value, ODS):
location = l2o([self.location, key[0]])
ulocation = o2u(location)
# handle cocos transformations going out
if self.cocosio and self.cocosio != self.cocos and '.' in location and ulocation in omas_physics.cocos_signals:
transform = omas_physics.cocos_signals[ulocation]
if transform == '?':
if self.consistency_check == 'warn':
printe('COCOS translation has not been setup: %s' % ulocation)
norm = 1.0
else:
raise ValueError('COCOS translation has not been setup: %s' % ulocation)
else:
norm = omas_physics.cocos_transform(self.cocos, self.cocosio)[transform]
value = value * norm
# get node information
info = omas_info_node(ulocation, imas_version=self.imas_version)
# coordinates interpolation
ods_coordinates, output_coordinates = self.coordsio
if cocos_and_coords and output_coordinates:
all_coordinates = []
coordinates = []
if len(output_coordinates) and 'coordinates' in info:
all_coordinates = list(map(lambda x: u2o(x, self.location), info['coordinates']))
coordinates = list(filter(lambda coord: not coord.startswith('1...'), all_coordinates))
if len(coordinates):
# if all coordinates information is present
if all([coord in output_coordinates and coord in ods_coordinates for coord in coordinates]):
# now that all checks are completed we can assign the structure information
if self.consistency_check and '.code.parameters.' not in location:
ulocation = o2u(location)
# handle cocos transformations coming in
if self.cocosio and self.cocosio != self.cocos and '.' in location and ulocation in omas_physics.cocos_signals and not isinstance(value, ODS):
transform = omas_physics.cocos_signals[ulocation]
if transform == '?':
if self.consistency_check == 'warn':
printe('COCOS translation has not been setup: %s' % ulocation)
norm = 1.0
else:
raise ValueError('COCOS translation has not been setup: %s' % ulocation)
else:
norm = omas_physics.cocos_transform(self.cocosio, self.cocos)[transform]
value = value * norm
# get node information
info = omas_info_node(ulocation, imas_version=self.imas_version)
# handle units (Python pint package)
if str(value.__class__).startswith("
else:
return value[l2o(key[1:])]
except ValueError: # ValueError is raised when nodes have no data
if dynamically_created:
del self[key[0]]
raise
else:
if cocos_and_coords is not None and self.consistency_check and not isinstance(value, ODS):
location = l2o([self.location, key[0]])
ulocation = o2u(location)
# handle cocos transformations going out
if self.cocosio and self.cocosio != self.cocos and '.' in location and ulocation in omas_physics.cocos_signals:
transform = omas_physics.cocos_signals[ulocation]
if transform == '?':
if self.consistency_check == 'warn':
printe('COCOS translation has not been setup: %s' % ulocation)
norm = 1.0
else:
raise ValueError('COCOS translation has not been setup: %s' % ulocation)
else:
norm = omas_physics.cocos_transform(self.cocos, self.cocosio)[transform]
value = value * norm
# get node information
info = omas_info_node(ulocation, imas_version=self.imas_version)
# coordinates interpolation
ods_coordinates, output_coordinates = self.coordsio
if cocos_and_coords and output_coordinates:
for item in omas_sample.__ods__:
setattr(ODS, 'sample_' + item, getattr(omas_sample, item))
except ImportError as _excp:
printe('OMAS sample function are not available: ' + repr(_excp))
raise
# --------------------------------------------
# import physics functions and add them as ODS methods
# --------------------------------------------
try:
from . import omas_physics
from .omas_physics import *
__all__.append('omas_physics')
__all__.extend(omas_physics.__all__)
for item in omas_physics.__ods__:
setattr(ODS, 'physics_' + item, getattr(omas_physics, item))
except ImportError as _excp:
printe('OMAS physics function are not available: ' + repr(_excp))
# --------------------------------------------
# import plotting functions and add them as ODS methods
try:
# --------------------------------------------
from . import omas_plot
__all__.append('omas_plot')
for item in omas_plot.__ods__:
setattr(ODS, 'plot_' + item, getattr(omas_plot, item))
except ImportError as _excp:
printe('OMAS plotting function are not available: ' + repr(_excp))
__all__.append('omas_sample')
for item in omas_sample.__ods__:
setattr(ODS, 'sample_' + item, getattr(omas_sample, item))
except ImportError as _excp:
printe('OMAS sample function are not available: ' + repr(_excp))
raise
# --------------------------------------------
# import physics functions and add them as ODS methods
# --------------------------------------------
try:
from . import omas_physics
from .omas_physics import *
__all__.append('omas_physics')
__all__.extend(omas_physics.__all__)
for item in omas_physics.__ods__:
setattr(ODS, 'physics_' + item, getattr(omas_physics, item))
except ImportError as _excp:
printe('OMAS physics function are not available: ' + repr(_excp))
# --------------------------------------------
# import plotting functions and add them as ODS methods
try:
# --------------------------------------------
from . import omas_plot
__all__.append('omas_plot')
for item in omas_plot.__ods__:
setattr(ODS, 'plot_' + item, getattr(omas_plot, item))
except ImportError as _excp:
printe('OMAS plotting function are not available: ' + repr(_excp))
# if the value is not an ODS strucutre
if not isinstance(value, ODS):
# convert simple dict of code.parameters to CodeParameters instances
if '.code.parameters' in location and not isinstance(value, CodeParameters) and isinstance(value, (dict, ODS)):
tmp = value
value = CodeParameters()
value.update(tmp)
# now that all checks are completed we can assign the structure information
if self.consistency_check and '.code.parameters.' not in location:
ulocation = o2u(location)
# handle cocos transformations coming in
if self.cocosio and self.cocosio != self.cocos and '.' in location and ulocation in omas_physics.cocos_signals and not isinstance(value, ODS):
transform = omas_physics.cocos_signals[ulocation]
if transform == '?':
if self.consistency_check == 'warn':
printe('COCOS translation has not been setup: %s' % ulocation)
norm = 1.0
else:
raise ValueError('COCOS translation has not been setup: %s' % ulocation)
else:
norm = omas_physics.cocos_transform(self.cocosio, self.cocos)[transform]
value = value * norm
# get node information
info = omas_info_node(ulocation, imas_version=self.imas_version)
# handle units (Python pint package)
if str(value.__class__).startswith("
setattr(ODS, 'sample_' + item, getattr(omas_sample, item))
except ImportError as _excp:
printe('OMAS sample function are not available: ' + repr(_excp))
raise
# --------------------------------------------
# import physics functions and add them as ODS methods
# --------------------------------------------
try:
from . import omas_physics
from .omas_physics import *
__all__.append('omas_physics')
__all__.extend(omas_physics.__all__)
for item in omas_physics.__ods__:
setattr(ODS, 'physics_' + item, getattr(omas_physics, item))
except ImportError as _excp:
printe('OMAS physics function are not available: ' + repr(_excp))
# --------------------------------------------
# import plotting functions and add them as ODS methods
try:
# --------------------------------------------
from . import omas_plot
__all__.append('omas_plot')
for item in omas_plot.__ods__:
setattr(ODS, 'plot_' + item, getattr(omas_plot, item))
except ImportError as _excp:
printe('OMAS plotting function are not available: ' + repr(_excp))
omas_ods_attrs = ['_consistency_check', '_dynamic_path_creation', '_imas_version', 'location', 'structure', '_cocos', '_cocosio', '_coordsio', '_unitsio', '_dynamic']