cherab / solps

Other
6 stars 5 forks source link

Check for IndexError when obtaining vessel configuration from MDSPlus #57

Closed vsnever closed 3 years ago

vsnever commented 3 years ago

In some cases, an attempt to load a SOLPS simulation from the MDSPlus server throws an IndexError when reading the vessel configuration. For example, the following:

from cherab.solps import load_solps_from_mdsplus
server = 'solps-mdsplus.aug.ipp.mpg.de:8001'
sim = load_solps_from_mdsplus(server, 182315)

will throw an error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/vlad/cherab-solps/cherab/solps/formats/mdsplus.py", line 46, in load_solps_from_mdsplus
    mesh = load_mesh_from_mdsplus(conn, MdsException)
  File "/home/vlad/cherab-solps/cherab/solps/formats/mdsplus.py", line 238, in load_mesh_from_mdsplus
    vessel = mds_connection.get(r'\SOLPS::TOP.SNAPSHOT.GRID:VESSEL').data()[:]
IndexError: invalid index to scalar variable.

Therefore, IndexError must be added to the list of exceptions.

vsnever commented 3 years ago

Fixed in #58.