Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
cyclobs
extract_cyclones
Commits
96e47871
Commit
96e47871
authored
May 25, 2020
by
CEVAER
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added ORM dependencies, added extract file date, finding track points for that date.
parent
bbc02554
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
55 additions
and
3 deletions
+55
-3
README.md
README.md
+1
-0
bin/extractSmapCyclone.py
bin/extractSmapCyclone.py
+50
-1
setup.py
setup.py
+4
-2
No files found.
README.md
View file @
96e47871
# smap_cyclones
Package used to adapt SMAP data for a cyclone oriented usage.
Provide scripts to extract cyclone data from SMAP NetCDF files.
\ No newline at end of file
bin/extractSmapCyclone.py
View file @
96e47871
#!/usr/bin/env python
import
argparse
import
logging
import
datetime
import
os
import
sys
from
sqlalchemy
import
create_engine
,
and_
from
sqlalchemy.orm
import
sessionmaker
from
cyclobs_orm
import
SimpleTrack
logging
.
basicConfig
()
logger
=
logging
.
getLogger
(
os
.
path
.
basename
(
__file__
))
logger
.
setLevel
(
logging
.
INFO
)
def
extractDateFromFilename
(
filename
):
datePart
=
"-"
.
join
(
filename
.
split
(
"_"
)[
4
:
7
])
return
datetime
.
datetime
.
strptime
(
datePart
,
"%Y-%m-%d"
)
def
getTrackPointsFromDatabase
(
session
,
smapDate
):
reqTracks
=
session
.
query
(
SimpleTrack
).
filter
(
and_
(
SimpleTrack
.
date
>=
smapDate
,
SimpleTrack
.
date
<
smapDate
+
datetime
.
timedelta
(
days
=
1
))).
all
()
return
reqTracks
def
processSmapFile
(
session
,
file
):
logger
.
debug
(
f
"Processing
{
file
}
..."
)
fileDate
=
extractDateFromFilename
(
os
.
path
.
basename
(
file
))
logger
.
debug
(
f
"File date
{
fileDate
}
"
)
trackPoints
=
getTrackPointsFromDatabase
(
session
,
fileDate
)
logger
.
debug
(
f
"
{
trackPoints
}
"
)
trakcPointsPerSid
=
{
trackPoint
.
sid
:
trackPoint
for
trackPoint
in
trackPoints
}
if
__name__
==
"__main__"
:
pass
\ No newline at end of file
description
=
"""
Read SMAP netCDF files from a directory, extract the wind data of cyclones and save it into a new netCDF file.
"""
parser
=
argparse
.
ArgumentParser
(
description
=
description
)
parser
.
add_argument
(
"--dbd"
,
action
=
"store"
,
type
=
str
,
required
=
True
,
help
=
'database (postgresql://user:pass@host:5432/base_name)'
)
parser
.
add_argument
(
"--debug"
,
action
=
"store_true"
,
default
=
False
,
help
=
"Run in debug mode (verbose output)"
)
args
=
parser
.
parse_args
()
if
sys
.
gettrace
():
logger
.
setLevel
(
logging
.
DEBUG
)
if
args
.
debug
:
logger
.
setLevel
(
logging
.
DEBUG
)
engine
=
create_engine
(
args
.
dbd
)
Session
=
sessionmaker
(
bind
=
engine
)
smapTests
=
[
"/home/datawork-cersat-public/provider/remss/satellite/l3/smap/smap/wind/v1.0/daily/2020/110/RSS_smap_wind_daily_2020_04_19_v01.0.nc"
,
"/home/datawork-cersat-public/provider/remss/satellite/l3/smap/smap/wind/v1.0/daily/2020/025/RSS_smap_wind_daily_2020_01_25_v01.0.nc"
]
for
f
in
smapTests
:
processSmapFile
(
Session
(),
f
)
setup.py
View file @
96e47871
...
...
@@ -5,11 +5,13 @@ from pathlib import Path
import
glob
install_requires
=
[
'sqlalchemy'
,
'cyclobs_orm'
]
setup
(
name
=
'smap_cyclones'
,
description
=
'
cyclobs web server
'
,
description
=
'
Package used to adapt SMAP data for a cyclone oriented usage.
'
,
url
=
'https://gitlab.ifremer.fr/cyclobs/cyclobs'
,
author
=
"Théo CEVAER"
,
author_email
=
"theo.cevaer@ifremer.fr"
,
...
...
@@ -18,7 +20,7 @@ setup(name='smap_cyclones',
include_package_data
=
True
,
scripts
=
glob
.
glob
(
'bin/**'
),
use_scm_version
=
True
,
setup_requires
=
[
'setuptools_scm'
ss
],
setup_requires
=
[
'setuptools_scm'
],
install_requires
=
install_requires
,
data_files
=
[
(
os
.
path
.
dirname
(
p
)
,
[
p
]
)
for
p
in
glob
.
glob
(
'etc/**'
,
recursive
=
True
)
if
not
os
.
path
.
isdir
(
p
)
],
zip_safe
=
False
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment