Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
I
ICARTT Python Package
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MBEES
ICARTT Python Package
Commits
4cae8366
Commit
4cae8366
authored
3 years ago
by
Florian Obersteiner
Browse files
Options
Downloads
Patches
Plain Diff
comments
parent
c17544f0
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!6
code refactor
This commit is part of merge request
!6
. Comments created here will be created in the context of that merge request.
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/icartt/dataset.py
+15
-8
15 additions, 8 deletions
src/icartt/dataset.py
tests/test_dataset.py
+2
-0
2 additions, 0 deletions
tests/test_dataset.py
with
17 additions
and
8 deletions
src/icartt/dataset.py
+
15
−
8
View file @
4cae8366
...
...
@@ -362,8 +362,8 @@ class Variable:
self
.
miss
=
miss
def
__repr__
(
self
):
# TODO: this sould be
more meaningful
return
"
ICARTT Variable object repr
"
# TODO: this sould be
something else than __str__ ?
return
self
.
desc
()
def
__str__
(
self
):
return
self
.
desc
()
...
...
@@ -419,9 +419,10 @@ class Dataset:
:return: list of time steps
:rtype: list
"""
# TODO: this method currently does not work at all.
# suggest to also change to return a numpy array of numpy.datetime64
# for consistency with other data output
return
[
# TODO see commit f5208db0 - this will do unexpected things if
# self.dateOfCollection is a naive datetime object (think DST transitions...)
self
.
dateOfCollection
+
datetime
.
timedelta
(
seconds
=
x
)
for
x
in
self
.
independentVariable
]
...
...
@@ -507,8 +508,11 @@ class Dataset:
# line 7 - UTC date when data begin, UTC date of data reduction or revision
# - comma delimited (yyyy, mm, dd, yyyy, mm, dd).
dmp
=
f
.
readline
()
self
.
dateOfCollection
=
datetime
.
datetime
(
*
map
(
int
,
dmp
[:
3
]))
# TODO: set UTC ?!
self
.
dateOfCollection
=
datetime
.
datetime
(
*
map
(
int
,
dmp
[:
3
]))
self
.
dateOfRevision
=
datetime
.
datetime
(
*
map
(
int
,
dmp
[
3
:
6
]))
# TODO: we should either use aware datetime (UTC), date objects or
# numpy.datetime64 here to avoid some 'rough edges' of Python's datetime library...
# line 8 - Data Interval (This value describes the time spacing (in seconds)
# between consecutive data records. It is the (constant) interval between
...
...
@@ -865,7 +869,8 @@ class Dataset:
# TODO: this could be more meaningful
return
"
ICARTT Dataset string representation
"
def
__init__
(
self
,
f
=
None
,
loadData
=
True
,
splitChar
=
"
,
"
,
format
=
Formats
.
FFI1001
):
# TODO: why is init comming last?
# TODO: why is init comming last?
def
__init__
(
self
,
f
=
None
,
loadData
=
True
,
splitChar
=
"
,
"
,
format
=
Formats
.
FFI1001
):
"""
Constructor method
"""
self
.
format
=
format
self
.
version
=
None
...
...
@@ -883,8 +888,10 @@ class Dataset:
self
.
dataSourceDescription
=
"
Musterdatenprodukt
"
self
.
missionName
=
"
MUSTEREX
"
# TODO: not 100% sure if this is relevant here, but those dates should refer to UTC
# - if you leave the datetime objects naive (no tzinfo set), they represent local time.
# TODO: see also comment on _readData method.
# we should either use aware datetime (UTC), date objects or
# numpy.datetime64 here to avoid some 'rough edges' of Python's
# datetime library...
self
.
dateOfCollection
=
datetime
.
datetime
.
today
()
self
.
dateOfRevision
=
datetime
.
datetime
.
today
()
self
.
dataIntervalCode
=
[
0.0
]
...
...
This diff is collapsed.
Click to expand it.
tests/test_dataset.py
+
2
−
0
View file @
4cae8366
...
...
@@ -311,6 +311,7 @@ class Create1001TestCase(unittest.TestCase):
class
BulkIOTestCase
(
unittest
.
TestCase
):
# TODO: need to test invalid input
# def testInvalid(self):
# for fn in fns_fail:
# with self.subTest(msg=f"Opening invalid file {str(fn)}"):
...
...
@@ -351,6 +352,7 @@ class BulkIOTestCase(unittest.TestCase):
ict
.
write
(
f
=
strOut
)
self
.
assertTrue
(
compareFiles
(
fn
,
strIn
,
strOut
))
# TODO: should also test dataset methods, e.g. .times
if
__name__
==
"
__main__
"
:
# pragma: no cover
unittest
.
main
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment