示例#1
0
def make_arcObspyrequest(station, begin, end, channel, loc):

    logger.info('\033[31m Obspy ARCLINKREQUEST \033[0m\n' % ())
    size = 0
    pid = os.getpid()

    rstation = station.split('_')

    if loc == '--':
        loc = ''
    client = Client(user=_mail, dcid_keys={'GFZ': '5]p[x#mJ'}, timeout=10)

    st = obspy.core.stream.Stream()
    for i in channel:
        st += client.getWaveform(rstation[0], rstation[1], loc, i, begin, end)

    output = str(pid) + '-' + station + '-ARCLINK.mseed'
    st.write(output, format='MSEED', reclen=512)
    size = proof_file_v2(output, channel)

    try:
        os.remove(output)
    except:
        print ''

    return size
示例#2
0
def getNetworkInventory(network, user1):
    '''
        Retrieve all stations from one WEBDC network
        
        :type network: str
        :param network: name of network to search for station
        '''

    inv = None
    isOk = False

    for i in range(5):
        try:
            client = Client(user=user1)  #hs
            #client  = Client (user=user1, timeout=100)                             #hs
            inv = client.getInventory(network,
                                      '*',
                                      '*',
                                      '*',
                                      restricted=None,
                                      permanent=None)
            isOk = True
            break

        except:
            #time.sleep (1.0); continue
            return None
    #endfor

    if not isOk: return None  # return _getFromCatalog (network)
    else: return inv
示例#3
0
def getInventory(station, usermail_1, key_1):

    client = Client(user=usermail_1, dcid_keys=key_1)
    inv = client.getInventory(station.net,
                              station.sta,
                              loc,
                              station.comp,
                              instruments=True)

    return inv
示例#4
0
def getInventoryViaArcLink(t1,t2,center,grradius,bbox,args):


    client = Client(user='******')

    coordLimits=getCoordLimits(center,grradius,bbox,args)


    inv = client.getInventory(args.net, '*', '*', args.cha, starttime=UTCDateTime(t1), endtime=UTCDateTime(t2), \
                             min_latitude=coordLimits[0], max_latitude=coordLimits[1], \
                             min_longitude=coordLimits[2], max_longitude=coordLimits[3])

    return inv
 def _fetchFromArclink(self, request, start, end):
     """
     """
     try:
         from obspy.arclink.client import Client
     except:
         return ''
     c = Client()
     # parameters
     nid = request.args0.get('network_id')
     sid = request.args0.get('station_id')
     lid = request.args0.get('location_id', '')
     cid = request.args0.get('channel_id', '*')
     try:
         st = c.getWaveform(nid, sid, lid, cid, start, end)
     except Exception, e:
         raise InternalServerError(e)
示例#6
0
def getDataViaArcLink(t1,t2,inv,args):

    client = Client(user='******')

    data = Stream()

    a = inv.keys() 
    for i in range(len(a)):
        l = a[i].split('.')
        if len(l) <= 2:
           pass
        else:
           Net = l[0]
           Sta = l[1]
           Cha = l[3]

           try: 
             st = client.getWaveform(Net, Sta, "", Cha, UTCDateTime(t1), UTCDateTime(t2), metadata="TRUE")
             data.append(st[0])
           except:
             pass
   
    return data
def make_arcObspyrequest(station, begin, end, channel, loc, pwdkeys):

    print 'INOBSPY ', pwdkeys, type(pwdkeys)
    print 'Obspy ARCLINKREQUEST FOR STATION '

    size = 0
    rstation = station.split('_')

    if loc == '--': loc = ''

    #   client = Client(user=_mail,dcid_keys=pwdkeys,timeout = 5)        #hs - Lutz
    client = Client(user=_mail, dcid_keys=pwdkeys, timeout=120)  #hs

    st = Stream()

    #for i in channel:
    #    try:    st += client.getWaveform(rstation[0], rstation[1], loc, i, begin, end)
    #    except: continue         # ArclinkException: No data available
    #endfor

    try:
        st += client.getWaveform(rstation[0], rstation[1], loc, '*', begin,
                                 end)  #hs v2
    except:
        return 0

    print 'INOBS ', rstation, channel
    streamList = []

    for i in st:
        streamList.append(i.stats.channel)

    #if len(set(streamList)) == len(channel): size = proof_file_v3(st, channel) #hs
    #else:                                        size = 0                           #hs

    size = proof_file_v3(st, channel)  #hs
    return size
示例#8
0
def getNetworks(user1, start, end):
    '''
    Return dictionary of available networks via Arclink
        
    :type start: obspy.core.utcdatetime.UTCDateTime
    :param start: Start date and time
    :type end: obspy.core.utcdatetime.UTCDateTime
    :param end: End date and time
    '''

    for i in range(3):
        Logfile.add(
            ' ',
            'Waiting for dictionary of available geofon networks (via Arclink) ....'
        )

        try:
            L = []
            client = Client(user=user1)  #hs
            #client = Client (user = user1, timeout=20)               #hs
            t = client.getNetworks(start, end)

            for index, i in enumerate(t.iterkeys()):
                z = i.split('.')
                L.append(z[0])

            L = list(set(L))
            break

        except:
            Logfile.exception('getGeofonNetworks')
            Logfile.exception('Retry access')
            L = []
            continue
    #endfor

    return L