当前位置: 首页>>代码示例>>Python>>正文


Python UTCDateTime.now方法代码示例

本文整理汇总了Python中obspy.UTCDateTime.now方法的典型用法代码示例。如果您正苦于以下问题:Python UTCDateTime.now方法的具体用法?Python UTCDateTime.now怎么用?Python UTCDateTime.now使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在obspy.UTCDateTime的用法示例。


在下文中一共展示了UTCDateTime.now方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: read_srcfrechet

# 需要导入模块: from obspy import UTCDateTime [as 别名]
# 或者: from obspy.UTCDateTime import now [as 别名]
  def read_srcfrechet(self, filename=None, update=False):
    """ Read in source derivative of misfit function
        Dchi/Dxs, Dchi/Dmt
    """
    with open(filename, 'r') as f:
      lines = [ x for x in f.readlines() if not(x.startswith('#')) ]

    lines = [x.split() for x in lines]

    t0  = float(lines[0][0]);  dchi_dt0  = float(lines[0][1])
    tau = float(lines[1][0]);  dchi_dtau = float(lines[1][1])
    x   = float(lines[2][0]);  dchi_dx   = float(lines[2][1])
    y   = float(lines[3][0]);  dchi_dy   = float(lines[3][1])
    z   = float(lines[4][0]);  dchi_dz   = float(lines[4][1])
    mxx = float(lines[5][0]);  dchi_dmxx = float(lines[5][1])
    myy = float(lines[6][0]);  dchi_dmyy = float(lines[6][1])
    mzz = float(lines[7][0]);  dchi_dmzz = float(lines[7][1])
    mxy = float(lines[8][0]);  dchi_dmxy = float(lines[8][1])
    mxz = float(lines[9][0]);  dchi_dmxz = float(lines[9][1])
    myz = float(lines[10][0]); dchi_dmyz = float(lines[10][1])

    dchi_dxs = np.array([dchi_dx, dchi_dy, dchi_dz])

    dchi_dmt = np.zeros((3,3))
    dchi_dmt[0,0] = dchi_dmxx
    dchi_dmt[1,1] = dchi_dmyy
    dchi_dmt[2,2] = dchi_dmzz
    dchi_dmt[0,1] = dchi_dmxy
    dchi_dmt[1,0] = dchi_dmxy
    dchi_dmt[0,2] = dchi_dmxz
    dchi_dmt[2,0] = dchi_dmxz
    dchi_dmt[1,2] = dchi_dmyz
    dchi_dmt[2,1] = dchi_dmyz

    # check if the same as event info
    data = self.data
    event = data['event']
    #...

    # record 
    src_frechet = {
        't0':dchi_dt0,
        'tau':dchi_dtau,
        'xs':dchi_dxs,
        'mt':dchi_dmt,
        'stat': {'code':0, 'msg':"created on "+UTCDateTime.now().isoformat()}
        }

    if 'src_frechet' not in data:
      data['src_frechet'] = src_frechet
    elif update:
      data['src_frechet'].update(src_frechet)
      data['src_frechet']['stat']['code'] = 1
      data['src_frechet']['stat']['msg'] = "updated on "+UTCDateTime.now().isoformat()
    else:
      raise Exception('src_frechet already set, not updated.')
开发者ID:taotaokai,项目名称:sem_utils,代码行数:58,代码来源:misfit_new.py

示例2: create_simple_inventory

# 需要导入模块: from obspy import UTCDateTime [as 别名]
# 或者: from obspy.UTCDateTime import now [as 别名]
def create_simple_inventory(
    network,
    station,
    latitude=None,
    longitude=None,
    elevation=None,
    depth=None,
    start_date=None,
    end_date=None,
    location_code="S3",
    channel_code="MX",
):
    """
    Create simple inventory with only location information,
    for ZNE component, especially usefull for synthetic data
    """
    azi_dict = {"MXZ": 0.0, "MXN": 0.0, "MXE": 90.0}
    dip_dict = {"MXZ": 90.0, "MXN": 0.0, "MXE": 0.0}
    channel_list = []

    if start_date is None:
        start_date = UTCDateTime(0)

    # specfem default channel code is MX
    for _comp in ["Z", "E", "N"]:
        _chan_code = "%s%s" % (channel_code, _comp)
        chan = Channel(
            _chan_code,
            location_code,
            latitude=latitude,
            longitude=longitude,
            elevation=elevation,
            depth=depth,
            azimuth=azi_dict[_chan_code],
            dip=dip_dict[_chan_code],
            start_date=start_date,
            end_date=end_date,
        )
        channel_list.append(chan)

    site = Site("N/A")
    sta = Station(
        station,
        latitude=latitude,
        longitude=longitude,
        elevation=elevation,
        channels=channel_list,
        site=site,
        creation_date=start_date,
        total_number_of_channels=3,
        selected_number_of_channels=3,
    )

    nw = Network(network, stations=[sta], total_number_of_stations=1, selected_number_of_stations=1)

    inv = Inventory([nw], source="SPECFEM3D_GLOBE", sender="Princeton", created=UTCDateTime.now())

    return inv
开发者ID:wjlei1990,项目名称:pytomo3d,代码行数:60,代码来源:utils.py

示例3: add_stationxml_to_asdf

# 需要导入模块: from obspy import UTCDateTime [as 别名]
# 或者: from obspy.UTCDateTime import now [as 别名]
def add_stationxml_to_asdf(ds, staxml_filelist, event=None,
                           create_simple_inv=False, sta_dict=None,
                           status_bar=False):
    # Add StationXML files.
    if create_simple_inv:
        if event is None:
            start_date = UTCDateTime.now()
        else:
            origin = event.preferred_origin() or event.origins[0]
            event_time = origin.time
            start_date = event_time - 300.0
        nstaxml = len(sta_dict)
        count = 0
        for tag, value in sta_dict.iteritems():
            count += 1
            inv = create_simple_inventory(
                value[0], value[1], latitude=value[2], longitude=value[3],
                elevation=value[4], depth=value[5], start_date=start_date)
            ds.add_stationxml(inv)
            if status_bar > 0:
                drawProgressBar((count)/nstaxml,
                                "Adding StationXML(created) data")
    else:
        nstaxml = len(staxml_filelist)
        if staxml_filelist is not None and nstaxml > 0:
            for _i, filename in enumerate(staxml_filelist):
                if not os.path.exists(filename):
                    raise ValueError("Staxml not exist %i of %i: %s"
                                     % (_i, nstaxml, filename))
                try:
                    ds.add_stationxml(filename)
                except Exception as err:
                    print("Error convert(%s) due to:%s" % (filename, err))
                if status_bar > 0:
                    drawProgressBar((_i+1)/nstaxml, "Adding StationXML data")
        else:
            print("No stationxml added")
开发者ID:wjlei1990,项目名称:pypaw,代码行数:39,代码来源:convert.py

示例4: test_now

# 需要导入模块: from obspy import UTCDateTime [as 别名]
# 或者: from obspy.UTCDateTime import now [as 别名]
 def test_now(self):
     """
     Test now class method of UTCDateTime class.
     """
     dt = UTCDateTime()
     self.assertTrue(UTCDateTime.now() >= dt)
开发者ID:avuan,项目名称:obspy,代码行数:8,代码来源:test_utcdatetime.py

示例5: test_now

# 需要导入模块: from obspy import UTCDateTime [as 别名]
# 或者: from obspy.UTCDateTime import now [as 别名]
 def test_now(self):
     """
     Test now class method of UTCDateTime class.
     """
     dt = UTCDateTime()
     self.assertGreaterEqual(UTCDateTime.now(), dt)
开发者ID:jshridha,项目名称:obspy,代码行数:8,代码来源:test_utcdatetime.py


注:本文中的obspy.UTCDateTime.now方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。