Skip to content

Commit

Permalink
Imports, TODO
Browse files Browse the repository at this point in the history
  • Loading branch information
krystophny committed Nov 22, 2023
1 parent 350f5f4 commit d55908c
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions python/libneo/mgrid.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
"""
Handle mgrid data
"""
import textwrap
import numpy as np
from netCDF4 import Dataset


def list_to_bytearray(input_strings, max_length=30):
import numpy as np

data_list = [[char.encode() for char in string] for string in input_strings]

# Pad the lists with empty bytes to make them of equal length
Expand Down Expand Up @@ -56,6 +54,8 @@ def __init__(
self.bz = []

def __str__(self):
import textwrap

return textwrap.dedent(
f"""
mgrid
Expand All @@ -71,6 +71,7 @@ def __repr__(self):

@classmethod
def from_file(cls, filename):
from netCDF4 import Dataset
with Dataset(filename, "r") as f:
coil_group = bytearray_to_list(f.variables["coil_group"][:])
coil_current = f.variables["raw_coil_cur"][:]
Expand Down Expand Up @@ -111,6 +112,8 @@ def from_file(cls, filename):
)

def write(self, filename):
from netCDF4 import Dataset

with Dataset(filename, "w") as f:
# Add dimensions
f.createDimension("stringsize", 30)
Expand Down Expand Up @@ -180,3 +183,8 @@ def add_coil(self, group_name, current):
if not group_name in self.coil_group:
self.coil_group.append(group_name)
self.coil_current.append(current)

# TODO: plot function
def plot(self):
import matplotlib.pyplot as plt
pass

0 comments on commit d55908c

Please sign in to comment.