Skip to content

Instantly share code, notes, and snippets.

@NeptuneProjects
Created August 8, 2020 13:46
Show Gist options
  • Save NeptuneProjects/98318a5de8e852fa75401cc7ca704523 to your computer and use it in GitHub Desktop.
Save NeptuneProjects/98318a5de8e852fa75401cc7ca704523 to your computer and use it in GitHub Desktop.
Python-based FDSN mass downloader based on Obspy
def mass_data_downloader(savepath, start='20141201', stop='20161201',
Network='XH', Station='*', Channel='HH*'):
'''
This function uses the FDSN mass data downloader to automatically download
data from the XH network deployed on the RIS from Nov 2014 - Nov 2016.
More information on the Obspy mass downloader available at:
https://docs.obspy.org/packages/autogen/obspy.clients.fdsn.mass_downloader.html
Inputs:
savepath: "[string to savepath]"
start: "YYYYMMDD"
stop: "YYYYMMDD"
Network: 2-character FDSN network code
Station: 2-character station code
Channel: 3-character channel code
*Note: Location is set to "*" by default.
William Jenkins
Scripps Institution of Oceanography, UC San Diego
February 2020
'''
print("=" * 65)
print("Initiating mass download request.")
start = UTCDateTime(start)
stop = UTCDateTime(stop)
if not os.path.exists(savepath):
os.makedirs(f'{savepath}/MSEED}')
os.makedirs(f'{savepath}/StationXML}')
domain = RectangularDomain(
minlatitude=-85,
maxlatitude=-75,
minlongitude=160,
maxlongitude=-130
)
restrictions = Restrictions(
starttime = start,
endtime = stop,
chunklength_in_sec = 86400,
network = Network,
station = Station,
location = "*",
channel = Channel,
reject_channels_with_gaps = False,
minimum_length = 0.0,
minimum_interstation_distance_in_m = 100.0
)
mdl = MassDownloader(providers=["IRIS"])
mdl.download(
domain,
restrictions,
mseed_storage=f"{savepath}/MSEED}",
stationxml_storage=f"{savepath}/StationXML/"
)
logger = logging.getLogger("obspy.clients.fdsn.mass_downloader")
logger.setLevel(logging.DEBUG)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment