EIDA / userfeedback

This repository is meant to collect feedback from EIDA users by means of its Issue Tracker
10 stars 4 forks source link

[EIDA token] How to use an EIDA token when using ObsPy Mass Downloader? #125

Closed WeiMouZhu closed 1 year ago

WeiMouZhu commented 2 years ago

Please provide the following information in the text:

WeiMouZhu commented 2 years ago

Hello, I have had an EIDA token and I want to download some seismic events data through Mass Downloader. This is the problem that I encounter. I wonder whether I use the token in the right way? Thank you a lot!

截屏2022-05-31 23 22 56

Below is the code:

import obspy, os
from obspy.clients.fdsn.mass_downloader import RectangularDomain, Restrictions, MassDownloader
from obspy.clients.fdsn import Client
###
lat_min = 27
lat_max = 45
lon_min = -12
lon_max = 5

pre_event_min = -1.
aft_event_min = 10.

if os.path.exists('data'):
    pass
else:
    os.mkdir('data')

if os.path.exists('RESP'):
    pass
else:
    os.mkdir('RESP')

################# read in the event parameters from  events.par (ZLF) #############
elf=open('log/events.par','r')
el=elf.read().splitlines()
elf.close()

i = 0
while i < len(el):
    event=el[i].split()

    event_dir = event[0]
    ymd = event[1]
    hour = event[2]
    mini = event[3]
    msec = event[4]

    lat = event[5]
    lon = event[6]
    depth =event[7]

    origin_time = obspy.UTCDateTime(ymd + ' ' + hour + ':' + mini + ':' + msec)

    #event_dir = ymd + '.' + hour.zfill(2) + '.' + mini.zfill(2)

    print('\033[1;34m Start downloading data for a new event \033[0m')
    print('event number: '+ str(i) + '; ' + event_dir)

    #Rectangular domain 
    domain = RectangularDomain(minlatitude=lat_min, maxlatitude=lat_max,
                               minlongitude=lon_min, maxlongitude=lon_max)

    restrictions = Restrictions(
        # Time
        starttime=origin_time - pre_event_min * 60,
        endtime=origin_time + aft_event_min * 60,
        # NO Gap
        reject_channels_with_gaps=True,
        # Trace
        minimum_length=0.90,
        # Station off 1km
        minimum_interstation_distance_in_m=10E3,
        # Only HH or BH channels
        channel_priorities=["HH[Z]", "BH[Z]"],
        # Location codes
        location_priorities=["", "00", "10"])

    # Providers 

    client_geofon = Client("GEOFON", eida_token = "./eidatokenZHU")
    client_orfeus = Client("ORFEUS", eida_token = "./eidatokenZHU")
    mdl = MassDownloader(providers=["client_geofon", "client_orfeus"])

    # The data will be downloaded to the "data/" and "stations"
    # folders with automatically chosen file names.
    mdl.download(domain, restrictions, mseed_storage="data/" + event_dir, stationxml_storage="RESP/" + event_dir)

    i = i + 1
megies commented 2 years ago

@WilmerZhu does downloading data with EIDA token works outside of the mass downloader, if you make requests with EIDA token and a regular obspy FDSN Client?

jschaeff commented 1 year ago

No feedback from OP, I close the issue, feel free to open it again if needed.