Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
EdosL0Util
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
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
SIPS
EdosL0Util
Commits
a2660b1a
Commit
a2660b1a
authored
7 years ago
by
Greg Quinn
Browse files
Options
Downloads
Patches
Plain Diff
rdrgen: add RATMS support
parent
2aafd00b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
edosl0util/rdrgen.py
+21
-3
21 additions, 3 deletions
edosl0util/rdrgen.py
tests/test_rdrgen.py
+14
-3
14 additions, 3 deletions
tests/test_rdrgen.py
with
35 additions
and
6 deletions
edosl0util/rdrgen.py
+
21
−
3
View file @
a2660b1a
...
...
@@ -25,7 +25,7 @@ def packets_to_rdrs(sat, l0_files, **kwargs):
build_rdr
(
sat
,
iter_pkts
(
l0_files
),
**
kwargs
)
def
build_rdr
(
sat
,
pkt_iter
,
aggr_level
=
None
,
diary_cushion
=
10000000
,
attr_overrides
=
{}):
def
build_rdr
(
sat
,
pkt_iter
,
output_dir
=
'
.
'
,
aggr_level
=
None
,
diary_cushion
=
10000000
,
attr_overrides
=
{}):
# divy packets up into temp files organized by granule
file_mgr
=
BinnedTemporaryFileManager
()
...
...
@@ -51,7 +51,8 @@ def build_rdr(sat, pkt_iter, aggr_level=None, diary_cushion=10000000, attr_overr
# now generate the RDRs
rdr_files
=
[]
for
aggr_iet
in
primary_aggr_iets
:
rdr_writer
=
RdrWriter
(
sat
,
rdr_types
,
aggr_iet
,
aggr_level
,
**
attr_overrides
)
rdr_writer
=
RdrWriter
(
sat
,
rdr_types
,
aggr_iet
,
aggr_level
,
output_dir
,
**
attr_overrides
)
rdr_writer
.
write_aggregate
(
primary_type
,
aggr_iet
,
aggr_level
)
gran_iets
=
get_aggregate_granule_times
(
sat
,
primary_type
.
gran_len
,
aggr_level
,
aggr_iet
)
...
...
@@ -73,6 +74,7 @@ def build_rdr(sat, pkt_iter, aggr_level=None, diary_cushion=10000000, attr_overr
rdr_writer
.
write_granule
(
packaged_type
,
gran_iet
,
blob
)
rdr_writer
.
close
()
rdr_files
.
append
(
rdr_writer
.
file_name
)
file_mgr
.
clean_up
()
return
rdr_files
...
...
@@ -500,6 +502,21 @@ class CrisScienceRdrType(object):
default_aggregation
=
15
@rdr_type_spec
class
AtmsScienceRdrType
(
object
):
product_id
=
'
RATMS
'
short_name
=
'
ATMS-SCIENCE-RDR
'
gran_len
=
31997000
sensor
=
'
atms
'
type_id
=
'
SCIENCE
'
document
=
'
474-00448-02-02_JPSS-DD-Vol-II-Part-2_0200B.pdf
'
apids
=
[
ApidSpec
(
515
,
'
CAL
'
,
max_expected
=
5
),
ApidSpec
(
528
,
'
SCI
'
,
max_expected
=
1249
),
ApidSpec
(
530
,
'
ENG_TEMP
'
,
max_expected
=
13
),
ApidSpec
(
531
,
'
ENG_HS
'
,
max_expected
=
5
)]
default_aggregation
=
15
@rdr_type_spec
class
SpacecraftDiaryRdrType
(
object
):
product_id
=
'
RNSCA
'
...
...
@@ -667,4 +684,5 @@ def get_overlapping_granules(sat, gran_len, start_iet, stop_iet):
iet_epoch
=
Time
(
'
1958-01-01
'
,
scale
=
'
tai
'
)
satellite_base_times
=
{
'
snpp
'
:
1698019234000000
}
platform_short_names
=
{
'
snpp
'
:
'
NPP
'
}
instrument_short_names
=
{
'
viirs
'
:
'
VIIRS
'
,
'
cris
'
:
'
CrIS
'
,
None
:
'
SPACECRAFT
'
}
instrument_short_names
=
{
'
viirs
'
:
'
VIIRS
'
,
'
cris
'
:
'
CrIS
'
,
'
atms
'
:
'
ATMS
'
,
None
:
'
SPACECRAFT
'
}
This diff is collapsed.
Click to expand it.
tests/test_rdrgen.py
+
14
−
3
View file @
a2660b1a
...
...
@@ -34,10 +34,16 @@ def generate_rdr_blob_packets(blob):
return
jpss_packet_stream
(
BytesIO
(
pkt_buf
))
def
test_can_reproduce_cris_rdr
():
orig_file_name
=
'
RCRIS-RNSCA_npp_d20171008_t0004096_e0012095_b30810_c20171008061237136301_nobu_ops.h5
'
def
test_can_reproduce_cris_rdr
(
tmpdir
):
verify_rdr_reproduction
(
'
RCRIS-RNSCA_npp_d20171008_t0004096_e0012095_b30810_c20171008061237136301_nobu_ops.h5
'
,
str
(
tmpdir
))
def
verify_rdr_reproduction
(
orig_file_name
,
tmp_dir
):
orig_file
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
orig_file_name
)
new_file
,
=
m
.
build_rdr
(
'
snpp
'
,
generate_rdr_packets
(
orig_file
))
new_file
,
=
m
.
build_rdr
(
'
snpp
'
,
generate_rdr_packets
(
orig_file
),
output_dir
=
tmp_dir
)
new_file
=
os
.
path
.
join
(
tmp_dir
,
new_file
)
with
h5py
.
File
(
orig_file
,
'
r
'
)
as
orig_h5
,
h5py
.
File
(
new_file
,
'
a
'
)
as
new_h5
:
root_attrs
=
[
'
Distributor
'
,
'
N_Dataset_Source
'
,
'
N_HDF_Creation_Date
'
,
'
N_HDF_Creation_Time
'
]
...
...
@@ -59,6 +65,11 @@ def test_can_reproduce_cris_rdr():
copy_attrs
(
lambda
h5
:
h5
[
'
Data_Products
'
][
coll
][
coll
+
'
_Gran_
'
+
str
(
gran_idx
)],
gran_attrs
)
p
=
subprocess
.
Popen
(
[
'
h5diff
'
,
'
-c
'
,
'
-p
'
,
'
1e-5
'
,
orig_file
,
new_file
],
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
)
assert
p
.
communicate
()[
0
]
==
''
assert
p
.
returncode
==
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