[yt-users] Code units have not been defined in Flash dataset

Alex Hill ashill at haverford.edu
Fri Jan 27 13:32:15 PST 2017


Hi,

I’ve encountered a new error when specifying a box using units other than code units. This is a Flash 4 plot file in cgs units.

Example:

import yt
yt.__version__

‘3.3.3’

d = yt.load('sn34_smd75_sub1_hdf5_plt_cnt_0030')
b = d.box([-500,-500,-20]*yt.units.pc.in_cgs(),[500,500,20]*yt.units.pc.in_cgs())
fp = yt.PhasePlot(b,'n','pk',['cell_volume'],weight_field=None, fractional=True)

I get the following error:

UnitParseError: Code units have not been defined.
Try creating the array or quantity using ds.arr or ds.quan instead.

If I instead do

b = d.box([-1.54e+21, -1.54e+21, -6.17e+19], [1.54e+21, 1.54e+21, 6.17e+19])

or

left = d.domain_left_edge
right = d.domain_right_edge
left[2] = -6.17e19
right[2] = 6.17e19
b = d.box(left, right)

I do not get any error. If I specify yt.units.cm, I do get the error.

This was not an issue on the same data file a few months ago. I think I have updated yt in the meantime, but I’m not sure what the version was.

Is this a bug, or am I doing something wrong?

Here is the unit registry for my data set:

reg = d.unit_registry

for un in reg.keys():
	if un.startswith('code_'):
		fmt_tup = (un, reg.lut[un][0], str(reg.lut[un][1]))
		print ("Unit name:      {:<15}\nCGS conversion: {:<15}\nDimensions:     {:<15}\n".format(*fmt_tup))

Unit name:      code_magnetic  
CGS conversion: 1.0            
Dimensions:     sqrt((mass))/(sqrt((length))*(time))

Unit name:      code_time      
CGS conversion: 1.0            
Dimensions:     (time)         

Unit name:      code_temperature
CGS conversion: 1.0            
Dimensions:     (temperature)  

Unit name:      code_pressure  
CGS conversion: 1.0            
Dimensions:     (mass)/((length)*(time)**2)

Unit name:      code_mass      
CGS conversion: 1.0            
Dimensions:     (mass)         

Unit name:      code_velocity  
CGS conversion: 1.0            
Dimensions:     (length)/(time)

Unit name:      code_length    
CGS conversion: 1.0            
Dimensions:     (length)       

Unit name:      code_density   
CGS conversion: 1.0            
Dimensions:     (mass)/(length)**3

Unit name:      code_metallicity
CGS conversion: 1.0            
Dimensions:     1              

Cheers,
 Alex


More information about the yt-users mailing list