當前位置: 首頁>>代碼示例>>Python>>正文


Python core.UTCDateTime方法代碼示例

本文整理匯總了Python中obspy.core.UTCDateTime方法的典型用法代碼示例。如果您正苦於以下問題:Python core.UTCDateTime方法的具體用法?Python core.UTCDateTime怎麽用?Python core.UTCDateTime使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在obspy.core的用法示例。


在下文中一共展示了core.UTCDateTime方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _load_data

# 需要導入模塊: from obspy import core [as 別名]
# 或者: from obspy.core import UTCDateTime [as 別名]
def _load_data(seedid, day, data, data_format, key='data',
               **prep_kw):
    """Load preprocessed or raw data"""

    from obspy import UTCDateTime as UTC
    from yam.util import _seedid2meta
    from yam.correlate import get_data, preprocess
    smeta = _seedid2meta(seedid)
    day = UTC(day)
    if key == 'data':
        obj = get_data(smeta, data, data_format, day,
                       overlap=0, edge=0, trim_and_merge=True)
        return obj
    stream = get_data(smeta, data, data_format, day,
                      overlap=0, edge=60, trim_and_merge=False)
    preprocess(stream, day, **prep_kw)
    return stream 
開發者ID:trichter,項目名稱:yam,代碼行數:19,代碼來源:commands.py

示例2: create_obs_network

# 需要導入模塊: from obspy import core [as 別名]
# 或者: from obspy.core import UTCDateTime [as 別名]
def create_obs_network(self):
        obs_stations = self.read_stations()
        if obs_stations:
            obs_network = obspy.core.inventory.Network(
                self.experiment_t[0]['net_code_s'])
            obs_network.alternate_code = \
                self.experiment_t[0]['experiment_id_s']
            obs_network.description = self.experiment_t[0]['longname_s']
            start_time, end_time = self.get_network_date()
            obs_network.start_date = UTCDateTime(start_time)
            obs_network.end_date = UTCDateTime(end_time)
            obs_network.total_number_of_stations = self.total_number_stations
            obs_network.stations = obs_stations
            return obs_network
        else:
            return 
開發者ID:PIC-IRIS,項目名稱:PH5,代碼行數:18,代碼來源:ph5tostationxml.py

示例3: output

# 需要導入模塊: from obspy import core [as 別名]
# 或者: from obspy.core import UTCDateTime [as 別名]
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) 
開發者ID:MITHaystack,項目名稱:scikit-dataaccess,代碼行數:34,代碼來源:data_fetcher.py

示例4: _read_dict

# 需要導入模塊: from obspy import core [as 別名]
# 或者: from obspy.core import UTCDateTime [as 別名]
def _read_dict(group):
    """Read a single stretching dictionary from group"""
    res = {'attrs': {}}
    for key, val in group.attrs.items():
        res['attrs'][key] = val
    for key, val in group.items():
        if key not in ('attrs'):
            res[key] = val[:]
    res['times'] = [UTC(t) for t in res['times']]
    res['group'] = group.name
    return res 
開發者ID:trichter,項目名稱:yam,代碼行數:13,代碼來源:commands.py

示例5: _get_data_files

# 需要導入模塊: from obspy import core [as 別名]
# 或者: from obspy.core import UTCDateTime [as 別名]
def _get_data_files(data):
    """
    Construct a glob expression from the data expression and return file names
    """
    from obspy import UTCDateTime as UTC
    kw = dict(network='*', station='*', location='*', channel='*',
              t=UTC('2211-11-11 11:11:11'))
    dataglob = data.format(**kw)
    dataglob = dataglob.replace('22', '*').replace('11', '*')
    fnames = glob.glob(dataglob)
    return fnames 
開發者ID:trichter,項目名稱:yam,代碼行數:13,代碼來源:commands.py

示例6: create_obs_station

# 需要導入模塊: from obspy import core [as 別名]
# 或者: from obspy.core import UTCDateTime [as 別名]
def create_obs_station(self, station_list, sta_code, array_name,
                           start_date, end_date, sta_longitude,
                           sta_latitude, sta_elevation, deployment):

        obs_station = obspy.core.inventory.Station(sta_code,
                                                   latitude=sta_latitude,
                                                   longitude=sta_longitude,
                                                   start_date=start_date,
                                                   end_date=end_date,
                                                   elevation=sta_elevation)

        obs_station.creation_date = UTCDateTime(station_list[deployment][0]
                                                ['deploy_time/epoch_l'])
        obs_station.termination_date = UTCDateTime(station_list[deployment][0]
                                                   ['pickup_time/epoch_l'])

        extra = AttribDict({
            'PH5Array': {
                'value': str(array_name)[8:],
                'namespace': self.manager.iris_custom_ns,
                'type': 'attribute'
            }
        })
        obs_station.extra = extra
        obs_station.site = obspy.core.inventory.Site(
            name=station_list[deployment][0]['location/description_s'])
        return obs_station 
開發者ID:PIC-IRIS,項目名稱:PH5,代碼行數:29,代碼來源:ph5tostationxml.py

示例7: fetch_usgs

# 需要導入模塊: from obspy import core [as 別名]
# 或者: from obspy.core import UTCDateTime [as 別名]
def fetch_usgs(out_path,
               date,
               stn,
               type='variation',
               interval='second',
               he=False,
               out_template='{stn}{date:%Y%m%d}v{suffix}.{suffix}'):
    """
    Fetch USGS magnetometer data for *date* at *stn*. Store the data
    in IAGA2002 format and return the file name (*out_template* serves
    as a template). Limit to data *type* and *interval*. If *he*, then
    include the H and E channels in the output (that is, local
    magnetic north and east components).
    """
    out_fname = os.path.join(out_path,
                             out_template.format(stn=stn.lower(),
                                                 date=date,
                                                 suffix=interval[:3]))

    input_factory = geomagio.edge.EdgeFactory()
    timeseries = input_factory.get_timeseries(
        observatory = stn,
        channels = ('H', 'E', 'Z', 'F'),
        type = type,
        interval = interval,
        starttime = UTCDateTime('{date:%Y-%m-%d}T00:00:00Z'.format(date=date)),
        endtime = UTCDateTime('{date:%Y-%m-%d}T23:59:59Z'.format(date=date)))

    if all([NP.isnan(trace).all() for trace in timeseries.traces]):
        raise ValueError('no data for {} on {:%Y-%m-%d} found'.format(stn, date))

    # convert from HEZF channels to XYZF channels
    algorithm = XYZAlgorithm(informat='obs', outformat='geo')
    xyzf = algorithm.process(timeseries)

    with open(out_fname, 'w') as fid:
        output_factory = geomagio.iaga2002.IAGA2002Factory()
        output_factory.write_file(
            channels = ('H', 'E', 'X', 'Y', 'Z', 'F') if he else ('X', 'Y', 'Z', 'F'),
            fh = fid,
            timeseries = xyzf)
    return out_fname 
開發者ID:butala,項目名稱:pyrsss,代碼行數:44,代碼來源:usgs_mag.py

示例8: start_correlate

# 需要導入模塊: from obspy import core [as 別名]
# 或者: from obspy.core import UTCDateTime [as 別名]
def start_correlate(io,
                    filter_inventory=None,
                    startdate='1990-01-01', enddate='2020-01-01',
                    njobs=None,
                    keep_correlations=False,
                    stack='1d',
                    **kwargs):
    """
    Start correlation

    :param io: |io|
    :param filter_inventory: filter inventory with its select method,
        specified dict is passed to |Inventory.select|
    :param str startdate,enddate: start and end date as strings
    :param njobs: number of cores to use for computation, days are computed
        parallel, this might consume much memory, default: None -- use all
        available cores
    :param keep_correlations,stack,\*\*kwargs: all other kwargs are passed to
        `~yam.correlate.correlate()` function
    """
    if filter_inventory:
        log.debug('filter inventory')
        io['inventory'] = io['inventory'].select(**filter_inventory)
    log.info('start preprocessing and correlation')
    tasks = list(IterTime(UTC(startdate), UTC(enddate)))
    # check for existing days
    # Not perfect yet:
    # If a day exits for one combination and not for another station
    # combination, it will be marked as done
    done_tasks = None
    if stack is not None:
        key2 = kwargs['outkey'] + '_s' + stack
        done_tasks = [UTC(t[-16:-6]) for t in
                      _get_existent(io['stack'], key2, 4)]
    if keep_correlations:
        key2 = kwargs['outkey']
        done_tasks2 = [UTC(t[-16:-6]) for t in
                       _get_existent(io['corr'], key2, 4)]
        if done_tasks is None:
            done_tasks = done_tasks2
        else:
            done_tasks = [t for t in done_tasks if t in done_tasks2]
    tasks = _todo_tasks(tasks, done_tasks)
    kwargs.update({'keep_correlations': keep_correlations, 'stack': stack})
    do_work = functools.partial(correlate, io, **kwargs)
    start_parallel_jobs(tasks, do_work, _write_stream, njobs=njobs)
    log.info('finished preprocessing and correlation') 
開發者ID:trichter,項目名稱:yam,代碼行數:49,代碼來源:commands.py

示例9: load

# 需要導入模塊: from obspy import core [as 別名]
# 或者: from obspy.core import UTCDateTime [as 別名]
def load(io, key, seedid=None, day=None, do='return', prep_kw={},
         fname=None, format=None):
    """
    Load object and do something with it

    :param io: io
    :param key: key of object to load
        (key inside HDF5 file, or one of data, prepdata, stations)
    :param seedid: seed id of a  channel (for data or prepdata)
    :param day: |UTC| object with day (for data or prepdata)
    :param do: specifies what to do with the object, default is ``'return'``
        which simply returns the object, other possible values are
        ``'print'`` -- print object (used by print command),
        ``'load'`` -- load object in IPython session (used by load command),
        ``'export'`` -- export correlations to different file format
        (used by export command)
    :param dict prep_kw: options passed to preprocess (for prepdata only)
    :param fname: file name (for export command)
    :param format: target format (for export command)
    """
    if key == 'stations':
        obj = io['inventory']
    elif key in ('data', 'prepdata'):
        if seedid is None or day is None:
            msg = 'seedid and day must be given for data or prepdata'
            raise ParseError(msg)
        if key == 'prepdata':
            prep_keys = ('remove_response', 'remove_response_options',
                         'filter', 'normalization',
                         'time_norm_options', 'spectral_whitening_options',
                         'downsample')
            prep_kw = {k: prep_kw.get(k) for k in prep_keys}
        obj = _load_data(seedid, day, io['data'], io.get('data_format'),
                         key, inventory=io['inventory'], **prep_kw)
    else:
        is_stretch = 't' in _analyze_key(key)
        fname_in = _get_fname(io, key)
        if is_stretch:
            obj = read_dicts(fname_in, key)
            if do == 'print':
                obj = '\n\n'.join(str(o) for o in obj)
        else:
            obj = obspy.read(fname_in, 'H5', group=key, headonly=do == 'print')
            if do == 'print':
                obj = obj.__str__(extended=True)
    if do == 'print':
        print(obj)
    elif do == 'load':
        _start_ipy(obj)
    elif do == 'return':
        return obj
    elif do == 'export':
        print(obj)
        obspyh5.set_index()
        obj.write(fname, format)
        obspyh5.set_index(INDEX)
    else:
        raise 
開發者ID:trichter,項目名稱:yam,代碼行數:60,代碼來源:commands.py

示例10: __init__

# 需要導入模塊: from obspy import core [as 別名]
# 或者: from obspy.core import UTCDateTime [as 別名]
def __init__(self, network_list=None, reportnum_list=None,
                 station_list=None, location_list=None, channel_list=None,
                 component_list=None, receiver_list=None, array_list=None,
                 minlatitude=None, maxlatitude=None, minlongitude=None,
                 maxlongitude=None, latitude=None, longitude=None,
                 minradius=None, maxradius=None, start_time=None,
                 end_time=None):

        self.network_list = network_list
        self.reportnum_list = reportnum_list
        self.station_list = station_list
        self.location_list = location_list
        self.channel_list = channel_list
        self.component_list = component_list
        self.receiver_list = receiver_list
        self.array_list = array_list
        self.minlatitude = minlatitude
        self.maxlatitude = maxlatitude
        self.minlongitude = minlongitude
        self.maxlongitude = maxlongitude
        self.latitude = latitude
        self.longitude = longitude
        self.minradius = minradius
        self.maxradius = maxradius
        self.start_time = start_time
        self.end_time = end_time
        self.ph5_station_id_list = []  # updated by PH5toStationXMLParser

        # assign default values
        if not self.network_list:
            self.network_list = ["*"]
        if not self.reportnum_list:
            self.reportnum_list = ["*"]
        if not self.station_list:
            self.station_list = ["*"]
        if not self.location_list:
            self.location_list = ["*"]
        if not self.channel_list:
            self.channel_list = ["*"]
        if not self.component_list:
            self.component_list = ["*"]
        if not self.receiver_list:
            self.receiver_list = ["*"]
        if not self.array_list:
            self.array_list = ["*"]
        if self.start_time:
            self.start_time = UTCDateTime(start_time)
        if self.end_time:
            self.end_time = UTCDateTime(end_time) 
開發者ID:PIC-IRIS,項目名稱:PH5,代碼行數:51,代碼來源:ph5tostationxml.py


注:本文中的obspy.core.UTCDateTime方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。