Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'list' object has no attribute 'filled' #107

Open
raffyjef opened this issue Aug 20, 2022 · 3 comments
Open

AttributeError: 'list' object has no attribute 'filled' #107

raffyjef opened this issue Aug 20, 2022 · 3 comments

Comments

@raffyjef
Copy link

Hi @josephhardinee, I have a problem processing the file when I am trying to use functions with time. I am trying to use this codes using the ATM4.txt files

import pydsd
import matplotlib.pyplot as plt
import pydsd.plot
import pydsd.partition

filename = 'merged_file.txt'
dsd = pydsd.read_parsivel(filename)
dsd.calculate_dsd_parameterization()
pydsd.plot.plot_dsd(dsd)
plt.show()

Here is the error:

runfile('/home/jeff/.config/spyder-py3/DSD_sample.py', wdir='/home/jeff/.config/spyder-py3')
Traceback (most recent call last):

File "/home/jeff/anaconda3/envs/wradlib/lib/python3.10/site-packages/spyder_kernels/py3compat.py", line 356, in compat_exec
exec(code, globals, locals)

File "/home/jeff/.config/spyder-py3/DSD_sample.py", line 21, in
pydsd.plot.plot_dsd(dsd)

File "/home/jeff/anaconda3/envs/wradlib/lib/python3.10/site-packages/PyDSD-1.0.6.2+5.g0a54715-py3.10.egg/pydsd/plot/plot.py", line 72, in plot_dsd
dsd.time["data"].filled(),

AttributeError: 'list' object has no attribute 'filled'

Do you have idea to fix this? My programming skills are not that advanced. Thank you

@sc-martirez
Copy link

Late but also had the same issue as well in that filled() is a numpy masked array method while dsd.time["data"] is just a list. Simple solution is to change the time attribute declarations in the ParsivelReader module to:

"data": np.ma.array(time_secs)

There also seems to be a bunch of other bugs related to the use of masked arrays. Had a similar issue again with dsd.calculate_radar_parameters() where masked Nd values where getting converted to NaN values so the radar params that were returned where just a bunch of NaNs. This was solved by using filled() on dsd.Nd["data"] before calling calculate_radar_parameters(). Llooking into the types of the variables you're dealing with should be the right direction if you ever encounter similar problems.

@raffyjef
Copy link
Author

Yes, I am getting NaN values when using the dsd.calculate_radar_parameters(). How do I use filled() on dsd.Nd["data"]. Sorry, I am lost.

@sc-martirez
Copy link

No worries, I just overwrote the Nd data after reading my disdrometer file. My code looks a little like this,

dsd = pydsd.read_parsivel(filename)
dsd.Nd["data"] = dsd.Nd["data"].filled()
dsd.calculate_radar_parameters()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants