[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Orekit Users] CelestialBody.getPVCoordinates() not working in Python
- To: orekit-users@orekit.org
- Subject: Re: [Orekit Users] CelestialBody.getPVCoordinates() not working in Python
- From: Petrus Hyvönen <petrus.hyvonen@gmail.com>
- Date: Thu, 20 Mar 2014 22:21:20 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=content-type:mime-version:subject:from:in-reply-to:date :content-transfer-encoding:message-id:references:to; bh=Fk2hj8p+dMm4qPScW2ItvOxRdwfNPmnkO1gQ8aPj6Ec=; b=OzGrtfatx6M3/Kk04JNdllbPT1nVJ3Q7Uh3NuR8xgAUlsJNhAi5chD4nDeZHuF4zZl IiqhLry2iH1tS0B3NW094AU3DopLS47jP2QdOr4Qm9MS9Yp3piilRtdtUX3MyNZmLAL9 MTTkTsHJ3rmQvGC7h8rV7sSJA5sQdnoQ1TkGcn9CglE18xT6rVLo55MmxOQO40T8cU8+ v6TJTPCYQSO3VG0XJrkK33RwdSz0rz4UrFRaGyjf2+l3ZfkR4EV4CFB/flx+O3yv485s CCRrdwvt4HfbwGHjCRMMQBWWBs35epXXI1lxPo2Gn+VwbIJFBskVdokjXUhHjZyxhVo5 y+4Q==
- In-reply-to: <sympa.1395344839.17955.320@orekit.org>
- References: <sympa.1395344839.17955.320@orekit.org>
Hi,
I'm not really sure why but sometimes you need to clarify to the object what they can be by casting them.
do a:
from org.orekits.utils import PVCoordinatesProvider
moon = PVCoordinatesProvider.cast_(moon)
This will make it work.
Regards
/Petrus
On 20 Mar 2014, at 20:57 , <ltrom1@gmail.com> <ltrom1@gmail.com> wrote:
> Hi everybody,
> I just got started today with Orekit, and I used JCC to integrate it in Python
> 2.7.
> I tried to run the demo python script from the wiki page and it worked fine.
> I am now trying to get the Moon position in EME2000 frame but the last line of
> the script below returns the error {'CelestialBody' object has no attribute
> 'getPVCoordinates'}:
> =========================================================
> import orekit
> orekit.initVM()
>
> from java.io import File
> from org.orekit.data import DataProvidersManager, ZipJarCrawler
> from org.orekit.time import TimeScalesFactory, AbsoluteDate
> from org.orekit.frames import FramesFactory
> from org.orekit.bodies import CelestialBodyFactory
>
> #Setup Orekit:
> DM = DataProvidersManager.getInstance()
> datafile = File('lib/xtra/orekit/orekit-data.zip')
> if datafile.exists() == False:
> print 'File :', datafile.absolutePath, ' not found'
>
> crawler = ZipJarCrawler(datafile)
> DM.clearProviders()
> DM.addProvider(crawler)
>
> #Get Moon position:
> utc = TimeScalesFactory.getUTC()
> gei = FramesFactory.getEME2000()
> moon = CelestialBodyFactory.getMoon()
>
> date = AbsoluteDate(2014, 01, 01, 00, 00, 00.000, utc)
> print moon.getPVCoordinates(date,gei).getPosition()
> =========================================================
>
> So I tried the following java code, and it worked fine so it's not helping me
> to understand what's wrong in my Python code. Now it's been a couple of hours
> I am fighting against this problem, but maybe there is somebody here who could
> give me some hints to get my python script working.
> Thanks in advance!
>
> =========================================================
>
> import org.apache.commons.math3.geometry.euclidean.threed.Vector3D;
> import org.orekit.bodies.CelestialBody;
> import org.orekit.bodies.CelestialBodyFactory;
> import org.orekit.errors.OrekitException;
> import org.orekit.frames.Frame;
> import org.orekit.frames.FramesFactory;
> import org.orekit.time.AbsoluteDate;
> import org.orekit.time.TimeScale;
> import org.orekit.time.TimeScalesFactory;
> import fr.cs.examples.Autoconfiguration;
>
> public class test_01 {
>
> public static void main(String[] args) {
> try {
> Autoconfiguration.configureOrekit();
>
> TimeScale utc = TimeScalesFactory.getUTC();
> Frame gei = FramesFactory.getEME2000();
> CelestialBody moon = CelestialBodyFactory.getMoon();
>
> AbsoluteDate date = new AbsoluteDate(2014, 01, 01, 00, 00, 00,
> utc);
> Vector3D pos_Moon = moon.getPVCoordinates(date,
> gei).getPosition();
> System.out.println(pos_Moon);
>
> } catch (OrekitException oe) {
> System.err.println(oe.getMessage());
> }
> }
> }
> =========================================================