def __init__(self, time, lat, lon, depth, magnitude, user=None, password=None, radius=None, dt=None, ddepth=None, dmag=None, rawdir=None, config=None, drop_non_free=True): """Create a GeoNetFetcher instance. Args: time (datetime): Origin time. lat (float): Origin latitude. lon (float): Origin longitude. depth (float): Origin depth. magnitude (float): Origin magnitude. user (str): (Optional) username for site. password (str): (Optional) password for site. radius (float): Search radius (km). dt (float): Search time window (sec). ddepth (float): Search depth window (km). dmag (float): Search magnitude window (magnitude units). rawdir (str): Path to location where raw data will be stored. If not specified, raw data will be deleted. config (dict): Dictionary containing configuration. If None, retrieve global config. drop_non_free (bool): Option to ignore non-free-field (borehole, sensors on structures, etc.) """ # what values do we use for search thresholds? # In order of priority: # 1) Not-None values passed in constructor # 2) Configured values # 3) DEFAULT values at top of the module if config is None: config = get_config() cfg_radius = None cfg_dt = None cfg_ddepth = None cfg_dmag = None if 'fetchers' in config: if 'GeoNetFetcher' in config['fetchers']: fetch_cfg = config['fetchers']['GeoNetFetcher'] if 'radius' in fetch_cfg: cfg_radius = float(fetch_cfg['radius']) if 'dt' in fetch_cfg: cfg_dt = float(fetch_cfg['dt']) if 'ddepth' in fetch_cfg: cfg_ddepth = float(fetch_cfg['ddepth']) if 'dmag' in fetch_cfg: cfg_dmag = float(fetch_cfg['dmag']) radius = _get_first_value(radius, cfg_radius, RADIUS) dt = _get_first_value(dt, cfg_dt, DT) ddepth = _get_first_value(ddepth, cfg_ddepth, DDEPTH) dmag = _get_first_value(dmag, cfg_dmag, DMAG) tz = pytz.UTC if isinstance(time, UTCDateTime): time = time.datetime self.time = tz.localize(time) self.lat = lat self.lon = lon self.radius = radius self.dt = dt self.rawdir = rawdir self.depth = depth self.magnitude = magnitude self.ddepth = ddepth self.dmag = dmag xmin = 158.555 xmax = 192.656 ymin = -51.553 ymax = -26.809 # this announces to the world the valid bounds for this fetcher. self.BOUNDS = [xmin, xmax, ymin, ymax] self.drop_non_free = drop_non_free
def __init__(self, time, lat, lon, depth, magnitude, user=None, password=None, radius=None, dt=None, ddepth=None, dmag=None, rawdir=None, config=None, drop_non_free=True): """Create a KNETFetcher instance. Download KNET/KikNet data from the Japanese NIED site: http://www.kyoshin.bosai.go.jp/cgi-bin/kyoshin/quick/list_eqid_en.cgi Args: time (datetime): Origin time. lat (float): Origin latitude. lon (float): Origin longitude. depth (float): Origin depth. magnitude (float): Origin magnitude. user (str): username for KNET/KikNET site. password (str): (Optional) password for site. radius (float): Search radius (km). dt (float): Search time window (sec). ddepth (float): Search depth window (km). dmag (float): Search magnitude window (magnitude units). rawdir (str): Path to location where raw data will be stored. If not specified, raw data will be deleted. config (dict): Dictionary containing configuration. If None, retrieve global config. drop_non_free (bool): Option to ignore non-free-field (borehole, sensors on structures, etc.) """ # what values do we use for search thresholds? # In order of priority: # 1) Not-None values passed in constructor # 2) Configured values # 3) DEFAULT values at top of the module if config is None: config = get_config() cfg_radius = None cfg_dt = None cfg_ddepth = None cfg_dmag = None cfg_user = None cfg_password = None if 'fetchers' in config: if 'KNETFetcher' in config['fetchers']: fetch_cfg = config['fetchers']['KNETFetcher'] if 'radius' in fetch_cfg: cfg_radius = float(fetch_cfg['radius']) if 'dt' in fetch_cfg: cfg_dt = float(fetch_cfg['dt']) if 'ddepth' in fetch_cfg: cfg_ddepth = float(fetch_cfg['ddepth']) if 'dmag' in fetch_cfg: cfg_dmag = float(fetch_cfg['dmag']) if 'user' in fetch_cfg: cfg_user = fetch_cfg['user'] if 'password' in fetch_cfg: cfg_password = fetch_cfg['password'] radius = _get_first_value(radius, cfg_radius, RADIUS) dt = _get_first_value(dt, cfg_dt, DT) ddepth = _get_first_value(ddepth, cfg_ddepth, DDEPTH) dmag = _get_first_value(dmag, cfg_dmag, DMAG) # for knet/kiknet, username/password is required if user is None or password is None: # check to see if those values are configured if cfg_user and cfg_password: user = cfg_user password = cfg_password else: fmt = 'Username/password are required to retrieve KNET/KikNET data.' raise Exception(fmt) if user == 'USERNAME' or password == 'PASSWORD': fmt = ('Username/password are required to retrieve KNET/KikNET\n' 'data. This tool can download data from the Japanese NIED\n' 'website. However, for this to work you will first need \n' 'to obtain a username and password from this website:\n' 'https://hinetwww11.bosai.go.jp/nied/registration/?LANG=en\n' 'Then create a custom config file by running the gmsetup\n' 'program, and edit the fetchers:KNETFetcher section\n' 'to use your username and password.') raise Exception(fmt) # allow user to turn restrict stations on or off. Restricting saves time, # probably will not ignore significant data. self.restrict_stations = config['fetchers']['KNETFetcher']['restrict_stations'] self.user = user self.password = password tz = pytz.UTC if isinstance(time, UTCDateTime): time = time.datetime self.time = tz.localize(time) self.lat = lat self.lon = lon self.radius = radius self.dt = dt self.rawdir = rawdir self.depth = depth self.magnitude = magnitude self.ddepth = ddepth self.dmag = dmag self.jptime = self.time + timedelta(seconds=JST_OFFSET) xmin = 127.705 xmax = 147.393 ymin = 29.428 ymax = 46.109 # this announces to the world the valid bounds for this fetcher. self.BOUNDS = [xmin, xmax, ymin, ymax] self.drop_non_free = drop_non_free
def __init__(self, time, lat, lon, depth, magnitude, user=None, password=None, radius=100, dt=16, ddepth=30, dmag=0.3, rawdir=None, config=None, drop_non_free=True): """Create a TurkeyFetcher instance. Download Turkish strong motion data from the Turkish NSMN site: http://kyhdata.deprem.gov.tr/2K/kyhdata_v4.php Args: time (datetime): Origin time. lat (float): Origin latitude. lon (float): Origin longitude. depth (float): Origin depth. magnitude (float): Origin magnitude. radius (float): Search radius (km). dt (float): Search time window (sec). ddepth (float): Search depth window (km). dmag (float): Search magnitude window (magnitude units). rawdir (str): Path to location where raw data will be stored. If not specified, raw data will be deleted. config (dict): Dictionary containing configuration. If None, retrieve global config. drop_non_free (bool): Option to ignore non-free-field (borehole, sensors on structures, etc.) """ # what values do we use for search thresholds? # In order of priority: # 1) Not-None values passed in constructor # 2) Configured values # 3) DEFAULT values at top of the module if config is None: config = get_config() cfg_radius = None cfg_dt = None cfg_ddepth = None cfg_dmag = None if 'fetchers' in config: if 'TurkeyFetcher' in config['fetchers']: fetch_cfg = config['fetchers']['KNETFetcher'] if 'radius' in fetch_cfg: cfg_radius = float(fetch_cfg['radius']) if 'dt' in fetch_cfg: cfg_dt = float(fetch_cfg['dt']) if 'ddepth' in fetch_cfg: cfg_ddepth = float(fetch_cfg['ddepth']) if 'dmag' in fetch_cfg: cfg_dmag = float(fetch_cfg['dmag']) radius = _get_first_value(radius, cfg_radius, RADIUS) dt = _get_first_value(dt, cfg_dt, DT) ddepth = _get_first_value(ddepth, cfg_ddepth, DDEPTH) dmag = _get_first_value(dmag, cfg_dmag, DMAG) tz = pytz.UTC self.time = tz.localize(time) self.lat = lat self.lon = lon self.radius = radius self.dt = dt self.rawdir = rawdir self.depth = depth self.magnitude = magnitude self.ddepth = ddepth self.dmag = dmag xmin = 25.664 xmax = 46.67 ymin = 34.132 ymax = 43.555 # this announces to the world the valid bounds for this fetcher. self.BOUNDS = [xmin, xmax, ymin, ymax] self.drop_non_free = drop_non_free
def __init__(self, time, lat, lon, depth, magnitude, email=None, process_type='raw', station_type='Ground', eq_radius=None, eq_dt=None, station_radius=None, rawdir=None, config=None, drop_non_free=True): """Create a CESMDFetcher instance. Download strong motion records from the CESMD site: https://strongmotioncenter.org/wserv/records/builder/ Args: time (datetime): Origin time. lat (float): Origin latitude. lon (float): Origin longitude. depth (float): Origin depth. magnitude (float): Origin magnitude. email (str): email address for CESMD site. process_type (str): One of 'raw' or 'processed'. station_type (str): One of "Array", "Ground", "Building", "Bridge", "Dam", "Tunnel", "Wharf", "Other" eq_radius (float): Earthquake search radius (km). eq_dt (float): Earthquake search time window (sec). station_radius (float): Station search radius (km). rawdir (str): Path to location where raw data will be stored. If not specified, raw data will be deleted. config (dict): Dictionary containing configuration. If None, retrieve global config. drop_non_free (bool): Option to ignore non-free-field (borehole, sensors on structures, etc.) """ # what values do we use for search thresholds? # In order of priority: # 1) Not-None values passed in constructor # 2) Configured values # 3) DEFAULT values at top of the module if config is None: config = get_config() cfg_eq_radius = None cfg_station_radius = None cfg_eq_dt = None cfg_email = None cfg_station_type = None cfg_process_type = None if 'fetchers' in config: if 'CESMDFetcher' in config['fetchers']: fetch_cfg = config['fetchers']['CESMDFetcher'] if 'eq_radius' in fetch_cfg: cfg_eq_radius = float(fetch_cfg['eq_radius']) if 'station_radius' in fetch_cfg: cfg_station_radius = float(fetch_cfg['station_radius']) if 'dt' in fetch_cfg: cfg_eq_dt = float(fetch_cfg['eq_dt']) if 'email' in fetch_cfg: cfg_email = fetch_cfg['email'] if 'process_type' in fetch_cfg: cfg_process_type = fetch_cfg['process_type'] if 'station_type' in fetch_cfg: cfg_station_type = fetch_cfg['station_type'] radius = _get_first_value(eq_radius, cfg_eq_radius, EQ_RADIUS) station_radius = _get_first_value(station_radius, cfg_station_radius, STATION_RADIUS) eq_dt = _get_first_value(eq_dt, cfg_eq_dt, EQ_DT) station_type = _get_first_value(station_type, cfg_station_type, STATION_TYPE) process_type = _get_first_value(process_type, cfg_process_type, PROCESS_TYPE) # for CESMD, user (email address) is required if email is None: # check to see if those values are configured if cfg_email: email = cfg_email else: fmt = 'Email address is required to retrieve CESMD data.' raise Exception(fmt) if email == 'EMAIL': fmt = ('Email address is required to retrieve CESMD\n' 'data. This tool can download data from the CESMD\n' 'website. However, for this to work you will first need \n' 'to register your email address using this website:\n' 'https://strongmotioncenter.org/cgi-bin/CESMD/register.pl\n' 'Then create a custom config file by running the gmsetup\n' 'program, and edit the fetchers:CESMDFetcher section\n' 'to use your email address.') raise Exception(fmt) self.metadata = None self.email = email self.process_type = process_type self.station_type = station_type tz = pytz.UTC if isinstance(time, UTCDateTime): time = time.datetime self.time = tz.localize(time) self.lat = lat self.lon = lon self.radius = radius self.station_radius = station_radius self.eq_dt = eq_dt self.rawdir = rawdir self.depth = depth self.magnitude = magnitude xmin = -199.528 xmax = -63.473 ymin = 17.44 ymax = 73.571 # this announces to the world the valid bounds for this fetcher. self.BOUNDS = [xmin, xmax, ymin, ymax] self.drop_non_free = drop_non_free
def __init__(self, time, lat, lon, depth, magnitude, radius=None, time_before=None, time_after=None, channels=None, rawdir=None, config=None, drop_non_free=True): """Create an FDSNFetcher instance. Download waveform data from the all available FDSN sites using the Obspy mass downloader functionality. Args: time (datetime): Origin time. lat (float): Origin latitude. lon (float): Origin longitude. depth (float): Origin depth. magnitude (float): Origin magnitude. radius (float): Search radius (km). time_before (float): Seconds before arrival time (sec). time_after (float): Seconds after arrival time (sec). rawdir (str): Path to location where raw data will be stored. If not specified, raw data will be deleted. config (dict): Dictionary containing configuration. If None, retrieve global config. drop_non_free (bool): Option to ignore non-free-field (borehole, sensors on structures, etc.) """ # what values do we use for search thresholds? # In order of priority: # 1) Not-None values passed in constructor # 2) Configured values # 3) DEFAULT values at top of the module if config is None: config = get_config() cfg_radius = None cfg_time_before = None cfg_time_after = None cfg_channels = None exclude_networks = EXCLUDE_NETWORKS exclude_stations = EXCLUDE_STATIONS reject_channels_with_gaps = REJECT_CHANNELS_WITH_GAPS minimum_length = MINIMUM_LENGTH sanitize = SANITIZE minimum_interstation_distance_in_m = MINIMUM_INTERSTATION_DISTANCE_IN_M network = NETWORK if 'fetchers' in config: if 'FDSNFetcher' in config['fetchers']: fetch_cfg = config['fetchers']['FDSNFetcher'] if 'radius' in fetch_cfg: cfg_radius = float(fetch_cfg['radius']) if 'time_before' in fetch_cfg: cfg_time_before = float(fetch_cfg['time_before']) if 'time_after' in fetch_cfg: cfg_time_after = float(fetch_cfg['time_after']) if 'channels' in fetch_cfg: cfg_channels = fetch_cfg['channels'] if 'exclude_networks' in fetch_cfg: exclude_networks = fetch_cfg['exclude_networks'] if 'exclude_stations' in fetch_cfg: exclude_stations = fetch_cfg['exclude_stations'] if 'reject_channels_with_gaps' in fetch_cfg: reject_channels_with_gaps = \ fetch_cfg['reject_channels_with_gaps'] if 'minimum_length' in fetch_cfg: minimum_length = fetch_cfg['minimum_length'] if 'sanitize' in fetch_cfg: sanitize = fetch_cfg['sanitize'] if 'minimum_interstation_distance_in_m' in fetch_cfg: minimum_interstation_distance_in_m = \ fetch_cfg['minimum_interstation_distance_in_m'] if 'network' in fetch_cfg: network = fetch_cfg['network'] radius = _get_first_value(radius, cfg_radius, RADIUS) time_before = _get_first_value(time_before, cfg_time_before, TIME_BEFORE) time_after = _get_first_value(time_after, cfg_time_after, TIME_AFTER) channels = _get_first_value(channels, cfg_channels, CHANNELS) tz = pytz.UTC if isinstance(time, UTCDateTime): time = time.datetime self.time = tz.localize(time) self.lat = lat self.lon = lon self.radius = radius self.time_before = time_before self.time_after = time_after self.rawdir = rawdir self.depth = depth self.magnitude = magnitude self.channels = channels self.network = network self.exclude_networks = exclude_networks self.exclude_stations = exclude_stations self.reject_channels_with_gaps = reject_channels_with_gaps self.minimum_length = minimum_length self.sanitize = sanitize self.minimum_interstation_distance_in_m = \ minimum_interstation_distance_in_m self.drop_non_free = drop_non_free self.BOUNDS = [-180, 180, -90, 90] self.config = config
def __init__(self, time, lat, lon, depth, magnitude, user=None, password=None, radius=100, dt=16, ddepth=30, dmag=0.3, rawdir=None, drop_non_free=True): """Create a TurkeyFetcher instance. Download Turkish strong motion data from the Turkish NSMN site: http://kyhdata.deprem.gov.tr/2K/kyhdata_v4.php Args: time (datetime): Origin time. lat (float): Origin latitude. lon (float): Origin longitude. depth (float): Origin depth. magnitude (float): Origin magnitude. radius (float): Search radius (km). dt (float): Search time window (sec). ddepth (float): Search depth window (km). dmag (float): Search magnitude window (magnitude units). rawdir (str): Path to location where raw data will be stored. If not specified, raw data will be deleted. drop_non_free (bool): Option to ignore non-free-field (borehole, sensors on structures, etc.) """ # what values do we use for search thresholds? # In order of priority: # 1) Not-None values passed in constructor # 2) Configured values # 3) DEFAULT values at top of the module config = get_config() cfg_radius = None cfg_dt = None cfg_ddepth = None cfg_dmag = None if 'fetchers' in config: if 'TurkeyFetcher' in config['fetchers']: fetch_cfg = config['fetchers']['KNETFetcher'] if 'radius' in fetch_cfg: cfg_radius = float(fetch_cfg['radius']) if 'dt' in fetch_cfg: cfg_dt = float(fetch_cfg['dt']) if 'ddepth' in fetch_cfg: cfg_ddepth = float(fetch_cfg['ddepth']) if 'dmag' in fetch_cfg: cfg_dmag = float(fetch_cfg['dmag']) radius = _get_first_value(radius, cfg_radius, RADIUS) dt = _get_first_value(dt, cfg_dt, DT) ddepth = _get_first_value(ddepth, cfg_ddepth, DDEPTH) dmag = _get_first_value(dmag, cfg_dmag, DMAG) tz = pytz.UTC self.time = tz.localize(time) self.lat = lat self.lon = lon self.radius = radius self.dt = dt self.rawdir = rawdir self.depth = depth self.magnitude = magnitude self.ddepth = ddepth self.dmag = dmag xmin = 25.664 xmax = 46.67 ymin = 34.132 ymax = 43.555 # this announces to the world the valid bounds for this fetcher. self.BOUNDS = [xmin, xmax, ymin, ymax] self.drop_non_free = drop_non_free
def __init__( self, time, lat, lon, depth, magnitude, user=None, password=None, radius=None, dt=None, ddepth=None, dmag=None, rawdir=None, config=None, drop_non_free=True, stream_collection=True, ): """Create a GeoNetFetcher instance. Args: time (datetime): Origin time. lat (float): Origin latitude. lon (float): Origin longitude. depth (float): Origin depth. magnitude (float): Origin magnitude. user (str): (Optional) username for site. password (str): (Optional) password for site. radius (float): Search radius (km). dt (float): Search time window (sec). ddepth (float): Search depth window (km). dmag (float): Search magnitude window (magnitude units). rawdir (str): Path to location where raw data will be stored. If not specified, raw data will be deleted. config (dict): Dictionary containing configuration. If None, retrieve global config. drop_non_free (bool): Option to ignore non-free-field (borehole, sensors on structures, etc.) stream_collection (bool): Construct and return a StreamCollection instance? """ # what values do we use for search thresholds? # In order of priority: # 1) Not-None values passed in constructor # 2) Configured values # 3) DEFAULT values at top of the module if config is None: config = get_config() cfg_radius = None cfg_dt = None cfg_ddepth = None cfg_dmag = None if "fetchers" in config: if "GeoNetFetcher" in config["fetchers"]: fetch_cfg = config["fetchers"]["GeoNetFetcher"] if "radius" in fetch_cfg: cfg_radius = float(fetch_cfg["radius"]) if "dt" in fetch_cfg: cfg_dt = float(fetch_cfg["dt"]) if "ddepth" in fetch_cfg: cfg_ddepth = float(fetch_cfg["ddepth"]) if "dmag" in fetch_cfg: cfg_dmag = float(fetch_cfg["dmag"]) radius = _get_first_value(radius, cfg_radius, RADIUS) dt = _get_first_value(dt, cfg_dt, DT) ddepth = _get_first_value(ddepth, cfg_ddepth, DDEPTH) dmag = _get_first_value(dmag, cfg_dmag, DMAG) tz = pytz.UTC if isinstance(time, UTCDateTime): time = time.datetime self.time = tz.localize(time) self.lat = lat self.lon = lon self.radius = radius self.dt = dt self.rawdir = rawdir self.depth = depth self.magnitude = magnitude self.ddepth = ddepth self.dmag = dmag self.drop_non_free = drop_non_free self.stream_collection = stream_collection
def __init__(self, time, lat, lon, depth, magnitude, user=None, password=None, radius=None, dt=None, ddepth=None, dmag=None, rawdir=None, config=None, drop_non_free=True): """Create a KNETFetcher instance. Download KNET/KikNet data from the Japanese NIED site: http://www.kyoshin.bosai.go.jp/cgi-bin/kyoshin/quick/list_eqid_en.cgi Args: time (datetime): Origin time. lat (float): Origin latitude. lon (float): Origin longitude. depth (float): Origin depth. magnitude (float): Origin magnitude. user (str): username for KNET/KikNET site. password (str): (Optional) password for site. radius (float): Search radius (km). dt (float): Search time window (sec). ddepth (float): Search depth window (km). dmag (float): Search magnitude window (magnitude units). rawdir (str): Path to location where raw data will be stored. If not specified, raw data will be deleted. config (dict): Dictionary containing configuration. If None, retrieve global config. drop_non_free (bool): Option to ignore non-free-field (borehole, sensors on structures, etc.) """ # what values do we use for search thresholds? # In order of priority: # 1) Not-None values passed in constructor # 2) Configured values # 3) DEFAULT values at top of the module if config is None: config = get_config() cfg_radius = None cfg_dt = None cfg_ddepth = None cfg_dmag = None cfg_user = None cfg_password = None if 'fetchers' in config: if 'KNETFetcher' in config['fetchers']: fetch_cfg = config['fetchers']['KNETFetcher'] if 'radius' in fetch_cfg: cfg_radius = float(fetch_cfg['radius']) if 'dt' in fetch_cfg: cfg_dt = float(fetch_cfg['dt']) if 'ddepth' in fetch_cfg: cfg_ddepth = float(fetch_cfg['ddepth']) if 'dmag' in fetch_cfg: cfg_dmag = float(fetch_cfg['dmag']) if 'user' in fetch_cfg: cfg_user = fetch_cfg['user'] if 'password' in fetch_cfg: cfg_password = fetch_cfg['password'] radius = _get_first_value(radius, cfg_radius, RADIUS) dt = _get_first_value(dt, cfg_dt, DT) ddepth = _get_first_value(ddepth, cfg_ddepth, DDEPTH) dmag = _get_first_value(dmag, cfg_dmag, DMAG) # for knet/kiknet, username/password is required if user is None or password is None: # check to see if those values are configured if cfg_user and cfg_password: user = cfg_user password = cfg_password else: fmt = 'Username/password are required to retrieve KNET/KikNET data.' raise Exception(fmt) if user == 'USERNAME' or password == 'PASSWORD': fmt = ('Username/password are required to retrieve KNET/KikNET\n' 'data. This tool can download data from the Japanese NIED\n' 'website. However, for this to work you will first need \n' 'to obtain a username and password from this website:\n' 'https://hinetwww11.bosai.go.jp/nied/registration/?LANG=en\n' 'Then create a custom config file by running the gmsetup\n' 'program, and edit the fetchers:KNETFetcher section\n' 'to use your username and password.') raise Exception(fmt) self.user = user self.password = password tz = pytz.UTC self.time = tz.localize(time) self.lat = lat self.lon = lon self.radius = radius self.dt = dt self.rawdir = rawdir self.depth = depth self.magnitude = magnitude self.ddepth = ddepth self.dmag = dmag self.jptime = self.time + timedelta(seconds=JST_OFFSET) xmin = 127.705 xmax = 147.393 ymin = 29.428 ymax = 46.109 # this announces to the world the valid bounds for this fetcher. self.BOUNDS = [xmin, xmax, ymin, ymax] self.drop_non_free = drop_non_free
def __init__(self, time, lat, lon, depth, magnitude, user=None, password=None, radius=None, dt=None, ddepth=None, dmag=None, rawdir=None, drop_non_free=True): """Create a KNETFetcher instance. Download KNET/KikNet data from the Japanese NIED site: http://www.kyoshin.bosai.go.jp/cgi-bin/kyoshin/quick/list_eqid_en.cgi Args: time (datetime): Origin time. lat (float): Origin latitude. lon (float): Origin longitude. depth (float): Origin depth. magnitude (float): Origin magnitude. user (str): username for KNET/KikNET site. password (str): (Optional) password for site. radius (float): Search radius (km). dt (float): Search time window (sec). ddepth (float): Search depth window (km). dmag (float): Search magnitude window (magnitude units). rawdir (str): Path to location where raw data will be stored. If not specified, raw data will be deleted. drop_non_free (bool): Option to ignore non-free-field (borehole, sensors on structures, etc.) """ # what values do we use for search thresholds? # In order of priority: # 1) Not-None values passed in constructor # 2) Configured values # 3) DEFAULT values at top of the module config = get_config() cfg_radius = None cfg_dt = None cfg_ddepth = None cfg_dmag = None cfg_user = None cfg_password = None if 'fetchers' in config: if 'KNETFetcher' in config['fetchers']: fetch_cfg = config['fetchers']['KNETFetcher'] if 'radius' in fetch_cfg: cfg_radius = float(fetch_cfg['radius']) if 'dt' in fetch_cfg: cfg_dt = float(fetch_cfg['dt']) if 'ddepth' in fetch_cfg: cfg_ddepth = float(fetch_cfg['ddepth']) if 'dmag' in fetch_cfg: cfg_dmag = float(fetch_cfg['dmag']) if 'user' in fetch_cfg: cfg_user = fetch_cfg['user'] if 'password' in fetch_cfg: cfg_password = fetch_cfg['password'] radius = _get_first_value(radius, cfg_radius, RADIUS) dt = _get_first_value(dt, cfg_dt, DT) ddepth = _get_first_value(ddepth, cfg_ddepth, DDEPTH) dmag = _get_first_value(dmag, cfg_dmag, DMAG) # for knet/kiknet, username/password is required if user is None or password is None: # check to see if those values are configured if cfg_user and cfg_password: user = cfg_user password = cfg_password else: fmt = 'Username/password are required to retrieve KNET/KikNET data.' raise Exception(fmt) self.user = user self.password = password tz = pytz.UTC self.time = tz.localize(time) self.lat = lat self.lon = lon self.radius = radius self.dt = dt self.rawdir = rawdir self.depth = depth self.magnitude = magnitude self.ddepth = ddepth self.dmag = dmag self.jptime = self.time + timedelta(seconds=JST_OFFSET) xmin = 127.705 xmax = 147.393 ymin = 29.428 ymax = 46.109 # this announces to the world the valid bounds for this fetcher. self.BOUNDS = [xmin, xmax, ymin, ymax] self.drop_non_free = drop_non_free
def __init__( self, time, lat, lon, depth, magnitude, user=None, password=None, radius=None, dt=None, ddepth=None, dmag=None, rawdir=None, config=None, drop_non_free=True, stream_collection=True, ): """Create a KNETFetcher instance. Download KNET/KikNet data from the Japanese NIED site: http://www.kyoshin.bosai.go.jp/cgi-bin/kyoshin/quick/list_eqid_en.cgi Args: time (datetime): Origin time. lat (float): Origin latitude. lon (float): Origin longitude. depth (float): Origin depth. magnitude (float): Origin magnitude. user (str): username for KNET/KikNET site. password (str): (Optional) password for site. radius (float): Search radius (km). dt (float): Search time window (sec). ddepth (float): Search depth window (km). dmag (float): Search magnitude window (magnitude units). rawdir (str): Path to location where raw data will be stored. If not specified, raw data will be deleted. config (dict): Dictionary containing configuration. If None, retrieve global config. drop_non_free (bool): Option to ignore non-free-field (borehole, sensors on structures, etc.) stream_collection (bool): Construct and return a StreamCollection instance? """ # what values do we use for search thresholds? # In order of priority: # 1) Not-None values passed in constructor # 2) Configured values # 3) DEFAULT values at top of the module if config is None: config = get_config() cfg_radius = None cfg_dt = None cfg_ddepth = None cfg_dmag = None cfg_user = None cfg_password = None if "fetchers" in config: if "KNETFetcher" in config["fetchers"]: fetch_cfg = config["fetchers"]["KNETFetcher"] if "radius" in fetch_cfg: cfg_radius = float(fetch_cfg["radius"]) if "dt" in fetch_cfg: cfg_dt = float(fetch_cfg["dt"]) if "ddepth" in fetch_cfg: cfg_ddepth = float(fetch_cfg["ddepth"]) if "dmag" in fetch_cfg: cfg_dmag = float(fetch_cfg["dmag"]) if "user" in fetch_cfg: cfg_user = fetch_cfg["user"] if "password" in fetch_cfg: cfg_password = fetch_cfg["password"] radius = _get_first_value(radius, cfg_radius, RADIUS) dt = _get_first_value(dt, cfg_dt, DT) ddepth = _get_first_value(ddepth, cfg_ddepth, DDEPTH) dmag = _get_first_value(dmag, cfg_dmag, DMAG) # for knet/kiknet, username/password is required if user is None or password is None: # check to see if those values are configured if cfg_user and cfg_password: user = cfg_user password = cfg_password else: fmt = "Username/password are required to retrieve KNET/KikNET data." raise Exception(fmt) if user == "USERNAME" or password == "PASSWORD": fmt = ( "Username/password are required to retrieve KNET/KikNET\n" "data. This tool can download data from the Japanese NIED\n" "website. However, for this to work you will first need \n" "to obtain a username and password from this website:\n" "https://hinetwww11.bosai.go.jp/nied/registration/?LANG=en\n" "Then create a custom config file by running the gmsetup\n" "program, and edit the fetchers:KNETFetcher section\n" "to use your username and password." ) raise Exception(fmt) # allow user to turn restrict stations on or off. Restricting saves # time, probably will not ignore significant data. self.restrict_stations = config["fetchers"]["KNETFetcher"]["restrict_stations"] self.user = user self.password = password tz = pytz.UTC if isinstance(time, UTCDateTime): time = time.datetime self.time = tz.localize(time) self.lat = lat self.lon = lon self.radius = radius self.dt = dt self.rawdir = rawdir self.depth = depth self.magnitude = magnitude self.ddepth = ddepth self.dmag = dmag self.jptime = self.time + timedelta(seconds=JST_OFFSET) self.drop_non_free = drop_non_free self.stream_collection = stream_collection
def __init__(self, time, lat, lon, depth, magnitude, radius=None, time_before=None, time_after=None, channels=None, rawdir=None, config=None, drop_non_free=True): """Create an FDSNFetcher instance. Download waveform data from the all available FDSN sites using the Obspy mass downloader functionality. Args: time (datetime): Origin time. lat (float): Origin latitude. lon (float): Origin longitude. depth (float): Origin depth. magnitude (float): Origin magnitude. radius (float): Search radius (km). time_before (float): Seconds before arrival time (sec). time_after (float): Seconds after arrival time (sec). rawdir (str): Path to location where raw data will be stored. If not specified, raw data will be deleted. config (dict): Dictionary containing configuration. If None, retrieve global config. drop_non_free (bool): Option to ignore non-free-field (borehole, sensors on structures, etc.) """ # what values do we use for search thresholds? # In order of priority: # 1) Not-None values passed in constructor # 2) Configured values # 3) DEFAULT values at top of the module if config is None: config = get_config() cfg_radius = None cfg_time_before = None cfg_time_after = None cfg_channels = None exclude_networks = EXCLUDE_NETWORKS exclude_stations = EXCLUDE_STATIONS reject_channels_with_gaps = REJECT_CHANNELS_WITH_GAPS minimum_length = MINIMUM_LENGTH sanitize = SANITIZE minimum_interstation_distance_in_m = MINIMUM_INTERSTATION_DISTANCE_IN_M network = NETWORK if 'fetchers' in config: if 'FDSNFetcher' in config['fetchers']: fetch_cfg = config['fetchers']['FDSNFetcher'] if 'radius' in fetch_cfg: cfg_radius = float(fetch_cfg['radius']) if 'time_before' in fetch_cfg: cfg_time_before = float(fetch_cfg['time_before']) if 'time_after' in fetch_cfg: cfg_time_after = float(fetch_cfg['time_after']) if 'channels' in fetch_cfg: cfg_channels = fetch_cfg['channels'] if 'exclude_networks' in fetch_cfg: exclude_networks = fetch_cfg['exclude_networks'] if 'exclude_stations' in fetch_cfg: exclude_stations = fetch_cfg['exclude_stations'] if 'reject_channels_with_gaps' in fetch_cfg: reject_channels_with_gaps = fetch_cfg['reject_channels_with_gaps'] if 'minimum_length' in fetch_cfg: minimum_length = fetch_cfg['minimum_length'] if 'sanitize' in fetch_cfg: sanitize = fetch_cfg['sanitize'] if 'minimum_interstation_distance_in_m' in fetch_cfg: minimum_interstation_distance_in_m = fetch_cfg['minimum_interstation_distance_in_m'] if 'network' in fetch_cfg: network = fetch_cfg['network'] radius = _get_first_value(radius, cfg_radius, RADIUS) time_before = _get_first_value(time_before, cfg_time_before, TIME_BEFORE) time_after = _get_first_value(time_after, cfg_time_after, TIME_AFTER) channels = _get_first_value(channels, cfg_channels, CHANNELS) tz = pytz.UTC self.time = tz.localize(time) self.lat = lat self.lon = lon self.radius = radius self.time_before = time_before self.time_after = time_after self.rawdir = rawdir self.depth = depth self.magnitude = magnitude self.channels = channels self.network = network self.exclude_networks = exclude_networks self.exclude_stations = exclude_stations self.reject_channels_with_gaps = reject_channels_with_gaps self.minimum_length = minimum_length self.sanitize = sanitize self.minimum_interstation_distance_in_m = minimum_interstation_distance_in_m self.drop_non_free = drop_non_free self.BOUNDS = [-180, 180, -90, 90]