Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dastools
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
9
Issues
9
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Javier Quinteros
dastools
Commits
da05fb34
Commit
da05fb34
authored
Jul 31, 2020
by
Javier Quinteros
2
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve logging output
parent
ffb87982
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
23 deletions
+20
-23
dasscripts/dasconv.py
dasscripts/dasconv.py
+17
-18
dasscripts/tdms.py
dasscripts/tdms.py
+3
-5
No files found.
dasscripts/dasconv.py
View file @
da05fb34
...
...
@@ -51,38 +51,38 @@ def printmetadata(data):
print
(
data
)
def
str2date
(
d
S
tr
):
def
str2date
(
d
s
tr
):
"""Transform a string to a datetime.
:param d
S
tr: A datetime in ISO format.
:type d
S
tr: string
:param d
s
tr: A datetime in ISO format.
:type d
s
tr: string
:return: A datetime represented the converted input.
:rtype: datetime
:rtype: datetime
.datetime
"""
# In case of empty string
if
(
d
Str
is
None
)
or
(
not
len
(
dS
tr
)):
if
(
d
str
is
None
)
or
(
not
len
(
ds
tr
)):
return
None
date
Parts
=
dS
tr
.
replace
(
'-'
,
' '
).
replace
(
'T'
,
' '
)
date
Parts
=
dateP
arts
.
replace
(
':'
,
' '
).
replace
(
'.'
,
' '
)
date
Parts
=
dateP
arts
.
replace
(
'Z'
,
''
).
split
()
date
parts
=
ds
tr
.
replace
(
'-'
,
' '
).
replace
(
'T'
,
' '
)
date
parts
=
datep
arts
.
replace
(
':'
,
' '
).
replace
(
'.'
,
' '
)
date
parts
=
datep
arts
.
replace
(
'Z'
,
''
).
split
()
# Consider the case in which just the first digits of microseconds
# are given and complete with 0's to have 6 digits
if
len
(
date
P
arts
)
==
7
:
date
Parts
[
6
]
=
dateParts
[
6
]
+
'0'
*
(
6
-
len
(
dateP
arts
[
6
]))
if
len
(
date
p
arts
)
==
7
:
date
parts
[
6
]
=
dateparts
[
6
]
+
'0'
*
(
6
-
len
(
datep
arts
[
6
]))
return
datetime
.
datetime
(
*
map
(
int
,
date
P
arts
))
return
datetime
.
datetime
(
*
map
(
int
,
date
p
arts
))
def
main
():
# Inspect the archive.py module to list the Classes based on Archive
dict
A
rchive
=
dict
()
dict
a
rchive
=
dict
()
for
name
,
obj
in
inspect
.
getmembers
(
da
):
if
inspect
.
isclass
(
obj
):
if
issubclass
(
obj
,
da
.
Archive
)
and
name
!=
'Archive'
:
dict
A
rchive
[
name
]
=
obj
dict
a
rchive
[
name
]
=
obj
helparchive
=
'Available options are [%s]'
%
', '
.
join
(
dict
A
rchive
.
keys
())
helparchive
=
'Available options are [%s]'
%
', '
.
join
(
dict
a
rchive
.
keys
())
# Check verbosity in the output
msg
=
'Read, manipulate and convert seismic waveforms generated by a DAS system.'
...
...
@@ -113,7 +113,7 @@ def main():
parser
.
add_argument
(
'--decimate'
,
type
=
int
,
choices
=
[
1
,
5
],
help
=
'Factor by which the sampling rate is lowered by decimation.'
,
default
=
1
)
parser
.
add_argument
(
'-o'
,
'--outstruct'
,
type
=
str
,
choices
=
dict
A
rchive
.
keys
(),
parser
.
add_argument
(
'-o'
,
'--outstruct'
,
type
=
str
,
choices
=
dict
a
rchive
.
keys
(),
help
=
helparchive
,
default
=
'StreamBased'
)
parser
.
add_argument
(
'--metadata'
,
action
=
'store_true'
,
default
=
False
,
help
=
'Read and display the metadata from the TDMS files'
)
...
...
@@ -143,7 +143,7 @@ def main():
# Selected archive structure
# Archive files in current directory
klass
=
dict
A
rchive
[
args
.
outstruct
]
klass
=
dict
a
rchive
[
args
.
outstruct
]
archive
=
klass
(
root
=
'.'
,
experiment
=
args
.
filename
,
strictcheck
=
False
)
expectedtimes
=
dict
()
...
...
@@ -161,7 +161,7 @@ def main():
# Save the previous Stream completely
if
curstream
is
not
None
:
archive
.
archive
(
tr0
)
logs
.
info
(
'Storing channel %s
'
%
curstream
)
logs
.
info
(
'Storing channel %s
. Starttime: %s'
%
(
curstream
,
data
[
1
].
get
(
'starttime'
,
None
))
)
# Update which stream is being processed
curstream
=
nslc
(
data
[
1
])
...
...
@@ -174,7 +174,6 @@ def main():
tr0
=
Trace
(
data
=
data
[
0
],
header
=
data
[
1
])
else
:
tr0
+=
Trace
(
data
=
data
[
0
],
header
=
data
[
1
])
# print(data[1], data[0])
# Update the datetime of the expected sample
expectedtimes
[
curstream
]
=
data
[
1
][
'starttime'
]
+
data
[
1
][
'npts'
]
/
data
[
1
][
'sampling_rate'
]
...
...
dasscripts/tdms.py
View file @
da05fb34
...
...
@@ -44,7 +44,7 @@ class TDMS(object):
# convoluted during the decimation
# for channel in range(self.__chstart, self.__chstop + 1, self.__chstep):
for
channel
in
self
.
__channels
:
logging
.
debug
(
'Create empty buffer
s'
)
logging
.
debug
(
'Create empty buffer
for channel %s'
%
channel
)
self
.
__buffer
[
channel
]
=
None
return
self
...
...
@@ -67,9 +67,9 @@ class TDMS(object):
:param channels: Selection of channels to work with (list of integers)
:type channels: list
:param starttime: Start of the selected time window
:type starttime: datetime.datetime
:type starttime: datetime.datetime
or NoneType
:param endtime: End of the selected time window
:type endtime: datetime.datetime
:type endtime: datetime.datetime
or NoneType
:param iterate: Select either Data (D) or Metadata (M)
:type iterate: str
:param decimate: Factor by which the sampling rate is lowered by decimation
...
...
@@ -339,8 +339,6 @@ class TDMS(object):
self
.
__currentfile
=
None
self
.
__search_data
()
# print('reset', self.__twstart, self.starttime)
def
__readmetadata
(
self
):
# Metadata
logs
=
logging
.
getLogger
(
'Read Metadata'
)
...
...
Javier Quinteros
@javier
mentioned in issue
#4 (closed)
·
Jul 31, 2020
mentioned in issue
#4 (closed)
mentioned in issue #4
Toggle commit list
Javier Quinteros
@javier
mentioned in issue
#1 (closed)
·
Jul 31, 2020
mentioned in issue
#1 (closed)
mentioned in issue #1
Toggle commit list
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment