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
5c372264
Commit
5c372264
authored
7 years ago
by
Christoph.Knote
Browse files
Options
Downloads
Patches
Plain Diff
Humongous reshuffling of modules and packages.
parent
2b24a485
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
README.md
+1
-1
1 addition, 1 deletion
README.md
icartt/dataset.py
+18
-4
18 additions, 4 deletions
icartt/dataset.py
with
19 additions
and
5 deletions
README.md
+
1
−
1
View file @
5c372264
# ICARTT
read
er
# ICARTT
file format reader and writ
er
This diff is collapsed.
Click to expand it.
icartt/dataset.py
+
18
−
4
View file @
5c372264
...
...
@@ -7,12 +7,16 @@ class Variable:
'''
@property
def
desc
(
self
):
'''
Return variable description string as it appears in an ICARTT file
'''
return
self
.
splitChar
.
join
(
[
self
.
name
,
self
.
units
,
self
.
units
]
)
def
__init__
(
self
,
name
,
units
,
scale
=
1.0
,
miss
=-
9999999
):
self
.
name
=
name
self
.
units
=
units
self
.
scale
=
scale
self
.
miss
=
str
(
miss
)
self
.
splitChar
=
'
,
'
class
Dataset
:
'''
...
...
@@ -114,17 +118,22 @@ class Dataset:
nul
=
[
prnt
(
self
.
splitChar
.
join
(
[
str
(
y
)
for
y
in
x
]
))
for
x
in
self
.
data
]
def
make_filename
(
self
):
'''
Create ICARTT-compliant file name based on the information contained in the dataset
'''
return
self
.
dataID
+
"
_
"
+
self
.
locationID
+
"
_
"
+
datetime
.
datetime
.
strftime
(
self
.
dateValid
,
'
%Y%m%d
'
)
+
"
_
"
+
"
R
"
+
self
.
revision
+
"
.ict
"
# sanitize function
def
__readline
(
self
,
do_split
=
True
):
dmp
=
self
.
input_fhandle
.
readline
().
replace
(
'
\n
'
,
''
).
replace
(
'
\r
'
,
''
)
if
do_split
:
dmp
=
[
word
.
strip
(
'
'
)
for
word
in
dmp
.
split
(
self
.
splitChar
)]
dmp
=
[
word
.
strip
(
'
'
)
for
word
in
dmp
.
split
(
self
.
splitChar
)
]
return
dmp
def
read_header
(
self
):
'''
Read the ICARTT header (from file)
'''
if
self
.
input_fhandle
.
closed
:
self
.
input_fhandle
=
open
(
self
.
input_fhandle
.
name
)
...
...
@@ -248,7 +257,9 @@ class Dataset:
return
[
float
(
x
.
replace
(
self
.
VAR
[
i
].
miss
,
'
NaN
'
))
for
i
,
x
in
enumerate
(
raw
)
]
def
read_data
(
self
):
'''
Read ICARTT data (from file)
'''
if
self
.
input_fhandle
.
closed
:
self
.
input_fhandle
=
open
(
self
.
input_fhandle
.
name
)
...
...
@@ -259,7 +270,10 @@ class Dataset:
self
.
input_fhandle
.
close
()
def
read_first_and_last
(
self
):
'''
Read first and last ICARTT data line (from file). Useful for quick estimates e.g. of the time extent
of big ICARTT files, without having to read the whole thing, which would be slow.
'''
if
self
.
input_fhandle
.
closed
:
self
.
input_fhandle
=
open
(
self
.
input_fhandle
.
name
)
...
...
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