ComputationalRadiationPhysics / openPMD-converter-GDF

converter between openPMD and GDF
9 stars 2 forks source link

GDF to HDF5 Example not Working? #5

Open ax3l opened 5 years ago

ax3l commented 5 years ago

Hi @KseniaBastrakova,

@ChristopherMayes tries to use the example script and it seems not to work. Can you please assist him? I can confirm the error he reports when trying the examples.

Thanks, Axel

 $python gdf_to_hdf.py examples/example_1.gdf examples/example_1.h5
Destination .hdf directory not specified. Defaulting to examples/example_1.hdf
Converting .gdf to .hdf file
unknown datatype of value
name= b'\x00\x00\x00\x00x\x00\xc5\xb9\xfe\x7f\x00\x00'
type= 32766
size= 2051
unknown datatype of value
name= b'\x00\x00\x00\x00x\x00\xc5\xb9\xfe\x7f\x00\x00'
type= 32766
size= 2051
Traceback (most recent call last):
  File "gdf_to_hdf.py", line 589, in <module>
    main(file_names)
  File "gdf_to_hdf.py", line 584, in main
    converter(gdf_path, hdf_path)
  File "gdf_to_hdf.py", line 577, in converter
    gdf_to_hdf(gdf_file, hdf_file)
  File "gdf_to_hdf.py", line 551, in gdf_to_hdf
    gdf_file_to_hdf_file(gdf_file, hdf_file)
  File "gdf_to_hdf.py", line 487, in gdf_file_to_hdf_file
    add_positionOffset(subparticles_group, size)
  File "gdf_to_hdf.py", line 431, in add_positionOffset
    positionOffset_group = particles_group.require_group('positionOffset')
AttributeError: 'NoneType' object has no attribute 'require_group'
ax3l commented 5 years ago

@ChristopherMayes whats the version of h5py you are using? python -c "import h5py; print(h5py.__version__)"

My software environment:

KseniaBastrakova commented 5 years ago

Thanks for bug report. I could reproduce it. Working on a fix.

ChristopherMayes commented 5 years ago

I have: HDF5: 1.10.4 h5py: 2.9.0 macOS Mojave (latest) python 3.6.8

KseniaBastrakova commented 5 years ago

Fixed

ChristopherMayes commented 5 years ago

It runs, but does not create the output file (test.h5): python gdf_to_hdf.py examples/example_1.gdf test.h5

Also, I had to add .py to the name of the script. The README has: python gdf_to_hdf examples/example_1.gdf examples/example_1.h5

KseniaBastrakova commented 5 years ago

oops) now, it should work

ax3l commented 5 years ago

*now? :)

ChristopherMayes commented 5 years ago

Okay, looks like it works now. And, it works on my own gpt files.

However, it doesn't look like the units are right for momentum. What units are they supposed to be? From what I can tell, momentum/x is being set to gamma*beta_x, which is dimensionless.

MKS units should be kgm/s, with a proper factor to convert p_x = massc_lightgammabeta_x

ax3l commented 5 years ago

How are the origin units in the GDF file again? Are they CGS, Lorentz-Heaviside CGS or something different? Looks like we add proper dimension meta data but don't scale unitSI accordingly yet.

ChristopherMayes commented 5 years ago

GPT normally records relativistic gamma and beta vector components, labeled: G Bx By Bz

Proper momentum/x would be: mass cLight G Bx

For an electron, m_e c = 2.73092449 10^-22 kg m / s

ax3l commented 5 years ago

Excellent, that's just what we have to put in unitSI.

@KseniaBastrakova for particles, the particleName/ group seems to be still missing when I run the GDF to HDF5 converter. Can you please run the validator after adding it to verify?

During convert, we can either keep unitSI to 1.0 and convert each momentum with each given mass, since we copy the data anyway, or we sort out by same-mass to create individual particle species and put m_species c in the unitSI.

KseniaBastrakova commented 5 years ago

Thanks for bug report. I could reproduce it. Working on a fix.

KseniaBastrakova commented 5 years ago

Fixed. I added m_species c in the unitSI. And for parclename/ i implemented classification into electrons, protons and electrons. (As advice by @BeyondEspresso)