Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CTDAS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
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
Tsurata, Aki
CTDAS
Commits
411385fc
Commit
411385fc
authored
14 years ago
by
Peters, Wouter
Browse files
Options
Downloads
Patches
Plain Diff
inquiring the unlimited length is made possible by adding a variable with the same name
parent
80962d6b
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
da/tools/io.py
+9
-14
9 additions, 14 deletions
da/tools/io.py
with
9 additions
and
14 deletions
da/tools/io.py
+
9
−
14
View file @
411385fc
...
...
@@ -192,16 +192,17 @@ class CT_CDF(object):
return
var
def
inquire_unlimited
(
self
):
"""
Get the index of the unlimited dimension
"""
"""
Get the index
and name
of the unlimited dimension
"""
try
:
index
=
self
.
file
.
dimensions
.
values
().
index
(
None
)
unlimname
=
self
.
file
.
dimensions
.
keys
()[
index
]
unlimlen
=
nc
f
.
file
.
variables
[
unlimname
].
shape
[
0
]
unlimlen
=
sel
f
.
file
.
variables
[
unlimname
].
shape
[
0
]
except
:
unlimlen
=
-
1
unlimname
=
'
None
'
return
unlimlen
return
(
unlimname
,
unlimlen
,)
def
AddData
(
self
,
datadict
,
silent
=
True
):
"""
...
...
@@ -225,7 +226,7 @@ class CT_CDF(object):
we don
'
t want the unlimited counter to increase everytime. To get the value of the counter (needed when appending data for instance)
use
unlim_count = ncf.inquire_unlimited()
unlimname,
unlim_count = ncf.inquire_unlimited()
where an integer value is returned for the length, and -1 indicates there is no unlimited dimension
...
...
@@ -296,18 +297,12 @@ class CT_CDF(object):
# Now that the variable instance is returned, start to add the data. First figure out if we are dealing with an unlimited dimension
dimlens
=
self
.
file
.
dimensions
.
values
()
dimnames
=
self
.
file
.
dimensions
.
keys
()
try
:
index
=
self
.
file
.
dimensions
.
values
().
index
(
None
)
except
:
index
=
-
1
has_unlimited_dim
=
(
index
>
0
)
unlimname
,
unlimlen
=
self
.
inquire_unlimited
()
has_unlimited_dim
=
(
unlimname
!=
'
None
'
)
# If so, check if the first dimension of the passed dataset corresponds to the unlimited dimension
if
has_unlimited_dim
and
var
.
dimensions
[
0
]
==
d
imname
s
[
index
]
:
if
has_unlimited_dim
and
var
.
dimensions
[
0
]
==
unl
imname
:
# Add the data to the unlimited dim, note the special occassion for passing only one value (a record)
...
...
@@ -361,7 +356,7 @@ if __name__ == '__main__':
#dimlag=ncf.AddLagDim(unlimited=True)
#dimidate=ncf.AddDateDimFormat()
unlimlen
=
ncf
.
inquire_unlimited
()
unlimname
,
unlimlen
=
ncf
.
inquire_unlimited
()
if
unlimlen
<
0
:
unlimlen
=
0
...
...
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