skuschel / postpic

The open-source particle-in-cell post-processor.
GNU General Public License v3.0
66 stars 27 forks source link

createField() produces misleading error if simextent=True #238

Closed stetie closed 5 years ago

stetie commented 5 years ago

I'm using the current postpic master 69fbf8c I've loaded a simulation with particles and ms is a MultiSpecies object on a particle species. If I run x = ms.createField('px', 'py') everything works as expected. But x = ms.createField('px', 'py', simextent=True) gives a error message

postpic/datareader/epochsdf.py in simextent(self, axis) 168 extents = m.extents 169 dims = len(m.dims) --> 170 axid = helper.axesidentify[axis] 171 return np.array([extents[axid], extents[axid + dims]]) 172

KeyError: 'px'

which is totally misleading. It took me 1.5h and a hint from @Ablinne to figure out that the simextent option is incompatible with the new interface. I strongly suggest that either simextent is ignored if it's used with incompatible options, or at the very least a sensible error message should be provided to the user.

skuschel commented 5 years ago

Thanks for the report! I will need to investigate and fix or remove it, but not during the next few weeks.

skuschel commented 5 years ago

I was just looking into this and realizing, that the simextent option does not make any sense for px nor py. simextent shall force the created field to match the extent of the simulationbox. But within a PIC only x, y, and z actually have a properly bound domain which is the simulationbox. px, py or pz are unbound. Therefore simextent=True fails to retrieve the min and max values for px. So it actually does what it should. But I agree that the error message is not helpful at all. I need to figure out how to deal with that best. Ideas are welcome!

skuschel commented 5 years ago

@stetie do you think, that #244 is sufficient to close this issue?

stetie commented 5 years ago

@skuschel Yes, that seems like a good solution. Thanks!