Giter Club home page Giter Club logo

ecrad_pylib's Introduction

The ECRad Pylib is a library to interact with the ECRad code. It provides classes for data storage/retrieval and a F2PY interface for controlling ECRad.

Installation

Installation is as simple as cloning this repository.

git clone https://github.com/AreWeDreaming/ECRad_Pylib.git

Dependencies

ECRad:

git clone https://github.com/AreWeDreaming/ECRad.git

Python 3.0 or higher The following Python packages (has to be Python 3):

  • wxPython
  • numpy
  • scipy
  • matplotlib
  • Netcdf4

Other:

  • Batch submissions only through SLURM

Usage

There are two main functionalities of the library.

  • Interacting with results obtained from ECRad
  • Controlling ECRad through the F2PY interface

For details refer to the documentation [WIP].

Contributing

At the moment all contributions should be discussed. Pull requests will be welcome once version 1.0 is stable.

License

MIT

This library makes use of the wxPython library. The license for wxPython can be found in the licenses folder.

ecrad_pylib's People

Contributors

arewedreaming avatar annamed-v1 avatar

Stargazers

Guillermo avatar

Watchers

 avatar

ecrad_pylib's Issues

Numerical problems (NaNs) with "get_theta_pol_phi_tor_from_two_points(x1_vec, x2_vec)"

Hi Severin et al,

ECRad_Scenario.set_up_launch_from_imas() reads in line-of-sight (LOS) data from the IMAS ECE IDS in the form of two LOS end points, from which it calculates the poloidal and toroidal inclinations of the sightline:

self['diagnostic']["theta_pol"][:], self['diagnostic']["phi_tor"][:] = \
get_theta_pol_phi_tor_from_two_points(x1_vec, x2_vec)

Now for a real case with perpendicular incidence, AUG, where both LOS end points are at the same toroidal angle, "phi_tor" should be zero.
Example:

   x1_vec = np.array([-2.3048453154126185, -0.45846223813263876, 0.04097180441021919])
   x2_vec = np.array([-0.9807852804032304, -0.1950903220161284, 0.006681805010885])
   thetap, phit = get_theta_pol_phi_tor_from_two_points(x1_vec, x2_vec)

which results in phit== Nan (and not zero).
The reason is that numerical rounding errors make the np.arccos() argument in "get_theta_pol_phi_tor_from_two_points()" very slightly larger than one. I suggest to use a numerically more stable expression, such as:

phi_1 = np.arctan2(x1_vec[1], x1_vec[0])
phi_12 = np.arctan2(x1_vec[1]-x2_vec[1], x1_vec[0]-x2_vec[0])
self['diagnostic']["phi_tor"][:,ich] = np.rad2deg(phi_1 - phi_12)

Hope this helps ...

Greetings,
Wolfgang

Should not set Scenario["plasma"]["2D_prof"] = []

Hi Severin et al,

ECRadScenario.set_up_profiles_from_imas() is a bit too eager to reset everything to an (empty) list:

for key in self["plasma"]:
self["plasma"][key] = []

for key in self["plasma"]:
self["plasma"][key] = []

E.g. Scenario['plasma']['2D_prof'] should remain a scalar boolean in order to be able to write it to netcdf output later on:

var = rootgrp["Scenario"].createVariable("plasma" + "_" + "2D_prof", "b")
var[...] = int(self["plasma"]["2D_prof"])

I got it to work after rewriting the two loops above as:

for key in ["rhot_prof", "rhop_prof", "Te", "ne"]:
    self["plasma"][key] = []

Greetings,
Wolfgang

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.