diff --git a/geomagio/TimeseriesFactory.py b/geomagio/TimeseriesFactory.py index 2a99522f54b273d682b434accf062b940eec6925..fb0ba2f6404ecf8ac21eea7b68828c77b67931a9 100644 --- a/geomagio/TimeseriesFactory.py +++ b/geomagio/TimeseriesFactory.py @@ -105,7 +105,11 @@ class TimeseriesFactory(object): channels=channels) data = Util.read_url(url) try: - timeseries += self.parse_string(data) + timeseries += self.parse_string(data, + observatory=observatory, + type=type, + interval=interval, + channels=channels) except NotImplementedError: raise NotImplementedError('"get_timeseries" not implemented') except Exception as e: @@ -115,7 +119,7 @@ class TimeseriesFactory(object): timeseries.trim(starttime, endtime) return timeseries - def parse_string(self, data): + def parse_string(self, data, **kwargs): """Parse the contents of a string in the format of an IAGA2002 file. Parameters diff --git a/geomagio/iaga2002/IAGA2002Factory.py b/geomagio/iaga2002/IAGA2002Factory.py index 83154283b14180e5530b3f80da88646480488c4e..0faadc7e7c7e2d6aa9ad3ad620ee5b9e44e9f148 100644 --- a/geomagio/iaga2002/IAGA2002Factory.py +++ b/geomagio/iaga2002/IAGA2002Factory.py @@ -34,21 +34,23 @@ class IAGA2002Factory(TimeseriesFactory): def __init__(self, **kwargs): TimeseriesFactory.__init__(self, **kwargs) - def parse_string(self, iaga2002String): + def parse_string(self, data, observatory=None, **kwargs): """Parse the contents of a string in the format of an IAGA2002 file. Parameters ---------- iaga2002String : str string containing IAGA2002 content. - + observatory : str + observatory in case headers are unavailable. + parses observatory from headers when available. Returns ------- obspy.core.Stream parsed data. """ - parser = IAGA2002Parser() - parser.parse(iaga2002String) + parser = IAGA2002Parser(observatory=observatory) + parser.parse(data) metadata = parser.metadata starttime = obspy.core.UTCDateTime(parser.times[0]) endtime = obspy.core.UTCDateTime(parser.times[-1]) diff --git a/geomagio/iaga2002/StreamIAGA2002Factory.py b/geomagio/iaga2002/StreamIAGA2002Factory.py index 208a190ba37d1d2feb46cc5dfca57627a6045c3f..7532aef0ac086d4e4cb9dbfaec80cf1463076531 100644 --- a/geomagio/iaga2002/StreamIAGA2002Factory.py +++ b/geomagio/iaga2002/StreamIAGA2002Factory.py @@ -28,7 +28,9 @@ class StreamIAGA2002Factory(IAGA2002Factory): Notes: Calls IAGA2002Factory.parse_string in place of IAGA2002Factory.get_timeseries. """ - return IAGA2002Factory.parse_string(self, self._stream.read()) + return IAGA2002Factory.parse_string(self, + data=self._stream.read(), + observatory=observatory) def put_timeseries(self, timeseries, starttime=None, endtime=None, channels=None, type=None, interval=None): diff --git a/geomagio/imfv283/IMFV283Factory.py b/geomagio/imfv283/IMFV283Factory.py index f7b493f7e18aaadc63159882edb9e342723872a4..effeec974e339b70074c5ae61f659e7e5fe4a75f 100644 --- a/geomagio/imfv283/IMFV283Factory.py +++ b/geomagio/imfv283/IMFV283Factory.py @@ -70,12 +70,12 @@ class IMFV283Factory(TimeseriesFactory): stats.channel, 'variation', 'minute') return timeseries - def parse_string(self, imfV283String): + def parse_string(self, data, **kwargs): """Parse the contents of a string in the format of an IMFV283 file. Parameters ---------- - IMFV283String : str + data : str string containing IMFV283 content. Returns @@ -84,7 +84,7 @@ class IMFV283Factory(TimeseriesFactory): parsed data. """ parser = IMFV283Parser() - parser.parse(imfV283String) + parser.parse(data) stream = parser.stream stream.merge() diff --git a/geomagio/pcdcp/PCDCPFactory.py b/geomagio/pcdcp/PCDCPFactory.py index 0cfc04d20a00335317cdac29f9e1621a3cc8506c..107d9bbe30c2600840d1d487459754c14b9e94d6 100644 --- a/geomagio/pcdcp/PCDCPFactory.py +++ b/geomagio/pcdcp/PCDCPFactory.py @@ -36,12 +36,12 @@ class PCDCPFactory(TimeseriesFactory): def __init__(self, **kwargs): TimeseriesFactory.__init__(self, **kwargs) - def parse_string(self, pcdcpString): + def parse_string(self, data, **kwargs): """Parse the contents of a string in the format of a pcdcp file. Parameters ---------- - pcdcpString : str + data : str String containing PCDCP content. Returns @@ -50,7 +50,7 @@ class PCDCPFactory(TimeseriesFactory): Parsed data. """ parser = PCDCPParser() - parser.parse(pcdcpString) + parser.parse(data) yr = int(parser.header['year']) yrday = int(parser.header['yearday']) diff --git a/geomagio/pcdcp/StreamPCDCPFactory.py b/geomagio/pcdcp/StreamPCDCPFactory.py index c7bc52925715911ea57a19a2f50c83f68acfa3b3..312e9361c85882a0f9bfe78e62c9481de99779b8 100644 --- a/geomagio/pcdcp/StreamPCDCPFactory.py +++ b/geomagio/pcdcp/StreamPCDCPFactory.py @@ -28,7 +28,9 @@ class StreamPCDCPFactory(PCDCPFactory): Notes: Calls PCDCPFactory.parse_string in place of PCDCPFactory.get_timeseries. """ - return PCDCPFactory.parse_string(self, self._stream.read()) + return PCDCPFactory.parse_string(self, + data=self._stream.read(), + observatory=observatory) def put_timeseries(self, timeseries, starttime=None, endtime=None, channels=None, type=None, interval=None):