Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
Oceano2python
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
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
US191
Oceano2python
Commits
6b022c50
Commit
6b022c50
authored
5 years ago
by
jacques.grelet_ird.fr
Browse files
Options
Downloads
Patches
Plain Diff
print header
parent
b1b8da99
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
ascii.py
+22
-6
22 additions, 6 deletions
ascii.py
with
22 additions
and
6 deletions
ascii.py
+
22
−
6
View file @
6b022c50
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
# write hdr and data in ascii files
# write hdr and data in ascii files
import
os
import
os
import
tools
def
writeAscii
(
cfg
,
device
,
fe
,
r
,
variables_1D
):
def
writeAscii
(
cfg
,
device
,
fe
,
r
,
variables_1D
):
if
not
os
.
path
.
exists
(
cfg
[
'
global
'
][
'
ascii
'
]):
if
not
os
.
path
.
exists
(
cfg
[
'
global
'
][
'
ascii
'
]):
...
@@ -9,20 +10,35 @@ def writeAscii(cfg, device, fe, r, variables_1D):
...
@@ -9,20 +10,35 @@ def writeAscii(cfg, device, fe, r, variables_1D):
fileName
=
"
{}/{}.{}
"
.
format
(
cfg
[
'
global
'
][
'
ascii
'
],
cfg
[
'
cruise
'
][
'
cycleMesure
'
],
device
.
lower
())
fileName
=
"
{}/{}.{}
"
.
format
(
cfg
[
'
global
'
][
'
ascii
'
],
cfg
[
'
cruise
'
][
'
cycleMesure
'
],
device
.
lower
())
print
(
'
writing header file: {}
'
.
format
(
fileName
))
print
(
'
writing header file: {}
'
.
format
(
fileName
))
writeHeader
(
fileName
,
fe
,
r
,
variables_1D
)
writeHeader
(
fileName
,
cfg
,
fe
,
r
,
variables_1D
,
device
.
lower
()
)
fileName
=
"
{}/{}_{}
"
.
format
(
cfg
[
'
global
'
][
'
ascii
'
],
cfg
[
'
cruise
'
][
'
cycleMesure
'
],
device
.
lower
())
fileName
=
"
{}/{}_{}
"
.
format
(
cfg
[
'
global
'
][
'
ascii
'
],
cfg
[
'
cruise
'
][
'
cycleMesure
'
],
device
.
lower
())
print
(
'
writing
Ascii
data file: {}
'
.
format
(
fileName
))
print
(
'
writing data
file: {}
'
.
format
(
fileName
))
writeData
(
fileName
,
fe
,
r
,
variables_1D
)
writeData
(
fileName
,
cfg
,
fe
,
r
,
variables_1D
)
print
(
'
done...
'
)
print
(
'
done...
'
)
def
writeHeader
(
hdrFile
,
fe
,
r
,
variables_1D
):
def
writeHeader
(
hdrFile
,
cfg
,
fe
,
r
,
variables_1D
,
device
):
f
=
open
(
hdrFile
,
'
w
'
)
f
=
open
(
hdrFile
,
'
w
'
)
f
.
write
(
"
Header file OK !
"
)
# first line, header ex:
# PIRATA-FR30 THALASSA IRD SBE911+ 09P-1263 BOURLES
print
(
"
{} {} {} {} {} {}
"
.
format
(
cfg
[
'
cruise
'
][
'
cycleMesure
'
],
cfg
[
'
cruise
'
][
'
plateforme
'
],
cfg
[
'
cruise
'
][
'
institute
'
],
cfg
[
device
][
'
typeInstrument
'
],
cfg
[
device
][
'
instrumentNumber
'
],
cfg
[
'
cruise
'
][
'
pi
'
]))
f
.
write
(
"
{} {} {} {} {} {}
\n
"
.
format
(
cfg
[
'
cruise
'
][
'
cycleMesure
'
],
cfg
[
'
cruise
'
][
'
plateforme
'
],
cfg
[
'
cruise
'
][
'
institute
'
],
cfg
[
device
][
'
typeInstrument
'
],
cfg
[
device
][
'
instrumentNumber
'
],
cfg
[
'
cruise
'
][
'
pi
'
]))
# write next lines, start and end profile ex:
# 00001 18/02/2020 19:04:19 18/02/2020 22:41:07 11°28.85 N 023°00.59 W 4063 5083 fr30001
# add PROFILE and END_PROFILE_TIME, BATH
for
i
in
range
(
fe
.
n
):
print
(
"
{:0>5d} {} {} {}
"
.
format
(
i
+
1
,
tools
.
julian2dt
(
fe
[
'
TIME
'
][
i
]).
strftime
(
"
%d/%m/%Y %H:%M:%S
"
),
tools
.
Dec2dmc
(
fe
[
'
LATITUDE
'
][
i
],
'
N
'
),
tools
.
Dec2dmc
(
fe
[
'
LONGITUDE
'
][
i
],
'
W
'
)))
f
.
write
(
"
{:0>5d} {} {} {}
\n
"
.
format
(
i
+
1
,
tools
.
julian2dt
(
fe
[
'
TIME
'
][
i
]).
strftime
(
"
%d/%m/%Y %H:%M:%S
"
),
tools
.
Dec2dmc
(
fe
[
'
LATITUDE
'
][
i
],
'
N
'
),
tools
.
Dec2dmc
(
fe
[
'
LONGITUDE
'
][
i
],
'
W
'
)))
f
.
close
()
f
.
close
()
def
writeData
(
dataFile
,
fe
,
r
,
variables_1D
):
def
writeData
(
dataFile
,
cfg
,
fe
,
r
,
variables_1D
):
f
=
open
(
dataFile
,
'
w
'
)
f
=
open
(
dataFile
,
'
w
'
)
f
.
write
(
"
ASCII file OK !
"
)
f
.
write
(
"
ASCII file OK !
"
)
f
.
close
()
f
.
close
()
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