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
CTDAS
CTDAS
Commits
60f637e2
Commit
60f637e2
authored
13 years ago
by
ivar
Browse files
Options
Downloads
Patches
Plain Diff
No commit message
No commit message
parent
6f6ccb8f
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
da/ctc13/NameConvert.py
+87
-0
87 additions, 0 deletions
da/ctc13/NameConvert.py
da/ctc13/obspack.py
+1
-1
1 addition, 1 deletion
da/ctc13/obspack.py
with
88 additions
and
1 deletion
da/ctc13/NameConvert.py
0 → 100755
+
87
−
0
View file @
60f637e2
#!/usr/bin/env python
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
# Name Convert
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
import
re
def
NameConvert
(
name
=
None
,
to
=
None
):
"""
Convert between old GLOBALVIEW-style and new ObsPack-style
print NameConvert(name=
"
lef_surface-pfp_1
"
, to=
'
GV
'
)
lef_01P0
print NameConvert(name=
"
hun_35C3
"
, to=
'
OP
'
)
hun_tower-insitu_35
"""
identifier
=
'
NameConvert
'
if
name
==
None
or
to
==
None
:
return
""
platform_dict
=
{
'
surface
'
:
0
,
'
shipboard
'
:
1
,
'
aircraft
'
:
2
,
'
tower
'
:
3
}
strategy_dict
=
{
'
flask
'
:
'
D
'
,
'
pfp
'
:
'
P
'
,
'
insitu
'
:
'
C
'
}
#----------------------------------->>>
if
to
.
upper
()
==
"
GV
"
:
# alt_surface-flask_1 -> alt_01D0
try
:
fields
=
name
.
split
(
'
_
'
)
code
=
fields
[
0
]
lab_num
=
int
(
fields
[
2
]
)
except
:
return
""
try
:
fields
=
fields
[
1
].
split
(
'
-
'
)
platform
=
fields
[
0
]
strategy
=
fields
[
1
]
except
:
return
""
platform_num
=
[
v
for
k
,
v
in
platform_dict
.
iteritems
()
if
platform
.
lower
()
==
k
]
if
len
(
platform_num
)
==
0
:
print
'
%s: Platform %s not found in platform dict.
'
%
(
identifier
,
platform
)
return
""
strategy_char
=
[
v
for
k
,
v
in
strategy_dict
.
iteritems
()
if
strategy
.
lower
()
==
k
]
if
len
(
strategy_char
)
==
0
:
print
'
%s: Strategy %s not found in strategy dict.
'
%
(
identifier
,
strategy
)
return
""
return
"
%s_%2.2d%1s%1d
"
%
(
code
,
lab_num
,
strategy_char
[
0
].
upper
(),
int
(
platform_num
[
0
]
)
)
#----------------------------------->>>
if
to
.
upper
()
==
"
OP
"
:
# hun_35C3 -> hun_tower-insitu_35
try
:
fields
=
name
.
split
(
'
_
'
)
code
=
fields
[
0
]
lab_num
=
int
(
fields
[
1
][:
2
]
)
strategy_char
=
fields
[
1
][
2
]
platform_num
=
int
(
fields
[
1
][
3
]
)
except
:
return
""
platform
=
[
k
for
k
,
v
in
platform_dict
.
iteritems
()
if
v
==
platform_num
]
if
len
(
platform
)
==
0
:
print
'
%s: Platform number %s not found in platform dict.
'
%
(
identifier
,
platform_num
)
return
""
pattern
=
re
.
compile
(
strategy_char
,
re
.
IGNORECASE
)
strategy
=
[
k
for
k
,
v
in
strategy_dict
.
iteritems
()
if
pattern
.
search
(
v
)
]
if
len
(
strategy
)
==
0
:
print
'
%s: Strategy character %s not found in strategy list.
'
%
(
identifier
,
strategy_char
)
return
""
return
"
%s_%s-%s_%d
"
%
(
code
,
platform
[
0
],
strategy
[
0
],
lab_num
)
if
__name__
==
"
__main__
"
:
print
NameConvert
(
name
=
"
mlo_01c0
"
,
to
=
"
OP
"
)
print
NameConvert
(
name
=
"
frd_tower-insitu_6
"
,
to
=
"
GV
"
)
This diff is collapsed.
Click to expand it.
da/ctc13/obspack.py
+
1
−
1
View file @
60f637e2
...
@@ -348,7 +348,7 @@ class ObsPackObservations(Observation):
...
@@ -348,7 +348,7 @@ class ObsPackObservations(Observation):
species
,
site
,
method
,
lab
,
nr
=
obs
.
fromfile
.
split
(
'
_
'
)
species
,
site
,
method
,
lab
,
nr
=
obs
.
fromfile
.
split
(
'
_
'
)
identifier
=
"
%s_%02d_%s
"
%
(
site
,
int
(
lab
),
method
,)
identifier
=
"
%s_%02d_%s
"
%
(
site
,
int
(
lab
),
method
,)
print
identifier
if
SiteInfo
.
has_key
(
identifier
):
if
SiteInfo
.
has_key
(
identifier
):
msg
=
"
Observation found (%s, %s)
"
%
(
obs
.
code
,
identifier
,)
;
logging
.
debug
(
msg
)
msg
=
"
Observation found (%s, %s)
"
%
(
obs
.
code
,
identifier
,)
;
logging
.
debug
(
msg
)
obs
.
mdm
=
SiteInfo
[
identifier
][
'
error
'
]
obs
.
mdm
=
SiteInfo
[
identifier
][
'
error
'
]
...
...
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