Pyephem: 'Titan' object has no attribute 'mag' - python

I tried to determine the magnitude of Titan, but the result is this error message:
AttributeError: 'Titan' object has no attribute 'mag'
>>> import ephem
>>> t = ephem.Titan()
>>> t.compute()
>>> t.ra
15:55:10.52
>>> t.mag
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'Titan' object has no attribute 'mag'
Doesn't Titan have the attribute magnitude? Why? I can determine the magnitude for Uranus, or the Moon, but not for Titan. At least not with the 'mag' attribute.
What would be the way?
edit:
With versions 3.7.5.3 and 3.7.5.1 of ephem.

According to the PyEphem Homepage Docs
The ephem.Body type is the only type with a .mag attribute
Titan is classified as a ephem.PlanetMoon object and so does not have a .mag attribute
The current list of ephem.Body objects are:
Jupiter,Mars,Mercury,Moon,Neptune,Pluto,Saturn,Sun,Uranus,Venus.
I am not aware of any way in ephem to calculate the .mag of an ephem.PlanetMoon object

Related

python-pcl Segmentation_PointXYZI' object has no attribute 'set_MaxIterations'

I'm new in C++. So, I'm trying to use python-pcl, but I got an error:
AttributeError: 'pcl._pcl.Segmentation_PointXYZI' object has no attribute 'set_MaxIterations'
I'm trying to create the segmentation object for the planar model and set the parameters with the PointXYZI type. I have to use PointXYZI. How can I solve this problem?
My code:
def cluster_extraction(self,data):
print("Type1: ", type(data))
cloud_filtered = self.downsampling(data,0.3)
print("Type2: ", type(cloud_filtered))
seg = cloud_filtered.make_segmenter()
seg.set_optimize_coefficients (True)
seg.set_model_type (pcl.SACMODEL_PLANE)
seg.set_method_type (pcl.SAC_RANSAC)
seg.set_MaxIterations (100)
seg.set_distance_threshold (0.02)
Output:
('Type1: ', <type 'pcl._pcl.PointCloud_PointXYZI'>)
('Type2: ', <type 'pcl._pcl.PointCloud_PointXYZI'>)
[ERROR] [1596926303.890116]: bad callback: <bound method sub_pub_node.callback of <__main__.sub_pub_node object at 0x7f154be44ad0>>
Traceback (most recent call last):
File "/opt/ros/melodic/lib/python2.7/dist-packages/rospy/topics.py", line 750, in _invoke_callback
cb(msg)
File "node.py", line 154, in callback
downsampled_data = self.processing(pcl2_data)
File "node.py", line 103, in processing
processing.cluster_extraction(pcl2_data)
File "node.py", line 43, in cluster_extraction
seg.set_MaxIterations (100)
AttributeError: 'pcl._pcl.Segmentation_PointXYZI' object has no attribute 'set_MaxIterations'
I am not sure from where you got your python-pcl package, but I will assume that you used this one, therefore, and because there is no method called set_MaxIterations(int ) in the Segmentation_PointXYZI class (Sample Consensus), you can try to replace it with setMaxIterations(int ).
Inside the definition of the PointCloud_PointXYZI class, you can find that the Segmentation method used for this type of point clouds is an instance from pcl_seg.SACSegmentation_PointXYZI_t which defines the method for setting the max number of iterations as setMaxIterations(int ).
Please check the documentation provided here and check the functions that you are using and how are they defined. (I know that can be tedious but it is necessary).
I hope this helped in solving the issue.
According to strawlab's official example the correct call is:
seg.set_max_iterations(100)

sns.countplot - 'AttributeError: 'module' object has no attribute 'countplot''

I am trying to create a countplot with sns. I adapted the following code:
sns.countplot(x="deck", data=titanic, palette="Greens_d")
I use a data frame called dfvp where XP is a categorical variable which can take two string values (either defense or prosecution).
here is my adapted code:
sns.countplot(x="XP", data=dfvp, palette="Greens_d")
Here is the error message that I get:
sns.countplot(x="XP", data=dfvp, palette="Greens_d")
Traceback (most recent call last):
File "<ipython-input-220-20d65ae5d282>", line 1, in <module>
sns.countplot(x="XP", data=dfvp, palette="Greens_d")
AttributeError: 'module' object has no attribute 'countplot'
FYI: I use ANACONDA and Python 3.4. on a PC with Windows 8.
Could you tell me how to fix this/what I am doing wrong?
EDIT:
Here is a MCVE
import seaborn as sns
dfvp = read_csv('C:\\Users\\VP_Prod_study_2_data changed_3.csv')
sns.countplot(x="XP", data=dfvp, palette="Greens_d")

Object Location Change on Blender Python

I was following an animation example with Python in Blender 2.69, by typing a line by line.
obj = bpy.context.object
obj.location[2] = 0.0
obj.keyframe_insert(data_path="location", frame=10.0, index=2)
obj.location[2] = 1.0
obj.keyframe_insert(data_path="location", frame=20.0, index=2)
But I have encountered an error on the 3rd line, which is saying
Traceback (most recent call last):
File "<blender_console>", line 1, in <module>
AttributeError: 'NoneType' object has no attribute 'location'
I am confused because I just followed a simple example.
Why is it saying the object has no attribute 'location'?
I'll be appreciated for your help, thanks.
You'll find that the error would be reported after the second line because the variable obj has not been set. Most likely this would be from a small typo.
You can verify this by looking at the type of the variable in the python console. When getting the error you will see -
>>> type(obj)
<class 'NoneType'>
While if it had been set correctly you will get -
>>> type(obj)
<class 'bpy_types.Object'>

'module' object has no attribute 'interpld'

I'm fresh on python,using python2.7,and got some questions on the code blew:
import numpy as np
from scipy import interpolate
import pylab as py
x=np.r_[0:10:11j]
y=np.sin(x)
xnew=np.r_[0:10:100j]
#f=interpolate.interpld(x,y)
py.figure(1)
py.clf()
py.plot(x,y,'ro')
for kind in ['nearest','zero','slinear','quadtatic','cublic']:
f=interpolate.interpld(x,y,kind=kind)
ynew=f(xnew)
py.plot(xnew,ynew,label=kind)
py.legend(loc='lower right')
but it resulted in:
Traceback (most recent call last):
File "C:\Users\LCL\.xy\startups\python_web\my_first_try_on_python_web\python_Interpolation\example1.py", line 22, in <module>
f=interpolate.interpld(x,y,kind=kind)
AttributeError: 'module' object has no attribute 'interpld'
You used interpld, i.e. INTERPLD.
You want interp1d, i.e. with the numeral 1, for one-dimensional.
It looks like you are using interpolate.interpld but the function name is interpolate.interp1d (with a number one instead of a letter L).
It should be "interp1d",the number 1,not L

Python: TypeError: 'float' object is not callable

I am trying to join 2 strings using this code:
def __get_temp(self):
return float(self.ask('RS'))
def __set_temp(self, temp):
set = ('SS' + repr(temp))
stat = self.ask(set)
return self.check(stat)
temp = property(__get_temp, __set_temp)
Once together, I then send a signal over a serial bus using PyVisa. However, when I try to call the function, I get
Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
chil.temp(13)
TypeError: 'float' object is not callable
I've tried looking around for explanation of this error, but none of them make any sense. Anyone know what is going on?
It looks like you are trying to set the property temp, but what you're actually doing is getting the property and then trying to call it as function with the parameter 13. The syntax for setting is:
chil.temp = 13

Categories