UnboundLocalError when running with default clustering parameters, and saveplots = True
KshitijAggarwal opened this issue · comments
Running the pipeline_scan
with the following state on 16A-459_TEST_1hr_000.57633.66130137732.scan7.cut
data:
st = rfpipe.state.State(sdmfile=dataloc, sdmscan=7, inprefs={'dtarr': [1,2,4], 'npix_max': 512, 'gainfile': gainloc, 'saveplots': True, 'savecands': True, 'maxdm': 1000, 'applyonlineflags': False, 'fftmode': 'cuda', 'flaglist': []})
cc = rfpipe.pipeline.pipeline_scan(st)
gives the following error (this error doesn't show up if clustercands
is set in the state):
`2018-10-28 16:27:17,175 - rfpipe.candidates - INFO - Calculating features for 1 candidate.
2018-10-28 16:27:17,181 - rfpipe.candidates - INFO - Saving CandData to /hyrule/data/users/kshitij/rfgpu/cands_16A-459_TEST_1hr_000.57633.66130137732.scan7.cut.7.1.pkl.
UnboundLocalError Traceback (most recent call last)
in
1 start = time.time()
----> 2 cc = rfpipe.pipeline.pipeline_scan(st)
3 end = time.time()
4 print(end-start)
~/anaconda3/envs/rfgpu/lib/python3.6/site-packages/rfpipe-1.1.5-py3.6.egg/rfpipe/pipeline.py in pipeline_scan(st, segments, cfile, vys_timeout)
26 for segment in segments:
27 candcollection += pipeline_seg(st, segment, cfile=cfile,
---> 28 vys_timeout=vys_timeout)
29
30 return candcollection
~/anaconda3/envs/rfgpu/lib/python3.6/site-packages/rfpipe-1.1.5-py3.6.egg/rfpipe/pipeline.py in pipeline_seg(st, segment, cfile, vys_timeout)
37
38 data = source.read_segment(st, segment, timeout=vys_timeout, cfile=cfile)
---> 39 candcollection = prep_and_search(st, segment, data)
40
41 return candcollection
~/anaconda3/envs/rfgpu/lib/python3.6/site-packages/rfpipe-1.1.5-py3.6.egg/rfpipe/pipeline.py in prep_and_search(st, segment, data)
49
50 if st.prefs.fftmode == "cuda":
---> 51 candcollection = search.dedisperse_search_cuda(st, segment, data)
52 elif st.prefs.fftmode == "fftw":
53 candcollection = search.dedisperse_search_fftw(st, segment, data)
~/anaconda3/envs/rfgpu/lib/python3.6/site-packages/rfpipe-1.1.5-py3.6.egg/rfpipe/search.py in dedisperse_search_cuda(st, segment, data, devicenum)
211 if st.prefs.savecands or st.prefs.saveplots:
212 # triggers optional plotting and saving
--> 213 cc = reproduce_candcollection(cc, data)
214
215 candidates.save_cands(st, candcollection=cc)
~/anaconda3/envs/rfgpu/lib/python3.6/site-packages/rfpipe-1.1.5-py3.6.egg/rfpipe/search.py in reproduce_candcollection(cc, data, wisdom)
434 cd = rfpipe.reproduce.pipeline_imdata(st, candloc, data_corr,
435 cpuonly=True, **kwargs)
--> 436 cc1 += candidates.save_and_plot(cd)
437
438 # TODO: validate that reproduced features match input features?
~/anaconda3/envs/rfgpu/lib/python3.6/site-packages/rfpipe-1.1.5-py3.6.egg/rfpipe/candidates.py in save_and_plot(canddatalist)
347 save_cands(st, canddata=canddata)
348 if st.prefs.saveplots:
--> 349 candplot(canddata, cluster=(clusters[i], clustersizes[i]), snrs=snrs)
350
351 return candcollection
UnboundLocalError: local variable 'clusters' referenced before assignment
`
Thanks for this. I fixed the way the clustercands
preference is interpreted. Default value is None
which does no clustering.