Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug in handling starttime and endtime #485

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions cxx/src/lib/io/fileio.cc
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,18 @@ std::vector<long int> fwrite_to_file(
fseek(fp,0L,2);

for (int i = 0; i < d.member.size(); ++i) {
<<<<<<< HEAD
/* Silenetly skip dead data */
if(d.member[i].dead()) continue;
long int foff = ftell(fp);
foffs.push_back(foff);
TimeSeries& t = d.member[i];
if (fwrite((void *)t.s.data(), sizeof(double), t.npts(), fp) != t.npts())
=======
if(d.member[i].dead())
foffs.push_back(-1);
else
>>>>>>> dac6e7f1729a67e87eaa44658263e18e705488aa
{
long int foff = ftell(fp);
foffs.push_back(foff);
Expand Down Expand Up @@ -207,9 +216,18 @@ std::vector<long int> fwrite_to_file(mspass::seismic::LoggingEnsemble<mspass::se
fseek(fp,0L,2);

for (int i = 0; i < d.member.size(); ++i) {
<<<<<<< HEAD
/* Silently skip dead data */
if(d.member[i].dead()) continue;
long int foff = ftell(fp);
foffs.push_back(foff);
Seismogram& t = d.member[i];
if (fwrite((void *)t.u.get_address(0,0), sizeof(double), 3*t.npts(), fp) != 3*t.npts())
=======
if(d.member[i].dead())
foffs.push_back(-1);
else
>>>>>>> dac6e7f1729a67e87eaa44658263e18e705488aa
{
if(d.member[i].dead()) continue;
long int foff = ftell(fp);
Expand Down
4 changes: 4 additions & 0 deletions data/yaml/mspass.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ Database:
concept: Time shift applied to define relative time of 0.0
aliases: t0shift
constraint: required
endtime:
type: double
concept: Time of last sample of data (epoch time or relative to some other time mark)
constraint: optional
utc_convertible:
type: bool
concept: When true starttime_shift can be used to convert relative time to UTC.
Expand Down
4 changes: 4 additions & 0 deletions data/yaml/mspass_fdsn.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ Database:
concept: Time shift applied to define relative time of 0.0
aliases: t0shift
constraint: required
endtime:
type: double
concept: Time of last sample of data (epoch time or relative to some other time mark)
constraint: optional
utc_convertible:
type: bool
concept: When true starttime_shift can be used to convert relative time to UTC.
Expand Down
7 changes: 6 additions & 1 deletion data/yaml/mspass_lite.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ Database:
concept: Time shift applied to define relative time of 0.0
aliases: t0shift
constraint: required
endtime:
type: double
concept: Time of last sample of data (epoch time or relative to some other time mark)
constraint: optional
utc_convertible:
type: bool
concept: When true starttime_shift can be used to convert relative time to UTC.
Expand Down Expand Up @@ -283,4 +287,5 @@ Metadata:
readonly: false
loc:
collection: wf_Seismogram
readonly: false
readonly: false

4 changes: 4 additions & 0 deletions data/yaml/mspass_s3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ Database:
concept: Time shift applied to define relative time of 0.0
aliases: t0shift
constraint: required
endtime:
type: double
concept: Time of last sample of data (epoch time or relative to some other time mark)
constraint: optional
utc_convertible:
type: bool
concept: When true starttime_shift can be used to convert relative time to UTC.
Expand Down
3 changes: 3 additions & 0 deletions python/mspasspy/db/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -6508,6 +6508,9 @@ def _atomic_save_all_documents(
# add tag - intentionally not set in mspass_object returned
if data_tag:
insertion_dict["data_tag"] = data_tag
# Always set starttime and endtime
insertion_dict["starttime"] = mspass_object.t0
insertion_dict["endtime"] = mspass_object.endtime()
else:
# We need to clear data tag if was previously defined in
# this case or a the old tag will be saved with this datum
Expand Down
Loading