Describe the bug
I can successfully calibrate my double-ended dataset using the ols
solver but not the wls
solver. Here is the double-ended Datastore object:
Sections:
coldprobe ( 9.31 +/- 0.01°C) 16.70 - 18.50
warmprobe ( 6.72 +/- 0.00°C) 12.90 - 14.68 and 913.91 - 915.82
Dimensions: (time: 197, x: 14432)
Coordinates:
* time (time) datetime64[ns] 2020-03-10T04:00:06 ... 2020-03-10T04:10:00
channel int64 1
* x (x) float64 0.068 0.195 0.322 ... 1.834e+03 1.834e+03
cold (x) object dask.array<chunksize=(14432,), meta=np.ndarray>
calibration (x) object dask.array<chunksize=(14432,), meta=np.ndarray>
warm (x) object dask.array<chunksize=(14432,), meta=np.ndarray>
Data variables:
warmprobe (time) float64 dask.array<chunksize=(97,), meta=np.ndarray>
coldprobe (time) float64 dask.array<chunksize=(97,), meta=np.ndarray>
userAcquisitionTimeFW (time) datetime64[ns] 2020-03-10T04:00:06 ... 2020-03-10T04:10:00
userAcquisitionTimeBW (time) datetime64[ns] 2020-03-10T04:00:00 ... 2020-03-10T04:09:54
st (x, time) float64 dask.array<chunksize=(14432, 97), meta=np.ndarray>
ast (x, time) float64 dask.array<chunksize=(14432, 97), meta=np.ndarray>
rst (x, time) float64 1.517e+03 1.52e+03 ... 4.169e+03
rast (x, time) float64 958.5 956.9 ... 2.906e+03 2.908e+03
Attributes:
_sections: coldprobe:\n- !!python/object/apply:builtins.slice\n - 1...
isDoubleEnded: 1
I can successfully execute
double.calibration_double_ended(sections=sections,
store_tmpw='tmpw',
method='ols')
to yield
Sections:
coldprobe ( 9.31 +/- 0.01°C) 16.70 - 18.50
warmprobe ( 6.72 +/- 0.00°C) 12.90 - 14.68 and 913.91 - 915.82
Dimensions: (mc: 50, params1: 14827, time: 197, x: 14432)
Coordinates:
* time (time) datetime64[ns] 2020-03-10T04:00:06 ... 2020-03-10T04:10:00
channel int64 1
* x (x) float64 0.068 0.195 0.322 ... 1.834e+03 1.834e+03
cold (x) object dask.array<chunksize=(14432,), meta=np.ndarray>
calibration (x) object dask.array<chunksize=(14432,), meta=np.ndarray>
warm (x) object dask.array<chunksize=(14432,), meta=np.ndarray>
* mc (mc) int64 0 1 2 3 4 5 6 7 ... 43 44 45 46 47 48 49
Dimensions without coordinates: params1
Data variables:
warmprobe (time) float64 dask.array<chunksize=(97,), meta=np.ndarray>
coldprobe (time) float64 dask.array<chunksize=(97,), meta=np.ndarray>
userAcquisitionTimeFW (time) datetime64[ns] 2020-03-10T04:00:06 ... 2020-03-10T04:10:00
userAcquisitionTimeBW (time) datetime64[ns] 2020-03-10T04:00:00 ... 2020-03-10T04:09:54
st (x, time) float64 dask.array<chunksize=(14432, 97), meta=np.ndarray>
ast (x, time) float64 dask.array<chunksize=(14432, 97), meta=np.ndarray>
rst (x, time) float64 1.517e+03 1.52e+03 ... 4.169e+03
rast (x, time) float64 958.5 956.9 ... 2.906e+03 2.908e+03
gamma float64 444.2
alpha (x) float64 0.007955 0.005639 ... -0.1873 -0.2025
df (time) float64 1.288 1.288 1.287 ... 1.286 1.287
db (time) float64 1.195 1.195 1.196 ... 1.193 1.192
gamma_var float64 2.946
alpha_var (x) float64 7.136e-06 5.804e-06 ... 7.185e-06
df_var (time) float64 3.77e-05 3.77e-05 ... 3.769e-05
db_var (time) float64 3.77e-05 3.77e-05 ... 3.769e-05
tmpf (x, time) float64 dask.array<chunksize=(14432, 97), meta=np.ndarray>
tmpb (x, time) float64 -3.249 -3.983 ... -20.17 -19.99
gamma_mc (mc) float64 444.1 444.7 445.1 ... 442.9 444.6 443.4
df_mc (mc, time) float64 1.288 1.288 1.286 ... 1.284 1.283
db_mc (mc, time) float64 1.194 1.196 1.196 ... 1.19 1.19
alpha_mc (mc, x) float64 0.008277 0.000818 ... -0.1901 -0.2043
tmpw (x, time) float64 dask.array<chunksize=(14432, 97), meta=np.ndarray>
p_val (params1) float64 444.2 1.288 ... -0.1873 -0.2025
Attributes:
_sections: coldprobe:\n- !!python/object/apply:builtins.slice\n - 1...
isDoubleEnded: 1
However, when I use the wls
solver:
double.calibration_double_ended(sections=sections,
store_tmpw='tmpw',
method='wls')
I get the error
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-41-8e89c7f1507f> in <module>
40 double.calibration_double_ended(sections=sections,
41 store_tmpw='tmpw',
---> 42 method='wls')
43
44 print('===========================================')
~/anaconda3/envs/dts-calibration/lib/python3.7/site-packages/dtscalibration/datastore.py in calibration_double_ended(self, sections, st_var, ast_var, rst_var, rast_var, store_df, store_db, store_gamma, store_alpha, store_ta, store_tmpf, store_tmpb, store_tmpw, tmpw_mc_size, store_p_cov, store_p_val, variance_suffix, method, solver, p_val, p_var, p_cov, remove_mc_set_flag, reduce_memory_usage, transient_asym_att_x, fix_gamma, fix_alpha, matching_sections, matching_indices, verbose, **kwargs)
2590 da_random_state=None,
2591 remove_mc_set_flag=remove_mc_set_flag,
-> 2592 reduce_memory_usage=reduce_memory_usage)
2593
2594 elif store_tmpw and method == 'ols':
~/anaconda3/envs/dts-calibration/lib/python3.7/site-packages/dtscalibration/datastore.py in conf_int_double_ended(self, p_val, p_cov, store_ta, st_var, ast_var, rst_var, rast_var, store_tmpf, store_tmpb, store_tmpw, store_tempvar, conf_ints, mc_sample_size, var_only_sections, da_random_state, remove_mc_set_flag, reduce_memory_usage, **kwargs)
3541
3542 else:
-> 3543 st_vari_da = da.from_array(st_vari, chunks=memchunk[1:])
3544
3545 self[k] = (
~/anaconda3/envs/dts-calibration/lib/python3.7/site-packages/dask/array/core.py in from_array(x, chunks, name, lock, asarray, fancy, getitem, meta)
2746
2747 chunks = normalize_chunks(
-> 2748 chunks, x.shape, dtype=x.dtype, previous_chunks=previous_chunks
2749 )
2750
AttributeError: 'NoneType' object has no attribute 'shape'
To Reproduce
Steps to reproduce the behavior:
- Example notebook 11.
- Create a new cell at the end of the notebook after running it
- Insert:
# Just make up some sections. LAFs Copied from a random notebook.
sections = {
'probe1Temperature': [slice(7.5, 17.), slice(70., 80.)], # cold bath
'probe2Temperature': [slice(24., 34.), slice(85., 95.)], # warm bath
}
ds.sections = sections
st_var, resid = ds.variance_stokes(st_label='st')
ast_var, _ = ds.variance_stokes(st_label='ast')
rst_var, _ = ds.variance_stokes(st_label='rst')
rast_var, _ = ds.variance_stokes(st_label='rast')
st_var=st_var,
ast_var=ast_var,
rst_var=rst_var,
rast_var=rast_var,
ds.calibration_double_ended(sections=sections,
st_var=st_var,
ast_var=ast_var,
rst_var=rst_var,
rast_var=rast_var,
store_tmpw='tmpw',
method='wls')
- See error
Expected behavior
I am unsure if I am doing something fundamentally wrong for the wls
method.
Additional context
The ols
method works using the code described in the steps to reproduce.
(edited to refer to example notebook 11)