diff --git a/script/run_mpi_all.sh b/script/run_mpi_all.sh new file mode 100644 index 00000000..e69de29b diff --git a/src/noisepy/seis/S1_fft_cc_MPI.py b/src/noisepy/seis/S1_fft_cc_MPI.py index d77d29b0..d78998f2 100644 --- a/src/noisepy/seis/S1_fft_cc_MPI.py +++ b/src/noisepy/seis/S1_fft_cc_MPI.py @@ -153,7 +153,7 @@ def cross_correlate( t10 = time.time() logger.debug("smoothing source takes %6.4fs" % (t10 - t00)) else: - sfft1 = fft1.reshape(N, Nfft2) + sfft1 = np.conj(fft1).reshape(N, Nfft2) # get index right for auto/cross correlation istart = iiS # start at the channel source / only fills the upper right triangle matrix of channel pairs diff --git a/src/noisepy/seis/plotting_modules.py b/src/noisepy/seis/plotting_modules.py index 6d76f575..3bf625ea 100644 --- a/src/noisepy/seis/plotting_modules.py +++ b/src/noisepy/seis/plotting_modules.py @@ -223,15 +223,14 @@ def plot_substack_cc(sfile, freqmin, freqmax, disp_lag=None, savefig=True, sdir= ax1.set_yticks(np.arange(0, nwin, step=tick_inc)) ax1.set_yticklabels(timestamp[0::tick_inc]) ax1.xaxis.set_ticks_position("bottom") - - ax2.plot(amax / min(amax), "r-") - ax2.plot(ngood, "b-") - ax2.set_xlabel("waveform number") - ax2.set_xticks(np.arange(0, nwin, step=tick_inc)) - ax2.set_xticklabels(tmarks[0:nwin:tick_inc]) - for tick in ax2.get_xticklabels(): - tick.set_rotation(30) - ax2.legend(["relative amp", "ngood"], loc="upper right") + ax2.set_title("stacked and filtered at %4.2f-%4.2f Hz" % (freqmin, freqmax)) + ax2.plot( + np.arange(-disp_lag, disp_lag + dt, dt), + np.mean(data, axis=0), + "k-", + linewidth=1, + ) + ax2.set_xticks(t) fig.tight_layout() # save figure or just show diff --git a/tutorials/full_socal.csv b/tutorials/full_socal.csv new file mode 100644 index 00000000..08fa026c --- /dev/null +++ b/tutorials/full_socal.csv @@ -0,0 +1,376 @@ +network,station,latitude,longitude,elevation +CI,ACP,32.9546,-116.30338,392 +CI,ADO,34.55046,-117.43391,908 +CI,AGM,32.84474,-114.78425,324 +CI,AGO,34.14647,-118.76699,259 +CI,ALP,34.68708,-118.29946,753 +CI,APL,35.34149,-116.87464,959 +CI,ARV,35.1269,-118.83009,258 +CI,ASP,35.86114,-119.38511,64 +CI,AVC,33.33312,-118.33542,0 +CI,AVM,35.06562,-116.61549,708 +CI,BAC,33.6122,-117.0406,551 +CI,BAI,34.77695,-118.77335,1035 +CI,BAK,35.34444,-119.10445,116 +CI,BAR,32.68005,-116.67215,529 +CI,BBR,34.2623,-116.92075,2069 +CI,BBS,33.92139,-116.98058,785 +CI,BC3,33.65515,-115.45366,1137 +CI,BCW,34.94009,-119.41313,1101 +CI,BEL,34.0006,-115.9982,1388 +CI,BFS,34.23883,-117.65853,1312 +CI,BHP,33.99053,-118.36171,81 +CI,BLA2,34.06931,-116.38993,1247 +CI,BLC,34.24356,-118.67312,607 +CI,BLY,33.7503,-114.52375,201 +CI,BOM,33.36465,-115.72963,-54 +CI,BOR,33.2682,-116.41716,252 +CI,BRE,33.80776,-117.98116,24 +CI,BTP,34.68224,-118.57398,1702 +CI,BUE,34.61299,-120.19679,110 +CI,CAC,34.13678,-118.12199,230 +CI,CAR,35.30819,-119.84583,765 +CI,CBC,34.13972,-118.12715,253 +CI,CBC,34.13989,-118.12756,253 +CI,CBC,34.14011,-118.1275,239 +CI,CBC,34.14011,-118.1275,248 +CI,CCA,35.15252,-118.01649,710 +CI,CCC,35.52495,-117.36453,670 +CI,CDD,32.58395,-114.35617,213 +CI,CDM,34.36855,-119.34144,166 +CI,CFD,34.39927,-119.51576,8 +CI,CFS,34.10539,-117.28287,312 +CI,CFT,34.03547,-117.11241,682 +CI,CGO,36.5504,-117.80295,2795 +CI,CHF,34.33341,-118.02585,1594 +CI,CHI,34.18156,-119.22244,3 +CI,CHK,34.06714,-118.97118,258 +CI,CHN,33.99879,-117.68044,208 +CI,CHR,34.72902,-119.39269,1021 +CI,CIA,33.4019,-118.41502,477 +CI,CJM,34.27117,-117.42448,1616 +CI,CJV2,34.52978,-118.1445,1296 +CI,CKP,33.55507,-114.8904,145 +CI,CLC,35.81574,-117.59751,775 +CI,CLI2,33.12112,-115.58016,-60 +CI,CLO,34.22038,-119.00891,48 +CI,CLT,34.09284,-117.31687,325 +CI,COA,32.86341,-115.12339,36 +CI,COK2,32.85053,-115.7284,-14 +CI,CPO,32.64266,-116.48514,838 +CI,CPT2,33.34183,-117.32502,771 +CI,CRF,33.87352,-118.03938,17 +CI,CRF,33.87352,-118.03938,18 +CI,CRG,35.2422,-119.72486,1169 +CI,CRN,33.87574,-117.56106,204 +CI,CRR,32.88682,-115.96918,66 +CI,CSH,33.6442,-116.5956,1637 +CI,CSL,34.49651,-118.61621,353 +CI,CSL,34.49651,-118.61621,354 +CI,CTC,33.65516,-115.99006,538 +CI,CTW,33.67728,-115.87214,504 +CI,CVW,34.92217,-118.93913,804 +CI,CWC,36.43988,-118.08016,1595 +CI,CWP,33.55797,-117.55775,242 +CI,CYP,32.90611,-116.62722,1013 +CI,CZN,33.91375,-116.78409,538 +CI,DAN,34.63745,-115.38115,428 +CI,DAW,36.27148,-117.59214,0 +CI,DEC,34.25353,-118.33383,519 +CI,DEV,33.93597,-116.57794,337 +CI,DGR,33.65001,-117.00947,650 +CI,DJJ,34.10618,-118.45505,268 +CI,DJJB,34.10618,-118.45505,268 +CI,DLA,33.84822,-118.09624,14 +CI,DNR,33.56667,-116.63056,1274 +CI,DPP,32.99889,-116.94187,463 +CI,DRE,32.80532,-115.44679,-13 +CI,DSC,35.14255,-116.10395,283 +CI,DTC,34.42416,-118.66191,0 +CI,DTC,34.42416,-118.66191,382 +CI,DTP,35.26742,-117.84581,908 +CI,DZA,32.60657,-116.77477,554 +CI,EDW2,34.8811,-117.99388,772 +CI,ELS2,33.64907,-117.42604,844 +CI,EML,32.89083,-116.84566,161 +CI,EMS,32.73921,-114.98521,11 +CI,EOC,34.45029,-119.76941,75 +CI,ERR,33.11652,-115.82273,-56 +CI,ERR,33.11675,-115.82267,-56 +CI,ESI2,33.67493,-117.32592,0 +CI,ESI2,33.67493,-117.32592,388 +CI,FDR,35.64262,-118.93433,350 +CI,FHO,34.09355,-116.93588,1614 +CI,FIG,34.72832,-119.98803,945 +CI,FMO,34.4092,-118.92121,137 +CI,FMP,33.71264,-118.29381,89 +CI,FON,34.09957,-117.43876,388 +CI,FOX2,34.7339,-118.24046,719 +CI,FRK,33.40209,-115.63835,60 +CI,FRM,34.77518,-118.96935,2443 +CI,FUL,33.8717,-117.92251,51 +CI,FUR,36.46703,-116.86322,-37 +CI,FUR,36.46719,-116.86322,-38 +CI,GATR,34.55266,-120.50235,590 +CI,GCC,34.32758,-118.31888,726 +CI,GFF,34.92381,-115.07266,791 +CI,GFS,34.4766,-120.21436,71 +CI,GLA,33.05149,-114.82706,610 +CI,GMA,34.29148,-116.38256,848 +CI,GMR,34.78457,-115.65994,1326 +CI,GOR,33.1537,-117.22921,138 +CI,GOU,34.22119,-118.18834,587 +CI,GR2,34.11816,-118.30024,342 +CI,GRA,36.99608,-117.36621,689 +CI,GSA,34.13677,-118.1283,234 +CI,GSC,35.30177,-116.80574,1000 +CI,GVR,34.04972,-118.11995,141 +CI,HAR,35.0114,-117.29909,620 +CI,HAY,33.70734,-115.63889,458 +CI,HDH,34.77529,-118.63999,964 +CI,HDH,34.77529,-118.63999,965 +CI,HEC,34.8294,-116.335,920 +CI,HIW,35.03998,-115.38423,1276 +CI,HLL,34.17643,-118.35967,193 +CI,HLN,34.12128,-117.21897,358 +CI,HMT2,33.70811,-117.00152,593 +CI,HOL,34.45831,-117.84539,1267 +CI,HYS,34.86532,-117.56975,833 +CI,IDO,33.79678,-116.22152,469 +CI,IDQ,33.76795,-116.23897,29 +CI,IDY,33.74642,-116.71536,1632 +CI,IKP,32.65012,-116.10948,906 +CI,IMP,32.90147,-115.56071,-27 +CI,IPT,34.19701,-117.28498,943 +CI,IRG5,32.9408,-115.7958,108 +CI,IRM,34.15738,-115.14513,567 +CI,ISA,35.66278,-118.47403,873 +CI,IVY,33.76025,-117.47678,330 +CI,JEM,33.08098,-116.59755,1308 +CI,JNH2,34.44894,-117.95541,1305 +CI,JPLS,34.2053,-118.17368,465 +CI,JRC2,35.98249,-117.80885,1469 +CI,JTH,34.12644,-116.03785,606 +CI,JVA,34.36622,-116.61266,904 +CI,KIK,34.15037,-118.10156,237 +CI,KML,33.59738,-117.87909,9 +CI,KYV,33.92545,-116.1734,1498 +CI,LAF,33.86889,-118.33143,20 +CI,LAT,34.04449,-118.77643,351 +CI,LBW1,33.798,-118.08837,-16 +CI,LBW2,33.798,-118.08837,-16 +CI,LCG,34.00033,-118.37794,108 +CI,LCP,34.73551,-120.27996,199 +CI,LDF,35.13066,-115.18416,1239 +CI,LDR,34.9906,-118.34156,1121 +CI,LEO,34.63064,-118.30505,1025 +CI,LFP,34.30529,-118.48805,368 +CI,LGB,33.9753,-118.14918,42 +CI,LJR,34.80762,-118.86775,1443 +CI,LKH,33.23598,-116.75876,847 +CI,LLS,33.68447,-117.94304,8 +CI,LMH,33.74418,-117.39135,496 +CI,LMR2,34.93439,-117.69629,964 +CI,LMS,33.81744,-117.445,443 +CI,LMY,34.73316,-119.10391,1575 +CI,LOC,34.69073,-120.4469,95 +CI,LPC,34.31478,-117.54642,1351 +CI,LRL,35.47954,-117.68212,1340 +CI,LRR2,34.52706,-118.02998,906 +CI,LTP,33.8811,-118.17568,20 +CI,LUC2,34.45638,-116.96423,886 +CI,LUG,34.3656,-117.36683,1140 +CI,LUS,33.01375,-117.16305,120 +CI,LVO,34.5558,-119.88387,275 +CI,LVY,34.17408,-119.15636,11 +CI,LVY,34.17408,-119.15636,12 +CI,LYP,32.70333,-116.7548,886 +CI,MAG,35.36165,-118.92282,135 +CI,MCT,34.22645,-116.04073,661 +CI,MES,34.26311,-119.09588,69 +CI,MGE,33.81841,-116.36874,68 +CI,MIK,34.13688,-118.12601,275 +CI,MIKB,34.13688,-118.12601,231 +CI,MIS,33.7403,-118.33517,299 +CI,MLAC,37.63019,-118.83605,2162 +CI,MLS,34.0046,-117.56162,230 +CI,MMC,33.57304,-117.76258,46 +CI,MMC,33.57304,-117.76258,55 +CI,MNO,33.94738,-117.17278,564 +CI,MOP,34.28096,-118.90469,141 +CI,MOR,33.50388,-117.13993,331 +CI,MPI,34.81258,-119.1453,2673 +CI,MPM,36.05799,-117.48901,1839 +CI,MPP,34.88848,-119.81362,1739 +CI,MRS,35.42522,-116.88957,1000 +CI,MSC,34.03852,-116.64795,938 +CI,MSJ,33.80801,-116.96789,466 +CI,MTA,33.42654,-117.37927,785 +CI,MTG,33.19915,-116.64727,1092 +CI,MTP,35.48434,-115.5532,1588 +CI,MUR,33.59999,-117.19543,562 +CI,MWC,34.22362,-118.05832,1725 +CI,NBS,34.78035,-116.55798,590 +CI,NCH,34.9427,-119.67395,665 +CI,NEE2,34.76759,-114.61881,271 +CI,NEN,34.77539,-118.50099,859 +CI,NJQ,34.53412,-120.17737,219 +CI,NOT,34.22869,-118.55829,247 +CI,NPN,35.46739,-115.26851,935 +CI,NSS2,33.55553,-115.94586,17 +CI,NWH,33.73314,-117.75109,95 +CI,NWH,33.73314,-117.75109,96 +CI,OAT,34.34361,-118.61442,1089 +CI,OCP,32.74755,-116.01931,155 +CI,OGC,33.78816,-117.844,64 +CI,OLI,33.94539,-117.92372,162 +CI,OLP,32.60771,-116.93019,159 +CI,OSI,34.6145,-118.7235,718 +CI,PALA,33.38905,-117.03182,552 +CI,PASC,34.17141,-118.18523,341 +CI,PDE,34.44199,-118.58215,328 +CI,PDM,34.30336,-114.14152,144 +CI,PDR,33.96273,-118.43702,45 +CI,PDU,34.1207,-117.63808,445 +CI,PDW,33.92397,-117.61713,166 +CI,PDW,33.92397,-117.61713,168 +CI,PER,33.86164,-117.20529,468 +CI,PGA,33.4914,-117.0635,351 +CI,PHL,35.40773,-120.54556,355 +CI,PLM,33.35361,-116.86265,1691 +CI,PLS,33.7953,-117.60906,1199 +CI,PMD,33.64785,-116.37769,296 +CI,POB2,33.68708,-116.92382,999 +CI,POR,36.10368,-119.00343,198 +CI,PSD,33.82393,-116.55026,144 +CI,PSR,34.09181,-117.80709,305 +CI,PTD,34.00443,-118.80686,7 +CI,PUT,34.69115,-117.96919,747 +CI,QAD,34.42367,-119.60926,68 +CI,QLC,35.04084,-119.97425,556 +CI,QUG,34.39558,-118.49837,515 +CI,RAG,34.68289,-116.15139,722 +CI,RCR,33.36237,-116.3096,193 +CI,RCT,36.30523,-119.24384,107 +CI,RCU,34.08309,-117.52442,329 +CI,RCU,34.08309,-117.52442,331 +CI,RFR,35.11358,-120.09721,386 +CI,RHC2,34.00095,-118.01333,362 +CI,RHR,33.29021,-117.17648,173 +CI,RIN,34.28196,-118.47925,304 +CI,RINB,34.28196,-118.47925,304 +CI,RIO,34.10473,-117.97956,118 +CI,RKMO,33.67421,-117.60947,408 +CI,RMM,34.64384,-116.62438,1777 +CI,RPV,33.74346,-118.40412,107 +CI,RRX,34.87533,-116.99684,676 +CI,RSB,33.9731,-117.3272,297 +CI,RSI,34.85191,-120.20868,181 +CI,RSS,33.97327,-117.32674,298 +CI,RUN,32.97222,-114.97809,116 +CI,RUS,34.05075,-118.08078,70 +CI,RVR,33.99351,-117.37545,266 +CI,RXH,33.18313,-115.62257,-59 +CI,SAL,33.2801,-115.98585,14 +CI,SAN,33.70432,-117.88578,11 +CI,SBB2,34.68844,-117.82424,825 +CI,SBC,34.44076,-119.71492,94 +CI,SBI,33.48046,-119.02986,41 +CI,SBPX,34.2324,-117.23484,1860 +CI,SCI2,32.9799,-118.54697,199 +CI,SCZ2,33.99543,-119.6351,440 +CI,SDD,33.55259,-117.66171,120 +CI,SDG,32.784,-117.13805,101 +CI,SDR,32.73561,-116.94241,113 +CI,SES,34.43692,-119.1375,480 +CI,SGL,32.64933,-115.72638,75 +CI,SHO,35.89953,-116.2753,451 +CI,SHO,35.8996,-116.27515,451 +CI,SHU,34.64279,-118.16454,774 +CI,SIL,34.34802,-116.82746,1698 +CI,SIL,34.34803,-116.82747,1698 +CI,SLA,35.89095,-117.28332,1174 +CI,SLB,33.48519,-115.86643,0 +CI,SLH,33.19269,-116.25399,208 +CI,SLM,34.45227,-118.42267,523 +CI,SLR,33.83359,-116.79737,1567 +CI,SLV,33.23854,-115.30436,254 +CI,SMF2,34.02201,-118.44627,52 +CI,SMI,34.03818,-120.35132,165 +CI,SMM,35.3142,-119.99581,599 +CI,SMR,35.37699,-120.61247,341 +CI,SMT,34.33364,-119.01381,683 +CI,SMV,34.27091,-118.74407,276 +CI,SMW,35.01108,-120.40997,169 +CI,SNCC,33.24787,-119.52437,275 +CI,SNO,34.03515,-116.80778,2339 +CI,SNR,32.86189,-115.43596,-63 +CI,SOC,33.38761,-117.58013,52 +CI,SPF,34.05933,-118.64614,470 +CI,SPG2,36.20057,-118.76624,627 +CI,SQC,34.86647,-120.29439,130 +CI,SRA,34.60601,-115.94987,338 +CI,SRI,33.97875,-120.07886,392 +CI,SRN,33.82854,-117.78938,208 +CI,SRT,35.69235,-117.75051,667 +CI,SSS,34.03103,-117.45498,336 +CI,SSS,34.03103,-117.45498,337 +CI,STC,34.30302,-119.18676,180 +CI,STG,33.664,-117.76856,49 +CI,STS,33.79033,-118.19878,4 +CI,SVD,34.10647,-117.09822,605 +CI,SWP,32.79184,-116.09718,265 +CI,SWP,32.79184,-116.09718,379 +CI,SWS,32.94508,-115.79988,140 +CI,SYN,34.60723,-120.0696,201 +CI,SYP,34.52775,-119.97834,1278 +CI,SYP,34.52781,-119.97832,1278 +CI,TA2,34.38203,-117.67822,2249 +CI,TEH,35.2913,-118.42079,846 +CI,TEJ,35.23107,-118.68878,650 +CI,TER2,35.33233,-119.36238,80 +CI,TFT,35.14592,-119.41946,233 +CI,THC,34.90853,-118.66443,1688 +CI,THM,33.65066,-116.07734,60 +CI,TIN,37.05422,-118.23009,1197 +CI,TJR,35.02722,-118.74373,398 +CI,TOR,33.57526,-116.22584,4 +CI,TOW2,35.80856,-117.76488,685 +CI,TPO,34.87883,-118.22864,769 +CI,TUQ,35.43584,-115.92389,1350 +CI,USB,34.413,-119.8427,14 +CI,USC,34.01919,-118.28631,58 +CI,VCP,33.23934,-117.02125,426 +CI,VCS,34.48372,-118.11781,992 +CI,VDJ,34.18986,-114.57145,284 +CI,VES,35.84089,-119.08469,154 +CI,VLO,32.97178,-116.41061,519 +CI,VLY,33.73615,-117.15806,445 +CI,VOG,36.32098,-119.38226,90 +CI,VTV,34.56065,-117.3296,843 +CI,WAS2,35.7377,-118.55743,1828 +CI,WBM,35.60839,-117.89049,892 +CI,WBP,35.87841,-118.07414,2494 +CI,WBS,35.53664,-118.14035,1927 +CI,WCS2,36.02521,-117.76526,1143 +CI,WES,32.75904,-115.73161,-8 +CI,WGR,34.51085,-119.27407,554 +CI,WHF,35.69513,-118.35183,859 +CI,WLH2,36.15207,-118.31319,2672 +CI,WLS2,34.57899,-117.71939,889 +CI,WLT,34.00948,-117.95077,107 +CI,WMD,33.03826,-115.58191,-45 +CI,WMF,36.11758,-117.85486,1537 +CI,WNM,35.8422,-117.90616,974 +CI,WNS,34.115,-118.38,306 +CI,WOR,35.69563,-118.24246,795 +CI,WRC2,35.9479,-117.65038,943 +CI,WRV2,36.00774,-117.8904,1070 +CI,WSS,34.1717,-118.64971,316 +CI,WTT2,33.94867,-118.25539,37 +CI,WVP2,35.94939,-117.81769,1465 +CI,WWC,33.94068,-116.40876,619 +CI,WWF,33.27884,-115.57888,-61 +CI,YEG2,35.43831,-119.96306,963 +CI,YUC,34.19675,-116.40576,1077 +CI,YUH2,32.64752,-115.92227,184 diff --git a/tutorials/noisepy_scedc_tutorial.ipynb b/tutorials/noisepy_scedc_tutorial.ipynb index 8a6d8e4b..8de041b4 100644 --- a/tutorials/noisepy_scedc_tutorial.ipynb +++ b/tutorials/noisepy_scedc_tutorial.ipynb @@ -1,12 +1,13 @@ { "cells": [ { + "attachments": {}, "cell_type": "markdown", "metadata": { "id": "PIA2IaqUOeOA" }, "source": [ - "# Welcome to the NoisePy SCEDC Colab Tutorial!\n", + "# Welcome to the NoisePy SCEDC Tutorial!\n", "\n", "Noisepy is a python software package to process ambient seismic noise cross correlations. \n", "\n", @@ -22,36 +23,13 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": { "id": "FaKuajVCOo2r" }, "source": [ - "First, we install the noisepy-seis package. ```NoisePy``` includes ```obspy``` as a depedency, therefore it is required to **restart runtime** after installation of noisepy." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "rR860zaZPZGH" - }, - "outputs": [], - "source": [ - "\n", - "! pip install --upgrade noisepy-seis\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "_QvfrDdZOv12" - }, - "source": [ - "## Restart runtime\n", - "\n", - "Required to properly install obspy on Colab instances." + "This tutorial should be ran after installing the noisepy package. " ] }, { @@ -67,7 +45,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "metadata": { "id": "vceZgD83PnNc" }, @@ -82,6 +60,7 @@ "import glob\n", "from datetime import datetime\n", "from datetimerange import DateTimeRange\n", + "import mpi4py\n", "\n", "\n", "# create directory to store data locally\n", @@ -103,11 +82,19 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": { "id": "yojR0Z3ALm6K" }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "2002-01-02T00:00:00 - 2002-01-04T00:00:00\n" + ] + } + ], "source": [ "# SCEDC S3 bucket common URL characters for that day.\n", "S3_DATA = \"s3://scedc-pds/continuous_waveforms/\"\n", @@ -129,7 +116,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": { "id": "mhfgrMPALsYS" }, @@ -151,7 +138,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "metadata": { "id": "dIjBD7riIfdJ" }, @@ -172,7 +159,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "metadata": { "id": "ByEiHRjmIAPB" }, @@ -224,12 +211,12 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "# For this tutorial make sure the previous run is empty\n", - "!rm -rf ./data/CCF" + "!rm -rf ~/data/CCF" ] }, { @@ -396,7 +383,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.2" + "version": "3.8.16" } }, "nbformat": 4, diff --git a/tutorials/run_mpi_scedc.ipynb b/tutorials/run_mpi_scedc.ipynb new file mode 100644 index 00000000..c17a841e --- /dev/null +++ b/tutorials/run_mpi_scedc.ipynb @@ -0,0 +1,165 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 15, + "metadata": {}, + "outputs": [], + "source": [ + "from noisepy.seis import cross_correlate, stack, plotting_modules # noisepy core functions\n", + "from noisepy.seis.asdfstore import ASDFCCStore # Object to store ASDF data within noisepy\n", + "from noisepy.seis.scedc_s3store import SCEDCS3DataStore, channel_filter # Object to query SCEDC data from on S3\n", + "from noisepy.seis.datatypes import ConfigParameters # Main configuration object\n", + "from noisepy.seis.channelcatalog import XMLStationChannelCatalog # Required stationXML handling object\n", + "import os\n", + "import glob\n", + "from datetime import datetime\n", + "from datetimerange import DateTimeRange\n", + "import mpi4py\n", + "import pandas as pd\n", + "\n", + "\n", + "# create directory to store data locally\n", + "path = \"~/s3tmp/data\"\n", + "# path = \"../../data/\" # for local runs\n", + "os.makedirs(path, exist_ok=True)\n", + "cc_data_path = os.path.join(path, \"CCF\")\n", + "stack_data_path = os.path.join(path, \"STACK\")\n", + "os.makedirs(cc_data_path, exist_ok=True)\n", + "os.makedirs(stack_data_path, exist_ok=True)\n", + "freq_norm=\"rma\"\n", + "cc_store = ASDFCCStore(cc_data_path) # Store for writing CC data\n", + "\n", + "\n", + "DATE_FORMAT = \"%Y_%m_%d\"" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [], + "source": [ + "nproc = 3" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Read the station information" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "ACP,ADO,AGM,AGO,ALP,APL,ARV,ASP,AVC,AVM,BAC,BAI,BAK,BAR,BBR,BBS,BC3,BCW,BEL,BFS,BHP,BLA2,BLC,BLY,BOM,BOR,BRE,BTP,BUE,CAC,CAR,CBC,CBC,CBC,CBC,CCA,CCC,CDD,CDM,CFD,CFS,CFT,CGO,CHF,CHI,CHK,CHN,CHR,CIA,CJM,CJV2,CKP,CLC,CLI2,CLO,CLT,COA,COK2,CPO,CPT2,CRF,CRF,CRG,CRN,CRR,CSH,CSL,CSL,CTC,CTW,CVW,CWC,CWP,CYP,CZN,DAN,DAW,DEC,DEV,DGR,DJJ,DJJB,DLA,DNR,DPP,DRE,DSC,DTC,DTC,DTP,DZA,EDW2,ELS2,EML,EMS,EOC,ERR,ERR,ESI2,ESI2,FDR,FHO,FIG,FMO,FMP,FON,FOX2,FRK,FRM,FUL,FUR,FUR,GATR,GCC,GFF,GFS,GLA,GMA,GMR,GOR,GOU,GR2,GRA,GSA,GSC,GVR,HAR,HAY,HDH,HDH,HEC,HIW,HLL,HLN,HMT2,HOL,HYS,IDO,IDQ,IDY,IKP,IMP,IPT,IRG5,IRM,ISA,IVY,JEM,JNH2,JPLS,JRC2,JTH,JVA,KIK,KML,KYV,LAF,LAT,LBW1,LBW2,LCG,LCP,LDF,LDR,LEO,LFP,LGB,LJR,LKH,LLS,LMH,LMR2,LMS,LMY,LOC,LPC,LRL,LRR2,LTP,LUC2,LUG,LUS,LVO,LVY,LVY,LYP,MAG,MCT,MES,MGE,MIK,MIKB,MIS,MLAC,MLS,MMC,MMC,MNO,MOP,MOR,MPI,MPM,MPP,MRS,MSC,MSJ,MTA,MTG,MTP,MUR,MWC,NBS,NCH,NEE2,NEN,NJQ,NOT,NPN,NSS2,NWH,NWH,OAT,OCP,OGC,OLI,OLP,OSI,PALA,PASC,PDE,PDM,PDR,PDU,PDW,PDW,PER,PGA,PHL,PLM,PLS,PMD,POB2,POR,PSD,PSR,PTD,PUT,QAD,QLC,QUG,RAG,RCR,RCT,RCU,RCU,RFR,RHC2,RHR,RIN,RINB,RIO,RKMO,RMM,RPV,RRX,RSB,RSI,RSS,RUN,RUS,RVR,RXH,SAL,SAN,SBB2,SBC,SBI,SBPX,SCI2,SCZ2,SDD,SDG,SDR,SES,SGL,SHO,SHO,SHU,SIL,SIL,SLA,SLB,SLH,SLM,SLR,SLV,SMF2,SMI,SMM,SMR,SMT,SMV,SMW,SNCC,SNO,SNR,SOC,SPF,SPG2,SQC,SRA,SRI,SRN,SRT,SSS,SSS,STC,STG,STS,SVD,SWP,SWP,SWS,SYN,SYP,SYP,TA2,TEH,TEJ,TER2,TFT,THC,THM,TIN,TJR,TOR,TOW2,TPO,TUQ,USB,USC,VCP,VCS,VDJ,VES,VLO,VLY,VOG,VTV,WAS2,WBM,WBP,WBS,WCS2,WES,WGR,WHF,WLH2,WLS2,WLT,WMD,WMF,WNM,WNS,WOR,WRC2,WRV2,WSS,WTT2,WVP2,WWC,WWF,YEG2,YUC,YUH2\n" + ] + } + ], + "source": [ + "sta=\",\".join(list(pd.read_csv(\"full_socal.csv\")[\"station\"]))\n", + "print(sta)" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "2002-01-02T00:00:00 - 2002-01-04T00:00:00\n", + "2002_01_02\n" + ] + } + ], + "source": [ + "\n", + "\n", + "start = datetime(2002, 1, 2)\n", + "end = datetime(2002, 1, 4)\n", + "range = DateTimeRange(start, end)\n", + "print(range)\n", + "\n", + "date_start=start.strftime(DATE_FORMAT)\n", + "date_end=end.strftime(DATE_FORMAT)\n", + "print(date_start)" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "mpiexec -n 3 noisepy cross_correlate --raw_data_path s3://scedc-pds/continuous_waveforms/ --xml_path s3://scedc-pds/FDSNstationXML/CI/ --ccf_path ~/s3tmp/data/CCF --freq_norm rma --stations \"SBC,RIO,DEV\" --start 2002_01_02 --end 2002_01_04\n" + ] + } + ], + "source": [ + "print((f'mpiexec -n {nproc} noisepy cross_correlate \\\n", + "--raw_data_path s3://scedc-pds/continuous_waveforms/ \\\n", + "--xml_path s3://scedc-pds/FDSNstationXML/CI/ \\\n", + " --ccf_path {cc_data_path} --freq_norm {freq_norm} --stations \"SBC,RIO,DEV\" \\\n", + "--start {date_start} --end {date_end}'))" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "256" + ] + }, + "execution_count": 17, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "os.system(f'mpiexec -n {nproc} noisepy cross_correlate \\\n", + "--raw_data_path s3://scedc-pds/continuous_waveforms/ \\\n", + "--xml_path s3://scedc-pds/FDSNstationXML/CI/ \\\n", + " --ccf_path {cc_data_path} --freq_norm {freq_norm} --stations \"SBC,RIO,DEV\" \\\n", + "--start {date_start} --end {date_end}')" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.8.16" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +}