-
Notifications
You must be signed in to change notification settings - Fork 10
/
smget
executable file
·71 lines (60 loc) · 1.96 KB
/
smget
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/tcsh -f
#
# SMGET CMTCODE, e.g. SMGET C202106062316A
# SMGET CMTCODE, e.g. SMGET C201606261117A
#
# Downloads simulations from the ShakeMovie website
#
# Last modified by fjsimons-at-alum.mit.edu, 06/17/2021
# Make sure the environmental variable MC is set, with subdirectory SEM, as
# the results are designed to go in $MC and $MC/SEM!
# Where is the website?
set IP = 128.112.172.121
set NS = global.shakemovie.princeton.edu
set PR = https://
# The CMT code
set CMT = $1
# The station we want
set STAT = PPGUY
# What we know the network is
set NETW = PN
# Flags identifying the "channels"
set SIM = (1d 3d)
# What we know their extensions are
set EXT = (modes sem)
# What we know their components are
set CMP = (LX MX)
# Where you will put it?
set mydata = $MC
set myddir = $MC/SEM
set mydcmt = $MC/SEM/$CMT
# If you didn't have it, will make it
test ! -d $mydata && mkdir $mydata
test ! -d $myddir && mkdir $myddir
test ! -d $mydcmt && mkdir $mydcmt
# Get the files!
foreach index (`seq 1 $#SIM`)
# Destination filename
set fname = $CMT\_$SIM[$index].sac.tar.gz
# Makes the URL and performs the query
# The below line used to work with http but ShakeMovie got an update to https and it broke
# curl -o $fname ''$PR''$NS'/shakemovie/dl?evid='$CMT'&product='$SIM[$index]''
# So now we change it as we did in MCMS2EVT
set noglob ########################################
set evtquery = "$PR$NS/shakemovie/dl?evid=$CMT&product=$SIM[$index]"
set actquery = "wget -q $evtquery -O $fname"
echo `$actquery`
unset noglob ########################################
# Make the destination
set fpart = $NETW.$STAT.$CMP[$index]
set lpart = $EXT[$index].sac
# Turns out the components are E, N, and Z
set wewant = ( {$fpart}E.$lpart \
{$fpart}N.$lpart \
{$fpart}Z.$lpart)
# Extract the station etc of interest
tar xvfz $fname $wewant
/bin/rm $fname
# Now actually put it there
mv $wewant $mydcmt
end