Пример #1
0
    def output(self):
        ''' 
        Generate data wrapper for USGS geomagnetic data

        @return geomagnetic data wrapper
        '''

        observatory_list = self.ap_paramList[0]()

        # USGS Edge server
        base_url = 'cwbpub.cr.usgs.gov'
        factory = EdgeFactory(host=base_url, port=2060)

        data_dict = OrderedDict()
        for observatory in observatory_list:
            ret_data = factory.get_timeseries(
                observatory=observatory,
                interval=self.interval,
                type=self.data_type,
                channels=self.channels,
                starttime=UTCDateTime(self.start_time),
                endtime=UTCDateTime(self.end_time))

            obs_data = OrderedDict()
            for label, trace in zip(self.channels, ret_data):
                time = pd.to_datetime(
                    trace.stats['starttime'].datetime) + pd.to_timedelta(
                        trace.times(), unit='s')
                obs_data[label] = pd.Series(trace.data, time)

            data_dict[observatory] = pd.DataFrame(obs_data)

        return TableWrapper(data_dict, default_columns=self.channels)
Пример #2
0
    def output(self):
        ''' 
        Generate data wrapper for USGS geomagnetic data

        @return geomagnetic data wrapper
        '''
        
        observatory_list = self.ap_paramList[0]()
        
        # USGS Edge server
        base_url = 'cwbpub.cr.usgs.gov'     
        factory = EdgeFactory(host=base_url, port=2060)

        data_dict = OrderedDict()
        for observatory in observatory_list:
            ret_data = factory.get_timeseries( observatory=observatory,
                                               interval=self.interval,
                                               type=self.data_type,
                                               channels=self.channels,
                                               starttime=UTCDateTime(self.start_time),
                                               endtime=UTCDateTime(self.end_time))

            obs_data = OrderedDict()
            for label, trace in zip(self.channels, ret_data):
                time = pd.to_datetime(trace.stats['starttime'].datetime) + pd.to_timedelta(trace.times(),unit='s')
                obs_data[label] = pd.Series(trace.data,time)
                
            
            data_dict[observatory] = pd.DataFrame(obs_data)
            
                
        return TableWrapper(data_dict, default_columns=self.channels)
Пример #3
0
def dont_get_timeseries():
    """edge_test.EdgeFactory_test.test_get_timeseries()"""
    # Call get_timeseries, and test stats for comfirmation that it came back.
    # TODO, need to pass in host and port from a config file, or manually
    #   change for a single test.
    edge_factory = EdgeFactory(host='TODO', port='TODO')
    timeseries = edge_factory.get_timeseries(
        UTCDateTime(2015, 3, 1, 0, 0, 0), UTCDateTime(2015, 3, 1, 1, 0, 0),
        'BOU', ('H'), 'variation', 'minute')
    assert_equals(timeseries.select(channel='H')[0].stats.station,
        'BOU', 'Expect timeseries to have stats')
    assert_equals(timeseries.select(channel='H')[0].stats.channel,
        'H', 'Expect timeseries stats channel to be equal to H')
def dont_get_timeseries():
    """edge_test.EdgeFactory_test.test_get_timeseries()"""
    # Call get_timeseries, and test stats for comfirmation that it came back.
    # TODO, need to pass in host and port from a config file, or manually
    #   change for a single test.
    edge_factory = EdgeFactory(host="TODO", port="TODO")
    timeseries = edge_factory.get_timeseries(
        UTCDateTime(2015, 3, 1, 0, 0, 0),
        UTCDateTime(2015, 3, 1, 1, 0, 0),
        "BOU",
        ("H"),
        "variation",
        "minute",
    )
    assert_equal(
        timeseries.select(channel="H")[0].stats.station,
        "BOU",
        "Expect timeseries to have stats",
    )
    assert_equal(
        timeseries.select(channel="H")[0].stats.channel,
        "H",
        "Expect timeseries stats channel to be equal to H",
    )
Пример #5
0
                    out_start = starttime
                if endtime is not None:
                    out_end = endtime

            if out_start <= out_end:
                # possibly re-initialize with previous 90 days of data
                in_start, in_end = svsqdist[ch].get_input_interval(
                    out_start, out_end, observatory=ob, channels=ch)

                # create factory and pull data from USGS Edge
                in_factory = EdgeFactory(host=edge_url,
                                         port=edge_port,
                                         interval='minute',
                                         type='adjusted')
                in_stream += in_factory.get_timeseries(starttime=in_start,
                                                       endtime=in_end,
                                                       observatory=ob,
                                                       channels=ch)
                print('Retrieved from Edge: %s-%s' % (ob, ch), end="")
                print(' from', in_start, 'to', in_end)
            else:
                print("Decreasing interval requested (", end="")
                print(out_start, 'to', out_end, ")", end="")
                print(" skipping %s-%s..." % (ob, ch))

        if in_stream.count() is not len(channels):
            # if any channel was not read in, STOP PROCESSING
            print("No inputs processed or written...")
            pass

        else:
            # channels are processed separately from input retrieval in order to