Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
geomag-algorithms
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
ghsc
National Geomagnetism Program
geomag-algorithms
Commits
c1a0c93c
Commit
c1a0c93c
authored
8 years ago
by
Jeremy M Fee
Browse files
Options
Downloads
Patches
Plain Diff
Use os line separator, convert iteration group to list for reuse
parent
a12b94d1
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bin/make_cal.py
+4
-1
4 additions, 1 deletion
bin/make_cal.py
with
4 additions
and
1 deletion
bin/make_cal.py
+
4
−
1
View file @
c1a0c93c
...
@@ -95,6 +95,8 @@ calfile = []
...
@@ -95,6 +95,8 @@ calfile = []
cals
=
sorted
(
cals
,
key
=
lambda
c
:
c
[
'
start
'
])
cals
=
sorted
(
cals
,
key
=
lambda
c
:
c
[
'
start
'
])
# group by date
# group by date
for
date
,
cals
in
itertools
.
groupby
(
cals
,
key
=
lambda
c
:
c
[
'
start
'
].
date
()):
for
date
,
cals
in
itertools
.
groupby
(
cals
,
key
=
lambda
c
:
c
[
'
start
'
].
date
()):
# convert group to list so it can be reused
cals
=
list
(
cals
)
# within each day, order by H, then D, then Z
# within each day, order by H, then D, then Z
for
channel
in
[
'
H
'
,
'
D
'
,
'
Z
'
]:
for
channel
in
[
'
H
'
,
'
D
'
,
'
Z
'
]:
channel_cals
=
[
c
for
c
in
cals
if
c
[
'
channel
'
]
==
channel
]
channel_cals
=
[
c
for
c
in
cals
if
c
[
'
channel
'
]
==
channel
]
...
@@ -104,13 +106,14 @@ for date, cals in itertools.groupby(cals, key=lambda c: c['start'].date()):
...
@@ -104,13 +106,14 @@ for date, cals in itertools.groupby(cals, key=lambda c: c['start'].date()):
# add channel header
# add channel header
calfile
.
append
(
CAL_HEADER_FORMAT
.
format
(
channel
=
channel
,
date
=
date
))
calfile
.
append
(
CAL_HEADER_FORMAT
.
format
(
channel
=
channel
,
date
=
date
))
calfile
.
extend
([
CAL_LINE_FORMAT
.
format
(
**
c
)
for
c
in
channel_cals
])
calfile
.
extend
([
CAL_LINE_FORMAT
.
format
(
**
c
)
for
c
in
channel_cals
])
calfile
.
append
(
''
)
# write calfile
# write calfile
filename
=
FILENAME_FORMAT
.
format
(
OBSERVATORY
=
OBSERVATORY
,
YEAR
=
YEAR
)
filename
=
FILENAME_FORMAT
.
format
(
OBSERVATORY
=
OBSERVATORY
,
YEAR
=
YEAR
)
print
>>
sys
.
stderr
,
'
Writing cal file to {}
'
.
format
(
filename
)
print
>>
sys
.
stderr
,
'
Writing cal file to {}
'
.
format
(
filename
)
with
open
(
filename
,
'
wb
'
,
-
1
)
as
f
:
with
open
(
filename
,
'
wb
'
,
-
1
)
as
f
:
f
.
write
(
'
\n
'
.
join
(
calfile
)
+
'
\n
'
)
f
.
write
(
os
.
linesep
.
join
(
calfile
))
"""
"""
...
...
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