jpjones76 / SeisIO.jl

Julia language support for geophysical time series data
http://seisio.readthedocs.org
Other
47 stars 21 forks source link

How to read an entire list of sac files? #91

Closed mcardenass closed 2 years ago

mcardenass commented 2 years ago

I have a list of sac files that do not follow a specific sequence to include wildcards. The list consists of the path and name of the file. Is there any parameter that can be included in the read_data function to indicate to load the entire list of files, or do I have to read one by one? Below is an example of my filelist, you can see that there are no consecutive days. Thanks

SAC/2017/TV01/20170625.z.sac SAC/2017/TV01/20170626.z.sac SAC/2017/TV01/20170627.z.sac SAC/2017/TV01/20170628.z.sac SAC/2017/TV01/20170629.z.sac SAC/2017/TV01/20170630.z.sac SAC/2017/TV01/20170701.z.sac SAC/2017/TV01/20170702.z.sac SAC/2017/TV01/20170703.z.sac SAC/2017/TV01/20170704.z.sac SAC/2017/TV01/20170705.z.sac SAC/2017/TV01/20170706.z.sac SAC/2017/TV01/20170707.z.sac SAC/2017/TV01/20170718.z.sac SAC/2017/TV01/20170719.z.sac SAC/2017/TV01/20170720.z.sac SAC/2017/TV01/20170721.z.sac SAC/2017/TV01/20170722.z.sac SAC/2017/TV01/20170723.z.sac

tclements commented 2 years ago

Have you tried from within the directory:

S = read_data("sac","*.sac") 

or from the root directory:

S = read_data("sac","SAC/2017/TV01/*.sac")
mcardenass commented 2 years ago

I did, so it works. I created a special list of files in the subdirectory of station TV01 and another list with the same files in the subdirectory of another station TV02. Thus, the Julia program could load the two file lists, preprocess with SeisNoise and then perform the cross-correlation. The problem is that both stations do not have the same number of files and there are lost seismic noise days. So I thought the read_data() function might include loading lists of files. Well, one solution is to separate the files that are only going to be processed.

tclements commented 2 years ago

read_data should accept a filelist. For example, I created a bunch of SAC files in my current directory and read all into a single SeisData:


julia> filelist = [f for f in readdir() if occursin("SAC",f)]
1804-element Vector{String}:
 "2016.105.00.43.10.212.2A.1..DPZ.R.SAC"   
 "2016.105.00.43.10.212.2A.10..DPZ.R.SAC"  
 ⋮
 "2016.105.00.43.10.212.2A.998..DPZ.R.SAC"
 "2016.105.00.43.10.212.2A.999..DPZ.R.SAC"
julia> S = read_data("sac",filelist)
SeisData with 1804 channels (2 shown)
    ID: 2A.1..DPZ                          2A.10..DPZ                         …
  NAME:                                                                       …
   LOC: 36.7677 N, -98.1014 E, 356.5 m     36.7533 N, -98.0919 E, 350.9 m     …
    FS: 100.0                              100.0                              …
  GAIN: 3.06318e9                          3.06318e9                          …
  RESP: a0 1.0, f0 1.0, 0z, 0p             a0 1.0, f0 1.0, 0z, 0p             …
 UNITS:                                                                       …
   SRC: C:\Users\tclements\data\20… C:\Users\tclements\data\20… …
  MISC: 0 entries                          0 entries                          …
 NOTES: 0 entries                          0 entries                          …
     T: 2016-04-14T00:43:10 (0 gaps)       2016-04-14T00:43:10 (0 gaps)       …
     X: -2.475e-03                         -8.205e-04                         …
        -4.023e-04                         +1.425e-04                         …
            ...                                ...                            …
        +1.972e-03                         -4.168e-04                         …
        (nx = 5800)                        (nx = 5800)                        …
     C: 0 open, 0 total
mcardenass commented 2 years ago

Yes, I can. Thanks, Tim.