You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This issue is related to cubewrite refactoring work in #99, where we are extracting the missing_value/fill value modifications into a separate function.
The code is not currently consistent in the way it treats the fill value's type. It first sets a fill value depending on the type of the cube's data, and then writes this to the cube's missing_data attribute:
This means there can be a mismatch between the missing_value and fill_values types. E.g. if the cube.data.dtype is np.float32, then the missing_value will have type float32, while the fill_value supplied to sman.write will use the default python float64 type.
@MartinDix do you know if there are reasons that the type needs to be treated differently in these two places? In terms of turning this part of the code into a separate function and adding unit tests, I think it becomes simpler if we are able to convert both the missing_value and fill_value to match the cube.data.dtype.
The text was updated successfully, but these errors were encountered:
This issue is related to
cubewrite
refactoring work in #99, where we are extracting the missing_value/fill value modifications into a separate function.The code is not currently consistent in the way it treats the fill value's type. It first sets a fill value depending on the type of the cube's data, and then writes this to the cube's
missing_data
attribute:um2nc-standalone/umpost/um2netcdf.py
Lines 331 to 339 in c1a4a54
where the
missing_data
attribute is forced to match the cube data's type.When the
fill_value
is used later as an argument to to thesman.write
function, the same type conversion is not applied, e.g:um2nc-standalone/umpost/um2netcdf.py
Lines 391 to 395 in c1a4a54
This means there can be a mismatch between the
missing_value
andfill_values
types. E.g. if thecube.data.dtype
isnp.float32
, then themissing_value
will have typefloat32
, while thefill_value
supplied tosman.write
will use the default pythonfloat64
type.@MartinDix do you know if there are reasons that the type needs to be treated differently in these two places? In terms of turning this part of the code into a separate function and adding unit tests, I think it becomes simpler if we are able to convert both the
missing_value
andfill_value
to match thecube.data.dtype
.The text was updated successfully, but these errors were encountered: