Skip to content
Snippets Groups Projects
Commit 807ca9a0 authored by Shavers, Nicholas H's avatar Shavers, Nicholas H
Browse files

import module syntax i.e __init__.py used

parent 2ce501ae
No related branches found
No related tags found
1 merge request!380xmlfactory mvp
...@@ -7,8 +7,6 @@ from typing import List, Optional, Tuple, Union ...@@ -7,8 +7,6 @@ from typing import List, Optional, Tuple, Union
from obspy.core import Stream, UTCDateTime from obspy.core import Stream, UTCDateTime
from geomagio.api.xml.XMLFactory import XMLFactory
from .algorithm import Algorithm, algorithms, AlgorithmException, FilterAlgorithm from .algorithm import Algorithm, algorithms, AlgorithmException, FilterAlgorithm
from .DerivedTimeseriesFactory import DerivedTimeseriesFactory from .DerivedTimeseriesFactory import DerivedTimeseriesFactory
from .PlotTimeseriesFactory import PlotTimeseriesFactory from .PlotTimeseriesFactory import PlotTimeseriesFactory
...@@ -25,6 +23,7 @@ from . import imfv122 ...@@ -25,6 +23,7 @@ from . import imfv122
from . import imfv283 from . import imfv283
from . import temperature from . import temperature
from . import vbf from . import vbf
from . import xml
class Controller(object): class Controller(object):
...@@ -562,7 +561,7 @@ def get_input_factory(args): ...@@ -562,7 +561,7 @@ def get_input_factory(args):
**input_factory_args, **input_factory_args,
) )
elif input_type == "xml": elif input_type == "xml":
input_factory = XMLFactory(**input_factory_args) input_factory = xml.XMLFactory(**input_factory_args)
# wrap stream # wrap stream
if input_stream is not None: if input_stream is not None:
input_factory = StreamTimeseriesFactory( input_factory = StreamTimeseriesFactory(
...@@ -649,7 +648,7 @@ def get_output_factory(args): ...@@ -649,7 +648,7 @@ def get_output_factory(args):
**output_factory_args, **output_factory_args,
) )
elif output_type == "xml": elif output_type == "xml":
output_factory = XMLFactory(**output_factory_args) output_factory = xml.XMLFactory(**output_factory_args)
# wrap stream # wrap stream
if output_stream is not None: if output_stream is not None:
output_factory = StreamTimeseriesFactory( output_factory = StreamTimeseriesFactory(
......
...@@ -185,12 +185,13 @@ class XMLFactory(TimeseriesFactory): ...@@ -185,12 +185,13 @@ class XMLFactory(TimeseriesFactory):
# Create Data element # Create Data element
data_elem = ET.SubElement(root, "Data") data_elem = ET.SubElement(root, "Data")
# All traces should have the same starttime and delta per convention # For each sample, create and add as sub element of <data>...</data>
for i in range(npts): for i in range(npts):
sample = ET.SubElement(data_elem, "Sample") sample = ET.SubElement(data_elem, "Sample")
for trace in timeseries: for trace in timeseries:
ch_name = trace.stats.channel ch_name = trace.stats.channel
value = trace.data[i] if i < len(trace.data) else "" value = trace.data[i] if i < len(trace.data) else ""
# For each channels trace, get data point, add as a sub element of <sample>...</sample>
ET.SubElement(sample, ch_name).text = f"{value}" ET.SubElement(sample, ch_name).text = f"{value}"
# Generate the XML string # Generate the XML string
......
"""IO Module for Edge Format
"""
from __future__ import absolute_import
from .XMLFactory import XMLFactory
__all__ = ["XMLFactory"]
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