Skip to content
Snippets Groups Projects
Commit e6d10897 authored by Philipp Niedermayer's avatar Philipp Niedermayer
Browse files

Support rad and deg NWA data

parent e5f742db
No related branches found
No related tags found
No related merge requests found
......@@ -326,12 +326,13 @@ class NWAData(Trace):
p_unit: str = 'a.u.'
@classmethod
def from_file(cls, magfile, phasefile=None, unwrap=False, verbose=0):
def from_file(cls, magfile, phasefile=None, *, isdeg=True, unwrap=False, verbose=0):
"""Read in data from CSV file for magnitude and phase
:param magfile: path to filename with magnitude trace data
:param phasefile: path to filename with phase trace data. If None, phase data is assumed to be the second column in magfile.
:param unwrap: if true, relative phase is unwraped to absolute phase centered around zero
:param isdeg: if phase data is in degree (True) or radians (False)
"""
f, m, *other = np.loadtxt(magfile, skiprows=3, delimiter=',').T
if phasefile is None:
......@@ -342,8 +343,10 @@ class NWAData(Trace):
raise ValueError('Files provided do not have equal frequency components.')
if unwrap:
if isdeg: p = np.deg2rad(p)
p = np.unwrap(p)
p -= np.mean(p)
if isdeg: p = np.rad2deg(p)
return NWAData(f, m, p)
return NWAData(f, m, p, p_unit='deg' if isdeg else 'rad')
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment