#7 Hdf5 writing added.#14
Conversation
| # Define function to get variable name as string | ||
| def get_name(var): | ||
| import itertools | ||
| return [tpl[0] for tpl in | ||
| itertools.ifilter(lambda x: var is x[1], globals().items())][0] | ||
|
|
There was a problem hiding this comment.
This might be dangerous to identify an array based on its values (and size). For numpy arrays this might be a better solution: https://stackoverflow.com/questions/34980833/python-name-of-np-array-variable-as-string Should test and implement if ok.
|
|
||
| growthRate = density[i]*eng.extractGrowthRate(o) | ||
| runawayDensity = density[i]*eng.extractFraction(o) | ||
| runawayCurrent = runawayDensity * 1.6e-19 * 3e8 * np.sign(E_parallel[i]) |
There was a problem hiding this comment.
Constants should be defined in the object. Later these can be easily replaced by ITM constants.
| runaway_current = np.array(runaway_current).reshape(1,rho_size) | ||
|
|
||
| # Write data to hdf5 file | ||
| hdf5Write.write(shot, run, temperature.reshape(1,rho_size), get_name(temperature), density, get_name(density), rhoTor, get_name(rhoTor), B0, get_name(B0), Z_eff, get_name(Z_eff), EHat, get_name(EHat), E_parallel, get_name(E_parallel), E_critical, get_name(E_critical), time, get_name(time), growth_rate, get_name(growth_rate), runaway_density, get_name(runaway_density), runaway_current, get_name(runaway_current)) No newline at end of file |
There was a problem hiding this comment.
distribution and all important outputs should also be saved. The aim is to have a full set of outputs in HDF5.
There was a problem hiding this comment.
Should be done similarly as for the others, but for each rho coordinate there will be a vector (Bigvector in NORSE naming) of distribution and the coordinates instead of a single number like for the other parameters. I will have to find a way to do this.
| # Written by Soma Olasz | ||
| # | ||
| # This function is created to write data to hdf5 file. | ||
|
|
There was a problem hiding this comment.
Should explore the use of standard headers, like:
# -*- coding: utf-8 -*-
"""
Created on Mon Aug 12 11:45:34 2019
@author: Fehérvári Gergő
"""
There was a problem hiding this comment.
Done for two scripts, the rest will be dealt with separately, when dealing with the relevant issue.
| import pwd | ||
|
|
||
|
|
||
| def write(shotnumber, runnumber, *args): |
There was a problem hiding this comment.
Would be safer from the point of view of data consistency to used a dictionary to pass data and respective names.
The hdf5 writing feature is added to the NORSE actor. If an existing hdf5 file is used, the data is added to the datasets. The modification has been tested in Kepler.