Writing correlations #73
-
I am trying to use this code to create the correlation database and I keep getting the error below. Please assist. from seismic.db.corr_hdf5 import CorrelationDataBase For this example, we are just gonna create an empty CorrStreamOf course, this will not really add any data to the filecst = CorrStream() Get your correlation dictionarywith open('/path/to/my/params.yaml') as file: I am trying to recreate the results in the example tutorial by creating a new correlationdatabase for use but I am unable to.KeyError Traceback (most recent call last) File h5py/_objects.pyx:54, in h5py._objects.with_phil.wrapper() File h5py/_objects.pyx:55, in h5py._objects.with_phil.wrapper() File ~/miniforge3/envs/salvus/lib/python3.11/site-packages/h5py/_hl/attrs.py:56, in AttributeManager.getitem(self, name) File h5py/_objects.pyx:54, in h5py._objects.with_phil.wrapper() File h5py/_objects.pyx:55, in h5py._objects.with_phil.wrapper() File h5py/h5a.pyx:80, in h5py.h5a.open() KeyError: "Can't open attribute (can't locate attribute: 'co')" During handling of the above exception, another exception occurred: KeyError Traceback (most recent call last) File ~/miniforge3/envs/salvus/lib/python3.11/site-packages/seismic/db/corr_hdf5.py:216, in DBHandler.get_corr_options(self) KeyError: 'No correlation options in file' During handling of the above exception, another exception occurred: KeyError Traceback (most recent call last) File ~/miniforge3/envs/salvus/lib/python3.11/site-packages/seismic/db/corr_hdf5.py:417, in CorrelationDataBase.enter(self) File ~/miniforge3/envs/salvus/lib/python3.11/site-packages/seismic/db/corr_hdf5.py:91, in DBHandler.init(self, path, mode, compression, co, force) File ~/miniforge3/envs/salvus/lib/python3.11/site-packages/seismic/db/corr_hdf5.py:97, in DBHandler.add_corr_options(self, co) File ~/miniforge3/envs/salvus/lib/python3.11/site-packages/seismic/db/corr_hdf5.py:522, in co_to_hdf5(co) KeyError: 'corr_args' |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Hi there, If you like you wrote, really entered this code
Then /path/to/my/parms.yaml and /path/to/myfile.h5 are probably not existing. So if you replace the path to the parameter file by an actual existing path with the properly formatted yaml file (see documentation), it should work. Best, |
Beta Was this translation helpful? Give feedback.
-
Hey Emerald, So the reason why you are getting issues is that your This is because SeisMIC will store CorrTraces within the hdf5 file in a hierarchy that depends on the header (also discussed in the link above). If you only provide a numpy array, which is essentially what you are doing, it will not know what to do with the data. Also, you will have to ask yourself, how wise it is to store data without knowing the sampling rate, recording time, station name, etc.. So I don't have a direct example of adding data from MSEED. But in the end, you will have to make sure to build a correct header (CorrStats class in SeisMIC) and just provide the data for each of the Traces -> build a stream like you did in your example. Hope that helps! Cheers, |
Beta Was this translation helpful? Give feedback.
Hey Emerald,
Ah that makes it a little clearer thanks.
So the reason why you are getting issues is that your
CorrTrace
s do not have any headers. So you either have to provide the kwarg_header
(containing the header of the CorrTrace itself, which follows the SEED combination logic (see docs).This is because SeisMIC will store CorrTraces within the hdf5 file in a hierarchy that depends on the header (also discussed in the link above). If you only provide a numpy array, which is essentially what you are doing, it will not know what to do with the data. Also, you will have to ask yourself, how wise it is to store data without knowing the sampling rate, recording time, station name, etc..
So …