Skip to content

Commit

Permalink
read actual dipole length from XML and reflect it to conversion factor
Browse files Browse the repository at this point in the history
  • Loading branch information
Naoto committed Apr 5, 2019
1 parent 3345f65 commit bf41a2f
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 2 deletions.
31 changes: 31 additions & 0 deletions bezpy/mt/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ def read_xml(fname):
site.Z = np.vstack([site.data['z_zxx'], site.data['z_zxy'],
site.data['z_zyx'], site.data['z_zyy']])

site.runlist = get_text(xml_site, "RunList").split()
site = read_runinfo(site,root)

try:
site.Z_var = np.vstack([site.data['z.var_zxx'], site.data['z.var_zxy'],
site.data['z.var_zyx'], site.data['z.var_zyy']])
Expand Down Expand Up @@ -189,3 +192,31 @@ def get_1d_site(name):
return _SITES1D[newname]

raise ValueError("No 1d site profile with the name: " + name)

def read_runinfo(site,root):
site.runinfo = {}

# fieldnotes = xml_site.find("FieldNotes")
for field in root.findall("FieldNotes"):
# runid of fieldnote
runid = field.attrib['run']
site.runinfo[runid] = {}
# index of runid in the runlist. This index is used to update the length of E-dipole
ind = site.runlist.index(runid)
try:
site.NIMSid = get_text( field.find('Instrument'), 'Id')
except KeyError:
site.NIMSid = None

# run through E component
for ecomp in field.findall("Dipole"):
# component
Edirection = ecomp.attrib['name']
length = convert_float(get_text(ecomp, "Length"))
site.runinfo[runid][Edirection] = length

# set start and end datetime
site.runinfo[runid]['Start'] = datetime.datetime.strptime( field.find('Start').text,'%Y-%m-%dT%H:%M:%S')
site.runinfo[runid]['End'] = datetime.datetime.strptime( field.find('End').text,'%Y-%m-%dT%H:%M:%S')

return site
16 changes: 14 additions & 2 deletions bezpy/mt/site.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,20 @@ def download_waveforms(self):

# Magnetic Field
self.waveforms[["FE", "FN", "FZ"]] *= 0.01 # nT
# Electric Field
self.waveforms[["QN", "QE"]] *= 2.44141221047903e-05 # mV/km
# Electric voltage
self.waveforms[["QN", "QE"]] *= 2.44141221047903e-06 # mV
# Electric Field (set default length of dipole as 100m)
self.waveforms[["QN", "QE"]] *= (1000.0/100.0) # mV/km
for runid in self.runlist:
try:
mask = ((self.waveforms.index>self.runinfo[runid]['Start']) & (self.waveforms.index<self.runinfo[runid]['End']))
self.waveforms["QN"].loc[mask] *= (1000.0/self.runinfo[runid]['Ex'])*(100.0/1000.0) # mV/km
self.waveforms["QE"].loc[mask] *= (1000.0/self.runinfo[runid]['Ey'])*(100.0/1000.0) # mV/km

except KeyError:
print(runid)
pass

# Renaming
self.waveforms.rename(columns={"FE": "BE", "FN": "BN", "FZ": "BZ",
"QE": "EE", "QN": "EN"},
Expand Down

0 comments on commit bf41a2f

Please sign in to comment.