Giter VIP home page Giter VIP logo

Comments (8)

seanmcleod avatar seanmcleod commented on June 4, 2024 1

@agodemar there are multiple ways to install Python modules in general, e.g. pip install etc.

But take a look at .travis.yml and note the -DINSTALL_PYTHON_MODULE=ON

  - pip install cython numpy pandas scipy
  - gem install gist
  - mkdir build
  - cd build
  - cmake -DCMAKE_INSTALL_PREFIX=~/ -DINSTALL_PYTHON_MODULE=ON -DCPACK_GENERATOR=DEB -DBUILD_SHARED_LIBS=$USE_SYSTEM_EXPAT -DSYSTEM_EXPAT=$USE_SYSTEM_EXPAT ..
  - make -j2

And take a look at jsbsim\python\CMakeLists.txt

# Install the JSBSim Python module
if (INSTALL_PYTHON_MODULE)
  execute_process(COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/findInstallDir.py OUTPUT_VARIABLE PYTHON_INSTALL_DIR)
  execute_process(COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/findModuleFileName.py OUTPUT_VARIABLE PYTHON_MODULE_NAME)
  install(FILES ${CMAKE_BINARY_DIR}/tests/${PYTHON_MODULE_NAME} DESTINATION ${PYTHON_INSTALL_DIR} COMPONENT pymodules)
endif()

So in theory if you execute CMake with the arguments you see in .travis.yml you should end up with the JSBSim python module installed.

from jsbsim.

seanmcleod avatar seanmcleod commented on June 4, 2024

@agodemar on Linux at least from what I've seen in terms of @bcoconni's commits he has things setup to allow a user to install the JSBSim python module etc. (although I'm not sure if this includes JSBSim_utils.py). So I would assume that once the user does the python install of the JSBSim module on Linux it would be available from any Jupyter notebook.

We'll need to look into the equivalent Python module install option on Windows.

For now as a very brief initial test on Windows with the JSBSim python module jsbsim.cp35-win_amd64.pyd with Jupyter I've done the following:

Built all using CMake with VS2017 and then changed into the tests directory where the python module/dll jsbsim.cp35-win_amd64.pyd ends up.

cd \Users\Sean\CMakeBuilds\3f00c6d9-d323-5a32-8a90-665138817fd4\build\x64-Release\tests
jupyter notebook

Then created a new Jupyter notebook and sucessfully executed the following code in the notebook:

import jsbsim
fdm = jsbsim.FGFDMExec(root_dir='\\source\\jsbsim')
fdm['atmosphere/rho-slugs_ft3']

0.0023768988323037404

This works because the Python module/dll is in the same directory as the notebook.

from jsbsim.

seanmcleod avatar seanmcleod commented on June 4, 2024

@bcoconni is there a way for a Python script to retrieve the output from an <output> element without having to read it in from a temporary .csv file or setup an output socket?

So for example I'm thinking of something along these lines from a Python script, inside and outside of a Jupyter notebook.

fdm.run('some script')
data_output = fdm.retreive_data_output()
# Use data_output, e.g. matplotlib the data etc.

from jsbsim.

agodemar avatar agodemar commented on June 4, 2024

@seanmcleod I'm working on Ubuntu (WLS on Windows 10). I've built all for Linux in jsbsim/build using CMake. What do you mean by "install the JSBSim python module"?

I feel a little dummy in these pythonic things, which I still do not handle easily.

EDIT
Forgot to configure cmake with -DINSTALL_PYTHON_MODULE=ON

Now

import jsbsim

works in Jupyter. Still, JSBSim_utils is not found. @bcoconni Should it be?

from jsbsim.

agodemar avatar agodemar commented on June 4, 2024

@seanmcleod thanks for the instructions. Now the first Jupyter very basic test works.

from jsbsim.

bcoconni avatar bcoconni commented on June 4, 2024

Still, JSBSim_utils is not found. @bcoconni Should it be?

I did not plan to release JSBSim_utils.py since it mostly contains stuff for the test suite (inheriting a test case, moving around files from source to build directory, etc.). So no, it is not installed by the installer.

If there are a couple of lines of general interest in there, I would rather move them in a separate file that would be located in the python directory for instance and make JSBSim_utils.py import that file.

from jsbsim.

agodemar avatar agodemar commented on June 4, 2024

@bcoconni @seanmcleod I've created a file jsbsim/doc/python/JSBSim_nb_utils.py which can be called in the first cell of a Jupyter notebook. It defines utility functions and classes. Initially, they are copied from jsbsim/tests/JSBSim_utils.py. In the future it will be cleaned up.

from jsbsim.

agodemar avatar agodemar commented on June 4, 2024

@seanmcleod I've closed this issue because it is resolved now. Regarding your question

@bcoconni is there a way for a Python script to retrieve the output from an element without having to read it in from a temporary .csv file or setup an output socket?

So for example I'm thinking of something along these lines from a Python script, inside and outside of a Jupyter notebook.

fdm.run('some script')
data_output = fdm.retreive_data_output()
... Use data_output, e.g. matplotlib the data etc.

please open a separate issue.

from jsbsim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.